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 561D4C4167B for ; Mon, 4 Dec 2023 20:15:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E04556B02F3; Mon, 4 Dec 2023 15:15:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DB46B6B02F6; Mon, 4 Dec 2023 15:15:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7BA26B02FA; Mon, 4 Dec 2023 15:15:28 -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 B45C46B02F3 for ; Mon, 4 Dec 2023 15:15:28 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8B31040347 for ; Mon, 4 Dec 2023 20:15:28 +0000 (UTC) X-FDA: 81530240736.24.1FD6437 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id 979664001C for ; Mon, 4 Dec 2023 20:15:26 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=pvZROeSi; dmarc=none; spf=pass (imf07.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701720926; 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=j4a2keWogdso4fUlAgHqKHIlC0vOWbd1pKMDRnrrrAI=; b=O1P8WostZ1W6w2VSD62TwbL6v6iAp8+5kJtR0VQIxXoM+6ItqvpldOW0d+v9Mb+JDt7qiq WLkFpX5OTCjoNr9cj5JOowV3g7hF2piyVKV1VKTwUMXn4zX4pTmo+/u9lRvCuLU9QXeg0j Q2a3nDKgGWpW+89FD9yJt6XxOHIJTXA= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=pvZROeSi; dmarc=none; spf=pass (imf07.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701720926; a=rsa-sha256; cv=none; b=F7CvG7qieuzyJqxEoaJaYUovo6x55hXNOe7gWmcq5Zt+Hi9hHSVFRJnjgCCY5lbEUjEjZz CWR409g+hBh5iCJcjSCPqmE6RPzPmuVYELV/ebxdaknpUl4hW1RpGc50gvwCNUUXmTD+uA PMv2jKRKsmZQeTifguuExOotrMPu9+I= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6B9CA61299; Mon, 4 Dec 2023 20:15:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E85EDC433C7; Mon, 4 Dec 2023 20:15:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1701720925; bh=Oa+AKNnfNJKYaj5c5DLXMZSQbG2uQbsRvEdWdjOKPxE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=pvZROeSiPwT0U9Ds4tzHhAfzYiGa8TlQ8YX3RHsa7xnOqpQNt6rX2SdCG53uQ0Ax5 rOE+cr/D7DDykyuEdJQg3wsmj56gubbWf+APhs1arrAJqJW/sGzZf4Za3UVDl/kORY WDvtLe1kGvWVrHW+rMQ4ZMZ9H2Tr/8IFN3pQAx/E= Date: Mon, 4 Dec 2023 12:15:24 -0800 From: Andrew Morton To: Dmytro Maluka Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/thp: add CONFIG_TRANSPARENT_HUGEPAGE_NEVER option Message-Id: <20231204121524.dfa9f98e809c91b353968d34@linux-foundation.org> In-Reply-To: References: <20231204163254.2636289-1-dmaluka@chromium.org> <20231204111301.7e087b2f851b30121561e8fc@linux-foundation.org> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 979664001C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ujp548upqksz4wctau1neuhh311j47hg X-HE-Tag: 1701720926-892210 X-HE-Meta: U2FsdGVkX1/zdgJ3HnYbeAuPR8TuY5f6XwMtHj1ANDJZexDKMj2lHJieYIjz8AcIc2KTsX4yaK2//GmauAGuKw6+jipXhkZz0GHoJI6FMySPFhidatWa0+bRLqa2GhbmWmJmmKD2VrvRBXSI6Ean1YLN9FCcChJwDQwFVLB6eu1edkYGaH5jDjRs2BnOOic17cc1zFT9HEE3tNg+/Dxnpv9Rhh49IcXNgUXkipORaIXTuMzELgTq8Nr8bwYyv5HthafWeaAn+tB7ShlYuhK8cBt4D+O/OJxcwzUAswoKMWjK+v8SA++PWRLdzfqGVzMMTYN1sRVqXmtxHm0Le/rpLjZhfVQ8RSFHerEQEwybN2MYOPnEyrjYy1UNofcM6ATeRUio2dKFiGutRLWEeyT26tQcHDrJqKg2XuMEJM5mCCJvcsBSFhy71x5fWm5x1+18AXd0eUvD/5HoGrysB+SVfurzjXRIia846aRGddk6gcdDWaotZmiQvQoJH7tX/rKf9CfBNCG1i+vWjzT4JizVTf0VpURlfvEc0cEPiZe6+8iPfpAGY41w7OyppjTSbcul7UeDWdw/E8ZR6VwPa+OgHGADHW/+JWvmPZPeZwGb0mW2j6Z/cGu2LyizYDIZCe3h3ql7hAFsNsHRhUKsVCyhilLYuyOHjvz6gM5DAdGtSzP5UhW0vSBox2n5wDP2k/krwSKC1Hu/jiz0xM5y6PiAIv2KBEa3/wH5AsmER4q+10eO4rT4wXy7OZbla95o5UzRI4sveg4sS+8dQxxPYBVB13fS8IXaAGbqfybwa/9cHdNoeRFzWgJND3zITBgsQIJJnSO9uPXWmzvXE3n03O+phKh5bL3c8F+OzuE9BKf6jt8yhzGkd1f1OOrR/9Yk4o2fum1FRkT79un/JRu6x1MuwEVoxFkvkzujZ859O/NkJClJ2C9rtzDsEXNdbUNkXoa6F/kfjen4GbS8kz1a2MH 9TV/VtVM OMG/XJwvQw7+4jglWBYdoi9bdNT4Bfy4vY2IpysFA62i9Lx6GXaulbu1D7bQMO8LbbUKS41vd29JGZLkSfCrJQZCX0Tua5ve0d6Lu0DtvEojec8bEBLWh5uDZNKvjQYg0Wm9h/tp2GUTykoEE75mlIbUBbz4papWCa1xYoYkKmIoYbvmh5suDv//mOYRKLVfktWGt2TYdpHdfA6RoP91JISpMxlRUcfYvdtM9KqzJ7q9BUMdStqpbBUPABk4k4xH0JV2sMnv2XJs724l49J0aGF+bfTUsUELy8cwkrJG+m0yjVzshZocynK/0MjzBj5KQuuakGWISDx+qyXLR5OBJg5wb8VE8o2gvDOTvoI0xOnCGeQcA5QOctCjvew== 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: On Mon, 4 Dec 2023 20:57:33 +0100 Dmytro Maluka wrote: > On Mon, Dec 04, 2023 at 11:13:01AM -0800, Andrew Morton wrote: > > On Mon, 4 Dec 2023 17:32:54 +0100 Dmytro Maluka wrote: > > > > > Add an option to disable transparent hugepages by default, in line with > > > the existing transparent_hugepage=never command line setting. > > > > > > Rationale: khugepaged has its own non-negligible memory cost even if it > > > is not used by any applications, since it bumps up vm.min_free_kbytes to > > > its own required minimum in set_recommended_min_free_kbytes(). For > > > example, on a machine with 4GB RAM, with 3 mm zones and pageblock_order > > > == MAX_ORDER, starting khugepaged causes vm.min_free_kbytes increase > > > from 8MB to 132MB. > > > > > > So if we use THP on machines with e.g. >=8GB of memory for better > > > performance, but avoid using it on lower-memory machines to avoid its > > > memory overhead, then for the same reason we also want to avoid even > > > starting khugepaged on those <8GB machines. So with > > > CONFIG_TRANSPARENT_HUGEPAGE_NEVER we can use the same kernel image on > > > both >=8GB and <8GB machines, with THP support enabled but khugepaged > > > not started by default. The userspace can then decide to enable THP > > > (i.e. start khugepaged) via sysfs if needed, based on the total amount > > > of memory. > > > > > > This could also be achieved with the existing transparent_hugepage=never > > > setting in the kernel command line instead. But it seems cleaner to > > > avoid tweaking the command line for such a basic setting. > > > > > > P.S. I see that CONFIG_TRANSPARENT_HUGEPAGE_NEVER was already proposed > > > in the past [1] but without an explanation of the purpose. > > > > > > ... > > > > > > --- a/mm/Kconfig > > > +++ b/mm/Kconfig > > > @@ -859,6 +859,12 @@ choice > > > madvise(MADV_HUGEPAGE) but it won't risk to increase the > > > memory footprint of applications without a guaranteed > > > benefit. > > > + > > > + config TRANSPARENT_HUGEPAGE_NEVER > > > + bool "never" > > > + help > > > + Disabling Transparent Hugepage by default. It can still be > > > > s/Disabling/Disable/ > > It is in line with the descriptions of TRANSPARENT_HUGEPAGE_ALWAYS and > TRANSPARENT_HUGEPAGE_MADVISE: "Enabling Transparent Hugepage ..." Those are incorrect also. > > > + enabled at runtime via sysfs. > > > endchoice > > > > The patch adds the config option but doesn't use it? > > I should have been more precise: it is not a new option but a new choice > for CONFIG_TRANSPARENT_HUGEPAGE, in addition to the existing ALWAYS and > MADVISE choices. In mm/huge_memory.c in the declaration of the > transparent_hugepage_flags variable, if either ALWAYS or MADVISE is > chosen, transparent_hugepage_flags is initialized with such a value > that makes khugepaged being started by default during bootup. This patch > allows enabling CONFIG_TRANSPARENT_HUGEPAGE without setting either > ALWAYS or MADVISE, so that transparent_hugepage_flags is initialized > with such a value that khugepaged is not started by default. OK, thanks.