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=-2.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 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 52EA8C7618F for ; Mon, 22 Jul 2019 21:13:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2120321955 for ; Mon, 22 Jul 2019 21:13:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lca.pw header.i=@lca.pw header.b="BFaD/7jU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732449AbfGVVNU (ORCPT ); Mon, 22 Jul 2019 17:13:20 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:34086 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732125AbfGVVNU (ORCPT ); Mon, 22 Jul 2019 17:13:20 -0400 Received: by mail-qk1-f195.google.com with SMTP id t8so29583593qkt.1 for ; Mon, 22 Jul 2019 14:13:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=BKxiGWjC+5P401jeWuqAwXoma7yfPGk4/g2Ytyh5U30=; b=BFaD/7jUsYikt25fnCeLunhpd4nXxRG1xIUkQlhVAPFQXJyx/6r2vVBCFl/NMqD8+U pbeanWTIc9BMwg32VoB/9EstVkIA1Quz19bbbkvvpefdgBlJXn01fqZYsfFJ2B8u6umk K+PQDVU84pJTf/VW30aLeOw9iatqrmyi1M7EUzyX2bhFdOPQdmlBf9AehzVOynsPESXe 7kvsKl82+LmMohjq+ELusDXm62Z369AQbp87hp0WoRk2eC8qsdvxghIhHcwbTz6XPLPk E1fPPylZLIDB1qiXxnwk7wQCr1VaAq+Nl0jRYC9RB+Q5Sd/U4eZpdjuXVxKCeRnDJ8rT Y85w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=BKxiGWjC+5P401jeWuqAwXoma7yfPGk4/g2Ytyh5U30=; b=uNQsRPQcczSK2lqu7d3Ytbm2xZ1cGrHezMlQB1b08lrP1Osi9sSYn32gg8hP7LbIIK iJSFE4+ecrHxAi6CJoBwcsGxmQhGxITJQf4V0V/tkLIuBLnN72uoMjS0ZM9qgaoT6wHb rbOcrz4gIDM7DTVvDdMy8RDhE/tU+MACQJ3QFvjMisBRpDqS/B/IJX2nGw13ePufCHKj ++zdwFYwYr/q6/5pmQoUeke1B+j0j1oDTks/wa3byReJdj7Bd59IoDTd3l5JvknDP7nv TuhYE9yl7SD3GU1xv3FNMryz7r7hRJZO4RN99xIMVhoyd/QRQwFxp0r1AaM8KJtXPgSe jafQ== X-Gm-Message-State: APjAAAXMdFgY96DBnNJJFSrtq8PQRXsHFSlZIfelvGq8ywEB/Zu7+Q+i 3+ByXMzwdy9g6CPZCDu53bu3HA== X-Google-Smtp-Source: APXvYqwsFCj6xytMhGmclxHIaeQskKQrC4psHIw5WW42v731oBjjDbzmgqJHveBylv4SkFw7Rlp47Q== X-Received: by 2002:a37:a010:: with SMTP id j16mr48945457qke.152.1563829999256; Mon, 22 Jul 2019 14:13:19 -0700 (PDT) Received: from dhcp-41-57.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id z1sm19024894qke.122.2019.07.22.14.13.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jul 2019 14:13:18 -0700 (PDT) Message-ID: <1563829996.11067.4.camel@lca.pw> Subject: Re: [PATCH] be2net: fix adapter->big_page_size miscaculation From: Qian Cai To: David Miller Cc: morbo@google.com, ndesaulniers@google.com, jyknight@google.com, 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, natechancellor@gmail.com, Jakub Jelinek Date: Mon, 22 Jul 2019 17:13:16 -0400 In-Reply-To: <1563572871.11067.2.camel@lca.pw> References: <75B428FC-734C-4B15-B1A7-A3FC5F9F2FE5@lca.pw> <20190718.162928.124906203979938369.davem@davemloft.net> <1563572871.11067.2.camel@lca.pw> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6 (3.22.6-10.el7) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2019-07-19 at 17:47 -0400, Qian Cai wrote: > On Thu, 2019-07-18 at 16:29 -0700, David Miller wrote: > > From: Qian Cai > > Date: Thu, 18 Jul 2019 19:26:47 -0400 > > > > >   > > >   > > > > On Jul 18, 2019, at 5:21 PM, Bill Wendling wrote: > > > >   > > > > [My previous response was marked as spam...] > > > >   > > > > Top-of-tree clang says that it's const: > > > >   > > > > $ gcc a.c -O2 && ./a.out > > > > a is a const. > > > >   > > > > $ clang a.c -O2 && ./a.out > > > > a is a const. > > > > > >   > > >   > > > I used clang-7.0.1. So, this is getting worse where both GCC and clang > > > will > > > > start to suffer the > > > same problem. > > > > Then rewrite the module parameter macros such that the non-constness > > is evident to all compilers regardless of version. > > > > That is the place to fix this, otherwise we will just be adding hacks > > all over the place rather than in just one spot. > > The problem is that when the compiler is compiling be_main.o, it has no > knowledge about what is going to happen in load_module().  The compiler can > only > see that a "const struct kernel_param_ops" "__param_ops_rx_frag_size" at the > time with > > __param_ops_rx_frag_size.arg = &rx_frag_size > > but only in load_module()->parse_args()->parse_one()->param_set_ushort(), it > changes "__param_ops_rx_frag_size.arg" which in-turn changes the value > of "rx_frag_size". Even for an obvious case, the compilers still go ahead optimizing a variable as a constant. Maybe it is best to revert the commit d66acc39c7ce ("bitops: Optimise get_order()") unless some compiler experts could improve the situation. #include int a = 1; int main(void) {         int *p;         p = &a;         *p = 2;         if (__builtin_constant_p(a))                 printf("a is a const.\n");         printf("a = %d\n", a);         return 0; } # gcc -O2 const.c -o const # ./const a is a const. a = 2