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.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 6D424C43464 for ; Sat, 19 Sep 2020 02:46:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CA964208DB for ; Sat, 19 Sep 2020 02:46:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="gtXloL/e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA964208DB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E16126B0037; Fri, 18 Sep 2020 22:46:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DC69A6B0055; Fri, 18 Sep 2020 22:46:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDBDA6B005A; Fri, 18 Sep 2020 22:46:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id B810C6B0037 for ; Fri, 18 Sep 2020 22:46:05 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 77CB08249980 for ; Sat, 19 Sep 2020 02:46:05 +0000 (UTC) X-FDA: 77278271490.07.birth35_010438e27130 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 5D68D1803FF02 for ; Sat, 19 Sep 2020 02:46:05 +0000 (UTC) X-HE-Tag: birth35_010438e27130 X-Filterd-Recvd-Size: 3274 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Sat, 19 Sep 2020 02:46:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=IqGNJCHkPeeEzn4NZlU91gM1WIifD6Ne5eGwToLNy+M=; b=gtXloL/e0Kvaq/QDn0ut5wgWxH pUgd7WNS1TYv4EPwksDQv4wRtU/ABSj2FZZKs3Ro769lszzyWDli9JsID75OJPO93KeciullZhnK9 oiYR7LwIJR1bAD+k7f8wF8BTYmz/GdCY9F/CvF5/FfNisiw/JcmtY+L6eMtWXFXfEm4u9OSavDvUH M0xkGhOfp/k0PUY3MzhqO3TwQ1fnJWbLnFAJ6+8Ij6CsZmFgzHzOuhdaI3X8x0S7g8ttdZC9jKkGU VHzhWzDHHXe6Io4gI1xZ1SreCnXrLA3Oi/TYk2qZHnVfAiiNCqbNsGpEZgMn51tr2IcPw23yhxIMk xYJ/ZgGw==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJSsu-0000w8-Ip; Sat, 19 Sep 2020 02:45:56 +0000 Date: Sat, 19 Sep 2020 03:45:56 +0100 From: Matthew Wilcox To: Arvind Sankar Cc: Linus Torvalds , "Gustavo A. R. Silva" , Dennis Zhou , Tejun Heo , Christoph Lameter , Linux-MM , Linux Kernel Mailing List , Kees Cook Subject: Re: [GIT PULL] percpu fix for v5.9-rc6 Message-ID: <20200919024556.GJ32101@casper.infradead.org> References: <20200918193426.GA15213@embeddedor> <20200918200252.GH32101@casper.infradead.org> <20200918202909.GA2946008@rani.riverdale.lan> <20200918210050.GA2953017@rani.riverdale.lan> <20200918223957.GA2964553@rani.riverdale.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200918223957.GA2964553@rani.riverdale.lan> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 06:39:57PM -0400, Arvind Sankar wrote: > On Fri, Sep 18, 2020 at 02:18:20PM -0700, Linus Torvalds wrote: > > On Fri, Sep 18, 2020 at 2:00 PM Arvind Sankar wrote: > > > > > > You could just assert that offsetof(typeof(s),flex) == sizeof(s), no? > > > > No, because the whole point is that I want that "sizeof(s)" to *WARN*. > > Ouch, offsetof() and sizeof() will give different results in the > presence of alignment padding. > > https://godbolt.org/z/rqnxTK We really should be using offsetof() then. It's harmless because we're currently overallocating, not underallocating. The test case I did was: struct s { int count; char *p[]; }; struct_size(&s, p, 5); (48 bytes) struct_size2(&s, p, 5); (also 48 bytes) struct_size2 uses offsetof instead of sizeof. Your case is different because the chars fit in the padding at the end of the struct.