Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2783909ybi; Thu, 18 Jul 2019 14:22:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkI4SG3binqxmkRv6aHuNHdhTW92y3vVHpEOxlEiC69jT/F2/qtvGv7YRaj+dcN9BH+aOk X-Received: by 2002:a63:6c02:: with SMTP id h2mr47969801pgc.61.1563484937719; Thu, 18 Jul 2019 14:22:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563484937; cv=none; d=google.com; s=arc-20160816; b=Yfvmze9L4pnxvk2OTovh+zr6XHRwyzwA3ngEt+4QGKQ75eNpe3ZPnVRieAnahH8ssq kk40wL5nliwLTbVzvPRfm4Ju5IauGYVQsAbCw2XoK8P4rJ64Vs8bq63LJZhm3YF8g9Sf BcbcMPDQ+r2T6cf/e+I/g5jAxGUqjpZqLU7hDXIPg5cocoj4NDvOPwEuJiXJj1lTxKgV fQ046ksfnUzpX6q2daFXEATr5imNbI/uB6J6sDqwxzs+P9L4XesZ/6Fk0/zavtNp/J2i Cd4LsqOk0X0kVBY918jRVeaYDmVz1vQNus2+jg/r2IAIi9G55wVBNgLJWLgFQjvEV77t JLNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=JLWgE4G1xumD+5ZusInPzcVsAid5/1NnJBPXIPh5kwU=; b=KUheF9OPJX4XRO+91bUhLEUs4b2MOriWM8bmSxDlhSyUmz7H5XIwsnux4+ionX4SlZ coM4VLwtPYDP5cBtpTI6uLHDs2I0a5VZAFouP7YlgE5WCoghv5A5xTh+fxMrCFn9NmN0 uf1a0bcCWaFZrHvu4gYThpzFzYq5QmSXsWHrpaGbNNfivu21xvYZlwbQwp9tdCvUI1lq s0UnIP9+NLwRoVIek6H+l3jKhz/Ba1ul3TbbS+KVRvrDGkLb0CtFlc6/s7czXkkZSBQE qvir4c+zL59O7Bk/YzwexJ8R1sP+Qh15IWcrWG683yaJtgVaqOhuu+5gf7xzgDFzmW+K 0QNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="c/8BoGQt"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c38si27705893pgc.65.2019.07.18.14.22.02; Thu, 18 Jul 2019 14:22:17 -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=@google.com header.s=20161025 header.b="c/8BoGQt"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728056AbfGRVVm (ORCPT + 99 others); Thu, 18 Jul 2019 17:21:42 -0400 Received: from mail-vs1-f66.google.com ([209.85.217.66]:33503 "EHLO mail-vs1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727781AbfGRVVm (ORCPT ); Thu, 18 Jul 2019 17:21:42 -0400 Received: by mail-vs1-f66.google.com with SMTP id m8so20216175vsj.0 for ; Thu, 18 Jul 2019 14:21:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JLWgE4G1xumD+5ZusInPzcVsAid5/1NnJBPXIPh5kwU=; b=c/8BoGQt9/QOqtqbYVLLVLcLBKKCNOL7ZGgciVXxCS21F1WB5gBw1Lhtv1yMwGbQ/8 FL7h6h0baE/EM6HpjnHtdgaCQxgO1LCBFh5EMOP8abh9QCVx9P0iVVBR1osJKkuIj37I 7In1Y7cMeJe/ozyMDC/3pmdbyV+j2J3tmfucx9P0zn3zlgwZMEGPszlG/ypDkHx9w0ey VmnNdkY5C43kS4BMQYBEBtVWCnmD58X/+gFuHIi7F0VXGS7IeLhQ6lpyF6vygZUViVa0 OEbs/lPqkuIOfBqlLezNboG1lpxEwSrVjAGOZTHk62zaj5AxQJAcmrSg06aF3ENi3eNO sM1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JLWgE4G1xumD+5ZusInPzcVsAid5/1NnJBPXIPh5kwU=; b=UcyfIzwe5LBWI2001g+RkY43DhcagznvN0OcHBGFyvOx8WeftAh3oqIlodMTPkgJw2 YPeWFoKVqExaOXHLO67sLhW7HXfn4ERfVwOEYf4Cy3+dibUoCWBuGnAJWD/LER5X9PLw m0ns1D2m96+e/WLhQ9y6DB7SfUA+fYKwbHYkO90zYrVEVodXtztAmIiPKAwVtMwbPdk5 41Xw6xwfDjLlRHg8cWKsyFU3k0m6kLKw8iGBK5oRILImcx6Dkh0iz5gf8wM7mmttEsX8 dwuCPlY//k4nGqWWSVJeTNvfwDarWZCU7StpZQ6inHNeVZsGq5F0PktaO5RfPlmHakn/ jqzQ== X-Gm-Message-State: APjAAAWZLbJZhzMXOW3eSpGcMgQEBuMePz9pEwT/jjc1+uZ0SpnrgpEx jRP3l5oDTLGPnimcl4WP39XGQama5PdRRoRvgWfu X-Received: by 2002:a67:d39e:: with SMTP id b30mr30387881vsj.212.1563484900833; Thu, 18 Jul 2019 14:21:40 -0700 (PDT) MIME-Version: 1.0 References: <1562959401-19815-1-git-send-email-cai@lca.pw> <20190712.154606.493382088615011132.davem@davemloft.net> <20190712.175038.755685144649934618.davem@davemloft.net> In-Reply-To: From: Bill Wendling Date: Thu, 18 Jul 2019 14:21:29 -0700 Message-ID: Subject: Re: [PATCH] be2net: fix adapter->big_page_size miscaculation To: Nick Desaulniers Cc: Qian Cai , 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-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [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. On Thu, Jul 18, 2019 at 2:10 PM Nick Desaulniers wrote: > > On Thu, Jul 18, 2019 at 2:01 PM Qian Cai wrote: > > > > > > > > > On Jul 12, 2019, at 8:50 PM, David Miller wrote: > > > > > > 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. > > > > 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. > > + 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. > > -- > Thanks, > ~Nick Desaulniers