From patchwork Wed May 29 11:18:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13678709 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 A0A83C27C44 for ; Wed, 29 May 2024 11:19:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D26096B009C; Wed, 29 May 2024 07:19:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CADA96B009D; Wed, 29 May 2024 07:19:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD9C56B009E; Wed, 29 May 2024 07:19:16 -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 806576B009C for ; Wed, 29 May 2024 07:19:16 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 23CE840905 for ; Wed, 29 May 2024 11:19:16 +0000 (UTC) X-FDA: 82171187112.13.6478464 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 7714740007 for ; Wed, 29 May 2024 11:19:14 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="R/attSln"; spf=pass (imf27.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=1716981554; a=rsa-sha256; cv=none; b=Dg7pvKnIhLmOA5KoVQ6U/xxHQnAMfzpCp+bb7XjU5U8w1fAQeAeos1pg6gQ7dsHgThw8XB MuxjxhXy55wScAux2SeuZCUEBqZqFVpD/Y598E1A+QOsJ2c3JsXjWKvxE1V40IJy0XsBaF ZYwsJAw6+2lgAGLzGHThMTMwNmbOm28= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="R/attSln"; spf=pass (imf27.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=1716981554; 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=eYW6FgG2O6XV/uk9aR1DRrJWoOUkUVwlSfHnXOiWQ04=; b=C1xjyMwURWCLv2QY5PWcJ7dehbAzn8tZVaEIHfSzM9k7bv5eqi1UCScKY7dfNNULAM2myU C/3gfoIDRIA2zvWJHCYK9NCo3IngSLrMBznH97X699h7kXlD7OsLKN2VnIxiWZCnd+S7AD efqcacLwdsAQLFLmZV/rTOfx4uHus1o= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716981553; 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=eYW6FgG2O6XV/uk9aR1DRrJWoOUkUVwlSfHnXOiWQ04=; b=R/attSlnudsGgZD2A123ebGkVnGtr5iW1IvBDndz5zRJQEV6KosbIhnOaZzoWjk7h7SNPU TdL46oXzx25CeVvqm3QimCZkAJJCS0xHlvfhs7zZSVP5bfDCXQpoKSiQRuJWxfWaTpIv9V FOWyufDMIO2WWcCP8d0lH7U13HGlMkU= 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-228-yxWjoKy1OFGlzWoM2RexRg-1; Wed, 29 May 2024 07:19:10 -0400 X-MC-Unique: yxWjoKy1OFGlzWoM2RexRg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 2072480028D; Wed, 29 May 2024 11:19:09 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.193.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B9D6C15BB9; Wed, 29 May 2024 11:19:07 +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 v2 1/6] mm: update _mapcount and page_type documentation Date: Wed, 29 May 2024 13:18:59 +0200 Message-ID: <20240529111904.2069608-2-david@redhat.com> In-Reply-To: <20240529111904.2069608-1-david@redhat.com> References: <20240529111904.2069608-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7714740007 X-Stat-Signature: xkhdppc74sz5uktb1d1nyqp939cuqe4i X-HE-Tag: 1716981554-485542 X-HE-Meta: U2FsdGVkX1+wnAT+zoFOZktXXDM9/F+ptPB/TjlGglQ1YG0eGziWZxUvjyoBPPeMBFoCJVQQkdF71qrm5Ix110+I33fv3u+HW0rE6pFVCSh6z/7rDDDnQSZsxghPm/AYjXexgGvPBjPnNTxzCgZq70UyKI87GjbgRsuvn5ar/FexK7VsTzSaktaUoFP5jT/ifE4xzvbkpcp4ybDqhPaonFnni2HslmupYzbKHOxgWkKirxMda1iMe0bk/XI86eNfRzPB0BpR8KsL/115/MD7ihhzZV/dJ9S7c7w7Mrzo1v0u27NHW7NVuAc3hx2zzl/6KhFOwhYILNhGYCgHmXhyVhF82yJQestLA7DKfpLhSzzXaZoNY3Ig4WTR2tAVHDk6hmRVPPK3fZd6C7OgNDC4qOzFUxljSOYR8Vmy4Tnwih0/jNOLtu968Bm9n/au7f03Ocw+as4dP50uItO7BuPMekjWKDM+Rjy8N48IY6+I+3VAc0lFUWf9UUleM2Md3rbppMu6JHWZvXrSSKTX4XsKW0+MW7D9PKT6XUVmb+63Jh7vLS93RfaR+BxyZG71zi/TnEYRg/ew+0Vucd9OPSfNqRFucOQoEpzHlPCvJF6CUXWoGjSUYJ3JCgBIsl0eICWzpLeTL9tXRNYNbYVKtM4Zx9EFPl650k5oumBEeqq+1+WvDebdX3lA/FlVsCHtjahO9op/DRlsqSYeNWFAUrap5Dh4+cFqj9s5caGYBw6OmqpbNGoBFbrXArGgvLev8fd9uLdEeSGa6JTJ0Xn+eKCs2wg5xs3ERzDZ8yt5XpKXcxhgrOPYWy05Wd5V5D9Dhvoi4W+M+cjhPIEdqmlowsvy/+WrcsaoGXCbqK9DRvMStq7KloQORE9Sgm+w37ev2RXdNsJpyFJIqlSDkAgDNGmlpnzFycPVRzEZScEI0MGBxLzSUSuBlexqyoJxiMcutMnxlYiV8dOuCMAN3JSlbSV Ju+TUR3U psa/dYaYkUvSMym8DiXniLnsYTCtzCTqzJNajxPrDD3vn5aecC9ZK5lOCjHXr1j2YA2MHJOBU64kPiuEbHFofs3bv+7EKVXRLfrFCTYaMMAZM/3on+AWrXD33mlKnBcO0NRMCT7Bl7NtrEHlKZSIMQrwQpfFDpEPYkZfDa58i8xb8h7ef10y+m7qwNEWPWD3YntqlkKjTI1Zz1AArEaAB5+JAH7V3aoxbP+Jespn0pw2aBqNd5l7wSyilpSQdna1ncSQdBQNucuqmTPjolf5ZJx4H87XhB1sNFGOQ 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. Move "page_type" before "mapcount", to make it clearer what typed folios are. Signed-off-by: David Hildenbrand --- include/linux/mm.h | 5 ----- include/linux/mm_types.h | 28 +++++++++++++++++----------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 3aa1b6889bccf..eebfce8f58bca 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 24323c7d0bd48..dd2ce1b3ec80e 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,18 +150,26 @@ 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 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 + * (page_type == _mapcount == -1). + * + * See page-flags.h for a list of page types which are currently + * stored here. */ - atomic_t _mapcount; + unsigned int page_type; /* - * 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 pages that are 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). */ - unsigned int page_type; + atomic_t _mapcount; }; /* Usage count. *DO NOT USE DIRECTLY*. See page_ref.h */ From patchwork Wed May 29 11:19:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13678710 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 74923C27C43 for ; Wed, 29 May 2024 11:19:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D766B6B009E; Wed, 29 May 2024 07:19:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CAE976B009F; Wed, 29 May 2024 07:19:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ADBDA6B00A0; Wed, 29 May 2024 07:19:20 -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 86C6D6B009E for ; Wed, 29 May 2024 07:19:20 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 14566A09BF for ; Wed, 29 May 2024 11:19:20 +0000 (UTC) X-FDA: 82171187280.29.4C21668 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 3884C40011 for ; Wed, 29 May 2024 11:19:18 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iPIbib+z; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of david@redhat.com designates 170.10.129.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=1716981558; 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=aDhi0IPu97eWFC0P0dRcSpVPyCoXJ2Cz890fKbkcPeQ=; b=cPOToySLuk3H+Xtw3CQctUS9Ew8/pkhnC1pi32nAMdxQzAX3MWqYFljFgjHQbMBQrTYBeS F28VLwInGY5IbHCvQIBuwFS7mQCmgQjkgfpT68ClsmM0724eBUjdMIpnmzd3KlXaJLbsMd NnC/GW2RNzMU/lRU526F9oCD0WiHnHc= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iPIbib+z; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716981558; a=rsa-sha256; cv=none; b=SCKSN6ofeT/xRDyaxMoOUXX45O9++6kv9rMCL50Is7iWO1TzUyxC1EVOqIHOKL2L1k6ocl j0jjP4HZV+1C/KO112oaFJ7cEcPnaUTghOcvUvJD5X5orT/XFGA+uquyqPIAJtI9bJ7mJr nAqc4esR9MkuXkqjscoNG/XGAnxZIbY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716981557; 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=aDhi0IPu97eWFC0P0dRcSpVPyCoXJ2Cz890fKbkcPeQ=; b=iPIbib+zMFoSzC3gzKltmvjBePDoP3YQ9IS98AE17CN7wEuP7o/GGD9q0QdvHgwdzJytrl UHF4X1sOWmxH597GV0Ol3/Y7D4HL859OVo6+uLbgI2vOhdHh8aL4tX78LNCjl1kePN8TvG HMVcXPhBVPG7wLnRvfGdY6VyC8XGb9k= 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-301-x4msqaDFNAKN7DdXTTBhqQ-1; Wed, 29 May 2024 07:19:11 -0400 X-MC-Unique: x4msqaDFNAKN7DdXTTBhqQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 3BC6B800169; Wed, 29 May 2024 11:19:11 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.193.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5868CC15BB1; Wed, 29 May 2024 11:19:09 +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 v2 2/6] mm: allow reuse of the lower 16 bit of the page type with an actual type Date: Wed, 29 May 2024 13:19:00 +0200 Message-ID: <20240529111904.2069608-3-david@redhat.com> In-Reply-To: <20240529111904.2069608-1-david@redhat.com> References: <20240529111904.2069608-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Rspamd-Queue-Id: 3884C40011 X-Stat-Signature: 7ihxiog6fwmbdccwbpjy4mkxsy8sawwd X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1716981558-973715 X-HE-Meta: U2FsdGVkX18FSfvKMa7KjKPar+EWDhh0bB/dOLc3J0K1/SqkWS0cdAXfpThOwS/4ausd/IA0lMb4FgjZ55fiKM5WtCCI6UxhsA31Wxq//PEHcxTNWKLJQkBWgAk1dE/U2NeQ6OaHckUleNeZgifWBoBprLE2YRr9Spd1cEY8Cgpq6UXjmOwbErAGsEXzWk925ROuM6bouuLIextP61WaL0xvx3495WKczQdkd7mux0Ykte+KzoVK72+ws3k4Oyo4wsb+TqImbQ9QE1cFOSzqdZQ2oSx8z/j8UzQejcxgItTi9E0Vr+zN+8g9AVvYzTSYfbXltXbjlCjbB7Ml7qGnzFnVJ487u401gfpBpWOhs04E9yJf35JD+7cjpvnQCPlgp/M49pgvBIo1hNlIDIoqXIwhsaBwXkYPSLOZVxbHuUOqG6bi662JYP9Eh6+r0O/YE5G1zk4E6eubPfxQH8tUAibIEsHzcGXDduQXQJ2gOdkSKnaOnfW5pRcLYOD+bQJppONn3lN2tygv/FdCZEQhS+e5zEaDAHklJPOnmxTolWBlTEU1ehM8ajIzYYBVliz6BlUwFXuvyI3cYXcFmqHT64er7jT6djEH1TRYb783Rm9LlZne0NBuprNfqLu2xE65DvmYqqwYNVB/F/t9yb0VOk+CVosa6qAnPockL7BphFtWjtI3WDf+OopzimNxR4z0JCflUHlvBa+/yqI1nJYG+TgOgPNZpDpziv/TN1vTSs16Sc4+4VZBTleQCug4092O9gjXS9M9p96YkjxdqaXzKnXitNhVJ4ezv1vqYKZDSt/mfYcKwjm1+NlACNxpKjz6x3WRpdgA1umllLyhqac3E2UClY79e9dI6zZCeUgd9Q0EO3NI2nPJxDRCOCPu8NC11h1F87kU60yyeZS4nNhn1Hw43AhKey7AdikWLES5e88q/5hh6hMuQ1ZWbK8LTA23oO6rzomXZYHL/NnpyNs 8vgIrSe1 d40l2BpMThwL9jaNaPCbhLbCKNE+PewmesfR7ZkAadbReF50J3Sc3JaulTS6FfWoWX6D0DmlS1nvdWiXJufF2EE0zcXbi0eSomVGT9Q6ZC9GGw5bBBim4xCwbUzNtz7qIznLdWuaz5tETZ9FdBXkXCmLIJ2Vfwp/W6yYUseco7EJSIUuIzJ0wFy6TVsB3EPt9I7wo5VRjihsOVcUas1XIe5t11KCN6vzSez+BaIPvDTre6Xe5dEJgN+zsKU9MHVBRe/GaQsihECsgVajxUZyQ+uHmjnIgvTm4z4+DryIrZAS7rpc5ia2N4+DFHTj0CmpUH3KUzSZ2p9eVH54= 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 16 bit: sufficient to store an offset into a 64 KiB page, which is the maximum base page size in *common* configurations (ignoring the 256 KiB variant). 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 (offset into a base page) that cannot go elsewhere for now. Let's reserve the lower 16 bit for that purpose and for catching mapcount underflows, and let's reduce PAGE_TYPE_BASE to a single bit. Note that we will still have to overflow the mapcount quite a lot until we would actually indicate a valid page type. Start handing out the type bits from highest to lowest, to make it clearer how many bits for types we have left. Out of 15 bit we can use for types, we currently use 6. If we run out of bits before we have better typing (e.g., memdesc), we can always investigate storing a value instead [1]. [1] https://lore.kernel.org/all/00ba1dff-7c05-46e8-b0d9-a78ac1cfc198@redhat.com/ Signed-off-by: David Hildenbrand --- include/linux/mm_types.h | 5 +++++ include/linux/page-flags.h | 22 +++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index dd2ce1b3ec80e..791afaf1b1ec3 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -157,6 +157,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 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. */ unsigned int page_type; diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index d1bdbaaccc964..f060db808102c 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -945,15 +945,19 @@ PAGEFLAG_FALSE(HasHWPoisoned, has_hwpoisoned) * mistaken for a page type value. */ -#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 +#define PAGE_TYPE_BASE 0x80000000 +/* + * Reserve 0xffff0000 - 0xfffffffe to catch _mapcount underflows and + * allow owners that set a type to reuse the lower 16 bit for their own + * purposes. + */ +#define PG_buddy 0x40000000 +#define PG_offline 0x20000000 +#define PG_table 0x10000000 +#define PG_guard 0x08000000 +#define PG_hugetlb 0x04008000 +#define PG_slab 0x02000000 +#define PAGE_MAPCOUNT_RESERVE (~0x0000ffff) #define PageType(page, flag) \ ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) From patchwork Wed May 29 11:19:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13678712 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 0AAD8C27C43 for ; Wed, 29 May 2024 11:19:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 231F06B00A3; Wed, 29 May 2024 07:19:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A1846B00A5; Wed, 29 May 2024 07:19:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E5C586B00A4; Wed, 29 May 2024 07:19:23 -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 A8D0F6B00A3 for ; Wed, 29 May 2024 07:19:23 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3BE07160A08 for ; Wed, 29 May 2024 11:19:23 +0000 (UTC) X-FDA: 82171187406.22.A19FDE5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 897E34000C for ; Wed, 29 May 2024 11:19:21 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="DzJ/cdoj"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.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=1716981561; 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=abET8lrE4AVrejWdoZuoMbV76D72y0iE8NVlu7Sa3/4=; b=bxnfF7/Q6LXq66AhGm8MEtUj+NmXCnNqOc7hjXhj05RAfyoDP1u2e2d/Z3NfTAzMvkOncu tem81pJcXOLJ4rIxT9AHUosqi5Lsa6X3N6ckEXK0wgdVoKO1OhJ2mm0QPm+UHo6YNHZZqM /ZJYeTz44O1lQqQLrZk733hA5OfSkLU= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="DzJ/cdoj"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.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=1716981561; a=rsa-sha256; cv=none; b=emQGu8B6N8C7Yt2/AaUNO/Efe/fBAQoyceY7pREZoJ6qnbO2Jo3LDzt3uFJ57LiU/arFoz YUO4RwgATYxP8+5kPlARKuTL2Bc6lxyU2WOFYnHg7VR2FGOsPlB8oVhozynF7WDSdJk/5Z 7hpal+ORNeR8aPajmrVSmkOoMwxbK28= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716981560; 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=abET8lrE4AVrejWdoZuoMbV76D72y0iE8NVlu7Sa3/4=; b=DzJ/cdojkPOv+fhRl0MjNKIVcUkk5t2phXR10oPn7zzTLtfahRK7OQJQSzTi8ci+sAejjR xG0AsOiHIO4sCp3964eK1bsSiHYjOh9tBYR/tWqrDM1oZnZe+RoVTXMe+9UTNtZQXyaRpA tzIe8FZXqhS6xZiqrXWwAGY2+3grWMg= 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-450-4ALCqXkLPimlN9lNjxcdCQ-1; Wed, 29 May 2024 07:19:14 -0400 X-MC-Unique: 4ALCqXkLPimlN9lNjxcdCQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 ABCCD101A52C; Wed, 29 May 2024 11:19:13 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.193.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B28EC15BB1; Wed, 29 May 2024 11:19:11 +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 v2 3/6] mm/zsmalloc: use a proper page type Date: Wed, 29 May 2024 13:19:01 +0200 Message-ID: <20240529111904.2069608-4-david@redhat.com> In-Reply-To: <20240529111904.2069608-1-david@redhat.com> References: <20240529111904.2069608-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Rspamd-Queue-Id: 897E34000C X-Stat-Signature: eoaueyotipbgkwgwe8u4a3mmwamwkno8 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1716981561-651349 X-HE-Meta: U2FsdGVkX1+W0YRffcLMVIuiWqdchL9xIxQ5gC0sOOz0/ZC/zBlxlcu7P8+TR1SOsLAd/WqEGS3pqx5nQwwyf4Ql8BCa+/G2OPxmqpfhtCQOQRKSy4mylj2jwKmo5C9SLivWYY9v5rgmBedPUIY2pET6RpM2ewJ7m/Q2+7rQAOyUeuAOlTUilgpJgsJps889RWl62lMHV5jnAuXdA6TjnZshhIv3v3js2ngEKEQQ92ep0tTpL+UPEYMFeY0ptwsDRY7/MsqXPj1gq5U5tlRZ/SN1Ilpiq+5tbTSmq+HDeutwhSmpxhRoSFi0u9A9pG3XVVyZe7mKE5rGpDdOszKR8FJdyd3200DGAcVBbiGugwt9nwljH+bvP/Zearrwh5CSrAoVea9EjB8QLAv5UuthVITqo38cM7KJO1fQeduo1cnQZbUvQfFXXOVi3zxYFZI5v4VJC1n/R76B0WInJSOGGDh0afr6LW8FWHz5ua7yumxT+3BxuHD2NiqJ6lhQnk0ATKSXQpgQhdZtUbOmVZuhYHIi2JY6LK/RzyVUPow0fxZl3QiEuPjTVD4IT+Gxwk78u7ijdf1KncgQ+3n4ONYiZoulrE+i0re08yWGxsnkk6unmkHTis1/V2rsbIZe6GupddsTnwgKfP5X3CTwi479IypfQvPgOrCpgHAqOnlxYVl4RChadiCV75YTTwrdk73B/t8OjvlSEIRqzAPI9CLCmQUAk5QHbEoU6GkLjrZr3HlLOun3GxhlPrQeKWADqjULmVXoPaij1/xfHY7rI1G8b5sdnAnETD/TZkWq3t66b8ukIKgoWo2YhhuaqwvfoV4TOgzRv3S87MJ4f/xY0e/HuKzWAogJJrhIPYkFEoAIuicXya+1YCg3cuQkc/W+b3WsYtGLhNfe0451SfqS9VdFJkjbuxAafvXMJJ/tWihacIcHSbA5XLhTChibjGXy/upYJFRRiWYhh1XCVmC1MB+ OLwfQ/iX RRhD1xpF2osRIUD4KLf/Z0pvqcZiUdlREOfFYC0hlqK2sGNwsd/xIxo+UjZtmmO2K3vy6LNoh1tus0tZGRCFIjzDyx9RvWasmsSe3GbM0J7atsNkOREmzQ3afkQHBw3KUR0Fi4CpoAk/lPWBCze24jp1HNml02xKnBUS7juVi4ENmz9i1XzFscvmF0Np67I8wejF6CfT90oBNmCRM9uwV6rmRih+SWIx1E+GIOrgFy66j69j2/gXFWCnDtU+zkFF3sOwG4y/EVmzCIil3p3wiLmonTftVk+SF3U1g0HwjSiN8duqbecnNv4At4NXLFgnyZqUTU+Z/I7NfRus= 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 won't be able to support 256 KiB base pages, which is acceptable. Teach Kconfig to handle that cleanly using a new CONFIG_HAVE_ZSMALLOC. 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 Reviewed-by: Sergey Senozhatsky --- drivers/block/zram/Kconfig | 1 + include/linux/page-flags.h | 3 +++ mm/Kconfig | 10 ++++++++-- mm/zsmalloc.c | 29 +++++++++++++++++++++++++---- 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig index 6aea609b795c2..40e035468de22 100644 --- a/drivers/block/zram/Kconfig +++ b/drivers/block/zram/Kconfig @@ -2,6 +2,7 @@ config ZRAM tristate "Compressed RAM block device support" depends on BLOCK && SYSFS && MMU + depends on HAVE_ZSMALLOC select ZSMALLOC help Creates virtual block devices called /dev/zramX (X = 0, 1, ...). diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index f060db808102c..3afcbfbb379ea 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -957,6 +957,7 @@ PAGEFLAG_FALSE(HasHWPoisoned, has_hwpoisoned) #define PG_guard 0x08000000 #define PG_hugetlb 0x04008000 #define PG_slab 0x02000000 +#define PG_zsmalloc 0x01000000 #define PAGE_MAPCOUNT_RESERVE (~0x0000ffff) #define PageType(page, flag) \ @@ -1072,6 +1073,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 b4cb45255a541..67dc18c94448d 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -128,7 +128,7 @@ config ZSWAP_COMPRESSOR_DEFAULT choice prompt "Default allocator" depends on ZSWAP - default ZSWAP_ZPOOL_DEFAULT_ZSMALLOC if MMU + default ZSWAP_ZPOOL_DEFAULT_ZSMALLOC if HAVE_ZSMALLOC default ZSWAP_ZPOOL_DEFAULT_ZBUD help Selects the default allocator for the compressed cache for @@ -154,6 +154,7 @@ config ZSWAP_ZPOOL_DEFAULT_Z3FOLD config ZSWAP_ZPOOL_DEFAULT_ZSMALLOC bool "zsmalloc" + depends on HAVE_ZSMALLOC select ZSMALLOC help Use the zsmalloc allocator as the default allocator. @@ -186,10 +187,15 @@ config Z3FOLD page. It is a ZBUD derivative so the simplicity and determinism are still there. +config HAVE_ZSMALLOC + def_bool y + depends on MMU + depends on PAGE_SIZE_LESS_THAN_256KB # we want <= 64 KiB + config ZSMALLOC tristate prompt "N:1 compression allocator (zsmalloc)" if ZSWAP - depends on MMU + depends on HAVE_ZSMALLOC 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 a2a5866473bb8..44e0171d60036 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,28 @@ static inline struct page *get_first_page(struct zspage *zspage) return first_page; } +#define FIRST_OBJ_PAGE_TYPE_MASK 0xffff + +static inline void reset_first_obj_offset(struct page *page) +{ + VM_WARN_ON_ONCE(!PageZsmalloc(page)); + page->page_type |= FIRST_OBJ_PAGE_TYPE_MASK; +} + static inline unsigned int get_first_obj_offset(struct page *page) { - return page->page_type; + VM_WARN_ON_ONCE(!PageZsmalloc(page)); + return page->page_type & FIRST_OBJ_PAGE_TYPE_MASK; } static inline void set_first_obj_offset(struct page *page, unsigned int offset) { - page->page_type = offset; + /* With 16 bit available, we can support offsets into 64 KiB pages. */ + BUILD_BUG_ON(PAGE_SIZE > SZ_64K); + VM_WARN_ON_ONCE(!PageZsmalloc(page)); + VM_WARN_ON_ONCE(offset & ~FIRST_OBJ_PAGE_TYPE_MASK); + page->page_type &= ~FIRST_OBJ_PAGE_TYPE_MASK; + page->page_type |= offset & FIRST_OBJ_PAGE_TYPE_MASK; } static inline unsigned int get_freeobj(struct zspage *zspage) @@ -791,8 +806,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 +981,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; @@ -1754,6 +1772,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 29 11:19:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13678711 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 3A785C25B75 for ; Wed, 29 May 2024 11:19:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ADEBC6B009F; Wed, 29 May 2024 07:19:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C9A46B00A0; Wed, 29 May 2024 07:19:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81ACF6B00A3; Wed, 29 May 2024 07:19:23 -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 5A1436B009F for ; Wed, 29 May 2024 07:19:23 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0F5D6120503 for ; Wed, 29 May 2024 11:19:23 +0000 (UTC) X-FDA: 82171187406.18.9307A7A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 5B945C0004 for ; Wed, 29 May 2024 11:19:21 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TmAeWmKW; spf=pass (imf10.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=1716981561; 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=lXRirrIvNUFDVUMts2hQOYTUr+V+4XzCDnXRbx7dYx4=; b=X4BHnSPnYo7scxPI/qzL1Z9856vX+e1bb3vzmu3z7jCcEY+63yY8krqiyiOJEElyhFnJBB 2PXAy2qLykvXFMaAO3jaAsiTT5F5L+BOnjfjvUncA7otXZgtegW/ib/VYjvtKfdACxwJuT vmvjp89m7J9anWtqFYWXZhb5FOYNEE4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716981561; a=rsa-sha256; cv=none; b=BmUb15axEwaH1bHxxzF2h+RU/0FSHIN3slC7OyYIluTCfo4dX4WFL7+Fa3tJyvWEblreej RX+00Ji7z/a3NFZDmFiYQXkT126sBGkMrB1cjoeUbA/3qFkF2EgVeqGvdduqoVUPBm0hQn +QmREU33qk1ioLOA6qgKB6qitFthSGo= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TmAeWmKW; spf=pass (imf10.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716981560; 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=lXRirrIvNUFDVUMts2hQOYTUr+V+4XzCDnXRbx7dYx4=; b=TmAeWmKW+lBYlXlXBPi7HQwYE5PqFM+SoWgfX7KUxRBI6tROOYKRqwPTM91jyQ0BGRvvPh zJ0VNEqv40NTTTCSFP7ybUcigXDzDW/zNBRbb1krMDZ+TZYOfyKsXHHKkVAjDvsfxxeIcQ 3n43J1MOi7YURmSj7MgNoxI8DEXQ6LI= 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-321-I5NU4P9fO96nrEfFJX_p9Q-1; Wed, 29 May 2024 07:19:16 -0400 X-MC-Unique: I5NU4P9fO96nrEfFJX_p9Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 7EDCE1C0512D; Wed, 29 May 2024 11:19:15 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.193.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1F68C15BB9; Wed, 29 May 2024 11:19:13 +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 v2 4/6] mm/page_alloc: clear PageBuddy using __ClearPageBuddy() for bad pages Date: Wed, 29 May 2024 13:19:02 +0200 Message-ID: <20240529111904.2069608-5-david@redhat.com> In-Reply-To: <20240529111904.2069608-1-david@redhat.com> References: <20240529111904.2069608-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 5B945C0004 X-Rspam-User: X-Stat-Signature: 7sr4ds1e7rh18pfr7sjtendbbnj3nk4b X-HE-Tag: 1716981561-187982 X-HE-Meta: U2FsdGVkX19PiN2OWe+VyFI2sG/GbcUTrK3+DpN9wnbK/lzAxPpVV0AwQdCe+5Q8BEMuaE82JnLsfmYtVdsGlgcIrv5xEtEnnugK/ywrZPnKQDSVGuBxcH1ynjRchIJ3LjeqWrHQdeeCIZq7DB37/3a7syvvvAQbA8NUveaZYROc/lFLD30zDCCviexEEG8+ZYHcdMzRn90/jJoPy1sAPBMTd1Sn2pRExziMpS4rH9pqim5v/e/zX/OtrXokLZrwsoBlPnVcbRYXPq7l4Kok0Z6o2kxN5rSwfwXh3wZixkmCr8+bcZ5QuYwlfbKCdHG1Vq5+buVCOqtxOrbIv1ZCu9Txn2b84zNiBzDl0zJiKCHBh97ZBawHR+UlNUowY67gVoOvaTXUqIbbsLI1x5CNGWhVRrzoCEDe3cq0jLjjt7pckBJYlApIuOxHcq8IvXGQ96rORXEffvXK6pQ/SfvW+9bfEP+MFTMdtz3RbVU+wwM7bRMDtFJvy/JtalNsvuiaZmRN6jR+r0x9QTj03g9Mi3pKWMqigRP5kc+QwncIsW/JbV8LBfhQ8tDoWpHbMRYKA8ayX+hN9NTjs0K97qUZIf+kSVsIhb52hBrGnP2JhiJT3YuIuRnifLOe4bX3L9VTJeXR+zDxnA5k2ixIOo3nauScJGSS3+/e4sh8p28LxVqKHDPB25QU2jPWTdhk8HA/7RSQUZF4QmZtcwpHO0KEZjl10/tqM4xi4jDrlldqEzOnHVCg3ya6uwpW6rW6umqMKVynhAOxULEO9XzJEBAVFianRMmEZg+bw4ybAFPGq02S1vmcDbs5l9G8p4GdxNbsxGqP/eScLSBsiFa6y8aGZaVbuJuBlJ0Ck8v8XQ1IwiqWgaySyO9r85MUxJgGfIZdIOyaw81ENgw/YJXSxuQzSytw+yx8awgVBxj/2xJ4+voGZlmHZsy4YFPN4Q5RhaaXGxXZPq2YfwU5ML3n1aq IgUU1ngV Khaj3BNfNmepFOgWr5tE8/Exxkt1R5u/DWpJvNUnlqtchntd8pfLfGM3WOf5J6Vd2HeNQx4VBMTF8IRmIu8SDUjAIkVgvQYsDnsdTf4mLA+lGfs8StNa52S1hW3Xq7J5BUkvFzNl7mqYD57giBXEc6re2RO2/G+15mRxKpDH/ZFiWGF5omqggm2/o+skcUYpMKBh+teRY8wxyaD6Cysb14KpXW5LJMgcGahghFHmvi+MiYRxC5hT7z7y0n9+twi9z1XfivmVjjbvXQYZWLAc1pjdOZUnLTD7gitt6 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 b1e3eb5787de1..591d28b9f3e48 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 29 11:19:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13678714 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 4C823C27C44 for ; Wed, 29 May 2024 11:19:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E5586B0099; Wed, 29 May 2024 07:19:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 66C676B00A4; Wed, 29 May 2024 07:19:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44B066B00A5; Wed, 29 May 2024 07:19:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 201016B0099 for ; Wed, 29 May 2024 07:19:25 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B7C271A0847 for ; Wed, 29 May 2024 11:19:24 +0000 (UTC) X-FDA: 82171187448.07.6E11A44 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf18.hostedemail.com (Postfix) with ESMTP id EC9C61C0023 for ; Wed, 29 May 2024 11:19:22 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LAgtLfFl; spf=pass (imf18.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=1716981563; 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=O9wGKMA7pg+ELfK4C46qM4+rq+qnJqY5pRyECiTlobg=; b=J3t+mots/uvGkZP7hGCLLEFOFjunhPEEI4koAP0hnwaIxlFU43SJ41QqYuGfg+o/Ob1F5t nH5hkFWQp2CVjeWUx107qZldUAnKq8RhyuaqH2eFWzIssfcf1Ju7N8ZpJTAEOgMvI/06dN pg6xXmnsZttvVsMXNNP4elx7zyS/bOM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716981563; a=rsa-sha256; cv=none; b=icupTu06p7DaBIKQ1dMUc4pZCOi/yvNf5IgyfNhpgA6sWX97TVqLGwQ6rmpxc5ZseOfSfS xiUv44zvTnSMH47mxhQX3Wl8e5TPhwP9BlVEL2ld9+cGljVnkwtYJx1QbyR4PYZuz1PRbp 2m47W2exmlN3s3sW1sXfNep3an5Py/U= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LAgtLfFl; spf=pass (imf18.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716981562; 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=O9wGKMA7pg+ELfK4C46qM4+rq+qnJqY5pRyECiTlobg=; b=LAgtLfFlfJ/Eofy7ud1asdljqy715pbOXELMxnHRA6EHSC06heT8d86bxcK8VrfYXDS+H1 7JpOCSD+s7SoVfQybS/CAF3YSA/f1YeM5zYNIynIfVWWLl2P/B7hu8sWfvPr7DM91xbACZ Cq4XId8vdGQfQHYoZqoMRGbxu6efQBU= 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-600-YyUVCmUjPleKjz5PsgrFIg-1; Wed, 29 May 2024 07:19:17 -0400 X-MC-Unique: YyUVCmUjPleKjz5PsgrFIg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 6752B3806701; Wed, 29 May 2024 11:19:17 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.193.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA1DAC15BB1; Wed, 29 May 2024 11:19:15 +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 v2 5/6] mm/filemap: reinitialize folio->_mapcount directly Date: Wed, 29 May 2024 13:19:03 +0200 Message-ID: <20240529111904.2069608-6-david@redhat.com> In-Reply-To: <20240529111904.2069608-1-david@redhat.com> References: <20240529111904.2069608-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: EC9C61C0023 X-Rspam-User: X-Stat-Signature: fc3kbwbyg3di5pa5ybj6zahf5ju1z4wh X-HE-Tag: 1716981562-524204 X-HE-Meta: U2FsdGVkX1/cHt8a9A1BzR0SE8RXOUrptZ7yDeF4X2WCRN4jg0emAbkZi1LLjwKknJZ8ZB8Z4odLlG5J2X3WA666U5ZSPAkAjE8n4p4UXT5QeG2R6yUb1BtKtKiuym/mWf0CrgyjX794MUCJQxIwBgzNQ3Ky+L+MJjffxwJ6TboLvz/2dw+mnxYv3ivciZK4PhmzLk0lUFDJIV6Z86bE0E11lBeXqm2q/BT+lR/QGx7qWNAA68Q/bNVsazK2Gt9c4IjRctFUymwCIWNBpd2Tyi/4cxRFpldXqLob5bGGsYydBMWW35QvLIyFHDB40VmUBcg88LLt2MUZLpseggukjoQU38ebS15RWTGCVzqvVMS3g+GPuOfpAVVGmId8IE+xeywBQLUjgMygtj1eFQfu1ef1QgNzQHf1wCdZFIAbMRJGR0HufLe4+H2cYByu1od368CvMBLc4mvaynknpk2JwsKTkWSWNP5pyDbkKELMG1PJN1ur4PpGEBQS9M5ZhRFXdLR7HvM/PSETAwJJEqKL+Nb/03ImAmsY1Q79o2GD8RsrGIqtMN/x1nbD5Z+S4nAmY7whwxqwo9SU7LcTYvR+wTKBc4KjU9Rt+p1mzEX57XbvfFfw0gPi6g1NNA46s7EpykKW5XkJ0bWxFY/eWjR/sF196NztZEYGf1VorRcICEr/dy59HEsOLJ8ftmo/zJo3NCIUg3JFGpYTFxC9RmBtfeu6EmSFkrRjh9vXQKkq9SAuxXaH3TjYXVqKlaNxzyZQEyPe+8Ae0bYTQhp9gsVITIjFLyKJr2pF6g4gDPBlxW5Krq7x0K5QFVhVFeBFspettRY8nbGyOdRpmKgOIZTXAloVQd62f4QWFMyCstTIinkxSbljNDhGYZkMKtdrV8LJ20HAJ28yQOi6ZrH4YJu8DjQvTVUrOBBGHvfkVdWL4o2o/gOmNMzXmddX0ET54zL6pp1mDFIzKsS3f6rEGHG c6eOQCs/ M3/u1Ch1d8TP+y8ZuDXxehhjtijt7WiVB65v00defc4jbzXpikqPw5xxYWcwv5j8JFIKeGBPPubbSjc0L6v3XiRBfqg2r78aT+TNqwlcz+6K32odBR1ILV9YkuOhbrjdqY/3uGOzwrabvF/XylpkjmZkENK2QrcnkS9vDpDSKuKJE0GNOT/wvn0e+QFAtiWvSkJPH51KabiP6eNADyFIkkWFaPlS6bXqr45FdL9J8iDXQq8Y4tO8pRbBEApVHMgVXHesXBYMPEM6wWZpq9oMva8kEcehpPN7QKdDa 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 ba06237b942d6..9fe5c02ae92e7 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 29 11:19:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13678713 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 59424C25B75 for ; Wed, 29 May 2024 11:19:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E60F6B00A0; Wed, 29 May 2024 07:19:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 645616B00A4; Wed, 29 May 2024 07:19:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 424A36B00A6; Wed, 29 May 2024 07:19:24 -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 05A046B00A0 for ; Wed, 29 May 2024 07:19:23 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id AD93DC0A35 for ; Wed, 29 May 2024 11:19:23 +0000 (UTC) X-FDA: 82171187406.09.A49BF0C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf15.hostedemail.com (Postfix) with ESMTP id F0541A000C for ; Wed, 29 May 2024 11:19:21 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FkGWzTNP; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of david@redhat.com designates 170.10.129.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=1716981562; 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=503jl45eQ6DH26oe7TpQo3EopwWo8mZfnH3eTedH2jo=; b=do++Q22k6qIUCdbyVgg4aI50jTd20eKZeGZ6wq1onBC3QvpiylY4WiaPi9yc9Jsy/V6DX/ Bj87U0q871eQcpxRk4VFpSu+99xT9ZsmLCfryowf7Ers1Lg7i0TtROxpLivjeUP8eNgleL ZTxXTMVEOxy4moX3PjixfQdOCu9T2Ic= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FkGWzTNP; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716981562; a=rsa-sha256; cv=none; b=fLfbWhMEMHPMtILiUGeEGeLcENKOkFZ/9e8WHT0vnTp4q6G9DKjBFhBoc1XTRZEdLW6DXg ZBCJxdCHdcwGLU8fStVPNFcUyCCicDeDsTl/1Kld7+jUMtVlrB+VxmnHzuZZmKWqaa5fEe itJH7EAPXbH/giXWfoa6ThytviKSnuE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716981561; 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=503jl45eQ6DH26oe7TpQo3EopwWo8mZfnH3eTedH2jo=; b=FkGWzTNPcBu12XnbrYcgxx+FqGK5qY02Oaf1Wtz6qP8P720WiVTZWOBSkGMfM3u1p2Qrmy uZMOrKBFFtgADCz8NCnoOBFc1rZctq/3vDbIjJ4tPPTuF5/VcWO9wzwEjYfDKpfpgRNxk2 7WeaGsDo2JvzkUC0Muut5qZ7p7/4eUo= 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-609-jaInmsy4NLOfXj_IkOsLPQ-1; Wed, 29 May 2024 07:19:19 -0400 X-MC-Unique: jaInmsy4NLOfXj_IkOsLPQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 3E2B185A58C; Wed, 29 May 2024 11:19:19 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.193.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DAFDC15BB9; Wed, 29 May 2024 11:19:17 +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 v2 6/6] mm/mm_init: initialize page->_mapcount directly in __init_single_page() Date: Wed, 29 May 2024 13:19:04 +0200 Message-ID: <20240529111904.2069608-7-david@redhat.com> In-Reply-To: <20240529111904.2069608-1-david@redhat.com> References: <20240529111904.2069608-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Rspamd-Queue-Id: F0541A000C X-Stat-Signature: xgk1sht3ng6hhg66wd6w1wyn65xy16yb X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1716981561-404475 X-HE-Meta: U2FsdGVkX1/HDrADaZEBObJJEAbTQzU2xXRhFe7SSYYH6RjmibI4Zdyced68riRI4gvAxfESsT9zntsOe/Kc/VDHPzSG5Oqoux8D9ErU/e1b0l5J+bi+Vpz7wV4zcjV3oqUc6l5/fBLfoJiwMHpcfE2ANygr95FxDilTkgBSwyw8s8WBhEuA23/4dy6rsDEmM9voAap/aubFSDnGK7sRqQY/OvNs6TLamhKDbKEZ2ca+ZQwYTM/oS8absYoJ0PzwBnExrZxji7lyftwOPQjgSitIImko8fZectn074RENyJLJBV73TVNoWXJajrTiHHPkVlgrLLMVgUcYnKyTHJ34meWvZEb+27/oqvT4jpwjk9vYQ9xF5biBh04Yn8gV4txIFOXZ9vFyPQ/nLYZY/t6EU6vEqG78H1lCQxdebstA3nHB6QaHeWjq+CkawcFGdFMl+JvkrPeaj7mwxyoIMNAYSTkQEQBXAwP810qUk8+xznBDvH8GpQebm/ct/quzPSWjjy3gi+7prWs75spmqwb/+kOGNKDg7z1x541GqikQQmK4FnsdmM4btG6Rw8SxaNKLZl9BLl+8IgTL7U4pz5pgL9DV6M6KRZl6+4Z60N6wILFfAkpQcT3r4c/nxYBdCiuCzdnSrFAplWuPWoyyju/ZTVm/eY2Iod96HsJO1E+AO8JHCx18gmDShfiGGMQ9usVh9ZOe9DjYN7IgrbisQxtu9tbfClW4S3S+sSyl4WakaG3ds6YTH8ceJgn2Lk64fImdpunYpI2/1RfUx4Xx9HBP89oBzoi7/MI43U20fuNABLe1ju2bau+pHztvVuz3puLgqCpvk3L/5PqupkwlnPdphdEK8ISzOQ0LKSIA7gTCselNEjuypv0toGyj4K2po7ZATMTiwQ5M9F2FIoo76rGEysINotsO/akrsVERA4W/Z3/AguTNVfQJd4KOa0YUHn6beIHAdHNR762qkIx7oh ov3IapgY /ufhGjTZoMe51Iu2txKa1Pzt7jqRPlajCasA87zapDqV9EUUMCDH0RMmgDeRKg27hUcvni8b79ehmDQpYo5kz6ROS6UzdWHXiCvJbrfJ7FsZiPvtp163b/FKuDWJgkK2Rid4aqEnhuhVm4cMhbCHbl2ZsVHF8PsxCO3Baygb5gIXnsYKmsJLgpcjNl1ogrSPgxnpTt6lPNoPIvHacRz6PgsMKhpgHSNcZA6Y563rPI7hbRrhjGhrIL2aWJNTKhN9d2xstx9Mxzs8eY2mBfX0SQTZlLAZ+c1nQTI9J 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 ----- mm/mm_init.c | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index eebfce8f58bca..c41c82bcbec2f 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/mm/mm_init.c b/mm/mm_init.c index e0023aa685556..426314eeecec3 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);