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 F0A63C3DA49 for ; Fri, 26 Jul 2024 10:45:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 46B1A6B00A7; Fri, 26 Jul 2024 06:45:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 41B726B00A8; Fri, 26 Jul 2024 06:45:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3095A6B00A9; Fri, 26 Jul 2024 06:45:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0C9876B00A7 for ; Fri, 26 Jul 2024 06:45:22 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7BD47A170E for ; Fri, 26 Jul 2024 10:45:21 +0000 (UTC) X-FDA: 82381572042.14.32BBEA6 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf28.hostedemail.com (Postfix) with ESMTP id 9A4E7C0024 for ; Fri, 26 Jul 2024 10:45:19 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf28.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721990664; 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; bh=auPeXSd0G37+FuRoeWN6kLd+FWDgaOVv2wazFZPlbts=; b=3gjamv/MfBEIz7c4l5SAhDnj/zLZP7mHRz0kEWdB6bPJMfoqYjlNM48XzH9OOOhxYcD2Dy gIsrDkF9abryhVXYIj1yAZz9HCvpitXM1NzBS/mQWmyJcQrU7jfe0c5NZHI73RCL0L4NeA tKAtIHPa8KxBS2Kep9/aGdBciis8OEY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721990664; a=rsa-sha256; cv=none; b=wOLNfTOP+cLCdAdg3EKXz0P1XYlkhv8jNsN8XkKgJE+IJZVWMM5XfG1NhCIVE+YGRL/Ef4 J8A1hgOL8rhv+On4r2ubkMTrQrMPRgTgtRal8OoIchAEx3XVHI//ItfIweSkeywHqfzarg bz25nnP0ri/iaUSPoqUOdYpF1yA3SEQ= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf28.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 27C911007; Fri, 26 Jul 2024 03:45:44 -0700 (PDT) Received: from [10.57.78.186] (unknown [10.57.78.186]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 866A13F73F; Fri, 26 Jul 2024 03:45:16 -0700 (PDT) Message-ID: Date: Fri, 26 Jul 2024 11:45:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm: huge_memory: don't start_stop_khugepaged for non-PMD THP Content-Language: en-GB To: Barry Song <21cnbao@gmail.com>, David Hildenbrand Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Barry Song , Lance Yang , Baolin Wang , Yang Shi , Zi Yan References: <20240726082818.260008-1-21cnbao@gmail.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 9A4E7C0024 X-Stat-Signature: krpi4874sij3hh8d3q87sx94upbr8y9q X-Rspam-User: X-HE-Tag: 1721990719-587081 X-HE-Meta: U2FsdGVkX1/dYUWc6ZlZpHs4zhSjymg/WNB1CMoqymxzfg05OtSJDjJRAYvvg8Z4qX8f/itNojrB4A3KI6nLf8AbltD3R7MZTL+ZkwRtWAn2J82EqAZkYKU0un2dYh0gjOx+b46rSyxCyVC2z+Msnl+Ao/vg/eRD+hVLEMthroLgwERlCCWPNnmB8dNoACqNQ4ioSL5di4mGM6nqSP0dr+rb+2qyRR6QIN30lpKOs5/RVI9n8RGWRZk1WK8OwieYM5ktId2+bZF+7xEPZVLwwSkWAvLqhExRlmqAExOBke24mAs7/bLy4aIrbHWh3YShRq3BcNb+Px8G8ZE8vKTeYsvzm4W0IsQLBifW72NfV05FHATcJrCkoL8V/jairK8+X9z/a9vXxwAuanyFbSSubpeXqmHq5JNmFiqAnmdQPWSdZ4xialUl4Kcf3mDLUFSbEJRoesfjNWlF2wW44TXjVGTT8H3asb6aSHUwx2bLxsIjX/m+LBjQJWA3xxV62Tz4vSFCYZeQWAAULPxCEUpu1wzTZ9ABuZ9bOnUHoyU8lk95m2aSHnlBEY4ELxpW9eJwlU41ebMxlcIYvnJkiBUp487kF0KgZxS1HWZZqMQRjXPS1H+sj7WIOSiONR09IS4mh10GW879U//QHjDYBdJjauSi2R0kncsQxPhOpHnuK2ygTjZIu2+2fcYtBQvGRuLl2rqN9IEdHCOUvf4CnGzS/RgqZAKWkaM5sfyunvvnzKJcMl98VP3EYlQCcaBQD8CNH782bNV6rxVTqWZJyGIrLORx/BO2EMWWSx1z6H4nyU50P8yAYjZJi9aBbokJ3Q+Fli810ipER3q00midxKLCbCjpCiESLRz/Eun5h9VVfAPbkhRd1vR80rHmCqfdCg69izpeRK9mmBwm3zQis0v3Crnk4G8RLG4JunM3hBEoCwct3n+dMqUSJPQVNgKnoyFKdKSPsWGtgyHwvThZOow bN5eRIiW x4fcdkZ2NbbQo5TfgKi8AOFO3RSP/E7kvRw8mN2iwnTfg/ReuJUE2bNVOKgr+k6sgA176Ao2kziYmzLf9glxK3Ts94jyF1oVIXZ0LvQb4SaVfGxix2Bf3+VDN9URHZCZYeB/vYm4HeVniQ/edq14eQJkuNUOmk9i6dbaWJITnXCzOTYbTq1yJCHP4LGS4uuZBbVfqsNx+63XJ1kJI5/AOgfFLCQF8ph4mLv3+8Qh3KTfuop7qW/RdCm0riW2wNCafU6Uhpb4kIOmRbDFVEpV271z8S4zjPOnIHCSL37N/neBnEYOoOvEd8rY//3hTy189zUDyraWTMS3TZVNd7M4t1kq09DPcpA2fouiqcbVs8fKzJUEqiRtMbIhDuHCDJlUbuw4JbRFLWrq36wa5GXkoS7KqiBVy+dAHgk8pdiQ9SfaORvk= 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 26/07/2024 11:04, Barry Song wrote: > On Fri, Jul 26, 2024 at 9:48 PM David Hildenbrand wrote: >> >> On 26.07.24 11:43, Ryan Roberts wrote: >>> On 26/07/2024 09:28, Barry Song wrote: >>>> From: Barry Song >>>> >>>> khugepaged will be automatically started when PMD-sized THP is enabled >>>> (either of the per-size anon control or the top-level control are set >>>> to "always" or "madvise"), and it'll be automatically shutdown when >>>> PMD-sized THP is disabled (when both the per-size anon control and the >>>> top-level control are "never"). >>>> >>>> It seems unnecessary to call start_stop_khugepaged() for non-PMD THP, >>>> as it would only waste CPU time. >>>> >>>> Cc: Lance Yang >>>> Cc: Ryan Roberts >>>> Cc: Baolin Wang >>>> Cc: David Hildenbrand >>>> Cc: Yang Shi >>>> Cc: Zi Yan >>>> Signed-off-by: Barry Song >>>> --- >>>> mm/huge_memory.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c >>>> index 41460847988c..bd365e35acf7 100644 >>>> --- a/mm/huge_memory.c >>>> +++ b/mm/huge_memory.c >>>> @@ -514,7 +514,7 @@ static ssize_t thpsize_enabled_store(struct kobject *kobj, >>>> } else >>>> ret = -EINVAL; >>>> >>>> - if (ret > 0) { >>>> + if (ret > 0 && order == HPAGE_PMD_ORDER) { >>>> int err; >>>> >>>> err = start_stop_khugepaged(); >>> >>> Personally I see this as a bit of a layering violation; its >>> start_stop_khugepaged() that should decide the policy for when to start and stop >>> the daemon. thpsize_enabled_store() should just be calling >>> start_stop_khugepaged() to notify that something potentially pertinent to the a >>> policy decision has changed. >> > > My impression is that it slightly deviates from the huge page documentation in > Documentation/admin-guide/mm/transhuge.rst. > > khugepaged will be automatically started when PMD-sized THP is enabled > (either of the per-size anon control or the top-level control are set > to "always" or "madvise"), and it'll be automatically shutdown when > PMD-sized THP is disabled (when both the per-size anon control and the > top-level control are "never"). But start_stop_khugepaged() doesn't unconditionally start khugepaged, it takes action based on hugepage_pmd_enabled() which only returns true if there are any pmd sized THP enabled (currently looking at anon and file, but should also look at shmem in future; that's a known bug that's been there forever). So I don't think it is inconsistent with the documentation? > > non-PMD size is not involved in khugepaged, but I agree the policy might change > in the future. > >> Agreed, skimming the subject I was under the impression that we would be >> fixing something here. > > working on another swapin_enabled and reviewing the enabled source code. > I don't need this startstop for all sizes in that case, so I made a > quick adjustment > to this part as well. If neither of you likes it, that's fine with me :-) > >> >> -- >> Cheers, >> >> David / dhildenb >> > > Thanks > Barry