Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8074092ybi; Tue, 23 Jul 2019 02:23:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeLfsdDCWSXjL5T6RPV9nb/Qe+IvRZKXrrg6Rd0ne5gfV7fMCc5L/epcur9bDs1I7RgJA+ X-Received: by 2002:a62:764d:: with SMTP id r74mr5011478pfc.110.1563873835467; Tue, 23 Jul 2019 02:23:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563873835; cv=none; d=google.com; s=arc-20160816; b=lpWCePvCOsHD3VD5/YjQjGnBnhAoiYrgD06pvb5ZOhhltbJdRhuh1qP++ZExgLUwFI lia/zTkTAYZ7Zvmua54aT3mjYJ48aCfN1VaQYAz18pDGH6ovJkBKRrvOikEA99l8Yhcp Ra2bo1TaSpIB0y1LmeWpvgnZ/yti/J9V7hEOGwQgALiCi7rSG8aR9UNAzbCd+GvTK7Ft ikyumMZ0Z2WvM5TmuJBrHzekmafCvOtlizUaY0hGqHHZ3half0ECrzLNoj5d5fwDiK+/ +jJTwDzbKm1c4F0Q5tm5pkrW/MgM1ByRJcVjrD4i0oWdsOvdqREJrkCnC6COHd//3Zec UidA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=O2LzIiKDY4d/HsG0eNgmi387YcnYg6wKjUrMRiQ2aBI=; b=diHEaITY/kdEjU1dSXKyPsd7+6iykP4NBS3+VW8cmg8lHKwi7XBnxnRMvcMgECXwcV 7gPzxdUT/lRsChxjufohmA5UOKJCtMFdwDTU83Neg6OuXDp9TKU4jCkqVXIrNEpvN24O FivEeP3zU9GkTd5/8Ipkt3Dbwe2/hSXVTl5MycMUtLpDux17FkUT2Y2jy22GXYKhKFiX iD0xURZnr8fFJfhZ9sDFadlKesDzVXmIFaJ6XCLl8LbmsDvQ1ZudxlOBN9XjDOOx8hSZ ZE99cTTadsbgMkeDlsfCCLW69ifBEonTQmpJuQJPWpPtDYD0Y1BwPoT2QhO9xv9N50RF WkEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=cQVGQ4Lo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x9si13118607plo.98.2019.07.23.02.23.38; Tue, 23 Jul 2019 02:23:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=cQVGQ4Lo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387916AbfGWDIs (ORCPT + 99 others); Mon, 22 Jul 2019 23:08:48 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:45387 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387905AbfGWDIp (ORCPT ); Mon, 22 Jul 2019 23:08:45 -0400 Received: by mail-qk1-f196.google.com with SMTP id s22so30107001qkj.12 for ; Mon, 22 Jul 2019 20:08:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=O2LzIiKDY4d/HsG0eNgmi387YcnYg6wKjUrMRiQ2aBI=; b=cQVGQ4Lo+reBiq8dbjN5yriOzZVvY96vvAv9q8SsuYXMB9Uau30z5v7ourRopELAFV HrSuYt9L9h2jrveEkYTf5QYuw4n3uzgINqxIf9oaP4qrM3vxOSfbI/eyebdNEedw9sF9 fnyXYmfKAQzMfGVsedovuQq8f4im3Cjf+KHSjHeyXl9m3EHsftdM5tHH+4KSxI9JW1Lm GX63sOgrwRVMD9cuOq0weGCDiiNaTCz17G7XnDt4HMCr7J7pvWTufHH7/U0V/19leICN 5WI55ujo/WvPH3ihrWHlYoNRj8G0G/etpXi9XaiBLtfuQoiIQ3IH4houeVK4ZQbWq6us h5mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=O2LzIiKDY4d/HsG0eNgmi387YcnYg6wKjUrMRiQ2aBI=; b=RZ+n/9J1LfE6mNplTfTVxr8RaeHjEglqzW45F4TWVuALlVWT2ogvDqIXvldAD0nM2c mgDOSDLm/7srT5gB0p2/hlee6YMbxqK3cD0VNseI39phOGcIUT7m9KjogIuSduahJNjk QfocI1GMGY2XZOooFa2e7uYWkVHPlFbVrGAIE60+Bt5JqPh9Kg1TC+UyERXOjGfz8Oec cLM5eaKGpjOp8kvELjaslEkhQPLHHb8eJbkE2OWLlMA06gcFJ9cbZMamjwkNJDL6pD3D wHg8fn+PvY5Zs3/0/GfGHcCIIb/8rcgV8wD1GXAU4z6E+3PmQbAaiYafYu9szM/CSRbl ljIQ== X-Gm-Message-State: APjAAAXJOhNsnbNsLYdmvEyCiFfI5QWDwByKbRn9N/T1q9dDbQQjg2rd 6H3xL3XBNHhIaauGAbmiBe1/Mw== X-Received: by 2002:a37:a7d6:: with SMTP id q205mr46498779qke.44.1563851324361; Mon, 22 Jul 2019 20:08:44 -0700 (PDT) Received: from [192.168.1.153] (pool-71-184-117-43.bstnma.fios.verizon.net. [71.184.117.43]) by smtp.gmail.com with ESMTPSA id x46sm26242144qtx.96.2019.07.22.20.08.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jul 2019 20:08:43 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: [PATCH] be2net: fix adapter->big_page_size miscaculation From: Qian Cai In-Reply-To: Date: Mon, 22 Jul 2019 23:08:41 -0400 Cc: David Miller , Bill Wendling , Nick Desaulniers , sathya.perla@broadcom.com, ajit.khaparde@broadcom.com, sriharsha.basavapatna@broadcom.com, somnath.kotur@broadcom.com, Arnd Bergmann , David Howells , "H. Peter Anvin" , netdev@vger.kernel.org, linux-arch@vger.kernel.org, Linux Kernel Mailing List , natechancellor@gmail.com, Jakub Jelinek Content-Transfer-Encoding: quoted-printable Message-Id: References: <75B428FC-734C-4B15-B1A7-A3FC5F9F2FE5@lca.pw> <20190718.162928.124906203979938369.davem@davemloft.net> <1563572871.11067.2.camel@lca.pw> <1563829996.11067.4.camel@lca.pw> To: James Y Knight X-Mailer: Apple Mail (2.3445.104.11) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The original issue, = https://lore.kernel.org/netdev/1562959401-19815-1-git-send-email-cai@lca.p= w/ The debugging so far seems point to that the compilers get confused by = the module sections. During module_param(), it stores = =E2=80=9C__param_rx_frag_size" as a =E2=80=9Cstruct kernel_param=E2=80=9D into the __param section. = Later, load_module() obtains all =E2=80=9Ckernel_param=E2=80=9D from the __param section and = compare against the user-input module parameters from the command-line. If there is a = match, it calls params[i].ops->set(¶ms[I]) to replace the value. If compilers = can=E2=80=99t see that params[i].ops->set(¶ms[I]) could potentially change the = value of rx_frag_size, it will wrongly optimize it as a constant. For example (it is not compilable yet as I have not able to extract variable from the __param = section like find_module_sections()), #include #include #define __module_param_call(name, ops, arg) \ static struct kernel_param __param_##name \ __attribute__ ((unused,__section__ = ("__param"),aligned(sizeof(void *)))) =3D { \ #name, ops, { arg } } struct kernel_param { const char *name; const struct kernel_param_ops *ops; union { int *arg; }; }; struct kernel_param_ops { int (*set)(const struct kernel_param *kp); }; #define STANDARD_PARAM_DEF(name) \ int param_set_##name(const struct kernel_param *kp) \ { \ *kp->arg =3D 2; \ } \ const struct kernel_param_ops param_ops_##name =3D { \ .set =3D param_set_##name, \ }; STANDARD_PARAM_DEF(ushort); static int rx =3D 1; __module_param_call(rx_frag_siz, ¶m_ops_ushort, &rx_frag_size); int main(int argc, char *argv[]) { const struct kernel_param *params =3D <<< Get all kernel_param = from the __param section >>>; int i; if (__builtin_constant_p(rx_frag_size)) printf("rx_frag_size is a const.\n"); for (i =3D 0; i < num_param; i++) { if (!strcmp(params[I].name, argv[1])) { params[i].ops->set(¶ms[i]); break; } } printf("rx_frag_size =3D %d\n", rx_frag_size); return 0; }