From mboxrd@z Thu Jan 1 00:00:00 1970 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 93237D6DDE3 for ; Fri, 15 Nov 2024 14:03:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C5286B0098; Fri, 15 Nov 2024 09:03:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 175D76B009A; Fri, 15 Nov 2024 09:03:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F31346B009C; Fri, 15 Nov 2024 09:02:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D27B76B0098 for ; Fri, 15 Nov 2024 09:02:59 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8FB68C15AA for ; Fri, 15 Nov 2024 14:02:59 +0000 (UTC) X-FDA: 82788493368.13.B58D3CB Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf21.hostedemail.com (Postfix) with ESMTP id B9EC91C0022 for ; Fri, 15 Nov 2024 14:01:30 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=rCr3i7Al; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf21.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731679313; a=rsa-sha256; cv=none; b=ZtWV0I+H9W9DssapTLPmN1YK4RAh6jXFDuSLEpym9+ucoYu7sosQgjxBVa9EkbAxVSndwO Zj5d6yGPqz/KZmNdYs/GH6ku10NcXlG5kZYqLpOFNLCr5YxeS68xYxZ/LoW6aRb+XdwWxh Lr5u/FkrIjLrFKEkJ1G0q7ThXDPRHEo= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=rCr3i7Al; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf21.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731679312; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IhstviW7ozYf7JTwvetHFmbz8Lit5rg3EcQY2QAqs1w=; b=T+rShNKu/3XKFG+FFnRY0UXqC9DLvDx49ndKc17F7BQgDQtMu1niAH5pafqU8zc10qAto8 4FnKv8lWAdgnUvC+O3+SRrDiTFt3yiNQD2iCwosxHcMbsngNuzYZDLlSOmrM3V0HAnoQTf cOyC8MOZ0+L2pBotjD7Wo9L4NPV+obI= Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20241115140255euoutp0201a456e8d308639688faf35ea97cd446~IKTeGIX_q1720617206euoutp027 for ; Fri, 15 Nov 2024 14:02:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20241115140255euoutp0201a456e8d308639688faf35ea97cd446~IKTeGIX_q1720617206euoutp027 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1731679375; bh=IhstviW7ozYf7JTwvetHFmbz8Lit5rg3EcQY2QAqs1w=; h=Date:To:From:Subject:CC:In-Reply-To:References:From; b=rCr3i7AlkEfVo4N/CsqQXQDMvSxf1oyLzq2a2lYBov9HqLdHM1owknpbwYpPS+yWT 8lT4tgihkG0AkYGF0YxmkooH8je6V0o4jZha1pwV3dar5DaN+F2fMkmn1D/VPNBpkn pji3+Fha3sXihWRhOz7D6lsde45xdtrBvaBDYFbU= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20241115140254eucas1p26d5b668caf97036d9c566aeb50f3d34d~IKTdyo1Qs2794627946eucas1p2I; Fri, 15 Nov 2024 14:02:54 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 70.3A.20409.E8457376; Fri, 15 Nov 2024 14:02:54 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20241115140254eucas1p2e77d484813d39b8e6c8c0dbd6046f3c4~IKTdZNrZr2804128041eucas1p2B; Fri, 15 Nov 2024 14:02:54 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241115140254eusmtrp1a4e280d0b0facbf4ae7403404586e6b2~IKTdYh0gB1681016810eusmtrp1S; Fri, 15 Nov 2024 14:02:54 +0000 (GMT) X-AuditID: cbfec7f4-c0df970000004fb9-7d-6737548e98c6 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id D2.75.19920.E8457376; Fri, 15 Nov 2024 14:02:54 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20241115140253eusmtip203cd16909d13e6003f7adf4ff86c7ffa~IKTc-bMJo1398113981eusmtip2T; Fri, 15 Nov 2024 14:02:53 +0000 (GMT) Received: from localhost (106.110.32.87) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 15 Nov 2024 14:02:52 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Date: Fri, 15 Nov 2024 15:02:52 +0100 Message-ID: To: Baolin Wang , , From: Daniel Gomez Subject: Re: [PATCH v2 4/5] mm: shmem: add a kernel command line to change the default huge policy for tmpfs CC: , , , <21cnbao@gmail.com>, , , , X-Mailer: aerc 0.18.2-67-g7f69618ac1fd In-Reply-To: <64091a3d5a8c5edb0461fae203cfcf6f302a19ce.1731397290.git.baolin.wang@linux.alibaba.com> X-Originating-IP: [106.110.32.87] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA02SeUwTQRjFM93tdqlps6wQxltq0Qha8YhdomCNqIsx8YhRJBotdl2I0GIr njERIiotQa3BY0UFg8qlaIsFPMAURRFCFI+gYqGiKKiAoIhySdma8N/ve/PefJmXwRGyWDgW j9buYvRadYwME6O2ij81M1PXKdlAriWA6npPUukF+Rg1eL8CUL8K/iLUp85UlLrcO5d6cScd oxz5g0Iq5W4aoBK6GgDV25OOqUbR+RfzAV3CvRfRGZZ4+vDD70Lamu1PWzrNIvrJ2V6ULnEG 0e2lrzC6yzJxtThCvFDDxETvZvSzQraKo77l5KBxSVP22pJuiw6B6vFG4IFDYh6sLbQLjUCM k0Q2gG15GYAffgKY8sCCuVwk0QWgNWGnEeDDiYxfy3nPNQC/NHMYPwx5+u73uAcrgKeTXgpd aQnhCSvPfURdjBAB8GrmV4Tn6TCpqFfkuhUl/GD9OS/ePg82m4zDUS8iEiZcKB62Y0P20kqL yMWjCS00WUwC1y6EqASQa0jE+PdMhYPHTw7v8iA0sDux2a37wrMnc1CeD8KnhW8FPOd5wOSO EJ5DYdOLKiHPo2Hr40IRz+Nh1akUd5aFWTc4N8fBe+84Id/KAphaHcPLi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iRkTV7JA2LUSn/8+Y5zAKDILya2zkNw6C8mtCxiZVzGKpJYW 56bnFhvqFSfmFpfmpesl5+duYgTG97ZjPzfvYJz36qPeIUYmDsZDjBIczEoivJdczdOFeFMS K6tSi/Lji0pzUosPMZoCPT2RWUo0OR+YYPJK4g3NDEwNTcwsDUwtzYyVxHndLp9PExJITyxJ zU5NLUgtgulj4uCUamDqOlR5Xubf/U+bT9my2Ky0Kn2//NXR4/cZqi0uWNdI/V4dnnqb//38 Y02sAQFLMj/FfLLkLKjI+PChIKea5eGEuVnL5FRv8ar47Def1PIis+3Sp0+3ii/FPk8Su110 s+6K8TxPy4jqdmFFBjmXpu39Mu8tTffsWPMtz1H3bv9j1umH+/K/2b1Zd6zgkOy9sk03NBew ZPEl9k5u/MIS4MhieW5G7gH3+08e17z5/UpuLWv4n9/VLOFe4dH8lxeHHf/+aOuyx00s1/8H Cc9eU+pWeqXnZqW9yOxO/3CG+0EPLHaujHk0a8UlTa18cdtVx6zDHwmUxgrc6WZ93DSBq26h +BNF9d9i/MvEX+6R+vVDiaU4I9FQi7moOBEAZuVPFHgDAAA= X-CMS-MailID: 20241115140254eucas1p2e77d484813d39b8e6c8c0dbd6046f3c4 X-Msg-Generator: CA X-RootMTR: 20241115140254eucas1p2e77d484813d39b8e6c8c0dbd6046f3c4 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20241115140254eucas1p2e77d484813d39b8e6c8c0dbd6046f3c4 References: <64091a3d5a8c5edb0461fae203cfcf6f302a19ce.1731397290.git.baolin.wang@linux.alibaba.com> X-Rspam-User: X-Rspamd-Queue-Id: B9EC91C0022 X-Rspamd-Server: rspam11 X-Stat-Signature: rgcoicn8yp4hbbxn75spcoco5w3b6cmg X-HE-Tag: 1731679290-1638 X-HE-Meta: U2FsdGVkX18JPqQbqFxrfV9BjRoLQa/ziWvhzXOaOx3c4D6TDtqPLCiU7dHiJS16CKJCgDj0R/dayU307bDxT7yHqOpaHvbrXfI9q6N0Ew0Va3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Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue Nov 12, 2024 at 8:45 AM CET, Baolin Wang wrote: > Now the tmpfs can allow to allocate any sized large folios, and the defau= lt > huge policy is still 'never'. Thus adding a new command line to change > the default huge policy will be helpful to use the large folios for tmpfs= , > which is similar to the 'transparent_hugepage_shmem' cmdline for shmem. I think it would be good to include a summary of why tmpfs is not enabling large folios by default as the other fs. David has been pretty good at repeating the reasons over and over and it would be very valuable to have them included here. > > Signed-off-by: Baolin Wang > --- > .../admin-guide/kernel-parameters.txt | 7 ++++++ > Documentation/admin-guide/mm/transhuge.rst | 6 +++++ > mm/shmem.c | 23 ++++++++++++++++++- > 3 files changed, 35 insertions(+), 1 deletion(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentat= ion/admin-guide/kernel-parameters.txt > index b48d744d99b0..007e6cfada3e 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -6943,6 +6943,13 @@ > See Documentation/admin-guide/mm/transhuge.rst > for more details. > =20 > + transparent_hugepage_tmpfs=3D [KNL] > + Format: [always|within_size|advise|never] > + Can be used to control the default hugepage allocation policy > + for the tmpfs mount. > + See Documentation/admin-guide/mm/transhuge.rst > + for more details. > + > trusted.source=3D [KEYS] > Format: > This parameter identifies the trust source as a backend > diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/a= dmin-guide/mm/transhuge.rst > index 5034915f4e8e..9ae775eaacbe 100644 > --- a/Documentation/admin-guide/mm/transhuge.rst > +++ b/Documentation/admin-guide/mm/transhuge.rst > @@ -332,6 +332,12 @@ allocation policy for the internal shmem mount by us= ing the kernel parameter > seven valid policies for shmem (``always``, ``within_size``, ``advise``, > ``never``, ``deny``, and ``force``). > =20 > +Similarly to ``transparent_hugepage_shmem``, you can control the default > +hugepage allocation policy for the tmpfs mount by using the kernel param= eter > +``transparent_hugepage_tmpfs=3D``, where ```` is one of = the > +four valid policies for tmpfs (``always``, ``within_size``, ``advise``, > +``never``). The tmpfs mount default policy is ``never``. > + > In the same manner as ``thp_anon`` controls each supported anonymous THP > size, ``thp_shmem`` controls each supported shmem THP size. ``thp_shmem`= ` > has the same format as ``thp_anon``, but also supports the policy > diff --git a/mm/shmem.c b/mm/shmem.c > index a3203cf8860f..021760e91cea 100644 > --- a/mm/shmem.c > +++ b/mm/shmem.c > @@ -548,6 +548,7 @@ static bool shmem_confirm_swap(struct address_space *= mapping, > /* ifdef here to avoid bloating shmem.o when not necessary */ > =20 > static int shmem_huge __read_mostly =3D SHMEM_HUGE_NEVER; > +static int tmpfs_huge __read_mostly =3D SHMEM_HUGE_NEVER; > =20 > /** > * shmem_mapping_size_orders - Get allowable folio orders for the given = file size. > @@ -4780,7 +4781,12 @@ static int shmem_fill_super(struct super_block *sb= , struct fs_context *fc) > sbinfo->gid =3D ctx->gid; > sbinfo->full_inums =3D ctx->full_inums; > sbinfo->mode =3D ctx->mode; > - sbinfo->huge =3D ctx->huge; > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE > + if (ctx->seen & SHMEM_SEEN_HUGE) > + sbinfo->huge =3D ctx->huge; > + else > + sbinfo->huge =3D tmpfs_huge; > +#endif > sbinfo->mpol =3D ctx->mpol; > ctx->mpol =3D NULL; > =20 > @@ -5259,6 +5265,21 @@ static int __init setup_transparent_hugepage_shmem= (char *str) > } > __setup("transparent_hugepage_shmem=3D", setup_transparent_hugepage_shme= m); > =20 > +static int __init setup_transparent_hugepage_tmpfs(char *str) > +{ > + int huge; > + > + huge =3D shmem_parse_huge(str); > + if (huge < 0) { > + pr_warn("transparent_hugepage_tmpfs=3D cannot parse, ignored\n"); > + return huge; > + } > + > + tmpfs_huge =3D huge; > + return 1; > +} > +__setup("transparent_hugepage_tmpfs=3D", setup_transparent_hugepage_tmpf= s); > + > static char str_dup[PAGE_SIZE] __initdata; > static int __init setup_thp_shmem(char *str) > {