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 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 68D0FC43464 for ; Sat, 19 Sep 2020 03:02:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9F41720DD4 for ; Sat, 19 Sep 2020 03:02:19 +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="kPwKmBGU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F41720DD4 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 F24F66B005A; Fri, 18 Sep 2020 23:02:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ED4736B005C; Fri, 18 Sep 2020 23:02:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DEA2C6B005D; Fri, 18 Sep 2020 23:02:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id C69806B005A for ; Fri, 18 Sep 2020 23:02:18 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 886138249980 for ; Sat, 19 Sep 2020 03:02:18 +0000 (UTC) X-FDA: 77278312356.13.crib74_4b0843327130 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 6409418140B67 for ; Sat, 19 Sep 2020 03:02:18 +0000 (UTC) X-HE-Tag: crib74_4b0843327130 X-Filterd-Recvd-Size: 3683 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Sat, 19 Sep 2020 03:02:17 +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=hHLRJYRyLvyIi3qhTA2v07I6meTEq9wQRnMdQHFqLUM=; b=kPwKmBGUzyvgAdyJ4zKTtLjMea JkkzqYMRkvWLb0eqBagDLnkeZq4HYmxYTbLLW2qE1Vxnm8+q/k6IekMqcPamr4rEaRWF3YOOK/UIW V22xtjGPQcPCFdsyg59TZ+ys2iNm/jwB40twlnbcIFEdKnrN0+BkpBwr+ASzivw/gujxexEf/yd2g TDAD5cIoCV3bn0mtiGNpHaIq8mVZLZmSdxtPXLIrxqinxQ5YCNe6AhaI7f69SCLbRVpaOrGu1MzvB eMfOcjFDMF3kCXcAFYsSCRiXbj9QGVDSynI6g+dxiqechWaAaCd/pyshj/7rR7cjEZ50TZ3UOnCkc P15UpPiA==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJT8e-0001nD-6H; Sat, 19 Sep 2020 03:02:12 +0000 Date: Sat, 19 Sep 2020 04:02:12 +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: <20200919030212.GK32101@casper.infradead.org> References: <20200918200252.GH32101@casper.infradead.org> <20200918202909.GA2946008@rani.riverdale.lan> <20200918210050.GA2953017@rani.riverdale.lan> <20200918223957.GA2964553@rani.riverdale.lan> <20200919025336.GA3008405@rani.riverdale.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200919025336.GA3008405@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 10:53:36PM -0400, Arvind Sankar wrote: > I think you can't do this in standard C. It's a GCC extension. > > A structure containing a flexible array member, or a union > containing such a structure (possibly recursively), may not be a > member of a structure or an element of an array. (However, these > uses are permitted by GCC as extensions.) I actually have a patch in the works which wants to do this. struct pagevec { - unsigned char nr; - bool percpu_pvec_drained; - struct page *pages[PAGEVEC_SIZE]; + union { + struct { + unsigned char sz; + unsigned char nr; + bool percpu_pvec_drained; + struct page *pages[]; + }; + void *__p[PAGEVEC_SIZE + 1]; + }; }; I don't think ANSI C permits this, but it's useful to be able to declare a pagevec on the stack and be guaranteed to get enough memory to hold a useful sized array of pointers (as well as be able to dynamically allocate a larger pagevec for the cases which want such a thing). We could certainly split pagevec into a variable length array version and have a struct stack_pagevec which had the extra padding, but that involves changing a lot more code.