From nobody Thu Dec 18 00:21:00 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C7B416EBF0 for ; Wed, 29 May 2024 11:19:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716981556; cv=none; b=uNJG33ZfW5dnOwPIhxT0bdsIt3xwualbKvG/DRgDzdIc0Z4x06YXSlIvwXmpssGxqv0xZtnVGMsL00iBGQYA/VVRrTaYM1gYONQBw87Ow6/sJisXU4z5VyEfpoyrGFgX0F5g03sXe4GsxxxwvAnANkU1/xQ1va4frBFKRMYjfnM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716981556; c=relaxed/simple; bh=WIyToRVLU5UPSAo+kAbFtG62AOKqZ9vqaCQCkPtTXdk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rqq7rgKGWOSR0d+3zlCagp2pW+6G+5obcS4WA6UyXtuiKK9hj69k39Pmk35EzQGwTFB7pCnSrMeyCo+SqecYeaWjARa3qJ5sAEbt6E1gScpsckV36dzsDJHF3GbWul2/uOklKIOdQHprcbMFJR4SIgN1/OYpnUh8o8wbBE5lVEU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=R/attSln; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="R/attSln" 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 Content-Type: text/plain; charset="utf-8" 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 Tested-by: Sergey Senozhatsky # zram/zsmalloc wo= rkloads --- 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; } =20 -/* - * 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 { =20 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 =3D=3D _mapcount =3D=3D -1). + * + * See page-flags.h for a list of page types which are currently + * stored here. */ - atomic_t _mapcount; + unsigned int page_type; =20 /* - * 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; }; =20 /* Usage count. *DO NOT USE DIRECTLY*. See page_ref.h */ --=20 2.45.1 From nobody Thu Dec 18 00:21:00 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2ACC617B43A for ; Wed, 29 May 2024 11:19:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716981557; cv=none; b=nuUzxS5eTtw0VCp8DzIdpxupS2MpbHL+Ofjae+f0rvC4kip9jkIR6iPY7q2eH6qzz9pBPTpvVUbvnBRWp9GfG2S2eCpFkGL/BdPirfjrlDzBP/G73qYxjf1+qPB5DY9cUNaY0CgbV5cjWqZjR2tDasbiH9+8HW1uQ4MtjEbT+0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716981557; c=relaxed/simple; bh=VvacQpudkRgTka6HEMDXAxvdAjKpN7bLGzx8y9wQUM8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AsXMOlkkfLdnN4qbZOvGgz8rOQNVACff3jXNyIwL1eiMbpEc9zs9N347qHNnhv6oDEgiODLNlaPeaQFoA3gOefdF/vF+134RpFZGBuRJtnr7FOwVaZYuW5rWiupmrLzGjz7AjlAoi2hj7VrWMzxnvb4g3TcZlMFqcGaDodtCEgY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DH9Xr/a7; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DH9Xr/a7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716981555; 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=DH9Xr/a7n8eAxetVQSfasBy4xd6J3ZwLuf9asLuEQQ0RzokDxnyu4+kpuBwAgfo5qxFXkI 2AWg5XvYiifAmecSucnslXCzu6ui7i1m4WqUs63AdLH/+kqYNf0fkft9iWHVSxms6mNjRt 4LzRURuLCKWgi35DV9viUgmgD5RFE7M= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 Content-Type: text/plain; charset="utf-8" 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 Tested-by: Sergey Senozhatsky # zram/zsmalloc wo= rkloads --- 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; =20 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. */ =20 -#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) =20 #define PageType(page, flag) \ ((page->page_type & (PAGE_TYPE_BASE | flag)) =3D=3D PAGE_TYPE_BASE) --=20 2.45.1 From nobody Thu Dec 18 00:21:00 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B66471802D4 for ; Wed, 29 May 2024 11:19:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716981560; cv=none; b=H7teIbWYLM46OuqhnFeJyIWjUJAmCowapGNAOXIG/MVpZdcFM4tiZU3K9PM/dLu7ZzTVVUDTzqzv0EgxHkO3YZFzLynU/b5yjSWDoc7lrV3nqoFWiiu3IcJSXgMnkmK/F6+Hvf722k3v2TnGLXcjgTJ3sJ4TNNIoCcw8KyPpTlg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716981560; c=relaxed/simple; bh=OrO0nNYJXDpgIo+jNEx/2QPJnhbsGB0t5v5pFQ5BtT4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MjMIMkhXkEDUbGowzEFEsYmX5FIZX1TZRjxabC4XI0KKyi7A+c4YKyPT+VlOPCc47K6Db7Fa3nkZx+iF9lEENKfx4etFXJO49Wjb+jxJnm3c19btt/7X5QQgZ1klF0ZV+kD0SHdLTdf9xbR7JX1mEHLAqbPkKbYsXQLXo5svaPU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=RGvmCHAH; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RGvmCHAH" 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=abET8lrE4AVrejWdoZuoMbV76D72y0iE8NVlu7Sa3/4=; b=RGvmCHAHdpO8+VcntLvPUEa/SfOPpEh2qwDzWW3igy7Lip4tK1CSWE+jwIia9GLzDjZ/dx dH6489AAUxYiqCp1ZN38pCiBW4f0pyf0/ua0E9SE4pVfaFBpnAok3+5jSPE33gXhceQji9 wWzxZ7BrqMxWvcYfLaZul5wEdyo7eqo= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 Content-Type: text/plain; charset="utf-8" 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.co= m/ Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: David Hildenbrand Reviewed-by: Sergey Senozhatsky Tested-by: Sergey Senozhatsky # zram/zsmalloc wo= rkloads --- 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 =3D 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) =20 #define PageType(page, flag) \ @@ -1072,6 +1073,8 @@ FOLIO_TYPE_OPS(hugetlb, hugetlb) FOLIO_TEST_FLAG_FALSE(hugetlb) #endif =20 +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 =20 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. =20 +config HAVE_ZSMALLOC + def_bool y + depends on MMU + depends on PAGE_SIZE_LESS_THAN_256KB # we want <=3D 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 zspa= ge *zspage) return first_page; } =20 +#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 |=3D 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; } =20 static inline void set_first_obj_offset(struct page *page, unsigned int of= fset) { - page->page_type =3D 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 &=3D ~FIRST_OBJ_PAGE_TYPE_MASK; + page->page_type |=3D offset & FIRST_OBJ_PAGE_TYPE_MASK; } =20 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 =3D 0; + reset_first_obj_offset(page); + __ClearPageZsmalloc(page); } =20 static int trylock_zspage(struct zspage *zspage) @@ -965,11 +981,13 @@ static struct zspage *alloc_zspage(struct zs_pool *po= ol, if (!page) { while (--i >=3D 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); =20 inc_zone_page_state(page, NR_ZSPAGES); pages[i] =3D page; @@ -1754,6 +1772,9 @@ static int zs_page_migrate(struct page *newpage, stru= ct page *page, =20 VM_BUG_ON_PAGE(!PageIsolated(page), page); =20 + /* 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 =3D get_zspage(page); pool =3D zspage->pool; --=20 2.45.1 From nobody Thu Dec 18 00:21:00 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73496180A6C for ; Wed, 29 May 2024 11:19:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716981561; cv=none; b=qWNN45Y0gLDstfKY68ZooHWkRQdDJYevxcbx9d9NdOhLwQAZI5UCAQg3YNJ94At1l7vtFH2ykqmkEIW0tkmKsN/hs5tY+/7uHkrbaC12hvAR8XEy217QDGCcE+jtOJf/rM/jY8gwZGtPMNfdHrAnzcFFywh2SndccNJ723h6sKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716981561; c=relaxed/simple; bh=G8bCvqh1wqCa8uGv9DTnkX6odqXl+cfD6if2DoZ6U5s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UrpnpmVK7/Te6ivyWxs3MMt/yxNFSgB7f8BwCJ8COHP8FdkABklEWPmfhP2APurt+lk83Q3hCq9/k6YV1vHFenB52PZBe5IbXaYXaBV1XbxYWHycU0LPjY88LT2r8bGS8W+6jewN+pT6MTtG+u9OlcUkHjegpUE63fPdoTFqCIQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=D6+VH6/r; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="D6+VH6/r" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716981559; 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=D6+VH6/rfsbp9G3uogE9uy/Aek3kjZ5/wsKcTSgBtqE+X8RAtTUehwOicGI7lESEiMfP/f Zwhs6L22CpZA0DVnyu0pYTMhDFgSTRp5y7AUf0+T1+ty5yaDtEIXvXAJC0auMgJ97rCJ7/ icahycXB7CIg5HqNk5ZkgZY5CZyD6fg= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 Content-Type: text/plain; charset="utf-8" Let's stop using page_mapcount_reset() and clear PageBuddy using __ClearPageBuddy() instead. Signed-off-by: David Hildenbrand Tested-by: Sergey Senozhatsky # zram/zsmalloc wo= rkloads --- 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 *rea= son) 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); } =20 @@ -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; } =20 --=20 2.45.1 From nobody Thu Dec 18 00:21:00 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A0F3180A83 for ; Wed, 29 May 2024 11:19:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716981562; cv=none; b=fzjzt4aMVEeu58uJXsilovQbCc23CyePLBvt1XrKoCxKhPDNTQXsVyGFi2dltUprLA9k9ygXFHrSFuygb9tGYLEmZtGzmzb4V9j3cRPBmu9/R4wxvTtlwZj03+MJWm+ZzypAE/vGthEVCHFUOKZV+4Tj+yeXLUzGrRm6cvIBW8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716981562; c=relaxed/simple; bh=u1TfSxJfb/OshHhAS7cl9CkuPjr/yVjayHR5SnVoIyo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ipQB+WcZwYthD5S9RcJlzYFQ9jfwr7e6PRqqX8SJiWqyjlkni5XMrNdflZAwCqZmcm/KFECFlbnS+1HCv1xfhO36B5GigzAmCEVg/kcYC+6GsTvaNs9P5WVBPjtDCCZw4p+ZqYAaSMm42WT0EJrzVVIWDJYLOdKQom3Qnj6XpnU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=PekxWPKT; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PekxWPKT" 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=O9wGKMA7pg+ELfK4C46qM4+rq+qnJqY5pRyECiTlobg=; b=PekxWPKTRkzVu7/8WIJK3BxLYPPBBF9+F02JjjXzFQB44NDacb7N48NdatcRVhxxaROrQA 0lWBzRYf9vOQgQv2Jw6/G79NHmmNXYd+ftZfb4JrCifDSXuGCLaPo8Fnq8e1soBxETdJwF BDi8C4F+zDMx1zneTgbdUzSWx51Z3Lg= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 Content-Type: text/plain; charset="utf-8" Let's get rid of the page_mapcount_reset() call and simply reinitialize folio->_mapcount directly. Signed-off-by: David Hildenbrand Tested-by: Sergey Senozhatsky # zram/zsmalloc wo= rkloads --- 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_spac= e *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); } } --=20 2.45.1 From nobody Thu Dec 18 00:21:00 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F3BE181300 for ; Wed, 29 May 2024 11:19:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716981564; cv=none; b=sr0ipeDqTT1HTnYsHCx2+B6R9r5abDyYqQV4d/hzWbYcfxBSNgf9dMjodywTwJdUI6A6Uc/JWgQQgE8zPwj3BcLy1+6/KQRpnblr98Hlci4RK1mE154TCjppsF1y5S1+Z4WvEDaTnxRDGLxrRYDgqD7NvyT87Bs3Xx/gIWyjxS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716981564; c=relaxed/simple; bh=OrtHN7gm6sG7/e44ksUr1jsieGg46k546PJ3cCa5NdE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S/6Opr29y49R+tRWZ7ns9N4LUFYQmIg9Mb3xGj7qH/e0HnoFw+da4qfdXmHF2cNJ+E/cxRsFPYGgn5S/hryFpdcjc21BHuju/qK8zgVLJZMoFYkuuFcJPOe+IGSwAqfCaq3e6Z+E4DGis8Bew/tYLn1dUDrB/q0Un3RcnliilBk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=h23b6e1B; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="h23b6e1B" 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=503jl45eQ6DH26oe7TpQo3EopwWo8mZfnH3eTedH2jo=; b=h23b6e1BiZmOdspkExb2c/aKQ7NIbdcL7jFLuCGGfMVcRbejSQ/ThcwFmT5n4N5musRcDq tGPXqXkObuN+obOm6vt9HUYG8yA+Y/svwQdStWt5lET6gQzdi8o5zJ8m29cRtGvOM/wkvH pYfpzykC1v163lmhbtV8o0VzW/Pmp8U= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 Content-Type: text/plain; charset="utf-8" Let's simply reinitialize the page->_mapcount directly. We can now get rid of page_mapcount_reset(). Signed-off-by: David Hildenbrand Tested-by: Sergey Senozhatsky # zram/zsmalloc wo= rkloads --- 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; } =20 -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, un= signed 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); =20 --=20 2.45.1