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 87CD8C43465 for ; Sat, 19 Sep 2020 03:37:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DD46B21897 for ; Sat, 19 Sep 2020 03:37:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NKq5xsKR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD46B21897 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=alum.mit.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 30A336B0055; Fri, 18 Sep 2020 23:37:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 294436B005C; Fri, 18 Sep 2020 23:37:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15AFE6B005D; Fri, 18 Sep 2020 23:37:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id EC84B6B0055 for ; Fri, 18 Sep 2020 23:37:07 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A796F180AD807 for ; Sat, 19 Sep 2020 03:37:07 +0000 (UTC) X-FDA: 77278400094.21.scale35_0d103c627130 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 84F77180442C3 for ; Sat, 19 Sep 2020 03:37:07 +0000 (UTC) X-HE-Tag: scale35_0d103c627130 X-Filterd-Recvd-Size: 4844 Received: from mail-qv1-f65.google.com (mail-qv1-f65.google.com [209.85.219.65]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Sat, 19 Sep 2020 03:37:07 +0000 (UTC) Received: by mail-qv1-f65.google.com with SMTP id cr8so4092118qvb.10 for ; Fri, 18 Sep 2020 20:37:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=toq7L4SsqCXQkGluRvxqWyOqRcCx3zVe/9m6BQKiNj4=; b=NKq5xsKRFFkUHwl4DGXnrrp/G1OqQNLCxeoEYtd0u6KVQvJmo60LvKkqWkoHSPwTLn yoXHS+ZksyW9w16cWLkyQEfj2mXUgNvLBZKqwBMNgqve+HPqpOpMlDzoGY1755W2snyE uEJB2ArbcoEQNqUZ/2DLQ5c8nCp62P0YxMuC97EAt+ieVfbz4dgTAiU7jW1yZcWwTkB3 D5D20Q1EyxEpHzusUSIguH2YPeHLUTsB2i6cJOsIiwToNshBr1vfj2AYZb9y8Lo6kCrH W8UfBkshddz5zOINqaZSJOr7haVapA5LWMu+Kc70uES3L03qSJG4ZTqeuQUMwUBxXlJA m/Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=toq7L4SsqCXQkGluRvxqWyOqRcCx3zVe/9m6BQKiNj4=; b=rGh51cmWLaz5rbGp1t51vSoTkq6LaWYhAvgdvXe7fTjTQ9TIGvdKId3LFQgDm0CMAN xg9qbxLeVPECnn3IEvw2Qib0tMW+8GM2kqoAmWa9maIgZMqiWR4qTt5HFxWRLzS43DVI Wd6k+9GpjeFKh9OaN2GYlofkMUgaUs2ciChueCdwESF1luMikybFkMWo+I7X/GoRqzRZ MOF4NBuM1GcRThbEZVGn5kwqau8PNSPbcb9GUguzDogW8l3nkKDW+1evtfMX2mU1kXce Lu7NShWQWXjYNOakViA53EfaXHKV53JgtM9ZLwCk3rdey+RPKZ/BiuC9oG0zHP8zggA0 ndGg== X-Gm-Message-State: AOAM530chSencSUN4N7tdxNTrWeXWd+v+KNqRUJpqzk+SZJBP5uYe5EP tRTAZOiZRus8IuUTCb+J17jD2Pcf5u8= X-Google-Smtp-Source: ABdhPJwEvd5oJAbcEssSmMyzVbLa0P+JOVCKw+dATnM3nOQC1r/DN9pd7rf1itdoheKAEa3WaO+1Ug== X-Received: by 2002:a05:6214:601:: with SMTP id z1mr36881818qvw.0.1600486626503; Fri, 18 Sep 2020 20:37:06 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id w194sm3400318qkb.130.2020.09.18.20.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 20:37:05 -0700 (PDT) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Fri, 18 Sep 2020 23:37:04 -0400 To: Matthew Wilcox Cc: Arvind Sankar , 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: <20200919033704.GA3014163@rani.riverdale.lan> References: <20200918193426.GA15213@embeddedor> <20200918200252.GH32101@casper.infradead.org> <20200918202909.GA2946008@rani.riverdale.lan> <20200918210050.GA2953017@rani.riverdale.lan> <20200918223957.GA2964553@rani.riverdale.lan> <20200919024556.GJ32101@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200919024556.GJ32101@casper.infradead.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000074, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Sep 19, 2020 at 03:45:56AM +0100, Matthew Wilcox wrote: > 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: > I wonder if there are cases where we know the total size, and are working out the number of elements in the flexible array by doing size - sizeof(s). Would a macro to do the inverse of struct_size(), i.e. get the count knowing the total size be useful?