From patchwork Tue Oct 10 14:27:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 13415651 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 9BA99CD8C8E for ; Tue, 10 Oct 2023 14:28:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 325068D00B9; Tue, 10 Oct 2023 10:28:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2ABD88D0002; Tue, 10 Oct 2023 10:28:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 14CC08D00B9; Tue, 10 Oct 2023 10:28:47 -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 F22D68D0002 for ; Tue, 10 Oct 2023 10:28:46 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C0EA24024A for ; Tue, 10 Oct 2023 14:28:46 +0000 (UTC) X-FDA: 81329783052.28.D456610 Received: from out-198.mta0.migadu.com (out-198.mta0.migadu.com [91.218.175.198]) by imf20.hostedemail.com (Postfix) with ESMTP id DBECB1C005D for ; Tue, 10 Oct 2023 14:28:44 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=fgCPyXho; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf20.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 91.218.175.198 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696948125; 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:references:dkim-signature; bh=GLeS08MBIWGTlAyOqrf8ngGV4rj6bq2718i39P+fBE0=; b=0BuCOB5enl+WFo3KP7T3znKqgGN606caNGex4obK272YK8Tj0AsK4i443p2uUvS4Wvau5e TOtk2faJgoYvpFW1H/3BScnKeU0OiLd3sFbkK4cbq7OL4iGpnh/6JOHU/VidfpQKhtRiCS XOgECvczZ2nsZgXcXS58qtUq9KV5SY0= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=fgCPyXho; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf20.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 91.218.175.198 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696948125; a=rsa-sha256; cv=none; b=4xQzerslYbFUgGJkrMZl7juv6ob5ovD1lUtkHi+/Q/VxcMcd4Rw0KRc0UFyUhKvfUAIyvi QD3NwNwHD/Wf+8PUBAG+tgZ9x947y61GMmasW4vuy2bBmDjRD4Rj5TLTNE8DGbbuDzFMww bL7P7mum8vaUPzUv8tiYGhtm4BeNQxI= 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=1696948122; 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; bh=GLeS08MBIWGTlAyOqrf8ngGV4rj6bq2718i39P+fBE0=; b=fgCPyXhoYfUC7YYYl8tbmesU6YmPouU1ODhbQ4C5ejRiZTvMAeIOKIIt9sB+Bi1MTFdfyL 16O8Zfs7mISfCxZCLesDUK0x1PtKIFbYWJ5XSQmhjhNMJPKCVpLJkVGELKvZB+zJKGuJy8 uZlhs5msyzRtDD0dz5FtKRSpSV16koU= 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 0/5] mm, kpageflags: support folio and fix output for compound pages Date: Tue, 10 Oct 2023 23:27:56 +0900 Message-Id: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: DBECB1C005D X-Stat-Signature: 86fki3bbw98rm6ub71gaahdpztb6tka1 X-HE-Tag: 1696948124-991044 X-HE-Meta: U2FsdGVkX198RtoStyH7Qm/iKI9an2uK9hx0FDp+/U1EnX1bKn5KX0CMHsUHLK1uC4DI5R4IQwshzbAO4T3YKzsNCmI4QO7luvp0FM37nKbmClZVzspC3Iy7/3aZumVL/Djw+Aaxv7RFebKTatvfP49YcEuQc1oxMb+Cm1rQObD16CKawzrbbuC2ju1h0qJiD0EvRp4Hlrc7pgq0Rw9CJdYGetajZMnHKlllM8WM6oZKdaJyfv0JGXmVs7IT3/g8RhXkggrJQ1o7v4gWwNJ2RRSFmi2vxoKhmMJ4/h70QVyFJ4sup7TA1peCEKqPGKFc0oi4o8PQvmDVnfvtG1crrBYpa4bTnYdibfRdd+7j3RV+DeEFdSzkJ4o9VpO7L3XhtkuhuBhl2gTP+OScYrUbFAWbL72xc3PVZ+M1sQyyYPw/vbiyZ5vq4y2g3Rksy3LHVrdKpLkOdhwm0PX7Zpw/VGUTHtLiuQ8Q39UUmGwx7OxTl1zPUz5fNV3XehAbUPHqlFyoYNnoMbbkdrJoV1aPcFrFV8Iss3LsT+/EB8aogDoeCCbM5EiC1+Biiz1+pdWyCFPEP9TV3cqEgd1/uJqh5AxogH+3E+vr2Nz8dqwrdBTuXRqTh3bBG3QEASSLj553riWbvzPxLQ4dgDHhq/KVqo0Sf6cwmpL7hhGV6cWXKSZj+yvukfy+JWYq8jyqFh58SOxlI+63HDIn/S9kDMeoSIBBHLB6YvqKDe0Nnjgk2R2kWzv93fddAzu+oi7x4cRmk2jgZ8TFL1j9CLawI4lWilHDTFf2mOL1J85ceZVDziSvnLFvmqG3eRjeo8f2e+DARXwANX5gz7ImZbO6MrUlRcbdiAA6VhqRkfiVf8vMeUCClE8D1kTB2JscfHLCT6gC7i5P+J8owu53Hp9TZ2AW/yfCYeqt2CUqBX7ueBxUvqN3ZvBu/K8Jc9fmQATzy3KNUprn0wM/F0PQY9jDO0r bKGXAgAe DS+PPK2lNHI7ghGuIgqOZuWP0NMeKTsVPfMrqXCkR0PnnYpI1Iv4cXjr3v+wo4q8s7pCW 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: Hi everyone, This patchset addresses 2 issues in /proc/kpageflags. 1. We can't easily tell folio from thp, because currently both pages are judged as thp, and 2. we see some garbage data in records of compound tail pages because we use tail pages to store some internal data. These issues require userspace programs to do additional work to understand the page status, which makes situation more complicated. This patchset tries to solve these by defining KPF_FOLIO for issue 1., and by hiding part of page flag info on tail pages of compound pages for issue 2. I think that technically some compound pages like thp/hugetlb/slab could be considered as folio, but in this version KPF_FOLIO is set only on folios in pagecache (so "folios in narrower meaning"). I'm not confident about this choice, so if you have any idea about this, please let me know. How we can see using tools/mm/page-types.c will change like below (only focusing on compound pages). Before patchset: // 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 // 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 700000004 14d0a4 1 __RU_l_____M___H______t________P____f_____F_1 700000005 14d0a5 1 ________W__M____T_____t_____________f_____F_1 700000006 14d0a6 2 ___________M____T_____t_____________f_____F_1 ... // free hugetlb (HVO disabled) offset len flags ... 106a00 1 _______________H_G___________________________ 106a01 1 L__U__A_________TG___________________________ 106a02 1fe ________________TG___________________________ // anonymous hugetlb (HVO disabled) 700000000 157200 1 ___U_______Ma__H_G__________________f_d_____1 700000001 157201 1 L__U__A____Ma___TG__________________f_______1 700000002 157202 1fe ___________Ma___TG__________________f_______1 // free hugetlb (HVO enabled) 12a600 1 _______________H_G___________________________ 12a601 1 L__U__A_________TG___________________________ 12a602 3f ________________TG___________________________ 12a641 1 L__U__A_________TG___________________________ 12a642 3f ________________TG___________________________ ... // anonymous hugetlb (HVO enabled) 700000000 15e600 1 ___U_______Ma__H_G__________________f_d_____1 700000001 15e601 1 L__U__A____Ma___TG__________________f_______1 700000002 15e602 3e ___________Ma___TG__________________f_______1 700000040 15e640 1 ___U_______Ma___TG__________________f_d_____1 700000041 15e641 1 L__U__A____Ma___TG__________________f_______1 700000042 15e642 3e ___________Ma___TG__________________f_______1 ... // slab 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 After patchset: // 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 700000004 148da8 1 __RU_l_____M___H___________f___P____f_____F_1 700000005 148da9 3 ________________T__________f________f_____F_1 // free hugetlb (HVO disabled) 116000 1 _______________H_G___________________________ 116001 1ff ________________TG___________________________ // anonymous hugetlb (HVO disabled) 700000000 116000 1 ___U_______Ma__H_G__________________f_d_____1 700000001 116001 1ff ________________TG__________________f_______1 // free hugetlb (HVO enabled) 116000 1 _______________H_G___________________________ 116001 1ff ________________TG___________________________ // anonymous hugetlb (HVO enabled) 700000000 116000 1 ___U_______Ma__H_G__________________f_d_____1 700000001 116001 1ff ________________TG__________________f_______1 // slab 0x0000000000000080 5659 22 _______S_____________________________________ slab 0x0000000000008080 1644 6 _______S_______H_____________________________ slab,compound_head 0x0000000000010080 6196 24 _______S________T____________________________ slab,compound_tail Thanks, Naoya Horiguchi --- Summary: Naoya Horiguchi (5): include/uapi/linux/kernel-page-flags.h: define KPF_FOLIO mm: kpageflags: distinguish thp and folio mm, kpageflags: separate code path for hugetlb pages mm, kpageflags: fix invalid output for PageSlab tools/mm/page-types.c: hide compound pages in non-raw mode fs/proc/page.c | 90 +++++++++++++++++++--------------- include/uapi/linux/kernel-page-flags.h | 1 + tools/mm/page-types.c | 3 +- 3 files changed, 53 insertions(+), 41 deletions(-)