From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7F4CC742D7 for ; Sat, 13 Jul 2019 00:50:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8567020896 for ; Sat, 13 Jul 2019 00:50:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727811AbfGMAum (ORCPT ); Fri, 12 Jul 2019 20:50:42 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:35388 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727236AbfGMAum (ORCPT ); Fri, 12 Jul 2019 20:50:42 -0400 Received: from localhost (unknown [IPv6:2601:601:9f80:35cd::d71]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 67C7214E32590; Fri, 12 Jul 2019 17:50:41 -0700 (PDT) Date: Fri, 12 Jul 2019 17:50:38 -0700 (PDT) Message-Id: <20190712.175038.755685144649934618.davem@davemloft.net> To: cai@lca.pw 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, linux-kernel@vger.kernel.org Subject: Re: [PATCH] be2net: fix adapter->big_page_size miscaculation From: David Miller In-Reply-To: References: <1562959401-19815-1-git-send-email-cai@lca.pw> <20190712.154606.493382088615011132.davem@davemloft.net> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Fri, 12 Jul 2019 17:50:41 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qian Cai 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 > > 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. Thank you.