From patchwork Mon May 27 14:14:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13675408 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 43C4CC25B74 for ; Mon, 27 May 2024 14:15:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C1C8E6B0098; Mon, 27 May 2024 10:15:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BCD116B0099; Mon, 27 May 2024 10:15:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A947E6B009A; Mon, 27 May 2024 10:15:13 -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 8DD806B0098 for ; Mon, 27 May 2024 10:15:13 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 3059941521 for ; Mon, 27 May 2024 14:15:13 +0000 (UTC) X-FDA: 82164372906.05.B3B2819 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id A1D0B1A0025 for ; Mon, 27 May 2024 14:15:11 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cnnWOlxR; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.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=1716819311; 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=fI7k3N6P8qJ4FuS4bDw6lNsnGteHRLAJN+b2iNRt+tE=; b=t4DXo+7ooocxcA295Uf1ydO3oqtRImuGy4KlQiiMEbWfR8zCfioWV0UzHrgSDhWVrtGtLy TILDW5bdijH0QQvw8RjAmOCpyWPThTxoYzbQT+IEjlu6wZMrEyFZPy15LIF+LEWKd+r4TD KYTiZeR2MV1zi4Gw6SN2+aJ/8kJFOKs= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cnnWOlxR; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.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=1716819311; a=rsa-sha256; cv=none; b=u9yC/aEYpnXH9cBnjXLCPbTgLDQCEnwpbE1qrswgnX1VyviXGvDLk5BvnYCTun3jcsjKc9 UQVpybFhRegfWODdT5oGbPm1751vtFK+YRuof2KM7Yat53jZ9HAiueUQJmEGfxEDEHklP5 uf6PC0TlXpEMBzApcewhGeqDClsqnuQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716819311; 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=fI7k3N6P8qJ4FuS4bDw6lNsnGteHRLAJN+b2iNRt+tE=; b=cnnWOlxRhK2XTGBkMAwbkn8/24KarkDsBnn2LA/rOyrWhtX92rIjA+TVpaHlaXm24/RHqx Vn0NOmYkxBwCklK3RnxiDWuDCDyFdE4uZu0KFAQTiFbCbe/6h+U2y4XvX/GoQDiiu4IH3S khW6RXBlTlpSNjw5UJW427vu6CB/ayo= 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-550-kXZuQwgiNe2ZxgXhztVTPw-1; Mon, 27 May 2024 10:15:03 -0400 X-MC-Unique: kXZuQwgiNe2ZxgXhztVTPw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 CA8BD8029E1; Mon, 27 May 2024 14:15:02 +0000 (UTC) Received: from t490s.redhat.com (unknown [10.39.192.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0613A1C0654B; Mon, 27 May 2024 14:15:00 +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 v1 1/6] mm: update _mapcount and page_type documentation Date: Mon, 27 May 2024 16:14:49 +0200 Message-ID: <20240527141454.113132-2-david@redhat.com> In-Reply-To: <20240527141454.113132-1-david@redhat.com> References: <20240527141454.113132-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Rspamd-Queue-Id: A1D0B1A0025 X-Stat-Signature: pqxdc4byh7b7fxcprek9ni9yya83nidw X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1716819311-391340 X-HE-Meta: U2FsdGVkX1/G6cz2liywVRaRZFhk++irkyEwaq0pIPcISas/71gabRiRMRicW5Tv/dUFE89FScKwzALethqDXrCSH+d+hG0WGw7ZvAv2TYaLF27+l5dJPZbz0fEuUOaM12ep7GwCH69NGQGUA0f1adoNXXeyi53cQrFNz23UwLLYvFhKpLhDHIuPHAeW9cdJIHl6wOYcc5D5wpEAMs2K+Oo1Mg+kJCLuTbm9hTyphXWuZLm8HQJcqlbU82JcSUbcdk3Byj6QSBG5cHYpVyXUgRzyEoQKECpnbcCzY/jc/iRFm+UQuZTRCDKVnrHh3TY3pyT8P4j4RjS14N8GZi5ASXxl21pTV8XLv/9uFosnRfXOu/3CoYp6jYUzr6RVQJSrT6U2jMn4R3voqm71xRrHK821i8rr3o8ICGLZQ0YLDqktt1tZ6SvZ2HW0yk2pEbAH8Fh9Er4iWSJ+ssnthQ/OKX8LDcP0t+Y5NnGfjeO7CuW687XLIQXF+hHTH5cwD+J/f251cW0xtSwoTL3h747lX6mM7k/nesBN/Dk9gJ4TIXcABFFXu9fUyQq+mgeA+cUuDyzdl34Sc+jAMWkcgXwDo8a6ddMo6723iARrJ6H37tPpRZL6u4oKjCRtt1WCXhq00hW9LOvMamW8B9HxAIdDQtZXMu8kmGfqsK7pzfhHqZrn4VcTWGarM+aomNrcPZBNlhoLUlTSR+DD0HD5GP4XDSyP5efnBRtgcIsHPzrCGwyvcOd890kZFE82/RSDze/t2wK2j71mF847f+TGIKz/pNmNAaVd9ql+QIwQVfZWtyvufPOY6A422rHmhsZUBcTo0yoqAdGW8wBqKsi+lEOj1h9bpiHxXga8+0PeLj/YdzFwMqPjS5QT9u9eeyxuXP1GdDV5IZSHUSL5osay7gdtB3e0eVGDXDrQAVEj1oLrWXVdh47SfKBoX25H4cwO1YvI+xMEhxfTUz/DxtBZ4PN Bmr5Iy6T Fa76hRYhxn6XfEVxW3XYVkjm9jEiR5ClUCFJO6MRyAw6z0Cg= 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 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..6b2aeba792c4 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 + * (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 Mon May 27 14:14:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13675410 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 AE687C25B7D for ; Mon, 27 May 2024 14:15:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 259E06B009B; Mon, 27 May 2024 10:15:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 232936B009C; Mon, 27 May 2024 10:15:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01C6F6B009D; Mon, 27 May 2024 10:15:16 -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 D68756B009B for ; Mon, 27 May 2024 10:15:16 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 84B73414C7 for ; Mon, 27 May 2024 14:15:16 +0000 (UTC) X-FDA: 82164373032.20.A868296 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 CA1E840008 for ; Mon, 27 May 2024 14:15:14 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cU8sFxJ3; spf=pass (imf07.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=1716819314; 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=cG/bHQ4quJa6Sy8Ny8W5KhH3qb/Pwqg5bjhVWAnFcjs=; b=xoYUjGOsRNFpUbaknMATxdDmwlk52UbnoX++O7iw+KTTR8U9hAZL5XzvjNYFks3Cw5AGZY WZlAFzCJD3aEeGzgFPpycsAYLs0Sp0JSEvkv+nwxPypZTDVN2HZ/nuuKZqtEsOjmj0Sn1i g/4/JVKxIms8Pt7YKkZ0wbx3FzDraCw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cU8sFxJ3; spf=pass (imf07.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=1716819314; a=rsa-sha256; cv=none; b=AjuRZHKMUFX8WLnXpxHtC396R5xZTTqgvtwfoXakbO1NVcjof4CUswCRNgvMZmPPXorTUm 7WdgO+QgPdhE1EMEM7sbmMK2qxz+ed2dTv2QYX4UzaZ5QNRnxWYDHo5xSa6+H1FHB/W6es QYCbV09Z3bobtRxc/tKzw12oxNDB5pI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716819314; 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=cG/bHQ4quJa6Sy8Ny8W5KhH3qb/Pwqg5bjhVWAnFcjs=; b=cU8sFxJ3VFRar/eyYxHUb6zj1dW4ZyH+b0inXfIjcAFDtIvj3DXD6MSFJWt5Rs4vtBQRbF 789vsAtzDA+0PManU+aOlXVPb4teiSfO/C+Es29HsgySOb+FhJGX61nfGa5fqbFXuaPJAQ RTGlZWx4UEuZIDeoLCD0BMVY4+AFPBA= 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-320-eU3y4psHO9CVn5thPdziNg-1; Mon, 27 May 2024 10:15:05 -0400 X-MC-Unique: eU3y4psHO9CVn5thPdziNg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 D3E611C0512D; Mon, 27 May 2024 14:15:04 +0000 (UTC) Received: from t490s.redhat.com (unknown [10.39.192.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39E141C00047; Mon, 27 May 2024 14:15:02 +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 v1 2/6] mm: allow reuse of the lower 16 bit of the page type with an actual type Date: Mon, 27 May 2024 16:14:50 +0200 Message-ID: <20240527141454.113132-3-david@redhat.com> In-Reply-To: <20240527141454.113132-1-david@redhat.com> References: <20240527141454.113132-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: CA1E840008 X-Stat-Signature: h6sbx5bzpscqcqys15kuk7d6aoqzrxyw X-Rspam-User: X-HE-Tag: 1716819314-473087 X-HE-Meta: U2FsdGVkX1+r7f+N1/a7jB3KCo+nZvGTfyO1/sWFVF8/RfYBwbi9EoEfiwTIHutTYpniwQTVltk0NI1QIu6uVAQc+cupMF2zrjPwwEFLWbtA01MKZcRZ/4EPNU9+g2PTqHOPCpwe3zuzSqh8Ch28Aod0F5X5OVrRSQCBNMGXZZJ/cKjDj2zc7mq5rY9GWyQ5ZdAWT9aMVUSQGIW4b0frElh3wQ39iCAJRduZu9foDnubEJ2/sPEvApoSFpc8eTqy54XGZzuZRYsubsw2bZwCbXhaBbaXxGleSeUmjVpWzI7D5vF5Zk3hVRwrYj3U7GOEVOp9a3fgseIWBl0W2O4mieFC5QsC4hPOkib4VoK+1YeaKPl+ez4r4pKgQMqHGIer2FIBZzeFp5vvY9JdbK4UtMMIpxo/Ar4zuCqLiRj2Sg9hOW9MB3QTix6MVXN7OUkmHefWVIWSc80VEeElH8VdrDQtPeGoZsqKXpb55xYNMThwTISfMju4Z0JDM1dBcgQZl0UNco9gusG046BLE6co2X63Wqxmumw5GNNe9doOsBLj2692EwQD54rhGvYaHlyrv7m3xWutVH15QlhAVUiDZeVKryMvAZnj7PywktBNF7iU6TjuMJvxNhdpWvEDsRari/OXbWGmMaR2+Dj1p+A0pTjOJAPgWpYs/TcNSJEk6cmHCdKl256wj7S2+nDd6yYrFocLyVH26D189WqtblYHakf7uHqW0KBhFfApMHfqH4c5lEQdjv5ZM3q9D6+T9wgAaEbOYzhlaccGM3PSiZ2uzelzbk4jy/QfqxZcw1WqnmZkVW2Bb/ESpKcnRFIQiL8K3PNYU2WKkNej6FhHVDIqMRhCeaqvDCVuXO0ddDAZqio2KpO2ZWsaDir3GOavj7zpYBI8iExHI9QWyfellhMJHbLHsif7Eb4YurkCz0kdTK3kXRzb/gzdrERoZbUqROuj7D/N3RSvAuNE+/aRWNG LtV/qNtQ YhVPNB9/z9Fmu07ms1tOFglVil390wXZT33atHdt3OYgAEJEoK5uf3gP7BAaD+aEnLvmtqZOpRMdaQY3RihjPmOMmNPv6uNWg3XcSZfESHZAwZnqzVE6MCUKOZ2BXa6kfpfOOfL1M8VGRsItHEisYgXpZ10LImUFU7UalSY4ISjJnHqdW8AkdWIFEIRdJHFhaO8PG3GFlb/jTEBfmIRf3Exn/2EwaXiatia5X29JusHTeXfo9BpjmXDaPMTSPcecE3DVtMyuhtixyycPFr4jichUXgw== 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 18 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. 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. Further, we could likely limit PAGE_TYPE_BASE to a single (highest) bit. Signed-off-by: David Hildenbrand --- include/linux/mm_types.h | 5 +++++ include/linux/page-flags.h | 20 ++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 6b2aeba792c4..598cfedbbfa0 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 104078afe0b1..b43e380ffa0b 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -945,14 +945,18 @@ PAGEFLAG_FALSE(HasHWPoisoned, has_hwpoisoned) */ #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 0x00010000 +#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 Mon May 27 14:14:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13675409 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 B816BC25B7D for ; Mon, 27 May 2024 14:15:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 606516B0099; Mon, 27 May 2024 10:15:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 564B26B009A; Mon, 27 May 2024 10:15:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 390A56B009B; Mon, 27 May 2024 10:15:14 -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 1923A6B0099 for ; Mon, 27 May 2024 10:15:14 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C3B73141550 for ; Mon, 27 May 2024 14:15:13 +0000 (UTC) X-FDA: 82164372906.29.751C93D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 09F0218002C for ; Mon, 27 May 2024 14:15:11 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PyEpytCb; spf=pass (imf16.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=1716819312; 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=NhkUSgtSn3vBcIMl6XAMgZKK8WplKXeQveOWeM1SVs0=; b=SHCT+GKq/iQorQECxln9bs0gxHUw27W9Fr6IMrZarxpMz7t/vJj/XPxFGv/nnQzOpDHY2g W7vzKRwSmB4EpNfjn+8hiY4tctFVxbRCNd/Tu0NR67coI9uFYvdpN/uu6sL3AnTM8rg/L6 Lv80k5UCUzd2rV1R4c0vhPgyhMGrDDk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716819312; a=rsa-sha256; cv=none; b=PJiGP+ry22VSTo9fSPqu3pV8lz6b6Dm6JFMBBonT2+qSkpygKZfW9LEy0yhUNVCwoGxpTH tI3qbSgYwxgx+7m0W+3Hes7WVre9KSZXVHV3jNEwNfOoXPDDKXFLT+F8J381NJzxw5TePu 7rHeRNUYCbq8vHrWAbd/O6nzFUMAUeU= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PyEpytCb; spf=pass (imf16.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=1716819311; 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=NhkUSgtSn3vBcIMl6XAMgZKK8WplKXeQveOWeM1SVs0=; b=PyEpytCbg9WhvrbOU2KxODy5+KGJkJgp6u7Ve1ExskwccC97ZBMbPC1XcZqyqLnWTt0nqQ dXJtmQwF+KJAmmsE/3OdtKI+cYiPOBiKX5bRS9QwwPoKTdl3Yt/MMva1kT6pi2VO4nhcZE p6UWwZab4V5H6Ucm35QnMoQYyJlgDFU= 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-215-HIw6c0EOM4SYxgQQgxJgVA-1; Mon, 27 May 2024 10:15:07 -0400 X-MC-Unique: HIw6c0EOM4SYxgQQgxJgVA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 52CBA185A780; Mon, 27 May 2024 14:15:07 +0000 (UTC) Received: from t490s.redhat.com (unknown [10.39.192.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 58D411C00A8E; Mon, 27 May 2024 14:15:04 +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 v1 3/6] mm/zsmalloc: use a proper page type Date: Mon, 27 May 2024 16:14:51 +0200 Message-ID: <20240527141454.113132-4-david@redhat.com> In-Reply-To: <20240527141454.113132-1-david@redhat.com> References: <20240527141454.113132-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 09F0218002C X-Rspam-User: X-Stat-Signature: 5jzz66cibak5bxhgrnhn47mx1br5t1pe X-HE-Tag: 1716819311-456525 X-HE-Meta: U2FsdGVkX19svVhTcZr+W27qc+mO1arpeFBh0Ay6dULmDlO0EmFwl+l8gnnxJeV5KoSeHedZNJPtX8lFJjPtx8ESnvm6BCbEPRU9wIlATB/UUMMZRbS5rQCrOa6JDDKBAj0nwcrXrqg9D6z3KXclc4iRf5kNUvQdR6hyNW5rUBzlbY763hhD43GPstWaVRrT/rIMBzd2TX+2Ke+Ij3lmO36N6uqSG40JhxhClTdtimkcWuG+uMZZl/LVAf5pMrl/uYZJNxg1YZsYgiTfUhojvoHKTeZHvGhAwuH2wdDW+v8Yi+kL2zwJlF4M/87OR+vsRaB0vpynu1sbkqKCygcwjmzbRDXFcH1i3VQczwo9rAECj/C5S9AqH0lWGytSk1C17Aa2GvDxefbXOHCoVDnly+GkS0rPScIboimmyfLlkAEsxZKtQHXjC/VB/19GSHYCRnB7b0VsmQfa3vH0V5fkxjZfH0y5e91dse3jhtJASp0X51sG0EQ0YGL6OMctPPryHEoqIj3Iznz61SY43ExtXydT//6K/nP1QGOf512KAvPQxgLur0KLzdd9lD3JFz1M28phRZCxpcdTHpugHXj5akuWHl5we/OawS6oep8Woz3q5E9QEx28k69rr9jX0mrMI97eNT8OYCZA99IL10Vy0bewIi/D00lVTkOxNlhdzEuOJmLnDBK1DrQPW0LdaQcwl4Mm4ks34XcVCbzI/CSfJcX2Xt+0YGdzZU7UPTq5YecblQGM3Wu/eI5VjGXhwPi2NsFA20UdoNmBg+aMN0r6bOB7KU4MDZddIUNCn3i1NsU2xFIFcGZZnqK/6j9q3DOGIe+ts4tjc6PyoVppd8x9sOn1zoL1MQ0qDmgCFQSwhbqizOq3RnJHNCCcWusHX2wQQpANTgFTqDpEGSMzB2WAcg0FuKb+yFBRStmVxlSVoqhFXazp3QjGFbfr4/fWitlbfuf/GIdBJs4gVOAce48 DzcslOXf Vi76YBk0bs3K0WuhYTwe+gEUG2b7WvxR4tqk9FNyOuBVtdLnZ2+xGf6FQ8/ZYCdO9IBMcAiz/oIqBVajJVNbMJANAwxjlmAN6iUNSUSL+oAbSVTUrwUbZkWza1khQ3MAOy/38TziUYEUH3pfqZ2XhikSIcpEAoD8u4i4OLLLXtxnKwO4H9iyg+IS4kCuI32kAJzM4U9QwQoa3VgZSasTmcaWtMF/KY/McJR55BRGefVWjr2Pga0GwShcVGzmdYu+opNCe4vafizSEKvaapSswskG/HlmuD755Vmz0GPs2aQ1aS3lWcMpq8DyXixYMV1EYVOW06BtpMEvHaHs= 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 --- 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 7b29cce60ab2..39c04419bf87 100644 --- a/drivers/block/zram/Kconfig +++ b/drivers/block/zram/Kconfig @@ -3,6 +3,7 @@ config ZRAM tristate "Compressed RAM block device support" depends on BLOCK && SYSFS && MMU depends on CRYPTO_LZO || CRYPTO_ZSTD || CRYPTO_LZ4 || CRYPTO_LZ4HC || CRYPTO_842 + 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 b43e380ffa0b..36d9ded4462d 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 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) @@ -1071,6 +1072,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..67dc18c94448 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 b42d3545ca85..1a6af454520e 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; @@ -1762,6 +1780,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 Mon May 27 14:14:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13675412 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 5688AC25B79 for ; Mon, 27 May 2024 14:15:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B98A26B009D; Mon, 27 May 2024 10:15:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A72596B00A2; Mon, 27 May 2024 10:15:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7FF296B009F; Mon, 27 May 2024 10:15:19 -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 48E906B009D for ; Mon, 27 May 2024 10:15:19 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BD5BBA1530 for ; Mon, 27 May 2024 14:15:18 +0000 (UTC) X-FDA: 82164373116.01.BE158C2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 2443280015 for ; Mon, 27 May 2024 14:15:16 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FH0Indix; spf=pass (imf02.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=1716819317; 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=hshwfl98bML8acqrBVRK8K6pB1i4C/7ItyePT11o37I=; b=OKcLz4xeb+6eMLLFBFnazEBK9E/bnf0DpTCCofyZITBTWip3APaJ+PXukEJdOdJs/OoJ7J vTJIW86flO4i4tDO3hWWStUTQoDkksQ05LOtlsNddxql4aq3l3klkaqHfTbgL14Pa55PHd rhWsrvLiQO3tgjM3YtmTD3nk920TGgg= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FH0Indix; spf=pass (imf02.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=1716819317; a=rsa-sha256; cv=none; b=Eu9Ici8Ac1fJ81yPVtVFwTbum6AZIgpBW05MGugtSfpdQhWikG55Zg/iPoCuPGQjJfiZQ/ BI6qlvcW6sG16UZyINJlB7SKGETn0sGLbegHinAI3KwzT3me+8GritmVJ8IxHmEDAWvdkZ /ut+AUVnWVfjrKIGr6MtNbbdyTj4skI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716819316; 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=hshwfl98bML8acqrBVRK8K6pB1i4C/7ItyePT11o37I=; b=FH0Indix9f/mdiHiwZexNkJ4+ru6n6TNYOF6Q6CbGXwx5mdWfOgeh5jx/efXB7DHkC1VDL arORcoFolLjzYoMI0JVIwUbfZB+jktbga8pzKuDOydmeZbgZOPupAKuMqdyLpNw9ej28iJ uAIvWi+xIn4IRFaM7aKDut78yZ0UDMc= 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-120-AAUNmNJgPs6LTG_45hYmFg-1; Mon, 27 May 2024 10:15:09 -0400 X-MC-Unique: AAUNmNJgPs6LTG_45hYmFg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 51D76185A78E; Mon, 27 May 2024 14:15:09 +0000 (UTC) Received: from t490s.redhat.com (unknown [10.39.192.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 902091C00A8F; Mon, 27 May 2024 14:15: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 v1 4/6] mm/page_alloc: clear PageBuddy using __ClearPageBuddy() for bad pages Date: Mon, 27 May 2024 16:14:52 +0200 Message-ID: <20240527141454.113132-5-david@redhat.com> In-Reply-To: <20240527141454.113132-1-david@redhat.com> References: <20240527141454.113132-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Stat-Signature: ojde8ubrkws5zxkro9et6gahed4axbmx X-Rspamd-Queue-Id: 2443280015 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1716819316-672148 X-HE-Meta: U2FsdGVkX18PDQXvTCNfwK7eMThGXzff53vGcBEOqa4bAly5GASyMBy60JHga2EDgukZWcjwmg6nfVCTnD04N0s0mJe0Wq/VhHQ3pdqZS6MD/odh4xDMrkpaYaMgf745HRPCGVCF0n4fscQCJMeDmQCX1O5WTzhVaLQAKI80dzCFjKiR3mb3T2MvY5RXimYKOmTTrGk1QIpugI8v2Kif8A1GdgOg3GsetLQpNxQOCTec6mSr/nZ7JDNbcBs+kB+4ucklB33v16JOsHv4xthqbTlxU7pYW9KUmIDoztBEzR/AqFLs4hEenqS7Frx5tWs4PgQwUeqXiI0ULSA7MBY+s0sGwOYsDUM83rkronIBhdDTaVIfd6tZq7RA4aPrdYhdbi4Dut0Gnk4qRU0g4VNu+8rEZUFyx7lfJmCiDY4VduTXbCrnvxAwLHz/NzNBDLAwQpsxjJW17odE4XEtLIG76yUcDVSn2JzNNsbNNQsfNINrNVFFuXFkymrmctBR6AUsE39q+DLFrNlOHtl6k7wdAZrpGYGy5gVTJdXVLgGPBjgZqxQD9cP7KA9oDBYCy8qsHtLOMMeKAxs9viyua3S/fiZHR2l0101Sg3Sw4R9CB48PoMBo9gl3kwCNqcDi07mbf3bdY+lzdZOJ4pyQ6gsAM+lZk+QfQTW+CnBwbyiIidPpMb7MW8fLiCkhHtaHDuz+MKmGVLOJ3AoC2wj2iaE++Y6bBzTb5NW4JthEyZWKraQs5LcnYomOIpyztJggpnpneBhO9f6aQQSMGXAr+U5sVl9ZZJ3qWcEE+LbMsI5XltKhKj2/g0zWJUHDki07+B6NHrM71iKq8gSvjKtEdx0+9cxh8j3AslDTZovS77E5+xlszvRrXYCRkoCbXAt0M/jD77MAMbc2Balr55nJrHr1qXzn/PYd4OCWqGdTy8OuipDWWs31EPmZeBvLCERXeO4tIo0lCE7VjPJvnkbLViY PTPTovDE 3H5LygZlmzMIWmP56T+fSFBywd+p2X5Q9U9zVKp9fPHwr/L464QC3f7f18HCikY3z1OgZgVnsER/bWK2aeXgEH03/6Qv8K+y97su8X/WcX25LCk0367uNfWwga+0ST9TZIh6pHXIR0TWE/Y5UoD5n8CKbQUNvZwxMOYpiVUBze2v+Q8RrMnGHJ9kRrH3PcD/iw+BZjm8MCdno6eSYgk9ZJWjGbTNrQFLMLHKL/WZRKljspECk5VdaYRcjNN2MjnHjXfruQgDeSohMS9lc9+wuyBV2am/A7cotYLzR 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 Mon May 27 14:14:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13675411 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 DFD60C25B7D for ; Mon, 27 May 2024 14:15:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 986C86B009C; Mon, 27 May 2024 10:15:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 90FAC6B009D; Mon, 27 May 2024 10:15:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6ED1C6B00A0; Mon, 27 May 2024 10:15:19 -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 47FD36B009C for ; Mon, 27 May 2024 10:15:19 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C3273C11A7 for ; Mon, 27 May 2024 14:15:18 +0000 (UTC) X-FDA: 82164373116.30.CD0E265 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 117561C001A for ; Mon, 27 May 2024 14:15:16 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MA3R21F3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.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=1716819317; 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=1jgAtxlgpKD5tttWASyjS08Kd902IxQGps+U4uBLOWU=; b=xbOKwRN5XSNTcgw88Q/ycVrwFYgdIFjfeC365Ov+ogJoPwCxYj4VFBabksOrVQX/wFwCMG wq/w+HN6oa5j2+qx11oVg4Re49YhQGQ9x7jut2y2vXCNDyUTUSvqbfx+CquHHfD++g6Ar9 FZl5plDPM4SA37Px3cSw2WtKLISNk7c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716819317; a=rsa-sha256; cv=none; b=Cm30bbSYNWCFYvuEmhVw5cymUEvlcEtzHrCw8Nd7plDAmN7n6eZKA+vuY+UMlKHCR63/wD oWnnQ+rmtUH2DldtP5vlROY5LrAXEOzwjCzD2dVKdsYC2j9sGsji8DC8o+3O2If2m+ibmP yOydu5NHMID3t8wRBfzqoUnt/zfuFpQ= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MA3R21F3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.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=1716819316; 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=1jgAtxlgpKD5tttWASyjS08Kd902IxQGps+U4uBLOWU=; b=MA3R21F3hPbj22MNXKamNxVMvJIEkAcEIeX+0FCwNCtPewEM2JjDTvoy5DqAh+4Ky4akXu J5W8AYMdHdBgfN86wzP8Dgnn6ehs9lnhNPDi7sbMxCap9p8trdrfF9buWmdqGcccWSZpJD JV9+z7AjB5YlcHmv4tPNVtIeLG7yOS8= 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-602-PvG6X_TONr6hv4V8Z_f-EA-1; Mon, 27 May 2024 10:15:11 -0400 X-MC-Unique: PvG6X_TONr6hv4V8Z_f-EA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 641568025FC; Mon, 27 May 2024 14:15:11 +0000 (UTC) Received: from t490s.redhat.com (unknown [10.39.192.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 89ADF1C00A8E; Mon, 27 May 2024 14:15: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 v1 5/6] mm/filemap: reinitialize folio->_mapcount directly Date: Mon, 27 May 2024 16:14:53 +0200 Message-ID: <20240527141454.113132-6-david@redhat.com> In-Reply-To: <20240527141454.113132-1-david@redhat.com> References: <20240527141454.113132-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Stat-Signature: i1sjohj3kx7b9fyaj1pwt7343ksegfox X-Rspamd-Queue-Id: 117561C001A X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1716819316-836309 X-HE-Meta: U2FsdGVkX1/eVi83dhirx5UHALJQy3qrzRavKPfNdfV7nfAB91SYf8E70N/zSlyAQLihY4Q/oCmpCe3ISJTBGWD0PAwLZBWrqw2OwWaOcvPlpwByVA0FYuMFrypExNvrez8ONfUYV7XUXR3wvyfm/wUUADV94tjF9t6ZvHf2Nud6MjAynPkeEkRp4cx5kyivSEyNDMmCGdEg8jkD7xVCCvc1+QE7nag+AoFePi3beTY2DLZg3EcvmIvRRGs5NATRsUDyGIT1O7FlIXsW39JV2rOxcgKkrPSUhKCj+MeM0UQoeHPm9/f3g3kjhIyv985+ZfBO4EjR3eS7nV2WYx1XQBIWlQsY7kiVy/9YRnBOgf6JVB/7EqVM5NehWf1UE2UbQSoI+og+uqk25MEbBaTfFm840wI/RqWSt4976B0ffVqlcYmhmEpdql3SXCvUDOQBiAvIZIEBSdZd2nf+OyQBEUJq8Ppzh+rHu2GXRSk23Qcw0kCcDv7WKyKA4R8GVaoxaAshkfJSCvFwGdyeC/rsg8BCVTYgGUeZGSNZSzyGuG5yLYKIcYP9JNTN/UWvT6vIaSbcf0EEbh06GlchQPqxzXyKsG9AyzXNnl/NTdRU7lfoAdC/rjIJbaPc3VMIIkNhUDr3oy4qqjqs8HRU2Bg7YTvE2PlibkU5eh4jsTdNcl1WTgpaJSPVzb8/w0utkfeb+Og+et+bKeVOA7IFuzwWLsZZGfgmaLQ4QTtGyPbgA6Og6bvP1vBd0quLCIX8LKJFZmkerui8603/KOirNFSc4Cwjw/nVlKYPcFiauQvmcwK8Y5R8MT/OuqEIXWVJT1EGQ06phYBdkTMkT7IQ5vawuPciJgxeQwQQn4DuwO0YL0jrxp3o9f5NtVrNL0qSE8GwPWrrsNWumiE64yYFdFczW3GeGZSVITWVEsPwOdivubJh5UlChNzTOCcmPzg2TtX9MHuf/wU7h7K4SKJAnIl xjUDNHbs Pq3BT75FOO/YFuQ5s5XesWKxueFnAh5Mis8v/WNuZUe7F9cZwpJsplqYC3yh8UCSr+tG/7C5RwcO6HDmwzpXTaOqWHZWKs36+cyNjTMmtZbIpo+j+PChxKBkRaDXZKy49RG1lFq+EqSf+tpu4Tkfm30B05knzaCMXm3QbohhK7Zj9WmJaShggWbEVXXMIaz6NWbJ/aJjb3fSfZz2sBiyzgV59F5gvPzNZZfOnRHfsMZoLFq6uZTyrO5NGK/Y9sAL/4Nm25UunbnXadq4EzJNpyCXnWEc0CDMpCugA 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 Mon May 27 14:14:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13675413 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 D2EA2C25B74 for ; Mon, 27 May 2024 14:15:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 232EA6B00A0; Mon, 27 May 2024 10:15:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E41D6B00A2; Mon, 27 May 2024 10:15:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 011766B00A3; Mon, 27 May 2024 10:15:22 -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 CAA606B00A0 for ; Mon, 27 May 2024 10:15:22 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 845F31C28B7 for ; Mon, 27 May 2024 14:15:22 +0000 (UTC) X-FDA: 82164373284.15.16AACCA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id C913340015 for ; Mon, 27 May 2024 14:15:20 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ys32Q7n+; spf=pass (imf01.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=1716819320; 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=mvfl7fozsgrYXK/cOQK4fr4wIb0TzpdI/FqNXmQZaNc=; b=kbQCpHYf7hGTqnivPG7ExkwIRK3O9LEPR+voYkhPAxza0X1N8Nx5coOM5BAPhlR9BwBNQu 7FUyaw28SD/JebFSH0Zcy0+Vr73jCt5XovRXTHQg30FKyGkI0msbAoVg0Tr4nx2QBLiT2c K9OYT0jMCjutFTvkdxr7I0P/RX2KoRY= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ys32Q7n+; spf=pass (imf01.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=1716819320; a=rsa-sha256; cv=none; b=y0Wia6iamRUCNlueHqmYU9CF5TqF3XX7uFK+OgsnQ4tIGFVvEXImeS/jWCiKWkDxUw5qlN T4drP/161Gda2kYbvb0APITHq7fOADZdCq8f1tlV2SlS+rTVC1uPLS4Gn90x5lZ2cRuXfn eLpMEnHxf54NXZw2kdvlaISe0diFWA0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716819320; 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=mvfl7fozsgrYXK/cOQK4fr4wIb0TzpdI/FqNXmQZaNc=; b=Ys32Q7n+O1EZoy2KSFo4DaXLBfWAzcLYnFtNtQOq7RyMrJGywkT5AZusLGz1BonMjnJRB5 m2ExDlVP+ByBdch6iNJjY1vSHX4BLF8DYmcL2ot7moF/uAgTefrKfWtUhtBEgNFA9ap3Ck IYoRIq6Tp5JigfCdjQOrZWZua4YN+P8= 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-626-fSndykL4PXGFfJJtu-ZbSQ-1; Mon, 27 May 2024 10:15:14 -0400 X-MC-Unique: fSndykL4PXGFfJJtu-ZbSQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 4E79A8058D1; Mon, 27 May 2024 14:15:14 +0000 (UTC) Received: from t490s.redhat.com (unknown [10.39.192.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A1631C00047; Mon, 27 May 2024 14:15: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 v1 6/6] mm/mm_init: initialize page->_mapcount directly in __init_single_page() Date: Mon, 27 May 2024 16:14:54 +0200 Message-ID: <20240527141454.113132-7-david@redhat.com> In-Reply-To: <20240527141454.113132-1-david@redhat.com> References: <20240527141454.113132-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Stat-Signature: rddd33hirwrwyzq8gdmggc1choxguf7d X-Rspamd-Queue-Id: C913340015 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1716819320-520053 X-HE-Meta: U2FsdGVkX18biSkkGy8unglf42Il+M23dbEHmRRecl4Lemtq3f9GTKlpZEAd64M6PMqcjSTfICxJoyWycMRa9OWvlUF5W/y7Qs01JaIJWuuQ4uX50/xt4PD+21Zj4slRWO4vArcodlsLvVWI9jWv7A689ca2s/eYdPcNbVU8oUyXn+brhA3L73KxkRorI77nhnntQGzQrxeD4gRofjPHeFxt91sAeQD03KaZaa2AVrq7uSKJ/DgY+V9/nOEaONIOlinYH1Y57qqRH8g3NEHceZgE5kzj9XqFkvHi7GPWavk0nOKVZrM01U5G9o/5JSMWRU74IhCNcrs8BeDhsvUvppAA0fSGD1tkKrmT6biyv7N0k8As2deEJlkf6j2KQFGtDikkT/Iu0MUou0RWTLYa4G3uExvtSSLh3UB7uixGGXjJobBRZljscDMq9Vs6cGRVJ/dB6tWVlCflVVO96h7ULTV/CGT9rcicV3BZuMh7BQsxms2yKzWGGB7rYYkm89iW7dlcXcNIDkatGINSwNsgrBvxiaBOe1ry+mbTSqNzZJBHRVjjUEWuAirfsmvATDijnBk2qQ6cyI06DFq7qRwB5HDcC676D9hVJhBDCWkNkoKLsBX3SsGJthBjUS11RSxdXmFgLNBopxUH1QVdtnj6tfuiqPvmvbpD2WsufO3VluXrxhV/5h2iYq3Eg5lFRP/+V5yZCZUWhm7aUWe+MxloPfWAhNmj+D7fRz8rsahh0inTE6EZKTg9wtNx5tT8ifgLGIlplykVJL+HMlcfYyd5PCGpNkMlxupqoOGXpxtZ/lrrqG1ZlIwSdocNLR4jS8y3JbYFUoKVZHB7kKw2VTKpVQkQzNH4GsotYq33nHwrPjY9KCvuHWjIvqAvx40f2TJ5+7fWuMxhR6eZym+qzyf4AAimd4Fj4s7B1Q1ZRB4mEy6nJZamkN/3gNQPf8dnAeHLwzn1s8Z2pDvP9wyfQM9 LuHeoSH5 brjpvoLfNbAiKUGEeoLeG8HasadT94RUzixxWgUOjwNrWK0TGAsSgD26//H7Fn9t149rv8eL6pl+bXR2dgIzTm8iVxIMd9kfkXVYjCQyNBPJlmOp3pWELufpUwnJyRF7dthigz3s+Y5rupt8SZGK/4XGRz+q7YwqBLnYk+lonxFT73ibOX3PjTEz1EXCYMJsJrCu3vBlJs4mEltSRacgTQTQEPN+i7/RdPJGBDoaOuLt/GqaklGLK4g9sXCihPDMWvUEkGuEwydlUoTyqOvYI+Vm3dbN9/+wD68ef 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 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/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);