From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-97.freemail.mail.aliyun.com (out30-97.freemail.mail.aliyun.com [115.124.30.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54F022BE7BA for ; Tue, 31 Mar 2026 09:17:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.97 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774948628; cv=none; b=BliK5HHr/0TVnjfLEUcybBw6qbAMSoNiBLm9zHWBvPjww00OSEWRILKWODmLq7HQc+9/YJBmQPAS2wFHXx9cjBl37XcC4rBxv2hGiAPL0WuoI13bpmqEVjjVdRs85fO45paAvYY/kSgZ+jrt2XXQst1+XutUdT8PuCUJ2BHJ6cI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774948628; c=relaxed/simple; bh=oIGReqqEMMCk5Z/PGHZzFDAai/y2oCT2JwclZCzlHn0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=EmFmMBsYHu43Zyy28qK5iqjZrGqFLlFffpIfvdO6tQ+WqrMX6P2D/zCO26srjXE8OxvxAM8MWSJKSS/G4IvwPkcKxOl3ARHsHEfsWECJrLKkEgZJTV8IGQA8aVw11ayaLv9BxWdc/evwOS2QdnwzU7HXhSjyLwg1SNroZMW3P8s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=hBWDTSPF; arc=none smtp.client-ip=115.124.30.97 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="hBWDTSPF" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1774948623; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; bh=KVOJiF6uwcHFWAX/3sTvyGHbX8XKYvu+j1EC4JDT8wE=; b=hBWDTSPFhxp5orttnLaYW+pe9YDNLgWh4U2toqcfg+gQc7ho+OSha7o1gNpgiLTfLBvcdAp6YJ6tWILCeaq14Fo9TfnZD4X3f+KXjdKeDNyiKJhou8fXKtx7p7nXAk6BzD4Ot5KReVxAvYCB/xVO4VKrSuefgxUzA+7q2L0R1m8= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045133197;MF=ying.huang@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0X03xQvk_1774948621; Received: from DESKTOP-5N7EMDA(mailfrom:ying.huang@linux.alibaba.com fp:SMTPD_---0X03xQvk_1774948621 cluster:ay36) by smtp.aliyun-inc.com; Tue, 31 Mar 2026 17:17:02 +0800 From: "Huang, Ying" To: Donet Tom Cc: "David Hildenbrand (Arm)" , Andrew Morton , Ingo Molnar , Peter Zijlstra , Ritesh Harjani , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Baolin Wang , Ying Huang , Juri Lelli , Mel Gorman , Vincent Guittot , Dietmar Eggemann , Steven Rostedt Subject: Re: [PATCH] sched/numa, mm: Skip page promotion if cpu pid is valid In-Reply-To: (Donet Tom's message of "Tue, 31 Mar 2026 14:33:10 +0530") References: <20260326071216.11883-1-donettom@linux.ibm.com> <2b8f30a6-a8d1-4ea5-8078-5eec399c8609@linux.ibm.com> <87cy0kpfdx.fsf@DESKTOP-5N7EMDA> Date: Tue, 31 Mar 2026 17:17:02 +0800 Message-ID: <875x6cpddd.fsf@DESKTOP-5N7EMDA> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Donet Tom writes: > Hi > > On 3/31/26 2:03 PM, Huang, Ying wrote: >> Hi, Donet, >> >> Donet Tom writes: >> >>> On 3/26/26 3:59 PM, David Hildenbrand (Arm) wrote: >>>> On 3/26/26 08:12, Donet Tom wrote: >>>>> If memory tiering is disabled, cpupid of slow memory pages may >>>>> contain a valid CPU and PID. If tiering is enabled at runtime, >>>>> there is a chance that in should_numa_migrate_memory(), this >>>>> valid CPU/PID is treated as a last access timestamp, leading >>>>> to unnecessary promotion. >>>> Is that measurable? Should we at least have a Fixes: ? >>>> >>>>> Prevent this by skipping promotion when cpupid is valid. >>>>> >>>>> Signed-off-by: Donet Tom >>>>> --- >>>>> kernel/sched/fair.c | 7 +++++++ >>>>> 1 file changed, 7 insertions(+) >>>>> >>>>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >>>>> index 4b43809a3fb1..f5830a5a94d5 100644 >>>>> --- a/kernel/sched/fair.c >>>>> +++ b/kernel/sched/fair.c >>>>> @@ -2001,6 +2001,13 @@ bool should_numa_migrate_memory(struct task_struct *p, struct folio *folio, >>>>> unsigned int latency, th, def_th; >>>>> long nr = folio_nr_pages(folio); >>>>> >>>> /* >>>> * When ... >>>> >>>>> + /* When tiering is enabled at runtime, last_cpupid may >>>>> + * hold a valid cpupid instead of an access timestamp. >>>>> + * If so, skip page promotion. >>>>> + */ >>>>> + if (cpupid_valid(folio_last_cpupid(folio))) >>>>> + return false; >>>>> + >>>> IIUC, as timestamp we use jiffies_to_msecs(). So, soon after bootup, >>>> we would no longer get false positives for cpupid_valid(). >>>> I suppose overflows are not a problem, correct? >>> Thank you, David, for guiding me in the right direction. >>> >>> I initially thought that overflows would not occur, and therefore >>> cpupid_valid() would not produce false positives. However, >>> after looking into it further, it appears that overflow can >>> happen when storing the access time. >>> >>> The last_cpupid field is used to store the last access time. >>> From the code, it appears that 21 bits are used for this >>> (#define LAST_CPUPID_SHIFT (LAST__PID_SHIFT + LAST__CPU_SHIFT)). >>> >>> With 21 bits, the maximum value that can be stored is >> It can be less than 21 bits, if CONFIG_NR_CPUS is small. >> >> DEFINE(NR_CPUS_BITS, order_base_2(CONFIG_NR_CPUS)); >> >>> 2097151ms (35Hrs) . If the access time exceeds this >>> range, it can overflow, which may lead to cpupid_valid() >>> returning false positives. >>> >>> I think we need a reliable way to determine cpupid_valid() that >>> does not produce false positives. >> Yes. IMHO, false positives is unavoidable. So, the patch fixes a >> temporal performance issue at the cost of a longstanding performance >> issue. Right? > > > I was trying to fix a functional issue. When memory tiering is > > enabled at runtime, treating last_cpupid as access time is incorrect, right? I don't think that it's a functional issue. It has only performance impact. Did you find any functionality bug? --- Best Regards, Huang, Ying