From patchwork Wed Aug 16 15:12:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13355390 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 DF80EC04FE2 for ; Wed, 16 Aug 2023 15:13:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59B2D280027; Wed, 16 Aug 2023 11:13:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54C30280021; Wed, 16 Aug 2023 11:13:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41376280027; Wed, 16 Aug 2023 11:13:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2FC2F280021 for ; Wed, 16 Aug 2023 11:13:35 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EDB1A1C929B for ; Wed, 16 Aug 2023 15:13:34 +0000 (UTC) X-FDA: 81130311948.18.59C8058 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf16.hostedemail.com (Postfix) with ESMTP id 0117B1800A6 for ; Wed, 16 Aug 2023 15:12:13 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eMVhuX7h; dmarc=none; spf=none (imf16.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692198734; a=rsa-sha256; cv=none; b=FkcdWyQOBLJuC8AevWv9IX5Sdbu0vVez1mXeASuHtz3exkel9w9yk2ybW0og4Ey8+MX2fc sDcLnEs1j84Wf8I9Ok+gqJnWaFeTxL1CgEo8E2tPRQF/LRDM+g1RIep8gy4LKpd5CP75HQ t+V+1HFgw8UYbPzuzvwJwJ+oTTfOsk4= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eMVhuX7h; dmarc=none; spf=none (imf16.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=1692198734; 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=BwcfAds/xhqZWiqRvjYyKhMdZCr8x2s3ljtlneKBAzo=; b=OVVaw9ucIedGnsdA3t8U6iT1r/jwcenJ9ilKmITT+WrnrCxRMbFg48WMmti+lOUJLNJC7b zjlDB56qeJ3PJal4Ybllwng2uIKniQy1leXSFPncohGGsPNwDhI7KOw3Z+cD3PkHfz7N89 mq6iM1gmbcJ9PJJ8lxweYL0rlCEIwcA= 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=BwcfAds/xhqZWiqRvjYyKhMdZCr8x2s3ljtlneKBAzo=; b=eMVhuX7hG9c7mw95dVUC5g5w4t hY8TCVDL86DD/XbzNDAA4HQBlF/etzuazHCgmR7BNO+kWirnhhiSbT3bCKya7lLe6DZpzkuFdhkM6 +7HRmMgUwUaiFX3yDvVdVFil0NVo/CYS2jUu2YP5lJ4+dTilOgLgpOgmGyptMGHz5caPfvauvbX+R aFbVRLbczS/xXGM6RV3PCLjq0i+S7tEGZmj941zqJ2dgzErrqNyMKHGvhwNexx6b6hP3HBOI14FP5 6j5fnndwE7Y1tn0OBzq8AMmXOee1K1U9CDHkTxYSNy7njUxf0o/RU3ySF7d88ogszL/qnvCtod59V FhKohhCA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qWIBu-00FL90-UO; Wed, 16 Aug 2023 15:12:10 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , Jens Axboe , io-uring@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 12/13] mm: Add tail private fields to struct folio Date: Wed, 16 Aug 2023 16:12:00 +0100 Message-Id: <20230816151201.3655946-13-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230816151201.3655946-1-willy@infradead.org> References: <20230816151201.3655946-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0117B1800A6 X-Stat-Signature: 61jjs7ztihcnqbabbjo8kx5fds6qxqdb X-HE-Tag: 1692198733-335035 X-HE-Meta: U2FsdGVkX19gcTHI0xkAnO8DKoHKwan6pz0fJG1O6R7ewngjuIuezfxG6EMYLd2+5dGSFPT/CCQl4FuuP5zdJT8b44PPkkTrspX6TKbfO9mYxqPrI55++uZce3+yv2qlS5Ff0MSLxEinv7MgD1iBC0hihnGA9T0ztxiYswHy54n9WxRJGOawQFbPMh0QND2YKcqtYUsQgy1NXRxtNdunT2IwNCNaECbTUnkvSFRGm6sEAgQ6IVLOOGZj7CxA/bK40wZCRvFFHQzISfHgffR4CDYYBHXMWAObfP6IqRlI4LiWM6BMYU/gmbidkwQyf79/l+W/n5ZmkZQo9PdeLgJZNOvIJQE5ZjEcKkzE7WeCgjzRpddR0bx+0knjxJ4L3Oe/DppJNOaws7qDsaLu4lOlYm+hEl5go7I6O7TA4XyD46wR7gJtlD7lxuolfDZyTDWZpPD/0JuX6McDc633oWx8O7amBXK8pqLyYsUNGKEG+sGmsELCr3b3AYkJugpZ2rwFbSKajSekxSxK72BbR6CD/r/nKKxzOXbYy0255fkwuOlJO849+wIuhHkYPSBJwlBPGaWjt2Pe0n2e5lI6MqG12UfiyQ0hzJEx5/qeBjwZ8Udsca7/2d/aaLVTO+2ZE/3/NRAl9Z4+OXPPy47NIcqA+x0TRq9dTekTf/SVIof9Po5rC/UXSJxZeTrDIRk3tXPivFKNMBfsUmrtZ3JkdqYJm2RLSK4e1Saf2uBTg4EZPhPFQ/cykXp6INv3it6nrJq+r3wzqXBqVADB/FI4iQ2IryBl6Rl337slpRzz5UrwrUBSnYJnbj7BEt2Jg8KD3leowj0CP5zSblMQPDjz1tT18bwjl7E8wyE797LRricsOB7rxTuB2vbk94spDwQ4+5Doav6vc1loVeY3a9z9bBWMCJeQcrRpueyEDyi4xr/YnbLTkwVZx9y97TJofBeUTd5WIXiko7GY/rPdjQSlEMP oghgpiXA ul4b4+3S7CDFYPwzsQjuym6ET4oYthBkepCfPKGfyZ4gGMh7dZGCZkiylSLE5qCef+wN3aOTfYAxG9XH9gMhJXKuQgjEtBDe96zx/XeBDSZYpCQQqMcHPmaM8dwnqDk2UZK5YrgZS4S1/Hw7eJyHPde+1T+d6kwNVuz30+U6XjvB6xTtsc4ZlKtwUUg== 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: Because THP_SWAP uses page->private for each page, we must not use the space which overlaps that field for anything which would conflict with that. We avoid the conflict on 32-bit systems by disallowing THP_SWAP on 32-bit. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/mm_types.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 659c7b84726c..3880b3f2e321 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -340,8 +340,11 @@ struct folio { atomic_t _pincount; #ifdef CONFIG_64BIT unsigned int _folio_nr_pages; -#endif + /* 4 byte gap here */ /* private: the union with struct page is transitional */ + /* Fix THP_SWAP to not use tail->private */ + unsigned long _private_1; +#endif }; struct page __page_1; }; @@ -362,6 +365,9 @@ struct folio { /* public: */ struct list_head _deferred_list; /* private: the union with struct page is transitional */ + unsigned long _avail_2a; + /* Fix THP_SWAP to not use tail->private */ + unsigned long _private_2a; }; struct page __page_2; }; @@ -386,12 +392,18 @@ FOLIO_MATCH(memcg_data, memcg_data); offsetof(struct page, pg) + sizeof(struct page)) FOLIO_MATCH(flags, _flags_1); FOLIO_MATCH(compound_head, _head_1); +#ifdef CONFIG_64BIT +FOLIO_MATCH(private, _private_1); +#endif #undef FOLIO_MATCH #define FOLIO_MATCH(pg, fl) \ static_assert(offsetof(struct folio, fl) == \ offsetof(struct page, pg) + 2 * sizeof(struct page)) FOLIO_MATCH(flags, _flags_2); FOLIO_MATCH(compound_head, _head_2); +FOLIO_MATCH(flags, _flags_2a); +FOLIO_MATCH(compound_head, _head_2a); +FOLIO_MATCH(private, _private_2a); #undef FOLIO_MATCH /*