From patchwork Wed Aug 21 17:39:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13771934 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 30581C531DC for ; Wed, 21 Aug 2024 17:39:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B02CF6B0167; Wed, 21 Aug 2024 13:39:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AAEF46B0168; Wed, 21 Aug 2024 13:39:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 927E86B0169; Wed, 21 Aug 2024 13:39:30 -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 731096B0167 for ; Wed, 21 Aug 2024 13:39:30 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2616E1210E8 for ; Wed, 21 Aug 2024 17:39:30 +0000 (UTC) X-FDA: 82476964500.04.3781765 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf20.hostedemail.com (Postfix) with ESMTP id 6CD7B1C0016 for ; Wed, 21 Aug 2024 17:39:28 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=dnEyN228; dmarc=none; spf=none (imf20.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724261909; a=rsa-sha256; cv=none; b=Op8VSM1nArCTWOPliVc1SYJxLNmmHFKseRF2n+7nU1OF5O7T7eLcnn/IEVC3AJh9clmBIj 75bF8vG8kRFhMmbGxTjSFES4D9ZsKhbFi/gYFJ7zDWIS1DkFMeqMLICT53NpKh7Re2hRls JE3adhkuv8+NdkTMtSZbcRQ3iZO9C10= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=dnEyN228; dmarc=none; spf=none (imf20.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724261909; 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=9J1dGJEjyIookDWkyWXpEPOywLE9l1WgoXewdQk9plQ=; b=ZB6pTh0RzpYuEIMckjmeOiWgUKviQ8ZYR7u1pBbSX2eRseCZtaa/g8Q918D4nvM7VCEGpo VxMUiv629GtGI7wOqTZ5dfkkjxbSA6qHgtZOfX/e6f1XFjUPz86z3wSVSfeHSBDh2sqMYq mdwlmyHEjFAfRsTypCoTaOvWGDzCQZ8= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=9J1dGJEjyIookDWkyWXpEPOywLE9l1WgoXewdQk9plQ=; b=dnEyN228r3HZhqbBP/e8fuzrXe HwKC5tCjx9+g4rCFe25bArQ21PYYdaOtpcBZl2OCaVwJEs3lmroahts1xBNABWaWCpxwz01i+FmbZ tF11jgUb6BT5u+QpnE6Rn9Z4dF60jPA7mc66CN9qVjFg02nmF4trpLYgc0rT/Ot2we+KNuGTcYE34 iNvRaQ4puiQfQbuheBQodgjnI/RS5jY3UzsakzQ2SaLuk/v3KVAsDO37zpac5zDj9+Xn4HJiXg+Qz 9eW7It83b9zlFY6xjKMNcCWBU1kOzHiuQXn/PpEjjJV2Cy2/CYV28mkaWnrsXUO5cxKBa4MchRq/W 2ul6pE0w==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgpIi-00000009WdI-0gWR; Wed, 21 Aug 2024 17:39:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , David Hildenbrand , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, Kent Overstreet Subject: [PATCH 1/4] printf: Remove %pGt support Date: Wed, 21 Aug 2024 18:39:09 +0100 Message-ID: <20240821173914.2270383-2-willy@infradead.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240821173914.2270383-1-willy@infradead.org> References: <20240821173914.2270383-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 6CD7B1C0016 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: bp4je46mb9mbghsp5i9g8rihtduueq9s X-HE-Tag: 1724261968-443834 X-HE-Meta: U2FsdGVkX1+TCxSrQKHHaVcLdSW0QdyAmaVFEmo92KYQaAka5zaXLGagqL9NnsOsCU9WJFRaEKWj9g+Sbd8bWXbemt9iMVeijsvkz1U05OguNxklJPAQvR/KLDAvyysPw07oPMY2vdNXQN8AO7flJGQKMJRt84HChRnIuAbkzXhdGvUW8rD86PeH4oJ4PVkO7aKy2EPhLorIU1hOUW+RWdR1VVbgPWgy3nZZnOA+ZfqyaFKJYpnIeL7IkoNo4mWTgkhGFBcHV2Cgkhr5vxpkkBs0RSFMaNwWNz3Nmt/JJcWmvo6SwfEmWjE0fVpMjP1LYOjetwo3DjzfjleW5QACCOraWoEyKOfck19C379zriLyzz4Wd95IC9M32rgPk0FEO9o8Pjmre8lNKIYAqDjB2/TQiJYTRRtisa/Zn2hX33bMzQLLmO0VX3vPWpMnf5nuukGo3EA+58dSd0LSgceDW71HpEdemGVlzkUu9DafcPrAPGALjiTs2CmlLAK2yuPkcaxhbeXGO1ewVcF3DiiLA7OdFdSsE13OItjKWQtLdvdrb/BzGEJJl/MPqN3HSokpKeKqhAbkDe+ijDwTsYNw8Vdyw/50ORFtUtbz278Xm7wb82av/95mmYWpaCRQhGc49gIxEa+IKPvKWabFOuCO3o7bhV8ZfScrLkGw3Vpig9u+xRES/P5wQoENZk671iO0d5prCxoNUFxcKhZC1SiEhajQTOgr+DQVaj2u5J62Kyz5+JgUgHPsgrUJEBb2ur01GoG1tCHUmmgKA/S0Bpmb3kMRo0XCXAZL3ybEpi/9ZAo9LsmBQNAs5LlVeYusxZUUoTQmAPlYHfrv+UkFSQZ6GeCyuX4qxU77WXHwEsSGRGU8R/WQjnjHwdcbQuBEyutAXynFN/H8ZZdTr++JHqjhE2qWZOelt92ZmVVySY1Y1XROZxZKd2dJZuiOhlFXp3vFuSqEEg76BOBvDanGiAg W63Qo3zy 5+gMLZH2LK8CXaOLFOB4hrc6CbE0BGpBcCfZsreIn3+Sbf/fVXl/nl/zbR06gHNr8DvgNDhALN82RYJr/gqDjrRWoZyt+PXiSdnpszo8qtnyVlnV+rIllked5DiDmR4C8ukllVAgPULADmsP2rrJSlEJvvRVgWOBYfgsJyOJZyiNf9D1JXBcjvVQcp7nL5sZHCMr8mG6TF0G6370mLyWg8oSwsCxMwTF3nU3HHLqsz+gi8tm+qJtPmeAtoKezVDLxjMt+hztGVof6g4r1Z7RepUdN27smiDm2uCWt 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: An upcoming patch will convert page type from being a bitfield to a single bit, so we will not be able to use %pG to print the page type any more. The printing of the symbolic name will be restored in that patch. Signed-off-by: Matthew Wilcox (Oracle) Acked-by: David Hildenbrand --- Documentation/core-api/printk-formats.rst | 4 +--- include/trace/events/mmflags.h | 10 --------- lib/test_printf.c | 26 ----------------------- lib/vsprintf.c | 21 ------------------ mm/debug.c | 2 +- mm/internal.h | 1 - 6 files changed, 2 insertions(+), 62 deletions(-) diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst index 4451ef501936..14e093da3ccd 100644 --- a/Documentation/core-api/printk-formats.rst +++ b/Documentation/core-api/printk-formats.rst @@ -576,13 +576,12 @@ The field width is passed by value, the bitmap is passed by reference. Helper macros cpumask_pr_args() and nodemask_pr_args() are available to ease printing cpumask and nodemask. -Flags bitfields such as page flags, page_type, gfp_flags +Flags bitfields such as page flags and gfp_flags -------------------------------------------------------- :: %pGp 0x17ffffc0002036(referenced|uptodate|lru|active|private|node=0|zone=2|lastcpupid=0x1fffff) - %pGt 0xffffff7f(buddy) %pGg GFP_USER|GFP_DMA32|GFP_NOWARN %pGv read|exec|mayread|maywrite|mayexec|denywrite @@ -591,7 +590,6 @@ would construct the value. The type of flags is given by the third character. Currently supported are: - p - [p]age flags, expects value of type (``unsigned long *``) - - t - page [t]ype, expects value of type (``unsigned int *``) - v - [v]ma_flags, expects value of type (``unsigned long *``) - g - [g]fp_flags, expects value of type (``gfp_t *``) diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h index b5c4da370a50..c151cc21d367 100644 --- a/include/trace/events/mmflags.h +++ b/include/trace/events/mmflags.h @@ -130,16 +130,6 @@ IF_HAVE_PG_ARCH_X(arch_3) __def_pageflag_names \ ) : "none" -#define DEF_PAGETYPE_NAME(_name) { PG_##_name, __stringify(_name) } - -#define __def_pagetype_names \ - DEF_PAGETYPE_NAME(slab), \ - DEF_PAGETYPE_NAME(hugetlb), \ - DEF_PAGETYPE_NAME(offline), \ - DEF_PAGETYPE_NAME(guard), \ - DEF_PAGETYPE_NAME(table), \ - DEF_PAGETYPE_NAME(buddy) - #if defined(CONFIG_X86) #define __VM_ARCH_SPECIFIC_1 {VM_PAT, "pat" } #elif defined(CONFIG_PPC) diff --git a/lib/test_printf.c b/lib/test_printf.c index 965cb6f28527..8448b6d02bd9 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -641,26 +641,12 @@ page_flags_test(int section, int node, int zone, int last_cpupid, test(cmp_buf, "%pGp", &flags); } -static void __init page_type_test(unsigned int page_type, const char *name, - char *cmp_buf) -{ - unsigned long size; - - size = scnprintf(cmp_buf, BUF_SIZE, "%#x(", page_type); - if (page_type_has_type(page_type)) - size += scnprintf(cmp_buf + size, BUF_SIZE - size, "%s", name); - - snprintf(cmp_buf + size, BUF_SIZE - size, ")"); - test(cmp_buf, "%pGt", &page_type); -} - static void __init flags(void) { unsigned long flags; char *cmp_buffer; gfp_t gfp; - unsigned int page_type; cmp_buffer = kmalloc(BUF_SIZE, GFP_KERNEL); if (!cmp_buffer) @@ -700,18 +686,6 @@ flags(void) gfp |= __GFP_HIGH; test(cmp_buffer, "%pGg", &gfp); - page_type = ~0; - page_type_test(page_type, "", cmp_buffer); - - page_type = 10; - page_type_test(page_type, "", cmp_buffer); - - page_type = ~PG_buddy; - page_type_test(page_type, "buddy", cmp_buffer); - - page_type = ~(PG_table | PG_buddy); - page_type_test(page_type, "table|buddy", cmp_buffer); - kfree(cmp_buffer); } diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 2d71b1115916..09f022ba1c05 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -2054,25 +2054,6 @@ char *format_page_flags(char *buf, char *end, unsigned long flags) return buf; } -static -char *format_page_type(char *buf, char *end, unsigned int page_type) -{ - buf = number(buf, end, page_type, default_flag_spec); - - if (buf < end) - *buf = '('; - buf++; - - if (page_type_has_type(page_type)) - buf = format_flags(buf, end, ~page_type, pagetype_names); - - if (buf < end) - *buf = ')'; - buf++; - - return buf; -} - static noinline_for_stack char *flags_string(char *buf, char *end, void *flags_ptr, struct printf_spec spec, const char *fmt) @@ -2086,8 +2067,6 @@ char *flags_string(char *buf, char *end, void *flags_ptr, switch (fmt[1]) { case 'p': return format_page_flags(buf, end, *(unsigned long *)flags_ptr); - case 't': - return format_page_type(buf, end, *(unsigned int *)flags_ptr); case 'v': flags = *(unsigned long *)flags_ptr; names = vmaflag_names; diff --git a/mm/debug.c b/mm/debug.c index 69e524c3e601..9f8e34537957 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -92,7 +92,7 @@ static void __dump_folio(struct folio *folio, struct page *page, pr_warn("%sflags: %pGp%s\n", type, &folio->flags, is_migrate_cma_folio(folio, pfn) ? " CMA" : ""); if (page_has_type(&folio->page)) - pr_warn("page_type: %pGt\n", &folio->page.page_type); + pr_warn("page_type: %x\n", folio->page.page_type); print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32, sizeof(unsigned long), page, diff --git a/mm/internal.h b/mm/internal.h index cde62b16b71c..a70547d33e0e 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1153,7 +1153,6 @@ static inline void flush_tlb_batched_pending(struct mm_struct *mm) #endif /* CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH */ extern const struct trace_print_flags pageflag_names[]; -extern const struct trace_print_flags pagetype_names[]; extern const struct trace_print_flags vmaflag_names[]; extern const struct trace_print_flags gfpflag_names[]; From patchwork Wed Aug 21 17:39:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13771935 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 080C0C52D7C for ; Wed, 21 Aug 2024 17:39:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 189A36B0168; Wed, 21 Aug 2024 13:39:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0EAA96B016A; Wed, 21 Aug 2024 13:39:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF5946B016B; Wed, 21 Aug 2024 13:39:32 -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 C9C126B0168 for ; Wed, 21 Aug 2024 13:39:32 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 89FB340517 for ; Wed, 21 Aug 2024 17:39:32 +0000 (UTC) X-FDA: 82476964584.30.1E9880A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP id DB8CC1A0002 for ; Wed, 21 Aug 2024 17:39:30 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=HmrbttBd; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724261954; 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=UxIoSp9JEZWib8zcfiFfoEXleyGuw9ixgY5suc0x7jk=; b=40X+LMe69iaSo0B6Co7H99nwJuFvsKsphx+qzSJQg5G9NaIdzLR3vZJyZxXgm1337jbQln k4YytLqMSH3w3SExPje6aOAX+6q6jkulC481MvYtiz1bZ0b12sng5FxaXYRvvilWXBWQmo I11zjixUMngiXbytnmzyi+Fv8NxnxZw= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=HmrbttBd; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724261954; a=rsa-sha256; cv=none; b=EzzSOK4Nutkt3lE0vLjTwlo2IFzCjNcwoSgEGFMjy0NOZbNBNAH2llev9FQedjl0P+PNJq 5lQbjpz0mg8r7elWUNxcUVJRMsQqpJRHcMfa+Ty4NrFy+7wIkZ2TpdgbmGmDNwj/ZnHWmh 36sw/5u9lQTwUVZqlk8H2PqD/OpXZMc= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=UxIoSp9JEZWib8zcfiFfoEXleyGuw9ixgY5suc0x7jk=; b=HmrbttBdREjF8300bxxNoLyjFi IPd+vfBfYy6+LI/HzZTXl8HV+e1O6eA1D7kbRShruKCyveGUH+FhJauUW2qoV+FVBmJre7AjjA2vc 5cXtGv8HM6bFQ/ROvjL+PNk68YjWK7ze61xigf2dvlwxQLSlKcU8hlfYEuLOKCUJCUNuUURUyNBJ0 vr6h/zPVJDHKJOdvN4XTiK0pRU1cPL3HCg6lOEly07gHqUI7YKnKL7zKC+OFHJoccis45MUGg9Yly YIxaXHX9JCjA9lPI3+DTRPBMvEgB27rS3P6gmVqg/N91q8dE6Ugtfoh7WaO4B3OuAnJ0ek+ZjRfZ5 LLnc5QDA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgpIi-00000009WdK-18AI; Wed, 21 Aug 2024 17:39:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , David Hildenbrand , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, Kent Overstreet Subject: [PATCH 2/4] mm: Introduce page_mapcount_is_type() Date: Wed, 21 Aug 2024 18:39:10 +0100 Message-ID: <20240821173914.2270383-3-willy@infradead.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240821173914.2270383-1-willy@infradead.org> References: <20240821173914.2270383-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: a58uzxcq6gpsws67q4wi8gjmfpd7wdrw X-Rspamd-Queue-Id: DB8CC1A0002 X-Rspamd-Server: rspam11 X-HE-Tag: 1724261970-280940 X-HE-Meta: U2FsdGVkX1/b/tYq0j7C2K23fXnbqGiiLKARu9nwUedS8P3ODdunjHrGC32Q5Ceoy+sSrFG/vn+xHznZXQqjOhC6IutevrDqrxdC2cQRZvsNPZwKXiecaP3tEbFa4Kd9hRWk+QFPPngaRGYJOEOiMjVJFJnCdrVJGgvBEwXwmNa5fR41trNeEpnqNFCcGnYEKMkyr4AypiOD7fJiAhVew9Fmr4oJh2SSysK/6hiWVrxaNsyOZKtKVV2zf/eVNMCXBp78GyTV5fKrQzw4Ylie10pQNyL7kh74h9Dx/wfHrB7yeht/VVR3qn2u4UKPOmr22Xi43R7NB09Vr+mp7pnZgNQ6a46QbVQM5tXh3kpZb5axJWaxsn5ioErFALfWl+TuVpjTIEMrNwzbSEAc2yuWk45li344qMBDfJWvhkgFOopswn0phFDklIp1CEId8GHecd81g8VdHGnIN7HmHOJxLkjQD0NrStOlJc6EV41Lvvw/AFcSPMNFcgb7PSKhnlycbFH6MPl3NtGGcbwM2jTDLG/Kkn/PD5j0Rjng4iAS4/LTJiw+cg36kBwVhbmRBe1BcGb9IIZl3IFNiA4A3H7U0ba7eaux66FpBX9tA21fL1h1vYIUA9wNbKDmiKkRGOhcvdI3HDwRK7z/fkdmjZMtt1CMaZVQy9+pOyHracHnoB4FiM8P5QDIwy9pJt6173OQd6MiGfJupzziVhNymABTguKMXUxSvkiMwtRib48+DigKwY8eciCuxId4m0WIAewMcycAXHHLunZacZAUvd+Z8lsmN4cIoOq568y7PrKZI5uqyivhhM2EkXCoRWpvkZ9khwujwlmL0JKIw0s78mKDzztH9GL+d0N4cpCrP5ZSR2q2axJAs1VLb21tECBZHaFtaS9KSHxVAY2yaphL3oWXAkVgwivhqRRZAvzP4kNf5XFDVXcGGh2Bk8tDTMUs8dTI+YafAmspPTV50ek03Cg gI69h05h 00fF4JTDdLVBpJxlXxAZ8bUlXOmq7+3B5AgI5p73mu3SQPNKE1QLm1Tc+2XbxwRhEdj78vdhdw1xIpdMOXpB8cfLdJXpI/fIadyooO8kxM7YXr4PB9GAcPjYkjZidFv4rAzwOC3dVKEIXvriesR8tssaHWmJ8vAQy3+xEB9cjBBEGEzeDjkVUpPjUp/e66AT+s2gwYi5osgheMofvb02KF/z33lj/yLa193BpAzFZkwcQw0fYtalPuBiRMftlvcIaycSgZlm7aMvipzfAfWV7iFRcRJXnSivZRYaAVcjRcwqub7NTFswLoXMqUlHcbOEm+pwu5lbdpyefBvs= 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: Resolve the awkward "and add one to this opaque constant" test into a self-documenting inline function. Signed-off-by: Matthew Wilcox (Oracle) Acked-by: David Hildenbrand --- fs/proc/internal.h | 3 +-- include/linux/mm.h | 3 +-- include/linux/page-flags.h | 12 +++++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/fs/proc/internal.h b/fs/proc/internal.h index a8a8576d8592..cc520168f8b6 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -166,8 +166,7 @@ static inline int folio_precise_page_mapcount(struct folio *folio, { int mapcount = atomic_read(&page->_mapcount) + 1; - /* Handle page_has_type() pages */ - if (mapcount < PAGE_MAPCOUNT_RESERVE + 1) + if (page_mapcount_is_type(mapcount)) mapcount = 0; if (folio_test_large(folio)) mapcount += folio_entire_mapcount(folio); diff --git a/include/linux/mm.h b/include/linux/mm.h index 00501f85f45f..47aa932075a8 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1232,8 +1232,7 @@ static inline int folio_mapcount(const struct folio *folio) if (likely(!folio_test_large(folio))) { mapcount = atomic_read(&folio->_mapcount) + 1; - /* Handle page_has_type() pages */ - if (mapcount < PAGE_MAPCOUNT_RESERVE + 1) + if (page_mapcount_is_type(mapcount)) mapcount = 0; return mapcount; } diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 17175a328e6b..998a99441e4f 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -956,12 +956,18 @@ enum pagetype { #define folio_test_type(folio, flag) \ ((READ_ONCE(folio->page.page_type) & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) -static inline int page_type_has_type(unsigned int page_type) +static inline bool page_type_has_type(int page_type) { - return (int)page_type < PAGE_MAPCOUNT_RESERVE; + return page_type < PAGE_MAPCOUNT_RESERVE; } -static inline int page_has_type(const struct page *page) +/* This takes a mapcount which is one more than page->_mapcount */ +static inline bool page_mapcount_is_type(unsigned int mapcount) +{ + return page_type_has_type(mapcount - 1); +} + +static inline bool page_has_type(const struct page *page) { return page_type_has_type(READ_ONCE(page->page_type)); } From patchwork Wed Aug 21 17:39:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13771933 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 258E1C52D6F for ; Wed, 21 Aug 2024 17:39:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A88FE6B0166; Wed, 21 Aug 2024 13:39:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A38DE6B0167; Wed, 21 Aug 2024 13:39:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B5C26B0168; Wed, 21 Aug 2024 13:39:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6D1006B0166 for ; Wed, 21 Aug 2024 13:39:27 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 228CD12111A for ; Wed, 21 Aug 2024 17:39:27 +0000 (UTC) X-FDA: 82476964374.03.D55C04E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP id 7DC3C1A0004 for ; Wed, 21 Aug 2024 17:39:25 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=bJhcCAbp; dmarc=none; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724261949; a=rsa-sha256; cv=none; b=WB1JtZdAaowGBe2A41HpzFiGEaoQmpez6fwEU+VDey50qeZ5bEu5CO10PxursDOTgBL2B2 yn1EAyzYYoaTV+wlANZbJUtcT6ZkEyoZ7YOWNFTbTe8RBDybtxmb1nQgQ6p4M22V8fencW o5WdfGjtN0iKPtso+PEKHuEUSSG8sFY= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=bJhcCAbp; dmarc=none; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724261949; 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=/gNJOwVwFwXavrN1cV3i41cegpVQxEH3cjGrajbBEY4=; b=1TlyrlHEF+jpbDPF1IsrHTwuvm2pple36sN8UMoVs2k/AK2UETggo8klzq8uYKA+RvZHxl XdkiEO6q1jB9ab4YjcYCUmNRcffX3zq3aRhXI+3RmjCNyBKq4a3pgcdUBOkQtZUn/hB2g9 Vlt81iOVOvPyq7597g216lLVtB0B5Ik= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=/gNJOwVwFwXavrN1cV3i41cegpVQxEH3cjGrajbBEY4=; b=bJhcCAbpNksm0dj6Eo3dRcdb3d hqFOdGGbwfMtufFwIQsVFOoYhnT9EArG6Yq6+Fa+ThFAy4KBeBLCbY0YtGs9Ac7kxN+y0rsPUYrWu sw2xcIoGudYL2YdzTWnurDRV/uU7+kn/5apsJbNfqxDKBqraXAiIPdODl9mOlB+Uj7ebgNigv0jzq qEkIyq4ETOJPbTYr+aRFxsGSCW2VZpvrIX0tDH7NkUIYqQ2SQFQ4z90vcvAob5b/ZW924BWuanMJo xwSNQgPT/UnA/3iRDO7nFyP1T0sEXUsDTGcH6LYRMy4nnS/b2ExPl968f3/+U/G6m8vewgVS6bp9O WtIqxv4g==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgpIi-00000009WdO-1Uci; Wed, 21 Aug 2024 17:39:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , David Hildenbrand , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, Kent Overstreet Subject: [PATCH 3/4] mm: Support only one page_type per page Date: Wed, 21 Aug 2024 18:39:11 +0100 Message-ID: <20240821173914.2270383-4-willy@infradead.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240821173914.2270383-1-willy@infradead.org> References: <20240821173914.2270383-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 7DC3C1A0004 X-Rspamd-Server: rspam01 X-Stat-Signature: nc31ahd5namc365ajp1ankaohocf91yt X-HE-Tag: 1724261965-175199 X-HE-Meta: U2FsdGVkX19vzt+4bK6/k5Fy/5u8svJNmewlvwfy7Y70kTRQkkL3zSBq15+bnTUrvsP+DpzcY1+HohPG7EAG6DZpYRa4PoOwddeM8u23QYokNDp+w8eqF50wtN2BBhnV5ge1a5xpO8B9azwtBaTganrO7l38AkgRclJ0jsaVjT1IsSfHKr3eg35192WebtGS5FbgkDCpmWvyGNSk0Ol5RybzAc01XgLfO351Z0x5mI8AYCVUXVchGjwS2xuYj2CX4jdhqX87G/6CfuwYJkfB1HUpf4xI+pfflb9Ce7AsyDi2suPmwU/GaVxEtIICakPqKH7qaFu2ToWZAhMPKg3csf4vRBap5qRFzkX93wuNRNSFjfF6lc/q2YM8KA7VSuC31FL7O2IzrWNSd5ZV5cszZT4Dri0gIs1iX2VMoUPQ7UQ990pRgn/7XfjsY3sGtH4/4wia0EmToSIerBZy4dgQSuvAlMNh8CFkifutyy63+8pd3UOsYCjmvZ2pBpO+rhwdEX1gXD8wAGPpnpHRM2TnWtf57CgVKODYlyPGdwzl8tXacld+sPgVII5xZPAfkRX6T4ZyipWH3N/U6LmQJKdf2YupehD3mM6w7VneFvIm8yJz8YUxJcnvnOv+boCE/Mkmt890bZvpEuXlhaoaXce+tXrQov5Egdgt6NRX+LRKXj5XG6s4Dx2YbtEdPPRsXItOaND7LzAjAmolTkX9TM+EH0oN2kgarsTzcrjJ2AK9+/7ZIlmFtZsO5gDEmZP/Nx5eGoIpHxxqexdqO/7aNt63osgl060hPGJZzwS2ixqT6MKeg3B+QzwzjE8W2fjma8yUrz6YDn/cd7ic3k/UgQb8VEFuRK5i0HLPSZcTq5zgTanX+RUnHeAOdm6ku9zoQwVMKb4VPRTttnFjZ4MPwwT9gRaJQftBmB/4xcHiRrB0iy4DMPJegTyDg4VRUDE9Plcf4rhQU/0MIcPl24Qa6Sb Y/lEe9Tl bi/42aTb46qCKcsmWQRDUmZpXcW4FGziELKFJL/VQFhdl8MnaUa6ZoOxPDMBIWnFOSHf0UrBDN3cdwgB5mJjSrCjY7iXC1pH3U5R+kLY4IMgR/2lZVoZJqI6p6ChcYo+L0aJzP/kefriyr8Qb6Xkxm/9BYBPiXZVBZUFoWv6wBy2yA2EZMmpcpSCd+xBiBMl3xZHsVnYrh9WQgNDPk6zhqpPxUsKAWKNGPcZ5jMB3XycJES7UNfkpINiFHEjlEET58GLb/dQ+CAoQIMfUGNPsc4Ud09uo0TEzxdsPRR2r8QCbZ55lGrMMEiqPnWtjxqRA9xPiLtlD5yfiYQc= 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: By using a few values in the top byte, users of page_type can store up to 24 bits of additional data in page_type. It also reduces the code size as (with replacement of READ_ONCE() with data_race()), the kernel can check just a single byte. eg: ffffffff811e3a79: 8b 47 30 mov 0x30(%rdi),%eax ffffffff811e3a7c: 55 push %rbp ffffffff811e3a7d: 48 89 e5 mov %rsp,%rbp ffffffff811e3a80: 25 00 00 00 82 and $0x82000000,%eax ffffffff811e3a85: 3d 00 00 00 80 cmp $0x80000000,%eax ffffffff811e3a8a: 74 4d je ffffffff811e3ad9 becomes: ffffffff811e3a69: 80 7f 33 f5 cmpb $0xf5,0x33(%rdi) ffffffff811e3a6d: 55 push %rbp ffffffff811e3a6e: 48 89 e5 mov %rsp,%rbp ffffffff811e3a71: 74 4d je ffffffff811e3ac0 replacing three instructions with one. Signed-off-by: Matthew Wilcox (Oracle) Acked-by: David Hildenbrand --- include/linux/page-flags.h | 68 ++++++++++++++++---------------------- kernel/vmcore_info.c | 8 ++--- mm/debug.c | 31 +++++++++++++---- 3 files changed, 56 insertions(+), 51 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 998a99441e4f..0c738bda5d98 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -923,42 +923,29 @@ PAGEFLAG_FALSE(HasHWPoisoned, has_hwpoisoned) #endif /* - * For pages that are never mapped to userspace, - * page_type may be used. Because it is initialised to -1, we invert the - * sense of the bit, so __SetPageFoo *clears* the bit used for PageFoo, and - * __ClearPageFoo *sets* the bit used for PageFoo. We reserve a few high and - * low bits so that an underflow or overflow of _mapcount won't be - * mistaken for a page type value. + * For pages that do not use mapcount, page_type may be used. + * The low 24 bits of pagetype may be used for your own purposes, as long + * as you are careful to not affect the top 8 bits. The low bits of + * pagetype will be overwritten when you clear the page_type from the page. */ - enum pagetype { - PG_buddy = 0x40000000, - PG_offline = 0x20000000, - PG_table = 0x10000000, - PG_guard = 0x08000000, - PG_hugetlb = 0x04000000, - PG_slab = 0x02000000, - PG_zsmalloc = 0x01000000, - PG_unaccepted = 0x00800000, - - 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. - */ - PAGE_MAPCOUNT_RESERVE = ~0x0000ffff, + /* 0x00-0x7f are positive numbers, ie mapcount */ + /* Reserve 0x80-0xef for mapcount overflow. */ + PGTY_buddy = 0xf0, + PGTY_offline = 0xf1, + PGTY_table = 0xf2, + PGTY_guard = 0xf3, + PGTY_hugetlb = 0xf4, + PGTY_slab = 0xf5, + PGTY_zsmalloc = 0xf6, + PGTY_unaccepted = 0xf7, + + PGTY_mapcount_underflow = 0xff }; -#define PageType(page, flag) \ - ((READ_ONCE(page->page_type) & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) -#define folio_test_type(folio, flag) \ - ((READ_ONCE(folio->page.page_type) & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) - static inline bool page_type_has_type(int page_type) { - return page_type < PAGE_MAPCOUNT_RESERVE; + return page_type < (PGTY_mapcount_underflow << 24); } /* This takes a mapcount which is one more than page->_mapcount */ @@ -969,40 +956,41 @@ static inline bool page_mapcount_is_type(unsigned int mapcount) static inline bool page_has_type(const struct page *page) { - return page_type_has_type(READ_ONCE(page->page_type)); + return page_mapcount_is_type(data_race(page->page_type)); } #define FOLIO_TYPE_OPS(lname, fname) \ -static __always_inline bool folio_test_##fname(const struct folio *folio)\ +static __always_inline bool folio_test_##fname(const struct folio *folio) \ { \ - return folio_test_type(folio, PG_##lname); \ + return data_race(folio->page.page_type >> 24) == PGTY_##lname; \ } \ static __always_inline void __folio_set_##fname(struct folio *folio) \ { \ - VM_BUG_ON_FOLIO(!folio_test_type(folio, 0), folio); \ - folio->page.page_type &= ~PG_##lname; \ + VM_BUG_ON_FOLIO(data_race(folio->page.page_type) != UINT_MAX, \ + folio); \ + folio->page.page_type = PGTY_##lname << 24; \ } \ static __always_inline void __folio_clear_##fname(struct folio *folio) \ { \ VM_BUG_ON_FOLIO(!folio_test_##fname(folio), folio); \ - folio->page.page_type |= PG_##lname; \ + folio->page.page_type = UINT_MAX; \ } #define PAGE_TYPE_OPS(uname, lname, fname) \ FOLIO_TYPE_OPS(lname, fname) \ static __always_inline int Page##uname(const struct page *page) \ { \ - return PageType(page, PG_##lname); \ + return data_race(page->page_type >> 24) == PGTY_##lname; \ } \ static __always_inline void __SetPage##uname(struct page *page) \ { \ - VM_BUG_ON_PAGE(!PageType(page, 0), page); \ - page->page_type &= ~PG_##lname; \ + VM_BUG_ON_PAGE(data_race(page->page_type) != UINT_MAX, page); \ + page->page_type = PGTY_##lname << 24; \ } \ static __always_inline void __ClearPage##uname(struct page *page) \ { \ VM_BUG_ON_PAGE(!Page##uname(page), page); \ - page->page_type |= PG_##lname; \ + page->page_type = UINT_MAX; \ } /* diff --git a/kernel/vmcore_info.c b/kernel/vmcore_info.c index 8b4f8cc2e0ec..1fec61603ef3 100644 --- a/kernel/vmcore_info.c +++ b/kernel/vmcore_info.c @@ -198,17 +198,17 @@ static int __init crash_save_vmcoreinfo_init(void) VMCOREINFO_NUMBER(PG_private); VMCOREINFO_NUMBER(PG_swapcache); VMCOREINFO_NUMBER(PG_swapbacked); -#define PAGE_SLAB_MAPCOUNT_VALUE (~PG_slab) +#define PAGE_SLAB_MAPCOUNT_VALUE (PGTY_slab << 24) VMCOREINFO_NUMBER(PAGE_SLAB_MAPCOUNT_VALUE); #ifdef CONFIG_MEMORY_FAILURE VMCOREINFO_NUMBER(PG_hwpoison); #endif VMCOREINFO_NUMBER(PG_head_mask); -#define PAGE_BUDDY_MAPCOUNT_VALUE (~PG_buddy) +#define PAGE_BUDDY_MAPCOUNT_VALUE (PGTY_buddy << 24) VMCOREINFO_NUMBER(PAGE_BUDDY_MAPCOUNT_VALUE); -#define PAGE_HUGETLB_MAPCOUNT_VALUE (~PG_hugetlb) +#define PAGE_HUGETLB_MAPCOUNT_VALUE (PGTY_hugetlb << 24) VMCOREINFO_NUMBER(PAGE_HUGETLB_MAPCOUNT_VALUE); -#define PAGE_OFFLINE_MAPCOUNT_VALUE (~PG_offline) +#define PAGE_OFFLINE_MAPCOUNT_VALUE (PGTY_offline << 24) VMCOREINFO_NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE); #ifdef CONFIG_KALLSYMS diff --git a/mm/debug.c b/mm/debug.c index 9f8e34537957..aa57d3ffd4ed 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -36,11 +36,6 @@ const struct trace_print_flags pageflag_names[] = { {0, NULL} }; -const struct trace_print_flags pagetype_names[] = { - __def_pagetype_names, - {0, NULL} -}; - const struct trace_print_flags gfpflag_names[] = { __def_gfpflag_names, {0, NULL} @@ -51,6 +46,27 @@ const struct trace_print_flags vmaflag_names[] = { {0, NULL} }; +#define DEF_PAGETYPE_NAME(_name) [PGTY_##_name - 0xf0] = __stringify(_name) + +static const char *page_type_names[] = { + DEF_PAGETYPE_NAME(slab), + DEF_PAGETYPE_NAME(hugetlb), + DEF_PAGETYPE_NAME(offline), + DEF_PAGETYPE_NAME(guard), + DEF_PAGETYPE_NAME(table), + DEF_PAGETYPE_NAME(buddy), + DEF_PAGETYPE_NAME(unaccepted), +}; + +static const char *page_type_name(unsigned int page_type) +{ + unsigned i = (page_type >> 24) - 0xf0; + + if (i >= ARRAY_SIZE(page_type_names)) + return "unknown"; + return page_type_names[i]; +} + static void __dump_folio(struct folio *folio, struct page *page, unsigned long pfn, unsigned long idx) { @@ -58,7 +74,7 @@ static void __dump_folio(struct folio *folio, struct page *page, int mapcount = atomic_read(&page->_mapcount); char *type = ""; - mapcount = page_type_has_type(mapcount) ? 0 : mapcount + 1; + mapcount = page_mapcount_is_type(mapcount) ? 0 : mapcount + 1; pr_warn("page: refcount:%d mapcount:%d mapping:%p index:%#lx pfn:%#lx\n", folio_ref_count(folio), mapcount, mapping, folio->index + idx, pfn); @@ -92,7 +108,8 @@ static void __dump_folio(struct folio *folio, struct page *page, pr_warn("%sflags: %pGp%s\n", type, &folio->flags, is_migrate_cma_folio(folio, pfn) ? " CMA" : ""); if (page_has_type(&folio->page)) - pr_warn("page_type: %x\n", folio->page.page_type); + pr_warn("page_type: %x(%s)\n", folio->page.page_type >> 24, + page_type_name(folio->page.page_type)); print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32, sizeof(unsigned long), page, From patchwork Wed Aug 21 17:39:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13771931 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 B4FB5C52D7C for ; Wed, 21 Aug 2024 17:39:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 46FED6B00AE; Wed, 21 Aug 2024 13:39:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 41DED6B00E7; Wed, 21 Aug 2024 13:39:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E6086B00DE; Wed, 21 Aug 2024 13:39:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 11DFC6B0163 for ; Wed, 21 Aug 2024 13:39:22 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C17C91A1009 for ; Wed, 21 Aug 2024 17:39:21 +0000 (UTC) X-FDA: 82476964122.21.AEF2C6C Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id 9393B120009 for ; Wed, 21 Aug 2024 17:39:19 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tOoYZbVB; dmarc=none; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724261901; a=rsa-sha256; cv=none; b=kM8Ircl/HCO+gBQpUfCb+saDzDvxzno4SPaoPhAb4yt27ckMBQtuVxfmzTOxfhY+g2VPqd sGo/D4YGtN4rZkvxTWyIkXt9CDTD2IDR50jL1ALniTuwmXjIgAemn1v8H79EjbesqTNI0Q R23hL2FIk4cevcnXe8zhTuhSiAwo3zA= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tOoYZbVB; dmarc=none; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724261901; 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=5DI5wKlXZGZKzwJ/MCoQ3cQHrHQLIvS5UVq04Bxcppo=; b=dZhVMmxVkzcSSeUqcod0rdjHpg8UW9qESJ74ke55n0u16KysQoKquWRDAeB9X/OOwhfM6r OaNkIklHwB5pqY4rpV9q0VlPr+UbGOPeTOxNeqSAMHOnnU5aYwspDz80eN02xzc0UWnJve U4k6B6393O1irzwbYRFHBOOSlNFvkCs= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=5DI5wKlXZGZKzwJ/MCoQ3cQHrHQLIvS5UVq04Bxcppo=; b=tOoYZbVBS/v0VTE0UFNURp3T9F SCj1/GCKHGgukcmtJkttB3xsdRSmavRKbta+N6gxcp6BLXMv2FXcnB3r/HVB6H7wXK/k1uVCYEpt/ nsFJBf2VxqFx1meg3aGp6u7tT/+tmeCOKQAIslnZLluV3wqxba8WSVgUxKJ2+eUV2HSKVN/znOwd2 HVPsJGDe2cHUNkOtTsDn3o1RUW+DXojI+wqjd4BHMorMdFKUYniSH9XZNK9dDQuw3cJ4HBlyB80Bs tc70e9uX54wB1WNQOsJ+EqspUnTfpsRPXjFZ3D94+V+JmvW5oHqZ6NdmLS9H7rx6pSD3Baaxnwho0 MEVAvuQg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgpIi-00000009WdV-247v; Wed, 21 Aug 2024 17:39:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , David Hildenbrand , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, Kent Overstreet Subject: [PATCH 4/4] zsmalloc: Use all available 24 bits of page_type Date: Wed, 21 Aug 2024 18:39:12 +0100 Message-ID: <20240821173914.2270383-5-willy@infradead.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240821173914.2270383-1-willy@infradead.org> References: <20240821173914.2270383-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9393B120009 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: y1yso7am1qhx39mss7awbcuy3oq4u3t5 X-HE-Tag: 1724261959-752623 X-HE-Meta: U2FsdGVkX1+K/x+Vup2vtsGsHQ+FRwuEA5M6lZ8oieGNxUIEdUqqW9yLfaanXKKrWZnAz+jgQMhgltjX8LYXCCFDlY7APw3YwGq8PhV7moIEDDMO1oltPGXlCPisxlcgiK+DB+ys+ILGq5vEEXDzkhf8gOdE+QjBgDFbodEgZIN0OwCB4oC9dzFCna/ZlGqYyWaSQPFPQyyrMi0tEoZmBGmHEVfNotLiNBGmwXS8VzxSCW+gqPWTPxgMC4TSOUq2/8ijw1AWRB67lUcG37vDc0Gk87BZzVA6xIx41LYhBwcA4XJdxy5Xl/3wAhtiDpd0yKjJohCRrEX3W33dkCmZIxo2wCtb6kjEgf+T2o67XJjRxF1VojeoHRNob96gsA4p07+km9s0yFs8cEMlvC7pyRN01heaAfWK8L/UbpFdljQ6BkR0SXAcmjTurwPp6797zW44liKb/aK7t102wO3uaU479hFGPrT6Ic5/otZ6jYDa7K0Na+P4RZcZx4CgZ/kr6fSENexBFrY6tnymwOY0HtaIYwTkSsORfsvZLzUiOUGQGMUECz2K5RNeYqMJgSlnmswYbVr6wbSLc4sL49XLr2jxrzJWKOnPYoKKZthX+/4S5/ScK/j08cFkMB1EP37ZVERPKjdGIgLRO12wrNWrPL8c2ll9uwz+NM3lgBUrn8VuJb7Ic3j5ZI0mTEQ2RTyeL4/hzQe4+1Be65VMbv6q2PKY6ko+wleuipX98dxAtc5zaZihnm64BwHE/dGOqVhHIgjApi5kp6jZe5vrmtmLLHNs+iP3X/PaY4a2yhKZ8V1kFLLemtlQeSO+1I6hSo7+FK98hZYFeOiErm1bXyVULJ7CMIOnliZs3oJgGzJ3eK9ODtkVafx3/vPltprZr9ptlnKtwQi4G/d1bKRdOl7Zxg6Wr3MLOCnCUgaiZaU3B1dO3VWPNaruwV79jPYtew8hw7hhQ424eTi62oa2Rws exEpyKgM 9p2RK2Ru9qsOXijxLxD2oZek+X7BVUPyW0RfkNAQ/3/yiYET8xwVOMOid+nP2Go6YPIQ4UZofXKbY97c74XAHADoxShH+lUnH0a1NOFnCfApnzBp/WDwS2rtNR/A8MXEYorYwZVLZNpH8U2YmGfCUlEiCqqB9IZ3Sn8wfBOk62/TDCD04qtg9OKmbGLUr6H3QUp9K4smadF1rP0qn3wmFTX6SyP5vXB2Bbcld3CO6n56gKOiEn7tBC1V1RNpVWpxLHS5W2i6fJq8aakFbHbs2LdgJ1HAHzD59qgS4fcwppT8YDbwu2re1xKStKUoOK3pSj8H33C4BHjSlPVY= 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: Now that we have an extra 8 bits, we don't need to limit ourselves to supporting a 64KiB page size. I'm sure both Hexagon users are grateful, but it does reduce complexity a little. We can also remove reset_first_obj_offset() as calling __ClearPageZsmalloc() will now reset all 32 bits of page_type. Signed-off-by: Matthew Wilcox (Oracle) Acked-by: David Hildenbrand --- drivers/block/zram/Kconfig | 1 - mm/Kconfig | 10 ++-------- mm/zsmalloc.c | 15 ++++----------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig index 40e035468de2..6aea609b795c 100644 --- a/drivers/block/zram/Kconfig +++ b/drivers/block/zram/Kconfig @@ -2,7 +2,6 @@ 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/mm/Kconfig b/mm/Kconfig index 3936fe4d26d9..5946dcdcaeda 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 HAVE_ZSMALLOC + default ZSWAP_ZPOOL_DEFAULT_ZSMALLOC if MMU default ZSWAP_ZPOOL_DEFAULT_ZBUD help Selects the default allocator for the compressed cache for @@ -154,7 +154,6 @@ 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. @@ -187,15 +186,10 @@ 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 HAVE_ZSMALLOC + depends on MMU 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 2d3163e4da96..73a3ec5b21ad 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -20,7 +20,7 @@ * 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: PG_zsmalloc, lower 16 bit locate the first object + * page->page_type: PGTY_zsmalloc, lower 24 bits locate the first object * offset in a subpage of a zspage * * Usage of struct page flags: @@ -452,13 +452,7 @@ 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; -} +#define FIRST_OBJ_PAGE_TYPE_MASK 0xffffff static inline unsigned int get_first_obj_offset(struct page *page) { @@ -468,8 +462,8 @@ static inline unsigned int get_first_obj_offset(struct page *page) static inline void set_first_obj_offset(struct page *page, unsigned int offset) { - /* With 16 bit available, we can support offsets into 64 KiB pages. */ - BUILD_BUG_ON(PAGE_SIZE > SZ_64K); + /* With 24 bits available, we can support offsets into 16 MiB pages. */ + BUILD_BUG_ON(PAGE_SIZE > SZ_16M); VM_WARN_ON_ONCE(!PageZsmalloc(page)); VM_WARN_ON_ONCE(offset & ~FIRST_OBJ_PAGE_TYPE_MASK); page->page_type &= ~FIRST_OBJ_PAGE_TYPE_MASK; @@ -808,7 +802,6 @@ static void reset_page(struct page *page) ClearPagePrivate(page); set_page_private(page, 0); page->index = 0; - reset_first_obj_offset(page); __ClearPageZsmalloc(page); }