Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1642523pxk; Fri, 18 Sep 2020 19:50:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYRqs0LK539b0dq/HN9x5lPCtIaWgDsYgwQmMpB3i8zOmi3m1VNoVtSNdxmsqBrlkwwPcO X-Received: by 2002:a50:c051:: with SMTP id u17mr43483426edd.39.1600483830738; Fri, 18 Sep 2020 19:50:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600483830; cv=none; d=google.com; s=arc-20160816; b=WR8oIju7/Azf673Yi5PTQxcp7xd3gzD8+xfLOoQO6eurB/B6cYHEUmn+h0nLHbRkPt 55ZhmozGXbkJWDWXepVLk0iarShyIU0BrYBQBt2FQQLRk8QM5Rnjr/KvkCaW7U4dbzFw Td2HIV7ku/ImYjBw1gqMsCHhAupF7coAAWS9qeoIuFDK/U4qXIRvpBDDd7KMC//OlOSz JybH+BtG4rzkH3UM+Cf6G3SczRjc/c+3oKnshGjVx/fUHrQC4tQJ5qNFHTKoRy5erS3Y PzCv6JlnVUMf9TirmXWjwbIr2BooKByJbQR9riIII3HaEjLUb3JQSSaoqMo5om/0qvwI 2Wow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IqGNJCHkPeeEzn4NZlU91gM1WIifD6Ne5eGwToLNy+M=; b=wImrPhj04vHgBqnQWosxvIsJYdruG907C7kz7pugO6RiTSvyx8KxgTepThQFCXH0Jg GZp2SRXHWMEmoWdcHTd4OkC9VPgro8F5X7q54c6/nbjMtpjiOUSMGQ7Yi4UZKN9VS1dQ G1YkyV8UZAzYBHQuxHKjHSdIThYKMw89VzG02NdIvUMi3iOrH9VAkbZ1mymJmBh2OXGv tOt7Z/qhCWld/MX6obD9aZwtXa52lrxiWO/SWRztQULUPZjk0zvHgWvtu6AUc/L4D/K0 KWx5y5wlO2SDyldKJ2gDUIAEsH2fUTzz41aTcDHSYiYKEtnih32vw+3s3nvfZhXKzX0f MNmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="gtXloL/e"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r24si3499435edc.149.2020.09.18.19.50.07; Fri, 18 Sep 2020 19:50:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="gtXloL/e"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726273AbgISCqJ (ORCPT + 99 others); Fri, 18 Sep 2020 22:46:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726129AbgISCqG (ORCPT ); Fri, 18 Sep 2020 22:46:06 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC657C0613CE for ; Fri, 18 Sep 2020 19:46:05 -0700 (PDT) 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.