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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1653DC6FA83 for ; Fri, 2 Sep 2022 19:48:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 64B8A80118; Fri, 2 Sep 2022 15:47:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FAFB80119; Fri, 2 Sep 2022 15:47:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49D5280118; Fri, 2 Sep 2022 15:47:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 2EBC780119 for ; Fri, 2 Sep 2022 15:47:09 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 191E3403C9 for ; Fri, 2 Sep 2022 19:47:09 +0000 (UTC) X-FDA: 79868178978.14.3CEF632 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id B06A618004D for ; Fri, 2 Sep 2022 19:47:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=D9OxPNakbQ7dXKQCeoqgLhnSNcTIRcyWrbUHuZ9BacA=; b=C9hzQIQYxRxO9E3u6NbkVaFzJl bPl4rX4I/YjP7q6oYtgXlF+spNpfnnNKp+aJP3hmVRnVobJT8wc4sFNnFfm09Mai0rsEsAebYchal E/qCfD3DEg40xlAfTTv/PvACmVsIE0FaNmpQhddJpXS0uFk0WQl5nTo8ZleU2kgBTYX8BFNZaPpgg fVdGrr/KTEcjct23RnMaLdVpiplLFnRQoggasky8S3KCzLxTWlZU5+K2d2LitP9FolRUWIKvaAR43 eDtCAu2lf94khoSndXK235u/ib72mV2oiGithjoWsCfIC95RqxzbeQq4KZ7RvW8hPg1MqzxzLTP5V /odqcHWg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oUCd0-007Ibf-3P; Fri, 02 Sep 2022 19:46:58 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v2 02/57] mm: Add the first tail page to struct folio Date: Fri, 2 Sep 2022 20:45:58 +0100 Message-Id: <20220902194653.1739778-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220902194653.1739778-1-willy@infradead.org> References: <20220902194653.1739778-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662148028; a=rsa-sha256; cv=none; b=hWJ+Th262ttw9h9LDbFVzdmSYgo76HwAKq/pFXmazV3xSyP17ILC1JfA5rZjNZBP0x+MuU NLY6r+tl5d2pF9uJkkvZibPRa/CCS9dGMRDFVAc4/VR/6MSOoF0UnPzQWCWbIf7WnjhUtv ZnfX0Ln3VyFBdrH9N8b31QSLSWDxg+8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=C9hzQIQY; dmarc=none; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662148028; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=D9OxPNakbQ7dXKQCeoqgLhnSNcTIRcyWrbUHuZ9BacA=; b=qdisPHXYF9xuNnDC8t4uJjovioB6pX7xMgwzCF64EKNFOmaT53hW9F+VFHJ3OEi1UEcFnf ysWPAPsNTlrgwKrMAnfTs+HCLb2AgIgBUe5ciu4pLpowvhH/6/7QcpQSxnan0c4L1jmMNv JoBRhy1WbsgafeOQyzYj9jUTDlf0Pjk= X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: B06A618004D Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=C9hzQIQY; dmarc=none; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspam-User: X-Stat-Signature: 4tho95un6nibbjxetup8n7taxxy7tnw1 X-HE-Tag: 1662148028-692895 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: Some of the static checkers get confused by extracting the page from the folio and referring to fields in the first tail page. Adding these fields to struct folio lets us avoid doing that. It has the risk that people will refer to those fields without checking that the folio is actually a large folio, so prefix them with underscores and document the preferred function to use instead. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/mm_types.h | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index cf97f3884fda..8a9ee9d24973 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -244,6 +244,13 @@ struct page { * @_refcount: Do not access this member directly. Use folio_ref_count() * to find how many references there are to this folio. * @memcg_data: Memory Control Group data. + * @_flags_1: For large folios, additional page flags. + * @__head: Points to the folio. Do not use. + * @_folio_dtor: Which destructor to use for this folio. + * @_folio_order: Do not use directly, call folio_order(). + * @_total_mapcount: Do not use directly, call folio_entire_mapcount(). + * @_pincount: Do not use directly, call folio_maybe_dma_pinned(). + * @_folio_nr_pages: Do not use directly, call folio_nr_pages(). * * A folio is a physically, virtually and logically contiguous set * of bytes. It is a power-of-two in size, and it is aligned to that @@ -282,9 +289,17 @@ struct folio { }; struct page page; }; + unsigned long _flags_1; + unsigned long __head; + unsigned char _folio_dtor; + unsigned char _folio_order; + atomic_t _total_mapcount; + atomic_t _pincount; +#ifdef CONFIG_64BIT + unsigned int _folio_nr_pages; +#endif }; -static_assert(sizeof(struct page) == sizeof(struct folio)); #define FOLIO_MATCH(pg, fl) \ static_assert(offsetof(struct page, pg) == offsetof(struct folio, fl)) FOLIO_MATCH(flags, flags); @@ -299,6 +314,19 @@ FOLIO_MATCH(_refcount, _refcount); FOLIO_MATCH(memcg_data, memcg_data); #endif #undef FOLIO_MATCH +#define FOLIO_MATCH(pg, fl) \ + static_assert(offsetof(struct folio, fl) == \ + offsetof(struct page, pg) + sizeof(struct page)) +FOLIO_MATCH(flags, _flags_1); +FOLIO_MATCH(compound_head, __head); +FOLIO_MATCH(compound_dtor, _folio_dtor); +FOLIO_MATCH(compound_order, _folio_order); +FOLIO_MATCH(compound_mapcount, _total_mapcount); +FOLIO_MATCH(compound_pincount, _pincount); +#ifdef CONFIG_64BIT +FOLIO_MATCH(compound_nr, _folio_nr_pages); +#endif +#undef FOLIO_MATCH static inline atomic_t *folio_mapcount_ptr(struct folio *folio) { -- 2.35.1