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=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 BD84FC76196 for ; Thu, 18 Jul 2019 21:10:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 95DFE21019 for ; Thu, 18 Jul 2019 21:10:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gihIi9b7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391312AbfGRVKT (ORCPT ); Thu, 18 Jul 2019 17:10:19 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:39816 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727685AbfGRVKT (ORCPT ); Thu, 18 Jul 2019 17:10:19 -0400 Received: by mail-pf1-f195.google.com with SMTP id f17so9183622pfn.6 for ; Thu, 18 Jul 2019 14:10:18 -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=XIOGrPriZRTmOk8GSJmi3uegRPz7ninV7z+aZhuIkLg=; b=gihIi9b7oPxy1tx75Cls+nO0enXj3oB8QkxlUTVV/M/G1/kEp22DkodSzf3/LK9W4m mrExFCM2INBQTjJInN/mL7aYxr/XE1J0aSWUSEzZ6chI5k21XlvoiuF8jTcs9cGTMMEe ZZQgWS+bVdOWdNd61wmtYFWLE76+nk4kkZKYkP6PJisk4aY87RRKIhDpkfvWQiEDfh6X enpUlUxRZQMHKwAZ1Z6UHOmbszX37eaNNM88mwbmHA48dD89o2cXynr58EWMw7up6l0f K211ghgxv57iC9d2FVVlVKXwS6OGUhUo13tdxlRtalgfxDcc7C6fXxcr9HaLNjhqivyE ueIQ== 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=XIOGrPriZRTmOk8GSJmi3uegRPz7ninV7z+aZhuIkLg=; b=orDTc/twjSVpeKDfRnS3A1IjcKE4F7fTaFlc+HS1ZfHDei+dFKprv0x/Yslf/pecsQ 1pMmo7N7VYKs75qQ+ct2OgBperzTL6ZlE7gux4jgGdpFjfSd6J1WBVUOy/uIebLe/1Cf h+r2COInFfyiKfKTEvdZT9R18TPyoRJYtmkAuX6hO1yawC6cBk4aT2PK2Qmv8BzmMsdU 9G3lq1cja6Z9pC7xbuOKdUWDisBqmLIVg1xXWR+vVbEH/cUpdAfp5kDrkKIcgS5uysoy VaocyTcZM/lwVkEiNzgpNFOhuKnZFUXtdmt3ZE4YpoR9iCVXyovHh5oMF1NyXQFyAwUW sa0w== X-Gm-Message-State: APjAAAXIfgdaJDoy8XOSMgn1uVHefYNORRbsJuw5/+OHDfn3KMAgES1D 3qEwjcSo74Xkr4hA5tpNnATuf6iGWV6CrSAfwptQsw== X-Google-Smtp-Source: APXvYqyfxbJyTy2CnYB4Y3JUva+s3RCza7Yed+0y2RO6CUA/IuyJ9wTiHjUtaSTz2/RvIQ4XBi0RHjtQiQXH47XyKfU= X-Received: by 2002:a63:2cd1:: with SMTP id s200mr46254603pgs.10.1563484217895; Thu, 18 Jul 2019 14:10:17 -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: Nick Desaulniers Date: Thu, 18 Jul 2019 14:10:06 -0700 Message-ID: Subject: Re: [PATCH] be2net: fix adapter->big_page_size miscaculation To: Qian Cai , Bill Wendling , James Y Knight Cc: 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 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