From patchwork Wed May 22 21:03:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13671078 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 71E99C25B78 for ; Wed, 22 May 2024 21:03:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 053626B0093; Wed, 22 May 2024 17:03:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 003BA6B0095; Wed, 22 May 2024 17:03:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE6A46B0096; Wed, 22 May 2024 17:03:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BE73C6B0093 for ; Wed, 22 May 2024 17:03:57 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3896A164CDE for ; Wed, 22 May 2024 21:03:57 +0000 (UTC) X-FDA: 82147258914.10.85540AC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 83B784001E for ; Wed, 22 May 2024 21:03:54 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HkD7xvPo; spf=pass (imf04.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716411834; a=rsa-sha256; cv=none; b=uw4x29+/LKKWp+Agz96xboqweSKKm/a8B+1FYv4/qA6ckUV2s3Y2ORCakG48OJvSQPXjvW U98630aD804b1s0RZU2NFFoh629wh7OxguLknwJWiSNogrFJXJHYDzreM1jUjGFRUfsZRG tTAJNwpG8W3g3o0LfIxax7UoQQZVIsc= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HkD7xvPo; spf=pass (imf04.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716411834; 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=02LYfptPkP3NVWI/Y1/skwE/AqJ4JQacKiY+62xb+tg=; b=CYjq++YSOO/tBz1RbMYRGlmkZMBHm1r9z45B/uYtYjU1tjDg4afcG+Fx77j4E2v6vCUlHc kehTTTeyrnQIl823dnnh3Pc6oRjZer+ebxwFYaiUNoifY+FrXecyoJSz2sAneuG4TvT1qP h8pHR+JFxyNroIDavags6w4nCCXfBCI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716411833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=02LYfptPkP3NVWI/Y1/skwE/AqJ4JQacKiY+62xb+tg=; b=HkD7xvPoadeiytz857EaTNYmZWnh9Tq6j4tML/NmY8JXV4bp5wzkDyD4aB+Q8Is5kpV6Kc W4+cJEqILe1XWNrMA0Fdb1Eem3W7lnhJTdXMiKVnHsGaOQ2nLkNbt07bz7/tSgNIxXcr3e BXXaDChLzx8m1ekMXptB2gOqsMAwQbw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-30-cKasN1UEODSQMPyfVtjrrA-1; Wed, 22 May 2024 17:03:48 -0400 X-MC-Unique: cKasN1UEODSQMPyfVtjrrA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC5A729AA3B8; Wed, 22 May 2024 21:03:47 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 61F1F28E2; Wed, 22 May 2024 21:03:45 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , "Matthew Wilcox (Oracle)" , Mike Rapoport , Minchan Kim , Sergey Senozhatsky , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH RFC 1/6] mm: update _mapcount and page_type documentation Date: Wed, 22 May 2024 23:03:36 +0200 Message-ID: <20240522210341.1030552-2-david@redhat.com> In-Reply-To: <20240522210341.1030552-1-david@redhat.com> References: <20240522210341.1030552-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspamd-Queue-Id: 83B784001E X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: tt1jtwrz3tcrumc779fej59jo3pxhgj1 X-HE-Tag: 1716411834-870364 X-HE-Meta: U2FsdGVkX19yi4/gsXp3MkZAdz6xpSUgmWMg+hBFjCOlDSYfk2UsvPTcg5apebewRh6jbyLXdDzzItfCNtLib+znlOuWReNTSEOYz/q60SF9MCNZX9p1HVqMIuqmdQqWi3MqffFlzDx1t4tPKVL+lJiXcE4yvYXMLEwMnUzMhwXLn+tHbl4a8AAGryxkwrWWriWLFbwqFi2OTwffcA/4/Fr2xu9YpX6b6ixGNYguNH211eUVAV6b2yecXnrtYq3jbcf/oOUHTYoJbsWXi+xWcTNWSCd0sOvDQWyJstq5h4XOMm1TC4CZEvUiMG6kH+qtv0Plgg3Tdf0dloTg6MYSre7d9bKeFD6FRv/Sa97Pr2rKX0Ykv7UIGLvD5jAoIVDtWKuQs1nUOHbJOXb74rzdMvwpBHu32cxE7job83ELx+23vA41lVyU/4tZmC+u6kwfj7CX/DSbRuQRPEdbsmESrwHTiKdapsMxCG1oIsLXVdmWBUDnh2SXiF0ijbye9xLZcrLM834hNwxYZkrlAd4xL+7oIL96NAAAoyQoNNghacfVEKFE+OSS039gBKsPCPvk7UrnUmg4K4g+KkR56Zf1Od+XQxex8aCcAnJQ7RPmX72sxgcdq2HcS9A5u7edO4I/PZgXVWfIBzAFDxUM9TBTE0zyYFgPbq7BYQSD4GLFO/7IbjzHJqysspk/mHY2ojAaxq06Ht0XRyxNwcVwHDYCxXQtCYW+BeknzSiO87XRcOvCXIStrDyOx8qdt1LKKHYXsQ4MZBLAu7pbFtB5npjNceDvpGW7F8BIMCkwuSDW73RuSKw7LJyESh8ngawF2K67petMxcu7NR85xXFXnVzCnOvU1Mfb8DSxBZbzpWGP7NHuquL7BvOs7sWHXmefk/uK5ISrX+cL2uew5GfSOBKfFUw0zMD9ks18NhBTVjAQk8GO5jpWo+rmqewI67Xk0oLOUNwFr7LAcAnIkjMC2zF LReJcSM+ PKoBdRmq9zJ/FoDq3OOAzK4TOHOqw1HPzTwoKcmtizB2G2Lmn/lc3dShLV38kT1hbGe2kTLb7nzrH8xwNgbTHtKlMYf5zD4C089YlSjr2ep034yfeJZ4+TQ0ZDoVo1UeGuY0qIeP1yno6TRWxEU0OoVaMw5Dte+iBDu2OP5zG8dWJIH93magnzoBSieC1QXzgbiQM04NJe9z1QNT9BRKE8mVCBAY4c06kEOn0b/Pg0MDbfui+5I6Q8hqbgvXNtXGOOm+YYyBPzS7PTGmUkFV1mDV+O8v3n7mCdAWo 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: List-Subscribe: List-Unsubscribe: Let's make it clearer that _mapcount must no longer be used for own purposes, and how _mapcount and page_type behaves nowadays (also in the context of hugetlb folios, which are typed folios that will be mapped to user space). Move the documentation regarding "-1" over from page_mapcount_reset(), which we will remove next. Signed-off-by: David Hildenbrand --- include/linux/mm.h | 5 ----- include/linux/mm_types.h | 24 +++++++++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 9849dfda44d4..018e7c0265ca 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1206,11 +1206,6 @@ static inline int folio_entire_mapcount(const struct folio *folio) return atomic_read(&folio->_entire_mapcount) + 1; } -/* - * The atomic page->_mapcount, starts from -1: so that transitions - * both from it and to it can be tracked, using atomic_inc_and_test - * and atomic_add_negative(-1). - */ static inline void page_mapcount_reset(struct page *page) { atomic_set(&(page)->_mapcount, -1); diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 24323c7d0bd4..532a3030405d 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -46,9 +46,7 @@ struct mem_cgroup; * which is guaranteed to be aligned. If you use the same storage as * page->mapping, you must restore it to NULL before freeing the page. * - * If your page will not be mapped to userspace, you can also use the four - * bytes in the mapcount union, but you must call page_mapcount_reset() - * before freeing it. + * The mapcount field must not be used for own purposes. * * If you want to use the refcount field, it must be used in such a way * that other CPUs temporarily incrementing and then decrementing the @@ -152,16 +150,24 @@ struct page { union { /* This union is 4 bytes in size. */ /* - * If the page can be mapped to userspace, encodes the number - * of times this page is referenced by a page table. + * For pages part of non-typed folios for which mappings are + * tracked via the RMAP, encodes the number of times this page + * is directly referenced by a page table. + * + * Note that the mapcount is always initialized to -1, so that + * transitions both from it and to it can be tracked, using + * atomic_inc_and_test() and atomic_add_negative(-1). */ atomic_t _mapcount; /* - * If the page is neither PageSlab nor mappable to userspace, - * the value stored here may help determine what this page - * is used for. See page-flags.h for a list of page types - * which are currently stored here. + * For head pages of typed folios, the value stored here + * allows for determining what this page is used for. The + * tail pages of typed folios will not store a type + * (mapcount == -1). + * + * See page-flags.h for a list of page types which are currently + * stored here. */ unsigned int page_type; }; From patchwork Wed May 22 21:03:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13671083 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 EB04BC25B78 for ; Wed, 22 May 2024 21:04:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81CF96B009F; Wed, 22 May 2024 17:04:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CC266B00A0; Wed, 22 May 2024 17:04:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 694406B00A1; Wed, 22 May 2024 17:04:13 -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 4874F6B009F for ; Wed, 22 May 2024 17:04:13 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BD2C2A4B82 for ; Wed, 22 May 2024 21:04:12 +0000 (UTC) X-FDA: 82147259544.02.7254174 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 11EB9A0008 for ; Wed, 22 May 2024 21:04:10 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LhsJd9Qb; spf=pass (imf25.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716411851; a=rsa-sha256; cv=none; b=XgG3QU9VgP7affAilJxpHfiZuX0u2onai6/jBNbKk44yWiYBdP12rAlvnn2qLDQXjO9R76 L2Z/vJMAcaKLiyO9qn5LRDb8h9+sPpQB/KzpsgB4Jdj2htUVcUcCqOtl/3R5q3fyOF3ZfW kHFjxBUoyua0p3cXgw7pQ20MVkKv7aU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LhsJd9Qb; spf=pass (imf25.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716411851; 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=bs73/DhQAjKCEOqgI5WjSruY0e+O/eQEazhESJihTfc=; b=ftzBeDyBEsCTcnGdgqRnAchrQOUXBXa3WpgsYFyf7g1+y5fwv3aCWXpNSdedGJ2I/eWQ2F YIqTtUbMzdnnkrb9H+MuQhERHSAcnSBHx4gk3+4/4R+uiU7SreSYuBdtT91CWpmQX0onPm VHMLOjla7byVCd23AiNpvfLnLFQIzrc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716411850; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bs73/DhQAjKCEOqgI5WjSruY0e+O/eQEazhESJihTfc=; b=LhsJd9QbkCpmzUyoTqYWnVRq1BtoeiUn1vI6cDCN2pN0DrCXLZP/nZ6HDwzWzPGULu22XI kHPPh3ZZbbZJWNW62Y/x4Z30oPpmfT1vJcYr7vTbA+5/m3W7ocr6bFFYMWaTceSAxbSaMX 1QrsoPLy1hdt1UXGu6LNGilq6wEZSLY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-515-HtzN_wyHOzWPGa337eP5gw-1; Wed, 22 May 2024 17:03:50 -0400 X-MC-Unique: HtzN_wyHOzWPGa337eP5gw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6B0D6185A78E; Wed, 22 May 2024 21:03:50 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2949B7414; Wed, 22 May 2024 21:03:47 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , "Matthew Wilcox (Oracle)" , Mike Rapoport , Minchan Kim , Sergey Senozhatsky , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH RFC 2/6] mm: allow reuse of the lower 16bit of the page type with an actual type Date: Wed, 22 May 2024 23:03:37 +0200 Message-ID: <20240522210341.1030552-3-david@redhat.com> In-Reply-To: <20240522210341.1030552-1-david@redhat.com> References: <20240522210341.1030552-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspamd-Queue-Id: 11EB9A0008 X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: x89grgemai564d79915fs3kcjuxymcf6 X-HE-Tag: 1716411850-139424 X-HE-Meta: U2FsdGVkX1/aBXmkC7T1FEXrAiPoMU+QGhblWXFruLXSKXsNis0fxBG2B90kOuhpxsXvI9bOnlw1uHw83Bpl6//ZjG5HcVESHiT+vAXCZZIDoRp24vIHjt5n/RdX8Bez+ngUi02y7GHDegnCFMn26N2bC1UprIqSe5khPRP6WswJ5+o2NO7/K7ijFe+cA5ZyNQVOBGPmysBXSSdF+Qgv42DmttXWD3mtIDg7URKodBZ3xjO+kYJI4cnCZOQGeR+nzFDSeOeFjoOwDXWQXmhbHsgbULrqM9afYHrvqmHQpLYMNMXghwYnzszp/QCm5iaYxA20i1rn3UwjD3RBcSQ9FlRvxTVBoBQEsrycLqT+GO2Xfr9xaoOFxBbsVzHAYlZq8gKN+o773VmCrxGuchRkgx2dijWGZBCBzyUxnfieA9CR/vymOvYGXZeCMB4Xax9ogoNm0JsxwMGksv0lNmM/vHDf5yMgnQhNKAFyP6cmizXU6DImCwq8kuffUVKxY5VFuzVLs5RBjjsH5VwSkhR4H7OvzcN3N7PhqpFfUaUdZT6Bc8yOCdM4jBQ6f6/kWeiv/hh8Q7Evm+cMHpb81MEJT5sxMJIMHvFUzaGX2ZWNALNvGENUkM7SgjnZDVJUf5iG03KMZuRSlPPMYuKfgDuqGXTsiY09WLbVspQVZCLZ2I7/NgMF6OkYNrxAbx80M5wfjWPrkeiT9f34Bof8wgHxKuxg9J4y2bnVOtEGj86q9r0VbnacxOYdjOWTudQCxtPkgKPqBKkm9ujvsuqYEzfKgT0HT+h6uH2Wbw1jz5/GoodL1EWF4xuN9E9xFD5eT8M3W6XMHOqEt+ELNbCukz7WzdTv3Zvm5uyKb8n7inNJeYWb8FlWBN1N6lH2/+JXKUL8QnUrJbTIPNaAK2aWumcYkzKe0d+K1mutY4sPO/pOcyZkJZ9tClj27r9nV/qlVn01QRe8YwXYIycjDUFnijV vzdHsWmh TVrgBh02oQkPPVtN1au786zaA74TnfxFzX5ydY1SxzztiZ9sz8Y9/pgnA+Y/PKNQgMNkT2SxFmLXy7Tw25aTWIDZo3mik6zjfiyM8ruJnhI2NP/BcnLnCbDfhboa/VYsmMJrwk5qC5frCQGm7P5rUfgRG3C7o6O1cYFnqe2UzlDlRi0B6pskuZ+ZjFgbXBXJdv+LPUV6QgnsXrp518iApwyTqDvqwgJd6xCZYsxYIF6tE4BIv05Bj9+ZG40D8JqZlHLtb6GFSpmBIZ4jFFFi8G7rW3w== 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: List-Subscribe: List-Unsubscribe: As long as the owner sets a page type first, we can allow reuse of the lower 16bit! Restrict it to the head page. We'll use that for zsmalloc next, to set a proper type while still reusing that field to store information that cannot go elsewhere for now. Fear of running out of bits for storing the actual type? Actually, we don't need one bit per type, we could store a single value instead. Signed-off-by: David Hildenbrand Signed-off-by: David Hildenbrand --- include/linux/mm_types.h | 5 +++++ include/linux/page-flags.h | 22 ++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 532a3030405d..6dae8e15037b 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -168,6 +168,11 @@ struct page { * * See page-flags.h for a list of page types which are currently * stored here. + * + * Owners of typed folios may reuse the lower 16bit of the + * head page page_type field after setting the page type, + * but must reset these 16 bit to -1 before clearing the + * page type. */ unsigned int page_type; }; diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 104078afe0b1..ed9ac4b5233d 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -942,17 +942,23 @@ PAGEFLAG_FALSE(HasHWPoisoned, has_hwpoisoned) * __ClearPageFoo *sets* the bit used for PageFoo. We reserve a few high and * low bits so that an underflow or overflow of _mapcount won't be * mistaken for a page type value. + * + * The highest bit must always be 1, to make page_has_type() work as expected. */ #define PAGE_TYPE_BASE 0xf0000000 -/* Reserve 0x0000007f to catch underflows of _mapcount */ -#define PAGE_MAPCOUNT_RESERVE -128 -#define PG_buddy 0x00000080 -#define PG_offline 0x00000100 -#define PG_table 0x00000200 -#define PG_guard 0x00000400 -#define PG_hugetlb 0x00000800 -#define PG_slab 0x00001000 +/* + * Reserve 0x0000ffff to catch underflows of _mapcount and + * allow owners that set a type to reuse the lower 16 bit for their own + * purposes. + */ +#define PAGE_MAPCOUNT_RESERVE -65536 +#define PG_buddy 0x00010080 +#define PG_offline 0x00020000 +#define PG_table 0x00040000 +#define PG_guard 0x00080000 +#define PG_hugetlb 0x00100800 +#define PG_slab 0x00200000 #define PageType(page, flag) \ ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) From patchwork Wed May 22 21:03:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13671079 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 8DF40C25B7C for ; Wed, 22 May 2024 21:04:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 164F36B0095; Wed, 22 May 2024 17:04:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1152C6B0096; Wed, 22 May 2024 17:04:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED0A86B0098; Wed, 22 May 2024 17:03:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id CCEB16B0095 for ; Wed, 22 May 2024 17:03:59 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7C1FA164CF2 for ; Wed, 22 May 2024 21:03:59 +0000 (UTC) X-FDA: 82147258998.12.08544B1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id C9829100016 for ; Wed, 22 May 2024 21:03:57 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BNzyaXA5; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716411837; 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=DITBJncVvL2hCWefig3RBM7cSj7OZ/WRaZeUNOkaevI=; b=WQdxXmR4ZtFAgKdR9cuRIld4sgr9/ZTVTGoVe+h/S+09srKvWQvdIG0IFqT7mLVi3WKwlD Zt7Xv+oHy6q8F4xV4ME63LnLMWV/JlfSKwQwkHQROw7oMaHcsJseyXZ7F8GsrGBoKlN+zo IyOPRs0EVFOnVj+g782CIj5EnDBZQCc= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BNzyaXA5; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716411837; a=rsa-sha256; cv=none; b=HKPK83HOC+IeksckAeNeZZRz2I3uhpQipFnVdFETUT8Ndfoe0uYpMjpB7yN0hXjhVBU6/E WoL7HnqaJB3/kI7SVtkhkl7u+46WuD3Ac1r47Q0KhExHJoj2n2s5IVZxH3ITQKu5EYYa3W UD2gTkVBX0Wpb2nV4ooWVjW/b8yw3FQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716411837; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DITBJncVvL2hCWefig3RBM7cSj7OZ/WRaZeUNOkaevI=; b=BNzyaXA5Ss4ZGKfbmBteNNnTKR22B+dYOgJ8u47EW87zNL/mQz+nvPEaM30lkGTGPfvMOP nq9SjkbFT99LvXA46CeSHWKBMG2uiy2ebyyhdSzVPKhsrYu4Dv8ETpXSW6g5flpI9h/hFv ijhfxo54P2di7wDhYRcFxC1e/3Yda8w= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-688-dYd8dj26PQesLwmRv2SXfA-1; Wed, 22 May 2024 17:03:53 -0400 X-MC-Unique: dYd8dj26PQesLwmRv2SXfA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F3C5780028D; Wed, 22 May 2024 21:03:52 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6A5628E3; Wed, 22 May 2024 21:03:50 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , "Matthew Wilcox (Oracle)" , Mike Rapoport , Minchan Kim , Sergey Senozhatsky , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH RFC 3/6] mm/zsmalloc: use a proper page type Date: Wed, 22 May 2024 23:03:38 +0200 Message-ID: <20240522210341.1030552-4-david@redhat.com> In-Reply-To: <20240522210341.1030552-1-david@redhat.com> References: <20240522210341.1030552-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspamd-Queue-Id: C9829100016 X-Stat-Signature: 1kqfcm7wk5kksqq44kpbxji7n748z4z7 X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1716411837-733803 X-HE-Meta: U2FsdGVkX1+CD7FjkMgCVM36OWFXhO3AxBIkYd/JYIy7sTRw5AEg9W/IHFKhCPFhln9utSq1hkbG8S0zPz2DM04CTQauuHV1AbAT4KiFxgcQEI9TUF2QKj9J21FEIWxoYzlZow2oAzX2UpUGzoaF0AGvlCA5rfRINtiuERyL4jKrQ8xNeqNwTsRXol1cY/GdZV0aPx71+fYz88lbCDoavPUFTDbpryvKYgM2qiuFvkU/pathKtW1u0dGO8P5HYXWpyGuR6IE87gZD1sZGj6fqe1J33y4zyKXyDRJ7wAxSFCbGqwrb5EVDVx8wyxkc1RLP64XH7vH1O0Rz9gLpLrqizn//y52UkW4thEE2+Eqd6SGGLByn61qsAkuI66O+ntY5By+px0h8iXOVZWx9ta+QhVxFNTIHDLLJNNMyt6aE77FeGG+4GvHYxhVSTygNLnJ6g3CzVhSXHZn5CtpHh0hdxUUo7Je/rsyM+QjYNcQ9xAyJX7jLph2+jKUs5xOl8kjONrhILA9I5T+39DZldIYSFyL2E41R49RvblkkYPW0fqTYr0yc73OQFG5AolM4i86se5nkDmkhJc0BIjmZ19S8mgc1O2HylmEX3X1AzJYW/cOUvPfsV3xkmNBnpN4etgn5jQxoQrmbBk/Pz/NxKXuIDFnwM4ucPLjO59os8iT8xW5xlbVY0q3J3DSSaxVeepNuLrPsgv9QJoarWs4bCsA+6lIhBSD2McbXXECCwPQpGo9RzVn3LLDRBxf2FPAL5UJ/bhiJbIUwSlzTg91ng3B3F7kL9M6ykEf4sZyOU5KPJLi82wpkyeOHwLY3t1lOeb+sb0XUcvHvGq8AM1bBJKSKtKebA8i3Ou+rJR2oylqa9gRx3FA7VHnF7PpHGyFtURH1MUaKgvJG3guTmVlqYN6LOopZgT9vbrrZcXCtmczd3jvIYegmGjR/1pBLr03INmY1E602+kmt7rUC55lYkU KlioHM3Q 02M+gN9YbGvTTgTS6fyx0B04FjUJcg1oiu3HGX1Jb90IHU4aG+jh/ePdQdFSMBoWY/I0vKyczBtal6MpE1iwWysynCJE+mOLzlVXnHhey9uxde1AZ5+AudHhiWBIA7Cytsd35SV3wXRY0L45gZkyZF27v7pQvYeknNLiXPQFaQNI0Y8ePe0Aojqab62Rm9Frgz8QlsU30sPRVDE+3HYMdYwy//Al8fo84dH0PdNm6t8bo3RDI74CP7LNawH2o5IlRJHV0qtsSHwSNFzfuhmDHaQkzmiJYlhBTDEIhZT4f7KDQJlZ5pU5PCb5b/B+wI4vf/Fd4sf0bGEBENj4= 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: List-Subscribe: List-Unsubscribe: Let's clean it up: use a proper page type and store our data (offset into a page) in the lower 16 bit as documented. We'll have to restrict ourselves to <= 64KB base page size (so the offset fits into 16 bit), which sounds reasonable. Unfortunately, we don't have any space to store it elsewhere for now. Based on this, we should do a proper "struct zsdesc" conversion, as proposed in [1]. This removes the last _mapcount/page_type offender. [1] https://lore.kernel.org/all/20231130101242.2590384-1-42.hyeyoo@gmail.com/ Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: David Hildenbrand --- include/linux/page-flags.h | 3 +++ mm/Kconfig | 1 + mm/zsmalloc.c | 23 +++++++++++++++++++---- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index ed9ac4b5233d..ccaf16656de9 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -959,6 +959,7 @@ PAGEFLAG_FALSE(HasHWPoisoned, has_hwpoisoned) #define PG_guard 0x00080000 #define PG_hugetlb 0x00100800 #define PG_slab 0x00200000 +#define PG_zsmalloc 0x00400000 #define PageType(page, flag) \ ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) @@ -1073,6 +1074,8 @@ FOLIO_TYPE_OPS(hugetlb, hugetlb) FOLIO_TEST_FLAG_FALSE(hugetlb) #endif +PAGE_TYPE_OPS(Zsmalloc, zsmalloc, zsmalloc) + /** * PageHuge - Determine if the page belongs to hugetlbfs * @page: The page to test. diff --git a/mm/Kconfig b/mm/Kconfig index b4cb45255a54..0371d79b1b75 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -190,6 +190,7 @@ config ZSMALLOC tristate prompt "N:1 compression allocator (zsmalloc)" if ZSWAP depends on MMU + depends on PAGE_SIZE_LESS_THAN_256KB # we want <= 64KB help zsmalloc is a slab-based memory allocator designed to store pages of various compression levels efficiently. It achieves diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index b42d3545ca85..6f0032e06242 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -20,7 +20,8 @@ * page->index: links together all component pages of a zspage * For the huge page, this is always 0, so we use this field * to store handle. - * page->page_type: first object offset in a subpage of zspage + * page->page_type: PG_zsmalloc, lower 16 bit locate the first object + * offset in a subpage of a zspage * * Usage of struct page flags: * PG_private: identifies the first component page @@ -450,14 +451,22 @@ static inline struct page *get_first_page(struct zspage *zspage) return first_page; } +static inline void reset_first_obj_offset(struct page *page) +{ + page->page_type |= 0xffff; +} + static inline unsigned int get_first_obj_offset(struct page *page) { - return page->page_type; + return page->page_type & 0xffff; } static inline void set_first_obj_offset(struct page *page, unsigned int offset) { - page->page_type = offset; + BUILD_BUG_ON(PAGE_SIZE & ~0xffff); + VM_WARN_ON_ONCE(offset & ~0xffff); + page->page_type &= ~0xffff; + page->page_type |= offset & 0xffff; } static inline unsigned int get_freeobj(struct zspage *zspage) @@ -791,8 +800,9 @@ static void reset_page(struct page *page) __ClearPageMovable(page); ClearPagePrivate(page); set_page_private(page, 0); - page_mapcount_reset(page); page->index = 0; + reset_first_obj_offset(page); + __ClearPageZsmalloc(page); } static int trylock_zspage(struct zspage *zspage) @@ -965,11 +975,13 @@ static struct zspage *alloc_zspage(struct zs_pool *pool, if (!page) { while (--i >= 0) { dec_zone_page_state(pages[i], NR_ZSPAGES); + __ClearPageZsmalloc(pages[i]); __free_page(pages[i]); } cache_free_zspage(pool, zspage); return NULL; } + __SetPageZsmalloc(page); inc_zone_page_state(page, NR_ZSPAGES); pages[i] = page; @@ -1762,6 +1774,9 @@ static int zs_page_migrate(struct page *newpage, struct page *page, VM_BUG_ON_PAGE(!PageIsolated(page), page); + /* We're committed, tell the world that this is a Zsmalloc page. */ + __SetPageZsmalloc(newpage); + /* The page is locked, so this pointer must remain valid */ zspage = get_zspage(page); pool = zspage->pool; From patchwork Wed May 22 21:03:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13671080 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 EC780C25B78 for ; Wed, 22 May 2024 21:04:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 783B86B009A; Wed, 22 May 2024 17:04:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6EBF26B009C; Wed, 22 May 2024 17:04:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5856B6B009B; Wed, 22 May 2024 17:04:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 393C86B0099 for ; Wed, 22 May 2024 17:04:04 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B19D11A4C0F for ; Wed, 22 May 2024 21:04:03 +0000 (UTC) X-FDA: 82147259166.23.DB80C40 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id E418440011 for ; Wed, 22 May 2024 21:04:01 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZXqd8BQX; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716411842; 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=V6qRfeG4CVJz5l48G3FsZPf4ap0/Ubwcpkx8trvSrMU=; b=KxZ94WfOyJ4uoWWl7s4TvV188r+6/zVhJbX8Ip00yUQ4Lw9qA7or8fzQ2mWbm6JPe19OFI +i4N5YAyZpGGwdCNqtqc7CGFdq5zQn5TbQ411NwrjjCGoufjhxuRbsZipz8q6qMJh++9cR XtrkTPM0gyyF3YIAHKKVZCvBxu4R7Zo= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZXqd8BQX; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716411842; a=rsa-sha256; cv=none; b=4mhC5jlsqoZvkoKirHJ0Vn8XRcNW/Vexno3J8y7vgtjjBSfgGEdBULN/7y/X7c54KdabwR lTanR7udMIfHBhV+OHE6mjV58zoplvg8CPwyQYRshJRfdSz6RqvwxRzsIEesE33Xej9KyT mUCLuiKSG3l0iKy79MVgwyKb3qVnkD0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716411841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V6qRfeG4CVJz5l48G3FsZPf4ap0/Ubwcpkx8trvSrMU=; b=ZXqd8BQXXaIQaZHIabCb7e1j2IwI5IX89oUA6oph2o02tMu3DZANjrPH7EmPKCpduPfWu5 Ss8lsUTHWVolSeNagID9vYzedVAdWyJNCm5NkRM2kr1j+zIfM4kC8xCTIfjDEsd2Yvi76Y qc3Grz8gyCUxb1ax6dEuLKNLT62jr2s= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-444-gaoAYFYkNC-gX_dN8vliYw-1; Wed, 22 May 2024 17:03:55 -0400 X-MC-Unique: gaoAYFYkNC-gX_dN8vliYw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 49F378008A4; Wed, 22 May 2024 21:03:55 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F27B7412; Wed, 22 May 2024 21:03:53 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , "Matthew Wilcox (Oracle)" , Mike Rapoport , Minchan Kim , Sergey Senozhatsky , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH RFC 4/6] mm/page_alloc: clear PageBuddy using __ClearPageBuddy() for bad pages Date: Wed, 22 May 2024 23:03:39 +0200 Message-ID: <20240522210341.1030552-5-david@redhat.com> In-Reply-To: <20240522210341.1030552-1-david@redhat.com> References: <20240522210341.1030552-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspamd-Queue-Id: E418440011 X-Stat-Signature: q1jp37g3aig5ewdii196wz93zk9r1o61 X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1716411841-185406 X-HE-Meta: U2FsdGVkX1/n6yZOJXNpcZDJh4KDuj/LDRXM7zZGxIRs2Q8CbWCHIQHsT/K9MfnkjldKsrQaOtZGVM/NLQSJ6yvwArQdzN7Fr3LmlNY36rDoO932s6etrSKojTgNtvd843caHbinelmI8NpWBDAinEh8ZsrJB90TYcgS3+zqsNlYPkwENtt53vdHXBmiKe/bDYkVNM0gB7fsOXojWXJ+Q6pqYuit7fHki1E94me81nwp9IAg8UcZi757+iH+fzg7shK9rVn5lISvH9+r8oIGlFwHxKvy3jheH1CXmiMr/T5uHmm1UWEnpIIex0q5ZAqo7aPziXPg28RRGMnnMZ0FaenjLt066Xq678glDOQLJjOrIDsJvJTb3Ym1CU8uOZpk6FlZvAyj6gvRypYQd7ZczB0nuQcMCygVMehvDvL3lYd2d0BQi/yoL2jA+mBOugaddE2U11/JBNJw3ywucXP0F34XSpY0p/lTKTEEv6+Gxa7KBO0LHPHL1Ow4gzJgPXmsGCjapzGsNXEQSWhiOn2p0F0HsY7sfztcuREeyoOMAnlLkmpDAyweUIkSE0LeSIxpVFMwwh1tsDf5buyQ/eT0fHr2vJ5Fd5VKYTHv7eDXHMOk4hpNaanIPZSGfyhamGprc2nmhNklZ+zFFUPv0mzTpxouiOdjl9PJwllYuyE0wD6Rv+0hrp7KFBlBCoDqcGyfEgCy2L8xvpJigeo4tdCKmOXu2Zm09R+p91jcWhkXA09kT64uKPfJZ/Wr/jJl4amOYiRDRW3mrtka7gaURnY51pjpdk4bWNA2DJHv+cD4XL5f6f6xWrmnj4Z3q3npGhPkfUINSGIPhGU6Ns1SIYYyRBK+11i4Hx7doiAGKYH4St0YVRrC0KOE5+rr11xnfZWlpvpKbhjH/6ryi2MGohR8mu38Lr99OntBUlHyzBRBhGaroipEnyv7rqpYhcVXtVDGVWjHo4auGcRx5OfX7qZ wwVb01wN 6kOiI/vEMvXLbNNzp0llH+Ti/MiyozLAlBxhKQtjHyIhdfdH5ngNHYXBvgMwUbU5ketRv71Qqwvwtzp95u8R003sQEH7uFgFwzHeh975meEMaBkFezAy91lOlXe2N9dxEkQfChe2RqwzHtPFwJ0QnrS+WI2lNDyWgof6sE8N6PUyO1N1xBFdTd7DBivRb3qr0QDRHJcFDaubrPluzht347JQnEvwzSoTOjMDMpdjcflC+fvl/TSi3t/XUBy9sdoOTIPpKgMRRDImU/5JvSc3YCqWFShbbSi9Ydm6o 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: List-Subscribe: List-Unsubscribe: Let's stop using page_mapcount_reset() and clear PageBuddy using __ClearPageBuddy() instead. Signed-off-by: David Hildenbrand --- mm/page_alloc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2e22ce5675ca..b595342e73c2 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -498,7 +498,8 @@ static void bad_page(struct page *page, const char *reason) dump_stack(); out: /* Leave bad fields for debug, except PageBuddy could make trouble */ - page_mapcount_reset(page); /* remove PageBuddy */ + if (PageBuddy(page)) + __ClearPageBuddy(page); add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); } @@ -1346,7 +1347,8 @@ static void check_new_page_bad(struct page *page) { if (unlikely(page->flags & __PG_HWPOISON)) { /* Don't complain about hwpoisoned pages */ - page_mapcount_reset(page); /* remove PageBuddy */ + if (PageBuddy(page)) + __ClearPageBuddy(page); return; } From patchwork Wed May 22 21:03:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13671081 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 D5560C25B7A for ; Wed, 22 May 2024 21:04:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2BC06B0099; Wed, 22 May 2024 17:04:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD88C6B009B; Wed, 22 May 2024 17:04:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 904716B009D; Wed, 22 May 2024 17:04:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 60D346B0099 for ; Wed, 22 May 2024 17:04:04 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1661AA8348 for ; Wed, 22 May 2024 21:04:04 +0000 (UTC) X-FDA: 82147259208.19.2161461 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 645AEA000C for ; Wed, 22 May 2024 21:04:02 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fTyhkeWl; spf=pass (imf25.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716411842; 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=UoCowHIZmwbvZhrcmlKDIE01w7msvc9uRa4jOe21Z9s=; b=4+mtkg6lfi2UM4gxLxHENkI9yyg0DE+OqIDEE+Wcwn1gtMkvlRz0J8d2quBmZnj77mMSsf 3t2aFPxZBjxpJtAXQdQZcptm5FIGFt5Kk1+2iPCIUdj/mmqCdSkiMISGSJ8wgtJnJQ3s7P Xyto5OOQpSakGcAXRG/+Z/K7lOwAd6g= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fTyhkeWl; spf=pass (imf25.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716411842; a=rsa-sha256; cv=none; b=y0/8/3Okk1B9gpv8J+h584xloJiZ6ey5sQxmVKdkkn+j2C/RIufuXJG+GyOtc9qhJ6C+XW WydI+krCvxdVmk91nxKSyf6HLNAeFZETaxNF3gVDDzfb18tuHTijcfM9YSQT9RRB+reTmo 5Nm8kv1lbA1+Ks245B2ejE26d2DX4qs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716411841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UoCowHIZmwbvZhrcmlKDIE01w7msvc9uRa4jOe21Z9s=; b=fTyhkeWlGhpiTNDRbJVouWI9IkWIIQ4NquTg7hPWe6i9or7tiRwpfZTKdamyE4GSEjoiqO Os7Z2B44Y3H44kQcKUIM2lFqQlWElXs45rjCFW7+coyMWryIfKY7otAlDfVDogy8RTLqp4 R4VTbauXZgpzIdEp+rOPy9CleAMXbHM= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-194-SYtBQfzfNPKl0OuyCBwpzw-1; Wed, 22 May 2024 17:03:58 -0400 X-MC-Unique: SYtBQfzfNPKl0OuyCBwpzw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C62691C05142; Wed, 22 May 2024 21:03:57 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8409628E2; Wed, 22 May 2024 21:03:55 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , "Matthew Wilcox (Oracle)" , Mike Rapoport , Minchan Kim , Sergey Senozhatsky , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH RFC 5/6] mm/filemap: reinitialize folio->_mapcount directly Date: Wed, 22 May 2024 23:03:40 +0200 Message-ID: <20240522210341.1030552-6-david@redhat.com> In-Reply-To: <20240522210341.1030552-1-david@redhat.com> References: <20240522210341.1030552-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Stat-Signature: o5d69zrwixs1euzew3neace7hrq6qws3 X-Rspamd-Queue-Id: 645AEA000C X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1716411842-776684 X-HE-Meta: U2FsdGVkX19nNOQNCNLqC3tKTX8Nrc5WCyzhDirMA6vlwxuukONHMZtYbAviYt49TxSDOe9hvVaS2WuU2nxSN8TZmfaCqAHlAojnwiWjoG6Yh9WU+BKkcUW0MSLgnmQBC5XiOfQdG9nL7S9TGTprFbP8kyATOuQxhy9eZgYJrFFsRrOlXYMvuI/qpBC+6AzOPKdmUAR5YbXoEwIlvuDZivXBB+LlMDZZjdZNI5LsAu/IqEr23JBTd0TJ8JNM2N+b2LmpBHTsDBtFkbrSpZbEzxiP2T4HptrPjHKsgcY9DVZYVeFmoB4uIbI8E1XEGVpr+mivYhUDjdghQQqtlpTdKd5uSrwQ9sFuNHex2o9vE8cgxtXZegWPjOuZpbmO08VmOUNyoMcfVtM53kJpFtjsgBRqMs88wUFpQ6oTIyKo/vc41HMTpKd9jsitKLZW1TTV38CF7QD7zIolydbcjQmR0IhVw9sGR7Bk1kZJsZfg4t5iMV7Kh7LZuhs1WPMr6GQyM5BYr4UZKAphzJ04ImNvkFP0A+iDVa7OdNgdDHY85mKId/M6OSVfEv69axpoPQ08FHH8r2Epm8YES4WF4u3ALoArEhdMui7pLgj1VaO1hTdSpFPXKA4HwaC8dJxljoukwWer1MK4YeL3M4wwwGwyk6b+5/TZlKLDm4/wDaJ/N59sA88AGadq5oa7NX113xlfkUHxT8V0K2HWjMLtv4wY5H8P3wNVe6Ff3JOTknVoShrte2htzBOwDKWwhu3ceU6/bgY4NFw0i6+eNC0nG3vz4fiyzdsrudJ9tmp993n0Ym4A4EblDS/BtaoifIt3seD7ipuQe/S33/VTX8paaT7TepA+CpSKcCmkQngBWvQE1XVQfWXr+mXmDhGdueEuslZiEIZusWW3HBHkAUAVNJJvD2AI0uYYxnul5ahcCbU5isjQkIN9fJ2/lyJ5njo9rX0Q+nxVeDvLaCnXZR316Bb ILycNe5C AeI4QUltkqZGlpIYuBhExpDGwl7ncMVwX16KMw2xjbO6q8boeKQCwKqOAKgM1scDqXbySE9ONE3zmqm79PWorisqQ4R7Xk5O1uQkQzewrhV2sNaSTl8WuH+ne1bmZfBM8wwP4EiIfCd+YDTJODEv//gu500FdJirZLjT6atoy32Eu2LhPUWUUENoWfn2eZsZE3FU/canVLIkJ+xEoEoFK0F6IBT5v2fqNT6Mh1BpTUjh9d12DBi61hFRCwht6NPZNwh930VCdhbnCnDmZnfh64gH0jRhU1grZhSfC 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: List-Subscribe: List-Unsubscribe: Let's get rid of the page_mapcount_reset() call and simply reinitialize folio->_mapcount directly. Signed-off-by: David Hildenbrand --- mm/filemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/filemap.c b/mm/filemap.c index 382c3d06bfb1..c4ac7289e88a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -177,7 +177,7 @@ static void filemap_unaccount_folio(struct address_space *mapping, * and we'd rather not leak it: if we're wrong, * another bad page check should catch it later. */ - page_mapcount_reset(&folio->page); + atomic_set(&folio->_mapcount, -1); folio_ref_sub(folio, mapcount); } } From patchwork Wed May 22 21:03:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13671082 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 84F6EC25B78 for ; Wed, 22 May 2024 21:04:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EAB8A6B009E; Wed, 22 May 2024 17:04:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E5BB76B009D; Wed, 22 May 2024 17:04:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD4886B009E; Wed, 22 May 2024 17:04:06 -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 A91D56B009C for ; Wed, 22 May 2024 17:04:06 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 563AFA4B76 for ; Wed, 22 May 2024 21:04:06 +0000 (UTC) X-FDA: 82147259292.01.BC7A5B8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 9970040019 for ; Wed, 22 May 2024 21:04:04 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=U0FDIkZL; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716411844; 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=pNNk1s4j6/1176F8MI21H7X7UFnb72xKHXVGsllS3eQ=; b=IcCXYFmOdiTNBezLJZIh3in7eXuE4CAVvTERxN7hQU9cEejeR1fOpYIT2mdjEweAKpIe+p G0YmF3BnOoM50wCgk4YAMt7We1YkYHx5W5mM8//T/ESF9bCwf1SJQBdvKziNkw/E5k2IHX hraCNUQRL+5lWK2DJWjhCpPgf8zh3Yk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716411844; a=rsa-sha256; cv=none; b=Km7AcboCb8dyJ78xuq0RoIqbqOXsyP2PJlDiZh5avKhx405PKm16zuHBLlma50a4z0NOIN bqof651MOerK7G2f8kINs2FIEJJrZzdErX6QpfdO7UTuh/eSKNUPp0IUwkqxk+vICnOj8Z S7WAT/MveY0h8w/jJAjnIgrS5AU5G7U= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=U0FDIkZL; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716411844; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pNNk1s4j6/1176F8MI21H7X7UFnb72xKHXVGsllS3eQ=; b=U0FDIkZL3hWLMmX7qmNKcRkWOrJv7yt968k0FiHLE6ftUR486CytCIa+J/JL405XF0CSP9 /5DiWiibZb3Z5KCyc1YNWPgMAaxm10petyaGn9JTOvVPv3c6GcQUv2tDlutcoimkK/5r0Z cVnrOvQoYPDtonLDIIsbGFlCW6HOkvE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-422-ye0R7uQTPwaFaQc8HubRsQ-1; Wed, 22 May 2024 17:04:02 -0400 X-MC-Unique: ye0R7uQTPwaFaQc8HubRsQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A68A680118E; Wed, 22 May 2024 21:04:00 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 315BF28E3; Wed, 22 May 2024 21:03:58 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , "Matthew Wilcox (Oracle)" , Mike Rapoport , Minchan Kim , Sergey Senozhatsky , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH RFC 6/6] mm/mm_init: initialize page->_mapcount directly in__init_single_page() Date: Wed, 22 May 2024 23:03:41 +0200 Message-ID: <20240522210341.1030552-7-david@redhat.com> In-Reply-To: <20240522210341.1030552-1-david@redhat.com> References: <20240522210341.1030552-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Stat-Signature: edoikuq9aitak1zd8usbdjmed39azo1k X-Rspamd-Queue-Id: 9970040019 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1716411844-374559 X-HE-Meta: U2FsdGVkX1+FyvfbF6ZzUqLdpfrgYQH/gTVNtz/1gBYGzlGCKI/Ga4tJ17P9LspQEzXhbAXA+LBGQdIZTwdL157qHVwVn3BIl55JUIG/nlLwxuITyf8vZdNa+v0ydZaSUgbV6eMHOOSdVnElzpcgLUQVRvdRPGExmiVvoBuwuNT7XgMLC+DLeTlAJHXcWZyNb1au+iEKiiBUN2BRmKYrMtLATsUmgbVjd39e6F/tGdqCouIgtg/WvyBY9jcNcn5mNs/55SZ919K1l/0QWFohkrz8ek1b9HQEavURWALpFqLoCHBeoN90ydxmD/xShbP5lUqm0EnjzJlca7s5X6qxH7VKj2zIGp7BlQz/fzJzFXppyy1SUJNHP5r1qaCnqjf8VgeaeSw8ICEMeye+2iZkSjiVF5hCRTRW4cm8/BMAsSSQcecGhWvU3WrfT/ucdRx2Nx0We9uYFK4+MESbwDwK7B55LwHXdRwleoP6Rw8idLjNla59Vopogm9WKuQPPvGcyqvvXZFdqo1IJ2nPGmdi2EAimCCDJNKsNczIHUu5B2JSURSCyXFevYel8gFqvYog+hVNYSaK93E+6dG8q5C8vkZLU9lQIrmwYaPbxPULX9GFPyMDK/ER4L+ogvXwUxpdW4pVxY7Dy8PsVMnLPuGwm4/bZvstbVeSw5ZLzYoxQGlCO1LQHkP0n5rl3p2OjDkTK28y0uURxkl2zaw07CJ6VSkrxrfa1EoNadamBX/r3/gjI+kUCaaBViL5YwNdZXPtcdmYDrhm58P3RjdSn7f/AHd8v4nNFc9nT0WrRiEqtthoFbWtdpeLkWM/s7+mSaaj+j9vhmaZznNRI4TDNwivTdGkKPB94E4lMwMoh+bM8WU+G+EIhy7AeXP4zwMHJQjfsPnPru5h53RTewcrrrDW07riGNVWR42GuumCpbwoq7oMVre4Wt7FJkDuJhUeNthd3mMP/IFpOxE9wiVEmZ2 vl71A0+K 8kKISJEUoP9rDncgtc5oQKfP7X3XA8zhFtYgEIwgAi1hOCFnhg6Zna/+Uvw6eaZ2nsyLHGXS4XXcDbSu6+GwkPzMs+ma+D4TyLPvbMxXDenzJLMwzgZBh1freZfI3N5HiugYMCT12OIQh+FJgERNUUbKjq0EboRyxbidnduZZFzCCy17nWxj348SbgcByQ9VevEoiL2/DhW/rJuyukS/+YXbMBNYBdFYZURsjUxLquJrARIcxXKLPgEzJQj/fmlz3Lz2Bb0GB42G+p4KIn5BHorNVM0BAldJFDKNL 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: List-Subscribe: List-Unsubscribe: Let's simply reinitialize the page->_mapcount directly. We can now get rid of page_mapcount_reset(). Signed-off-by: David Hildenbrand --- include/linux/mm.h | 5 ----- include/linux/mm_types.h | 2 +- mm/mm_init.c | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 018e7c0265ca..3e1d3b0d545e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1206,11 +1206,6 @@ static inline int folio_entire_mapcount(const struct folio *folio) return atomic_read(&folio->_entire_mapcount) + 1; } -static inline void page_mapcount_reset(struct page *page) -{ - atomic_set(&(page)->_mapcount, -1); -} - /** * page_mapcount() - Number of times this precise page is mapped. * @page: The page. diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 6dae8e15037b..c377c040f87d 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -169,7 +169,7 @@ struct page { * See page-flags.h for a list of page types which are currently * stored here. * - * Owners of typed folios may reuse the lower 16bit of the + * Owners of typed folios may reuse the lower 16 bit of the * head page page_type field after setting the page type, * but must reset these 16 bit to -1 before clearing the * page type. diff --git a/mm/mm_init.c b/mm/mm_init.c index f72b852bd5b8..b4916751edce 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -568,7 +568,7 @@ void __meminit __init_single_page(struct page *page, unsigned long pfn, mm_zero_struct_page(page); set_page_links(page, zone, nid, pfn); init_page_count(page); - page_mapcount_reset(page); + atomic_set(&page->_mapcount, -1); page_cpupid_reset_last(page); page_kasan_tag_reset(page);