From patchwork Tue Oct 10 14:27:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 150825 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp243848vqb; Tue, 10 Oct 2023 07:29:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFHBC2TtQQ+mbl5X9t31bLwtNjf0OaFzwEOGVlpWcrQB1M/a8we/Q2E+07YSMgDIYUNhvo5 X-Received: by 2002:a17:902:e5c7:b0:1c6:ec8:4c67 with SMTP id u7-20020a170902e5c700b001c60ec84c67mr18139008plf.18.1696948176111; Tue, 10 Oct 2023 07:29:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696948176; cv=none; d=google.com; s=arc-20160816; b=MnPcYDa12+SjnWDrZJrn+ZWHTutcaCzwxPXmfFSne8L++FuzlY/K7ZgIAHrOLEKWqb hUBOGbxkgOhZ438mMkilKt/Sxs81kLfjP+FoUKbpZp0GH3x3XHSsInnj5VQkvgskHmeT AqEE2CvCwgnbyTQKVmsGdUmNVEkMECYI5yJTfdYYbj3nhfBAkN2n2f12wfZw4eO77I6D 33y69N1dZWJU9uOsRwAora6isXGTLeeF87FnFgIH9IY9+uT0ytIO/P3PBAJTxhxgK8Yv u6sOQd9lZTNrBEBr9fEa85la+nWVDZzx95xZb/9pq+nt934io3b12IzS3D57kPiYXKvU COIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lBUz50yRXYSwkMpVqbF4xKRgGKpQYvwhtcgTljx7wmY=; fh=vd113QmVxKSP0xyTVgYADqM2Ffy1JHXPefyn38Zlb+8=; b=hjr/EK80+v1MWCBY/u9eWU8pGxG2EWRHBrWlqrMhfQ+PbaYbAqoTv0ynrQy+oyKhFB 8jeh5OWXMw4H+5jCo8oyd0fzuJcd69+rpk2sacCNQByWV25v7JN2RA7TNYTz+j9k87qt 7yqxUXyvhAfe/m1PdXpq22XOr0iVl3zNzUJp2N6Vli04js//AxXYAaKJxFuLMWRuMO1h zRmNcKbnog3t0f740woQ7mZ7EyF9/OPX9o7cQIh0CFkajIR3oMXEfRd/r+THVtXziSym AZs5CkXKGv7gl3nFFcPCBCN354jr/J7ym0BUSMevK2LsCXPtMtp0+r1x31DqTVjG/7kO tVhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=YUXjCIGK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id kh8-20020a170903064800b001c42d60b9e6si1451622plb.112.2023.10.10.07.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 07:29:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=YUXjCIGK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E7B5181C8091; Tue, 10 Oct 2023 07:29:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233162AbjJJO3O (ORCPT + 20 others); Tue, 10 Oct 2023 10:29:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233348AbjJJO2x (ORCPT ); Tue, 10 Oct 2023 10:28:53 -0400 Received: from out-200.mta0.migadu.com (out-200.mta0.migadu.com [IPv6:2001:41d0:1004:224b::c8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AD56103 for ; Tue, 10 Oct 2023 07:28:51 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1696948127; 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=lBUz50yRXYSwkMpVqbF4xKRgGKpQYvwhtcgTljx7wmY=; b=YUXjCIGKTxNpExiRwy5wj5HYemZEfcJ9ufogB+8cHg/UjkS0SCbQYARvOV3YrvQJ8h+xbz Th5rey7xD3OZISdwToRtGiUKbk9WRMhfP9YBFG3zk/ZKVyPJvSt0FCzAdLhCmhLVFpVm/Q O+0tz8vCi9Sa5w73oy9N7qPq9/zVhQ8= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , David Hildenbrand , "Kirill A. Shutemov" , Mike Kravetz , Miaohe Lin , Vlastimil Babka , Muchun Song , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 1/5] include/uapi/linux/kernel-page-flags.h: define KPF_FOLIO Date: Tue, 10 Oct 2023 23:27:57 +0900 Message-Id: <20231010142801.3780917-2-naoya.horiguchi@linux.dev> In-Reply-To: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> References: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 10 Oct 2023 07:29:31 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779379130993518638 X-GMAIL-MSGID: 1779379130993518638 From: Naoya Horiguchi Define a new KPF flag to represent folio in /proc/kpageflags and in-kernel user page-types.c. Note that in page-types.c I chose 'f' for the character representing folio, which conflicts with KPF_SOFTDIRTY, but we have no other choice because all reasonable choices ('f', 'F', 'o', 'O', 'l', 'L', 'i', and 'I') are already used. You need to pay attention to long flag names or the position of 'f' in short form. Signed-off-by: Naoya Horiguchi --- include/uapi/linux/kernel-page-flags.h | 1 + tools/mm/page-types.c | 1 + 2 files changed, 2 insertions(+) diff --git a/include/uapi/linux/kernel-page-flags.h b/include/uapi/linux/kernel-page-flags.h index 6f2f2720f3ac..9b43dadb7f49 100644 --- a/include/uapi/linux/kernel-page-flags.h +++ b/include/uapi/linux/kernel-page-flags.h @@ -36,5 +36,6 @@ #define KPF_ZERO_PAGE 24 #define KPF_IDLE 25 #define KPF_PGTABLE 26 +#define KPF_FOLIO 27 #endif /* _UAPILINUX_KERNEL_PAGE_FLAGS_H */ diff --git a/tools/mm/page-types.c b/tools/mm/page-types.c index 8d5595b6c59f..b78448d19e88 100644 --- a/tools/mm/page-types.c +++ b/tools/mm/page-types.c @@ -126,6 +126,7 @@ static const char * const page_flag_names[] = { [KPF_PGTABLE] = "g:pgtable", [KPF_ZERO_PAGE] = "z:zero_page", [KPF_IDLE] = "i:idle_page", + [KPF_FOLIO] = "f:folio", [KPF_RESERVED] = "r:reserved", [KPF_MLOCKED] = "m:mlocked", From patchwork Tue Oct 10 14:27:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 150824 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp243832vqb; Tue, 10 Oct 2023 07:29:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzgzRTq3txL7JrAXI96mib+rT/8aXHgI+Ub6QMg0e2ddAi2Sg6rhsiMzZPIHxe9VlT5Fsb X-Received: by 2002:a05:6a20:8f1d:b0:16b:79b3:210b with SMTP id b29-20020a056a208f1d00b0016b79b3210bmr12194113pzk.31.1696948174923; Tue, 10 Oct 2023 07:29:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696948174; cv=none; d=google.com; s=arc-20160816; b=g6JlxPcYgqy3TjGYr1JGMrRVR8PJqFxi7IszToRnJPCxJ6jUKl3ZGYRkseGYKPEFPr XP/5QhQHJAXYg17io8PKjygjyYjJ9tDAPgAyzWA+tJxFVWfL4lonmXE2dxQ4CMEPCF07 26dJrzhpaW7J5csngvfegest3SKw8YSg+qEbEUfudF0gwwoboEhhRFpwuJCqSEDKaUGN SL4WJ/X4lPvjdMj2OMOb6Pyt1hL+hcAj3nV3tFKPhu10bBghNXdEjnLhr3dZxzdKoCd/ OQt3CSU3GlrXc23RRPYBIPdySvzGxSOUK32jaq484tKIdVifnz7v0l+P5SNWh0+n8LZK L3AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ct5h8XiEF6Z6bh0u0KQdOShLvibauoLK/pnF+aCIbHs=; fh=vd113QmVxKSP0xyTVgYADqM2Ffy1JHXPefyn38Zlb+8=; b=BJZ5RE8Y9Nw2Wnkw9Qc48/CXTk9HE11DNFBa7NY3kQcycq1CIbIVsJAKA4XrXQKDcW PJl2JtiOgD3M/P+gT9KpTe5Z8GKBenMoQsQCR+HX1P8J137hDKP8u5BynHWe0S1WjzQx 1DIyAXWU7O69bk82hLW/vcOhHGix2hUa6zaM2WqLv8aGLLL31fIToE3bJncIG7pFEAZx lhe6RdXUV+BKfFgKsIvWBEFdrTX6gW6SEBE29XuaOjqW0MGwJJlelQ3VXAf0B26qQzBE IYW4W2tXlNEq928sRl8yEHtycpF0Pd0Kre2jTYToR6YcmfNGV8UceTjvhvlCnaj1wZVn uMsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="bpjtc/LF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id 36-20020a631664000000b0054ff717395dsi12213208pgw.691.2023.10.10.07.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 07:29:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="bpjtc/LF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 630BB8025B44; Tue, 10 Oct 2023 07:29:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233255AbjJJO3V (ORCPT + 20 others); Tue, 10 Oct 2023 10:29:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233386AbjJJO2y (ORCPT ); Tue, 10 Oct 2023 10:28:54 -0400 Received: from out-193.mta0.migadu.com (out-193.mta0.migadu.com [IPv6:2001:41d0:1004:224b::c1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC34B91 for ; Tue, 10 Oct 2023 07:28:52 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1696948131; 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=ct5h8XiEF6Z6bh0u0KQdOShLvibauoLK/pnF+aCIbHs=; b=bpjtc/LFwjIYuknqBdChdrg6pH5LhH0gERemOAwGNiqO/B0yhaIPcKkXhCyk1Y+6QiAB6D pdmVPLFHqF8iWcxI7QpWy2AkvCdR7eOxKKaViIq1Qya/PPl2bRQHZMcyklBZ8+34tDxuvO QoG/rGqvVIFHC+5eFcdEu8fJDv1/1Hs= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , David Hildenbrand , "Kirill A. Shutemov" , Mike Kravetz , Miaohe Lin , Vlastimil Babka , Muchun Song , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 2/5] mm: kpageflags: distinguish thp and folio Date: Tue, 10 Oct 2023 23:27:58 +0900 Message-Id: <20231010142801.3780917-3-naoya.horiguchi@linux.dev> In-Reply-To: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> References: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 10 Oct 2023 07:29:32 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779379129455855107 X-GMAIL-MSGID: 1779379129455855107 From: Naoya Horiguchi Currently a large folio is considered as thp in the output of /proc/kpageflags because stable_page_flags() does not have resolution to distinguish thp and large folio. This is confusing and the readers of /proc/kpageflags need additional checks in userspace, which is inefficient. Check page order in stable_page_flags() to distinguish thp and large folio. Although thp (or other types of compound page) is a special form of folio, but the KPF_FOLIO means "folio" in narrower meaning (representing folios in page cache), so KPF_FOLIO is not set on thp or hugetlb pages. This is because thp and hugetlb (and other compound pages) have their own KPF_* flags, so those are already identifiable. Thp and folio use some struct page's field of the first tail pages for internal use. There's no point to parse and show flag info based on tail pages, so return immediately when finding thp/folio tail pages. The output below shows how this patch changes the output of page-types. Before patch: // anonymous thp voffset offset len flags ... 700000000 156c00 1 ___U_l_____Ma_bH______t_____________f_d_____1 700000001 156c01 1 L__U_______Ma___T_____t_____________f_______1 700000002 156c02 1fe ___________Ma___T_____t_____________f_______1 ^ this 't' means thp // file thp 700000000 15d600 1 __RUDl_____M__bH______t_____________f__I____1 700000001 15d601 1 L__U_______M____T_____t_____________f_______1 700000002 15d602 1fe ___________M____T_____t_____________f_______1 // large folio 700000000 154f84 1 __RU_l_____M___H______t________P____f_____F_1 700000001 154f85 1 ________W__M____T_____t_____________f_____F_1 700000002 154f86 2 ___________M____T_____t_____________f_____F_1 After patch: // anonymous thp 700000000 117000 1 ___U_l_____Ma_bH______t_____________f_d_____1 700000001 117001 1ff ________________T_____t_____________f_______1 // file thp 700000000 118400 1 __RUDl_____M__bH______t_____________f__I____1 700000001 118401 1ff ________________T_____t_____________f_______1 // large folio 700000000 148da4 1 __RU_l_____M___H___________f___P____f_____F_1 700000001 148da5 3 ________________T__________f________f_____F_1 ^ this 'f' means folio Signed-off-by: Naoya Horiguchi --- fs/proc/page.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 195b077c0fac..78f675f791c1 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -154,11 +154,24 @@ u64 stable_page_flags(struct page *page) else if (PageTransCompound(page)) { struct page *head = compound_head(page); - if (PageLRU(head) || PageAnon(head)) - u |= 1 << KPF_THP; - else if (is_huge_zero_page(head)) { + /* + * We need to check PageLRU/PageAnon to make sure a given page + * is a thp, not a huge zero page or a generic compound page + * (allocated by drivers with __GFP_COMP). + */ + if (PageLRU(head) || PageAnon(head)) { + if (compound_order(head) == HPAGE_PMD_ORDER) + u |= 1 << KPF_THP; + else + u |= 1 << KPF_FOLIO; + } else if (is_huge_zero_page(head)) u |= 1 << KPF_ZERO_PAGE; - u |= 1 << KPF_THP; + + if (PageHead(page)) + u |= 1 << KPF_COMPOUND_HEAD; + if (PageTail(page)) { + u |= 1 << KPF_COMPOUND_TAIL; + return u; } } else if (is_zero_pfn(page_to_pfn(page))) u |= 1 << KPF_ZERO_PAGE; From patchwork Tue Oct 10 14:27:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 150827 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp243904vqb; Tue, 10 Oct 2023 07:29:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGAeCmUU/WpObMfwQA4HGi+LV0b/KBaWS8ibElEBjQUN3P/dk5agKB6uKUJTkrBWgaC/jkd X-Received: by 2002:a17:903:22d0:b0:1c3:62c4:7f12 with SMTP id y16-20020a17090322d000b001c362c47f12mr19192319plg.5.1696948182644; Tue, 10 Oct 2023 07:29:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696948182; cv=none; d=google.com; s=arc-20160816; b=tl2MQno3mb8G4jUL2jlbCyF2YlLgwe6Efed16mFI7XLIFZjLmueGybggUfRBAQbhD1 Mm41Xtx1VyQ/DxKKIUZfLtDq35DGlLXlkoo6OWDUBcZ6rt2kkmTzxCrjsLE9uQt6qpti ppx6MEhQ/L5VnbsI2mjCHhfPIHPTD5WR6oGMa2e3ybpHWnRGL+ZL9ZKFZySpUnyL1sMs N5sOQFX8Fgfg2RDNTm1LBdAOM1mVGaau1XUaF4lQsw/3hu6wtIdjOW7tJQURvk1FPoVt +ip/vUrJSvJL6jIJYv/CiVjR4xYj65wgfBfbXQHBIq/keGORqHHyQPmb7SiSCV9MlHtq cmsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/jN8h55KNP3RtmvUZhOGO1MAcrm7V1DX54vKKCbAGW4=; fh=vd113QmVxKSP0xyTVgYADqM2Ffy1JHXPefyn38Zlb+8=; b=MDdvUj0TUjNgDPV/BYF4izgzVPqsZZNZ8aQ/5PGCJc2Z6z95xQlQYRgny5Vh4j9J1R GxSvvMNrNGr9iGttiLmn4pQHybUzmSzsI70riKig8CChJINqA6fnYbWjnq3UsFEYp3bx ASmdGPK7A4fmWLWmAQ3gyPLQCqnuyTiR9NHTNwF/HrU8/fiDH9t/c1SMSY2kAqH7mHPw HN12w7XU035wfOYL2pOAQYygc43mOCaeQI61fa9qRUF2syg6n+SFAS3Nm2gAUmSEzGlc Ha2eJrQwpD9XoukUkddnOQGZ4ifbY285xEx6DQzwgdD++IOOzmC9uJXgj651KbuoQgqZ izVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=FLuxcLJc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id ju4-20020a170903428400b001bf1005924csi11449081plb.321.2023.10.10.07.29.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 07:29:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=FLuxcLJc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 152CF801C93F; Tue, 10 Oct 2023 07:29:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233254AbjJJO3S (ORCPT + 20 others); Tue, 10 Oct 2023 10:29:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233493AbjJJO27 (ORCPT ); Tue, 10 Oct 2023 10:28:59 -0400 Received: from out-193.mta0.migadu.com (out-193.mta0.migadu.com [IPv6:2001:41d0:1004:224b::c1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A212FAF for ; Tue, 10 Oct 2023 07:28:56 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1696948135; 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=/jN8h55KNP3RtmvUZhOGO1MAcrm7V1DX54vKKCbAGW4=; b=FLuxcLJc7MCThBfukRGPV/s0DkOpYhPtv8G1oc+pjfFNMFlePzS1gd3bcdx3OjEWEtwW79 Y93/hs4sGbhOPLdoBK9ceAD39O+cKFKsl5IBEFQ7Vu0D4I1DeN5FK3Bj6lQjjmpW2x8c+Z HfvyEq0sy9NhAJKbfwL6i2M897zQLx4= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , David Hildenbrand , "Kirill A. Shutemov" , Mike Kravetz , Miaohe Lin , Vlastimil Babka , Muchun Song , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 3/5] mm, kpageflags: separate code path for hugetlb pages Date: Tue, 10 Oct 2023 23:27:59 +0900 Message-Id: <20231010142801.3780917-4-naoya.horiguchi@linux.dev> In-Reply-To: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> References: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 10 Oct 2023 07:29:40 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779379137807514558 X-GMAIL-MSGID: 1779379137807514558 From: Naoya Horiguchi Hugetlb pages use some struct page's field of the first few tail pages for internal use. There's no point to parse and show the kpageflags info based on tail pages, so return immediately when finding hugetlb tail pages. Signed-off-by: Naoya Horiguchi --- fs/proc/page.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 78f675f791c1..9b6ded8a2c90 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -135,23 +135,20 @@ u64 stable_page_flags(struct page *page) if (PageKsm(page)) u |= 1 << KPF_KSM; - /* - * compound pages: export both head/tail info - * they together define a compound page's start/end pos and order - */ - if (PageHead(page)) - u |= 1 << KPF_COMPOUND_HEAD; - if (PageTail(page)) - u |= 1 << KPF_COMPOUND_TAIL; - if (PageHuge(page)) + if (PageHuge(page)) { u |= 1 << KPF_HUGE; + if (PageHead(page)) + u |= 1 << KPF_COMPOUND_HEAD; + if (PageTail(page)) { + u |= 1 << KPF_COMPOUND_TAIL; + return u; + } /* - * PageTransCompound can be true for non-huge compound pages (slab - * pages or pages allocated by drivers with __GFP_COMP) because it - * just checks PG_head/PG_tail, so we need to check PageLRU/PageAnon - * to make sure a given page is a thp, not a non-huge compound page. + * PageTransCompound can be true for any types of compound pages, + * because it just checks PG_head and PageTail, but at this point + * PageSlab and PageHuge are already checked to be false. */ - else if (PageTransCompound(page)) { + } else if (PageTransCompound(page)) { struct page *head = compound_head(page); /* From patchwork Tue Oct 10 14:28:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 150826 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp243899vqb; Tue, 10 Oct 2023 07:29:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEj+Ht++Ya/ICIKHW3L7zgAuh80tPjl4FAwCt9FcLzEz4xpZAb+np+j72GQ/AupveqzsxqT X-Received: by 2002:a05:6a21:614:b0:164:c705:383a with SMTP id ll20-20020a056a21061400b00164c705383amr13888677pzb.19.1696948182147; Tue, 10 Oct 2023 07:29:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696948182; cv=none; d=google.com; s=arc-20160816; b=cYe9c93z4U09+yQMoPAAYHpBuuiHroJs9EahYkMLsz6wvDeB5DWts+tAGUNjhBSDcU 3xUo9p7oK0uI57qiTUVS1+Ew7RfGMVSREDk5eJVQZoywQNLon/oQnvYrOrRpBpv/oJnJ n+1ljuVVzv8hlB8+W3c9g6u3NDueJCegHddhDvJ0DYb3RTMOcUjCrX0fjjH80XFTrnIP oGoeCnkPGnS6ipG6Y7D+pFEi+X/jGuyuIKBxVrvwKmpXa19GtwRB/O3gOUA1VDOyqZFt eGe5xTN+1dykE84wBSDUP7kheVz9HNCNfc4CCYXUwG+TCfW8lgvobkYkp+nUCD3wy3U1 rU6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8iM6qPUOV4SzLi4G7vOLG6YfwWxmIMlrGIRntMRiEaw=; fh=vd113QmVxKSP0xyTVgYADqM2Ffy1JHXPefyn38Zlb+8=; b=KiOwhZnlV7SHMbNT2huuXH3pxAg7sZzoclJ2WV99q8b99ljij9/a17VA+TFQ7FCFEV 2E9RGxgEuOG6txd/8r1EHTuRbyXZPZCXXffIo+gqlMNfv20x2oPLWb/SCY/Ybd+yFa5Q aTkMkRFk5YblXHjNClLLW7BgclNC6jo8KHla+LFWC/TSHmH3Ek/NYg+VtJWoRHSojxVX eyWGkUF5/aqkkWgLY4ExKNC5GGdS2x18p6C62QrnHLp+pjq41YIGF0v6f2VRMMkiQjJB B2VrRyzBSQQhNs4Q2BZeueRDCyy9Za0tUmw7/xte7I/WQY3p8IU8R0BHzKqDm3H7wLLb XqUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=LGQ17jWA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id a11-20020a056a000c8b00b006933bf7aedbsi10061503pfv.285.2023.10.10.07.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 07:29:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=LGQ17jWA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 0074C80A7901; Tue, 10 Oct 2023 07:29:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233227AbjJJO3R (ORCPT + 20 others); Tue, 10 Oct 2023 10:29:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233641AbjJJO3G (ORCPT ); Tue, 10 Oct 2023 10:29:06 -0400 Received: from out-197.mta0.migadu.com (out-197.mta0.migadu.com [IPv6:2001:41d0:1004:224b::c5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33307B9 for ; Tue, 10 Oct 2023 07:29:03 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1696948139; 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=8iM6qPUOV4SzLi4G7vOLG6YfwWxmIMlrGIRntMRiEaw=; b=LGQ17jWAmO3AzMTEsiisqBbOeFYutV+KmHjON926qys/pAgpt4siIMYDJofdhHOETudxF3 D4Y7Fa+Xzgy6CTNCoSSFTQWg1Owoi4swnyZrRm/n404f16vqJBzEonrBhPIQKvt0miTdvg JaSCNdpTWTvdYNouWp5c6jdVh0y3xac= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , David Hildenbrand , "Kirill A. Shutemov" , Mike Kravetz , Miaohe Lin , Vlastimil Babka , Muchun Song , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 4/5] mm, kpageflags: fix invalid output for PageSlab Date: Tue, 10 Oct 2023 23:28:00 +0900 Message-Id: <20231010142801.3780917-5-naoya.horiguchi@linux.dev> In-Reply-To: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> References: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 10 Oct 2023 07:29:39 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779379137145957314 X-GMAIL-MSGID: 1779379137145957314 From: Naoya Horiguchi The flag field of slab tail pages is used for internal purpose and there's no point in exposing such info to userspace. Here's the output of `page-types -r -b slab` command now: flags page-count MB symbolic-flags long-symbolic-flags 0x0000000000000080 5304 20 _______S_____________________________________ slab 0x0000000000008080 1488 5 _______S_______H_____________________________ slab,compound_head 0x0000000000010081 365 1 L______S________T____________________________ locked,slab,compound_tail 0x0000000000010080 4142 16 _______S________T____________________________ slab,compound_tail 0x0000000000010180 649 2 _______SW_______T____________________________ slab,writeback,compound_tail 0x0000000000010181 474 1 L______SW_______T____________________________ locked,slab,writeback,compound_tail 0x0000000000201080 192 0 _______S____a________x_______________________ slab,anonymous,ksm 0x0000000000001080 427 1 _______S____a________________________________ slab,anonymous 0x0000000000409080 237 0 _______S____a__H______t______________________ slab,anonymous,compound_head,thp 0x0000000000411081 78 0 L______S____a___T_____t______________________ locked,slab,anonymous,compound_tail,thp 0x0000000000609080 77 0 _______S____a__H_____xt______________________ slab,anonymous,compound_head,ksm,thp 0x0000000000611081 32 0 L______S____a___T____xt______________________ locked,slab,anonymous,compound_tail,ksm,thp 0x0000000000411080 698 2 _______S____a___T_____t______________________ slab,anonymous,compound_tail,thp 0x0000000000611080 142 0 _______S____a___T____xt______________________ slab,anonymous,compound_tail,ksm,thp 0x0000000000611180 32 0 _______SW___a___T____xt______________________ slab,writeback,anonymous,compound_tail,ksm,thp 0x0000000000411181 95 0 L______SW___a___T_____t______________________ locked,slab,writeback,anonymous,compound_tail,thp 0x0000000000411180 64 0 _______SW___a___T_____t______________________ slab,writeback,anonymous,compound_tail,thp 0x0000000000611181 13 0 L______SW___a___T____xt______________________ locked,slab,writeback,anonymous,compound_tail,ksm,thp In this output, "locked" and "writeback" flags are completely pointless because these are encoded in folio->_flags_1 via folio_set_order() and those pages are actually not locked nor written back. As for "anonymous" and "ksm" flags, these are encoded in folio->mapping and the actual value is like 0xdead000000000003. I'm not sure how this value is set, but according to the comment in include/linux/page-flags.h: > * For slab pages, since slab reuses the bits in struct page to store its > * internal states, the page->mapping does not exist as such, nor do these > * flags below. So in order to avoid testing non-existent bits, please > * make sure that PageSlab(page) actually evaluates to false before calling > * the following functions (e.g., PageAnon). See mm/slab.h. , so we don't have to check PageAnon and PageKsm for slab pages. So return immediately when finding slab tail pages. Note that KPF_HWPOISON is special and it can be helpful to make it visible in /prock/kpageflag even on compound tail pages. After this patch, `page-types -r -b slab` command shows the following simpler output (without any invalid flags). 0x0000000000000080 5659 22 _______S_____________________________________ slab 0x0000000000008080 1644 6 _______S_______H_____________________________ slab,compound_head 0x0000000000010080 6196 24 _______S________T____________________________ slab,compound_tail Signed-off-by: Naoya Horiguchi --- fs/proc/page.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 9b6ded8a2c90..899b96a26fbd 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -122,18 +122,18 @@ u64 stable_page_flags(struct page *page) k = page->flags; u = 0; - /* - * pseudo flags for the well known (anonymous) memory mapped pages - * - * Note that page->_mapcount is overloaded in SLAB, so the - * simple test in page_mapped() is not enough. - */ - if (!PageSlab(page) && page_mapped(page)) - u |= 1 << KPF_MMAP; - if (PageAnon(page)) - u |= 1 << KPF_ANON; - if (PageKsm(page)) - u |= 1 << KPF_KSM; +#ifdef CONFIG_MEMORY_FAILURE + u |= kpf_copy_bit(k, KPF_HWPOISON, PG_hwpoison); +#endif + + if (PageSlab(page)) { + u |= 1 << KPF_SLAB; + if (PageHead(page)) + u |= 1 << KPF_COMPOUND_HEAD; + if (PageTail(page)) + u |= 1 << KPF_COMPOUND_TAIL; + return u; + } if (PageHuge(page)) { u |= 1 << KPF_HUGE; @@ -173,9 +173,18 @@ u64 stable_page_flags(struct page *page) } else if (is_zero_pfn(page_to_pfn(page))) u |= 1 << KPF_ZERO_PAGE; + /* + * pseudo flags for the well known (anonymous) memory mapped pages + */ + if (page_mapped(page)) + u |= 1 << KPF_MMAP; + if (PageAnon(page)) + u |= 1 << KPF_ANON; + if (PageKsm(page)) + u |= 1 << KPF_KSM; /* - * Caveats on high order pages: PG_buddy and PG_slab will only be set + * Caveats on high order pages: PG_buddy will only be set * on the head page. */ if (PageBuddy(page)) @@ -192,11 +201,6 @@ u64 stable_page_flags(struct page *page) u |= 1 << KPF_IDLE; u |= kpf_copy_bit(k, KPF_LOCKED, PG_locked); - - u |= kpf_copy_bit(k, KPF_SLAB, PG_slab); - if (PageTail(page) && PageSlab(page)) - u |= 1 << KPF_SLAB; - u |= kpf_copy_bit(k, KPF_ERROR, PG_error); u |= kpf_copy_bit(k, KPF_DIRTY, PG_dirty); u |= kpf_copy_bit(k, KPF_UPTODATE, PG_uptodate); @@ -214,10 +218,6 @@ u64 stable_page_flags(struct page *page) u |= kpf_copy_bit(k, KPF_UNEVICTABLE, PG_unevictable); u |= kpf_copy_bit(k, KPF_MLOCKED, PG_mlocked); -#ifdef CONFIG_MEMORY_FAILURE - u |= kpf_copy_bit(k, KPF_HWPOISON, PG_hwpoison); -#endif - #ifdef CONFIG_ARCH_USES_PG_UNCACHED u |= kpf_copy_bit(k, KPF_UNCACHED, PG_uncached); #endif From patchwork Tue Oct 10 14:28:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 150823 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp243794vqb; Tue, 10 Oct 2023 07:29:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNaaKnNcN2mOa/MAMBTMLqRGTTKWNi47alb1iDNkM5RkChGNEU0lx2zDh9xdPeXnl/KwSx X-Received: by 2002:a05:6a20:1609:b0:153:7515:9919 with SMTP id l9-20020a056a20160900b0015375159919mr22309958pzj.21.1696948170541; Tue, 10 Oct 2023 07:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696948170; cv=none; d=google.com; s=arc-20160816; b=LyKhNplLg7nYP++QrdUt8rFIsmbkPWlH0RG3ULuYET7n/gtsd30CSlDMpNBrb9bbkK gskgU6MLHD7CkXOt/8pjD4btcn5VAM4KItwZTbuyqejjASCUd4bo3A2RJ/s7ne7+mhGM AnekMABZ4HC6YMIGTWE4Q83TtPlaZIDHnylxR8RJagLDKKD0M6d4xkIKbj9JXo9tdTok DwQi169ZPuzPsErSEavjLzanT9fQZBvSHz5EuMWVz/fOFV7c/nai08ahS+pW4vDcFJbD glAu7oCfipsZ2SH+38agtwSAWwN/ItdxjmNbS/lnxcYERgDkPvpTK4/BuXEaiaXDhTES dRQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=R/QG0Z2F3QpUoVuiwm1cdKUqeM2tUh0VmscjJ0F6F+U=; fh=vd113QmVxKSP0xyTVgYADqM2Ffy1JHXPefyn38Zlb+8=; b=Lbzb32ZV9DhTvT/0Ksw8p+RdQWqMuBpLRY/E5arpWZJ/65+SblhnMSvEf/f1rZmQ6L Sk68IEPXnk/jg6Ny/3scL/F9CBICeJsqhsTerRl010lxt0GxToNLWl2DUIuP/Is5obOi u9+cGnkDAui3LI/fLLCMidOo0smRs4A0iw8aSsLPZPg98FF9qleBtA81DVt4d6mbEJIH XqgV6ea4fFkLqgpogzfSnrj8/rEEU93kDX7igusBVQ6Igj2BvOInw8+Y3OZhNoTU3dX6 2YoPLU+JZeVflca+L4xbQQq+viUznzCkYKK8PBb/uLLAz/+Jph6VTB7935Tj1ryT8Nnc 4rhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=MWezG50+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id y14-20020a056a00190e00b006910a45a23bsi10108478pfi.366.2023.10.10.07.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 07:29:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=MWezG50+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 7DD9C81C50A1; Tue, 10 Oct 2023 07:29:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233121AbjJJO3M (ORCPT + 20 others); Tue, 10 Oct 2023 10:29:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233684AbjJJO3I (ORCPT ); Tue, 10 Oct 2023 10:29:08 -0400 Received: from out-195.mta0.migadu.com (out-195.mta0.migadu.com [IPv6:2001:41d0:1004:224b::c3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70888A9 for ; Tue, 10 Oct 2023 07:29:06 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1696948144; 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=R/QG0Z2F3QpUoVuiwm1cdKUqeM2tUh0VmscjJ0F6F+U=; b=MWezG50+O7UF+lm6gT/NNY5RH7a9ZopHj6n/EIkn62Z4LPC8w5SNIXi0a8Rgj52GVjSvYo 3EvJzzjr7YfdBb0crTZGG+Hndwx69pJFC8xJobtbDgC16FB0JY6EgocjAcpWMzR122rcVV 9pbMUMojnK8Du56fogifM1zDVCrzEt8= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , David Hildenbrand , "Kirill A. Shutemov" , Mike Kravetz , Miaohe Lin , Vlastimil Babka , Muchun Song , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 5/5] tools/mm/page-types.c: hide compound pages in non-raw mode Date: Tue, 10 Oct 2023 23:28:01 +0900 Message-Id: <20231010142801.3780917-6-naoya.horiguchi@linux.dev> In-Reply-To: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> References: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 10 Oct 2023 07:29:24 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779379124878476621 X-GMAIL-MSGID: 1779379124878476621 From: Naoya Horiguchi In non-raw mode (i.e. calling page-types without -r flag), any flags for compound pages except for hugetlb are supposed to be hidden. But currently KPF_THP is shown and the newly added flag KPF_FOLIO is also shown, which is unexpected. So hide them. Signed-off-by: Naoya Horiguchi --- tools/mm/page-types.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mm/page-types.c b/tools/mm/page-types.c index b78448d19e88..c37e1e79bc61 100644 --- a/tools/mm/page-types.c +++ b/tools/mm/page-types.c @@ -508,7 +508,7 @@ static uint64_t well_known_flags(uint64_t flags) /* hide non-hugeTLB compound pages */ if ((flags & BITS_COMPOUND) && !(flags & BIT(HUGE))) - flags &= ~BITS_COMPOUND; + flags &= ~(BITS_COMPOUND|BIT(THP)|BIT(FOLIO)); return flags; }