netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qian Cai <cai@lca.pw>
To: David Miller <davem@davemloft.net>
Cc: sathya.perla@broadcom.com, ajit.khaparde@broadcom.com,
	sriharsha.basavapatna@broadcom.com, somnath.kotur@broadcom.com,
	arnd@arndb.de, dhowells@redhat.com, hpa@zytor.com,
	netdev@vger.kernel.org, linux-arch@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	natechancellor@gmail.com
Subject: Re: [PATCH] be2net: fix adapter->big_page_size miscaculation
Date: Thu, 18 Jul 2019 17:01:27 -0400	[thread overview]
Message-ID: <D7E57421-A6F4-4453-878A-8F173A856296@lca.pw> (raw)
In-Reply-To: <20190712.175038.755685144649934618.davem@davemloft.net>



> On Jul 12, 2019, at 8:50 PM, David Miller <davem@davemloft.net> wrote:
> 
> From: Qian Cai <cai@lca.pw>
> Date: Fri, 12 Jul 2019 20:27:09 -0400
> 
>> Actually, GCC would consider it a const with -O2 optimized level because it found that it was never modified and it does not understand it is a module parameter. Considering the following code.
>> 
>> # cat const.c 
>> #include <stdio.h>
>> 
>> static int a = 1;
>> 
>> int main(void)
>> {
>> 	if (__builtin_constant_p(a))
>> 		printf("a is a const.\n");
>> 
>> 	return 0;
>> }
>> 
>> # gcc -O2 const.c -o const
> 
> That's not a complete test case, and with a proper test case that
> shows the externalization of the address of &a done by the module
> parameter macros, gcc should not make this optimization or we should
> define the module parameter macros in a way that makes this properly
> clear to the compiler.
> 
> It makes no sense to hack around this locally in drivers and other
> modules.

If you see the warning in the original patch,

https://lore.kernel.org/netdev/1562959401-19815-1-git-send-email-cai@lca.pw/

GCC definitely optimize rx_frag_size  to be a constant while I just confirmed clang
-O2 does not. The problem is that I have no clue about how to let GCC not to
optimize a module parameter.

Though, I have added a few people who might know more of compilers than myself.

  reply	other threads:[~2019-07-18 21:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-12 19:23 [PATCH] be2net: fix adapter->big_page_size miscaculation Qian Cai
2019-07-12 22:46 ` David Miller
2019-07-13  0:27   ` Qian Cai
2019-07-13  0:50     ` David Miller
2019-07-18 21:01       ` Qian Cai [this message]
2019-07-18 21:10         ` Nick Desaulniers
2019-07-18 21:21           ` Bill Wendling
2019-07-18 23:26             ` Qian Cai
2019-07-18 23:29               ` David Miller
2019-07-19 21:47                 ` Qian Cai
2019-07-22 21:13                   ` Qian Cai
2019-07-22 22:58                     ` James Y Knight
2019-07-23  3:08                       ` Qian Cai
     [not found]           ` <CAGG=3QWkgm+YhC=TWEWwt585Lbm8ZPG-uFre-kBRv+roPzZFbA@mail.gmail.com>
2019-07-18 21:22             ` Nick Desaulniers
2019-07-18 21:28               ` Bill Wendling
2019-07-19 10:32 ` kbuild test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D7E57421-A6F4-4453-878A-8F173A856296@lca.pw \
    --to=cai@lca.pw \
    --cc=ajit.khaparde@broadcom.com \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=sathya.perla@broadcom.com \
    --cc=somnath.kotur@broadcom.com \
    --cc=sriharsha.basavapatna@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).