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=-3.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 A866EC43464 for ; Fri, 18 Sep 2020 20:41:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2AB2C2311B for ; Fri, 18 Sep 2020 20:41:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="Ucxy8AMp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2AB2C2311B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B97A9900002; Fri, 18 Sep 2020 16:41:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B48206B0095; Fri, 18 Sep 2020 16:41:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A10D8900002; Fri, 18 Sep 2020 16:41:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0005.hostedemail.com [216.40.44.5]) by kanga.kvack.org (Postfix) with ESMTP id 8503B6B0093 for ; Fri, 18 Sep 2020 16:41:03 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 38484181AEF2A for ; Fri, 18 Sep 2020 20:41:03 +0000 (UTC) X-FDA: 77277351606.18.hand71_1b1426d2712e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 184581005E8A7 for ; Fri, 18 Sep 2020 20:41:03 +0000 (UTC) X-HE-Tag: hand71_1b1426d2712e X-Filterd-Recvd-Size: 5256 Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Sep 2020 20:41:02 +0000 (UTC) Received: by mail-io1-f67.google.com with SMTP id m17so8454381ioo.1 for ; Fri, 18 Sep 2020 13:41:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zQJsMUBUH1rRWO3srepDjolJw233J5qBV1esDpsMte0=; b=Ucxy8AMpaTBz1vIbcCX1grgPVCFNbATgxM5UumcQAyP06cFkZzWPmHVwfLh7iIY0XN 5aKj2UZ2jXFEdHPMpXsQfftNcVbI26Q3YGly9XUChwPeu4mi/qcH2q3EgG9EI/fxCS9v 3yiYpw2C8TNlrT1Sw8d28NTCKS0ybLuACCd1A= 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=zQJsMUBUH1rRWO3srepDjolJw233J5qBV1esDpsMte0=; b=kq3XqISDRKV8S9QB/WDaqJtzS1feiBApDmE6jvioHHjTb5GKDYfenCNPaWtsusf96n CZP43LSa+kNpwxsjlocgA57zsGVUIVMtBFGyLoKv0mxKoq1kWsHMFsLeVdE385qTsCtJ DHQSlgDQrDGWrJ7xgXAPIItmRa1K64K8LZLOzPbLnzN2OZyetjEUna+AQ3Ll1ts/Br6g hwGCHK/8NcoyFFnZNd4U4P123ad/TPQlEfbuZBt6NW19qKuukTPG3tInhO2hvoZ1PvRV ynzerfUS0RkXjc8Q2Q6my85hdoee8MvkkxKuNaIlbxzvELCVvF/EdmDk5KQs7k/bYOSO X0qA== X-Gm-Message-State: AOAM531t3P6GTJpeK4W0eZwka/RnvkB3CNhVPJRggrDz1F7CPNhK4ON7 vOkUvkMKhhtVr9nr4A0INF0WmzzmDvoq2Q== X-Google-Smtp-Source: ABdhPJwNFD8KUWqOU5P5Cq/pelMBFqanlzPcgYlCx7FKIg+aIwod8Ja87pr66+ntsps9vtUbpMQMiA== X-Received: by 2002:a5d:84c6:: with SMTP id z6mr1672352ior.0.1600461661673; Fri, 18 Sep 2020 13:41:01 -0700 (PDT) Received: from mail-io1-f47.google.com (mail-io1-f47.google.com. [209.85.166.47]) by smtp.gmail.com with ESMTPSA id m5sm2314521ilc.79.2020.09.18.13.41.00 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Sep 2020 13:41:00 -0700 (PDT) Received: by mail-io1-f47.google.com with SMTP id d190so8442338iof.3 for ; Fri, 18 Sep 2020 13:41:00 -0700 (PDT) X-Received: by 2002:a6b:7717:: with SMTP id n23mr29111497iom.151.1600461660527; Fri, 18 Sep 2020 13:41:00 -0700 (PDT) MIME-Version: 1.0 References: <20200917204514.GA2880159@google.com> <20200918162305.GB25599@embeddedor> <20200918193426.GA15213@embeddedor> <20200918200252.GH32101@casper.infradead.org> <20200918202909.GA2946008@rani.riverdale.lan> In-Reply-To: <20200918202909.GA2946008@rani.riverdale.lan> From: Linus Torvalds Date: Fri, 18 Sep 2020 13:40:44 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [GIT PULL] percpu fix for v5.9-rc6 To: Arvind Sankar Cc: Matthew Wilcox , "Gustavo A. R. Silva" , Dennis Zhou , Tejun Heo , Christoph Lameter , Linux-MM , Linux Kernel Mailing List , Kees Cook Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Sep 18, 2020 at 1:29 PM Arvind Sankar wrote: > > In general (i.e. outside the implementation of the macro itself), what > is the preferred way of getting the size of just the header? > 1) offsetof(typeof(s),flex) > 2) struct_size(s, flex, 0) I think those two should end up being equivalent. > 3) sizeof(s) This works right now, but exactly *because* it works, we're not seeing the questionable cases. Of course, _also_ exactly because it just silently works, I also don't know if there may be thousands of perfectly fine uses where people really do want the header, and a "sizeof()" is simpler than alternatives 1-2. It's possible that there really are a lot of "I want to know just the header size" cases. It sounds odd, but I could _imagine_ situations like that, even though no actual case comes to mind. > 4) new macro that's easier to read than 1 or 2, but makes it clear > what you're doing? I don't think this would have any real advantage, would it? Now what might be good is if we can make "struct_size()" also actually verify that the member that is passed in is that last non-sized member. I'm not sure how to do that. I know how to check that it's *not* that last unsized member (just do "sizeof(s->flex)", and it should error), but I don't see how to assert the reverse of that). Because that kind of "yes, we actually pass in the right member" check would be good to have too. Linus