Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2881540ybi; Thu, 18 Jul 2019 16:27:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwC7WtMEprOqZw+Dh6WF7OK0JVhOkRdan4w3ImVj+7Vee505Q39pX6RhevbRTX399ABpJ5C X-Received: by 2002:a65:6256:: with SMTP id q22mr50096109pgv.408.1563492444681; Thu, 18 Jul 2019 16:27:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563492444; cv=none; d=google.com; s=arc-20160816; b=riq8gkG1Nt3G5yhQieBHy9HIgpU2ZJKpufD/ya+Q+zLEi6tM58//s/h8ymP3raRWVD PcHOTcNGBEnfJQfPyDlSHd/DR70BehWUh1F7QF3OkhToqfoLXrPbJJAoW7SobA9Iohr0 qJVW1/WP2MC/+MUCn+12Yk8iMfTQHqL2xW6dB9ahwT+41xofk518B4WWWPMo7U/ePSZm 222z0u0UHv4JmF104UcETyLJuOdcoaI8jD86FuSl3KI6vt7iRc4e3BJq1m4TvpXNnKeU QtEONv2LSEiGViESQQelf3ZUS+y6YJmcZlWQRmvWwyc/O02qlZQuvti/oAIgkBB4365v Zcvg== 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=TED1YMmih5CMaQpPogtNSe98eoJfXq3PHOIoVZoVmXs=; b=crX6L8ZE7J24dhOz4uJ7wcf2SII2sqS7VtRO1y24lRlf9iOLaXT+Dmgs7U1MsjLG7C Z66bvIl2W3hFtAyxLLLrVe0yWfbXp2qAgTtuELsVWDJB8SW8bn77xKNk+nKTp4++nRVO KiLwu9b0OoffJWV2bavJAR4HNOlc1fTKbVOe8izgTEe6X/pwL3vZHxBB6lW0547V8s+9 d4gW+OhDsK7veyEqsgqusogxh62fpoIIqUnhYANuqms8Ka6p4T+unrcs1kAWXPTM80mw X5IPIDFdOvX//Og23LfA5SljP/7oxMDxmFtiQOzIOgbRyukemqEGkgKkPg4k6anfZGnG ivuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=eWao9mqt; 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 k22si2898008pfk.90.2019.07.18.16.27.08; Thu, 18 Jul 2019 16:27:24 -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=eWao9mqt; 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 S1726112AbfGRX0u (ORCPT + 99 others); Thu, 18 Jul 2019 19:26:50 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:33706 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbfGRX0u (ORCPT ); Thu, 18 Jul 2019 19:26:50 -0400 Received: by mail-qk1-f196.google.com with SMTP id r6so21940989qkc.0 for ; Thu, 18 Jul 2019 16:26:49 -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=TED1YMmih5CMaQpPogtNSe98eoJfXq3PHOIoVZoVmXs=; b=eWao9mqtXSE9FIpvXcxEjX2v53F6fcDEZeDqxHDrpIeaRS5OKgD4U/69LRSNZavmD7 rYeX8gV/Hh3ZXxyRPUBw7KyXz8txocn8hhhDI7pU9igo+83feIiGMF56X7JKVhEj0J9W t6SB4Cy35v7f1/5I9equwIeHf+7qmPUlEx+mIYXjOnjMdiGPdMcbqQmoHJtY7GU2SWqB g30Rk2Bkpmn/YEbtqxobLlyI8MWPxYvRFQiMSN4rT3cCJgCNwC0oz1fVtmQbSZv5AWvh HPMpy7q/q3HRkE2pxwIYMXjUVL8WM+m+UfKTQs0in8APrDxMNsW9pBas0Lwipp4Q1MLk PmDQ== 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=TED1YMmih5CMaQpPogtNSe98eoJfXq3PHOIoVZoVmXs=; b=LGEk5jKkbsjd9zIibE9ydOf02FqfD5Fl3IMPrLrwBwmCENP6pvRFQgY/YyHSU6L0Tr WWyjIpXv7uGPR2IA72u+jxpA3LQUj9DRbF1VVxsXQ4rNbhDHoX38IICYNLNfLWGLhwEY s0tjLiIEvcqVc+49Ics1EPSdUJTKo2LdXfuFRVZ+RF7dMariz0x7qpKudkMTgTYDF6JO gx9oSJv1djJxgW0gwXUJ8Il2e9Rw10jox8HOyGGyZANZGp8oDHNfm0AYKiyH88x2ZLEz 6fRmbsHygG6/1hljxrAPpLIOtLBXVZ/YgC0n2PhGuscf2QoOmv2JDoINb82SEj4Y6r7c Sh+w== X-Gm-Message-State: APjAAAU8UxyEoIysMDPZodXykG7aWnP5JnK1TAWkVoWKZIZ8pSRo6uBy j0jCety1DUReNanxEN/CjRYL+A== X-Received: by 2002:a37:aa0d:: with SMTP id t13mr34659564qke.167.1563492409444; Thu, 18 Jul 2019 16:26:49 -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 i23sm12971496qtm.17.2019.07.18.16.26.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jul 2019 16:26:48 -0700 (PDT) Content-Type: text/plain; charset=us-ascii 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: Thu, 18 Jul 2019 19:26:47 -0400 Cc: Nick Desaulniers , James Y Knight , David Miller , 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 , LKML , Nathan Chancellor Content-Transfer-Encoding: quoted-printable Message-Id: <75B428FC-734C-4B15-B1A7-A3FC5F9F2FE5@lca.pw> References: <1562959401-19815-1-git-send-email-cai@lca.pw> <20190712.154606.493382088615011132.davem@davemloft.net> <20190712.175038.755685144649934618.davem@davemloft.net> To: Bill Wendling 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 > On Jul 18, 2019, at 5:21 PM, Bill Wendling wrote: >=20 > [My previous response was marked as spam...] >=20 > Top-of-tree clang says that it's const: >=20 > $ gcc a.c -O2 && ./a.out > a is a const. >=20 > $ 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. >=20 >=20 > On Thu, Jul 18, 2019 at 2:10 PM Nick Desaulniers > wrote: >>=20 >> On Thu, Jul 18, 2019 at 2:01 PM Qian Cai wrote: >>>=20 >>>=20 >>>=20 >>>> On Jul 12, 2019, at 8:50 PM, David Miller = wrote: >>>>=20 >>>> From: Qian Cai >>>> Date: Fri, 12 Jul 2019 20:27:09 -0400 >>>>=20 >>>>> 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. >>>>>=20 >>>>> # cat const.c >>>>> #include >>>>>=20 >>>>> static int a =3D 1; >>>>>=20 >>>>> int main(void) >>>>> { >>>>> if (__builtin_constant_p(a)) >>>>> printf("a is a const.\n"); >>>>>=20 >>>>> return 0; >>>>> } >>>>>=20 >>>>> # gcc -O2 const.c -o const >>>>=20 >>>> 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. >>>>=20 >>>> It makes no sense to hack around this locally in drivers and other >>>> modules. >>>=20 >>> If you see the warning in the original patch, >>>=20 >>> = https://lore.kernel.org/netdev/1562959401-19815-1-git-send-email-cai@lca.p= w/ >>>=20 >>> 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. >>>=20 >>> Though, I have added a few people who might know more of compilers = than myself. >>=20 >> + Bill and James, who probably knows more than they'd like to about >> __builtin_constant_p and more than other LLVM folks at this point. >>=20 >> -- >> Thanks, >> ~Nick Desaulniers