Message ID | 20240216114045.24828-1-byungchul@sk.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-68536-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp451339dyb; Fri, 16 Feb 2024 03:41:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV3jVHFq+e4OrsRb6Mu/YOf6sarZvcczaKCF2ArWUMX4LL/YL/JTm5pdJDT07N2nquttZCc3khUmVkgVcaT0wQ58ehh1Q== X-Google-Smtp-Source: AGHT+IHOiBiHocypygEb3P7gkfaxPvOnmI8n9pdUOpPCqzBe9wCKpYlO2IrSTDRgAxTjLIeAqcAL X-Received: by 2002:a05:6a21:31c8:b0:19e:ca72:9420 with SMTP id zb8-20020a056a2131c800b0019eca729420mr4927370pzb.57.1708083680720; Fri, 16 Feb 2024 03:41:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708083680; cv=pass; d=google.com; s=arc-20160816; b=OfmP4t8RJ430iPLd0DjQza8EfMOCapnTRm9XYhkCBYPZFLgJZi6VJ5F420S7lIoNB/ 6jHaeJmiXLjKW1x0a3w6t3fWu2COuj4rb68dKDYYAoJKC9J5rsoDpZObsOkwuw8Kbkb3 2PVMMBDzoUhxy01DMZ/FRGeVxpk9IySV3JmgmoZ4RxRciUr6FfrHjuzfkFIdI2d5titT pd1pUULFvfUhbXeXyC2kw/eGxJyqIPkRAKIjv2RnjTc/C2ko1Kh6SF3+obhL1676MDbj Ua4y2TNc0XX8qcB3Ibz2eZCfKKleDnyuHn+rQdDSPHarwsuXL2BZuU3HiYDAVsVHllbg LX4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=ivZo6uh3Un/VCOyfN2ySsjpXKhlpcdjC80yKcqJDW0o=; fh=9zEYt4zz6rI+VqvqNwRVmEtZ8tn4doHELJIRnrdpBTA=; b=IIi3wXiAZEzeNGyjoWTwYCBhd9eiAWMCo4yuApFu7TVzWMkwomI/m9mJynQ9jMJeD7 4qKDRcMoSeySw/ZSZRehTqEUppVzQaVCwrZyh0l9oEujCasRSD9I/QT2ZPyO1zXRJLLz 9jxbn7orWjNyLpKuzCQzGiRxb1dvQ0Bu6UYcWbpIPVLpLq1oyjnnv/SSUweWHmX6jtGe T/SjLgxQiZ9Umto+qOXaDl5vduTi8/scgf6fGPYZYMp7DQPTk977+q6wPN2BUzJok4/P WOAjgFTQCwXvbei4GmLK9iVZ03ZSgcP/3+6Sq57fSj/MyL8YtlbjGDHsUUpTFxixZix/ TEow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-kernel+bounces-68536-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68536-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l7-20020a170903120700b001db29e31989si2919978plh.327.2024.02.16.03.41.20 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 03:41:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68536-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-kernel+bounces-68536-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68536-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8DF59283792 for <ouuuleilei@gmail.com>; Fri, 16 Feb 2024 11:41:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C64A477F2F; Fri, 16 Feb 2024 11:41:07 +0000 (UTC) Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 980C81E532 for <linux-kernel@vger.kernel.org>; Fri, 16 Feb 2024 11:40:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=166.125.252.92 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708083666; cv=none; b=VHJTt9rOojP1C2rs+7Q29snwUOOCp2B1Ze2ZAitGFa3sk5tOcLipx8HcQMbnA1UP8Lrw+ohxpPMk2ANL4e4LsdQF1f8PIN5ehes3oIFbVD0PdsGKYW8wCigIay2YemgcJKdtTwo/eYYtfxJcSNfQu8nBJ7/3fR4sWZ4X4/EZOQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708083666; c=relaxed/simple; bh=1DTsuV0GohoVyTNm9GIav9horrUC6znhfC34fbIjuiQ=; h=From:To:Cc:Subject:Date:Message-Id; b=DC4/gFyfDZdJfCar1O0UmMnRknDxuwG1pTrIjIM/hqWJ6GtVnMgVaLkWeFxeUlBLdEWv6aJ4cFxR6FiTbp7BhTzLnpUdI6oljHZlLFouU4oLumHIki4JoKXojccw/knpp22/4aKsW7dAdp70uSIKihc9aZ3jqmQM/xGd8I9cHuk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com; spf=pass smtp.mailfrom=sk.com; arc=none smtp.client-ip=166.125.252.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sk.com X-AuditID: a67dfc5b-d6dff70000001748-3c-65cf49c77cc0 From: Byungchul Park <byungchul@sk.com> To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel_team@skhynix.com, akpm@linux-foundation.org Subject: [PATCH v3] sched/numa, mm: do not promote folios to nodes not set N_MEMORY Date: Fri, 16 Feb 2024 20:40:45 +0900 Message-Id: <20240216114045.24828-1-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDLMWRmVeSWpSXmKPExsXC9ZZnke5xz/OpBg0/9S3mrF/DZnHp8VU2 i+kvG1ksnk7Yymxxt38qi8XlXXPYLO6t+c9qMfndM0aLSwcWMFkc7z3AZLGv4wGTRceRb8wW W49+Z3fg9Vgzbw2jR8u+W+weCzaVemxeoeWx6dMkdo871/aweZyY8ZvF4/2+q2wem09Xe3ze JBfAFcVlk5Kak1mWWqRvl8CVMWHvEaaCezwVBw++YmxgnM/VxcjJISFgIrF4229GGHvVhT/s IDabgLrEjRs/mbsYuThEBN4wSnQuO8MGkmAWyJNo/d/HBGILCwRLnLx1kLWLkYODRUBVoqPf FSTMK2AqceRHHwvETHmJ1RsOgM2RENjAJnHw5jeoZZISB1fcYJnAyL2AkWEVo1BmXlluYmaO iV5GZV5mhV5yfu4mRmAYLqv9E72D8dOF4EOMAhyMSjy8B/6cTRViTSwrrsw9xCjBwawkwjup 90yqEG9KYmVValF+fFFpTmrxIUZpDhYlcV6jb+UpQgLpiSWp2ampBalFMFkmDk6pBkaBradn 6ahe5O42LZ5vGL7ZoUqJ8xZ7eWuxnGKrnkM282SBQ3c1EuMvv622czE7f/qa3uTD5cc4vY5F nBctfC7l9yRReoLB5QWByqly5e9bOns5lqtw6clUMa7V1Dp8d3mb/U47sQ/KVg8v3RQ4Ef6V uYj5xlG22qaHsz2iv/B2a7/rLn/6XomlOCPRUIu5qDgRAA88nK8/AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMLMWRmVeSWpSXmKPExsXC5WfdrHvc83yqwcQmWYs569ewWVx6fJXN YvrLRhaLpxO2Mlvc7Z/KYnF47klWi8u75rBZ3Fvzn9Vi8rtnjBaXDixgsjjee4DJYl/HAyaL jiPfmC22Hv3O7sDnsWbeGkaPln232D0WbCr12LxCy2PTp0nsHneu7WHzODHjN4vH+31X2TwW v/jA5LH5dLXH501yAdxRXDYpqTmZZalF+nYJXBkT9h5hKrjHU3Hw4CvGBsb5XF2MnBwSAiYS qy78YQex2QTUJW7c+MncxcjFISLwhlGic9kZNpAEs0CeROv/PiYQW1ggWOLkrYOsXYwcHCwC qhId/a4gYV4BU4kjP/pYIGbKS6zecIB5AiPHAkaGVYwimXlluYmZOaZ6xdkZlXmZFXrJ+bmb GIFBtaz2z8QdjF8uux9iFOBgVOLhPfDnbKoQa2JZcWXuIUYJDmYlEd5JvWdShXhTEiurUovy 44tKc1KLDzFKc7AoifN6hacmCAmkJ5akZqemFqQWwWSZODilGhgtotVPvXe8OW9DV/vaAqvd Zmf3cyYzZjBWd1xvDedvaVt8Infa7L1Nbhs8uQ7ePhgTkDVt3sW2NCkvn4UBkXVZK/Y3ZPn/ mJPS+uPkpyO8i7ReRtcE9Cm8/Xor5PcN17VnFgd32kr7JpytE1tvyf2j9/iTzZpblnKER+zy 4z6148zahU4+f3KUWIozEg21mIuKEwGVPcGaJgIAAA== X-CFilter-Loop: Reflected Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790845242980983620 X-GMAIL-MSGID: 1791055553430093438 |
Series |
[v3] sched/numa, mm: do not promote folios to nodes not set N_MEMORY
|
|
Commit Message
Byungchul Park
Feb. 16, 2024, 11:40 a.m. UTC
Changes from v2: 1. Rewrite the comment in code and the commit message becasue it turns out that this patch is not the real fix for the oops descriped. The real fix goes in another patch below: https://lore.kernel.org/lkml/20240216111502.79759-1-byungchul@sk.com/ Changes from v1: 1. Trim the verbose oops in the commit message. (feedbacked by Phil Auld) 2. Rewrite a comment in code. (feedbacked by Phil Auld) --->8--- From 150af2f78e19217a1d03e47e3ee5279684590fb4 Mon Sep 17 00:00:00 2001 From: Byungchul Park <byungchul@sk.com> Date: Fri, 16 Feb 2024 20:18:10 +0900 Subject: [PATCH v3] sched/numa, mm: do not promote folios to nodes not set N_MEMORY A numa node might not have its local memory but CPUs. Promoting a folio to the node's local memory is nonsense. So avoid nodes not set N_MEMORY from getting promoted. Signed-off-by: Byungchul Park <byungchul@sk.com> --- kernel/sched/fair.c | 7 +++++++ 1 file changed, 7 insertions(+)
Comments
On Fri, Feb 16, 2024 at 08:40:45PM +0900, Byungchul Park wrote: > From 150af2f78e19217a1d03e47e3ee5279684590fb4 Mon Sep 17 00:00:00 2001 > From: Byungchul Park <byungchul@sk.com> > Date: Fri, 16 Feb 2024 20:18:10 +0900 > Subject: [PATCH v3] sched/numa, mm: do not promote folios to nodes not set N_MEMORY "do not try to promote folios to memoryless nodes" because AFAICS we are just trying. Even if should_numa_migrate_memory() returns true, I assume that we will fail somewhere down the chain e.g: migrate_pages() when we see that this node does not any memory, right? > A numa node might not have its local memory but CPUs. Promoting a folio > to the node's local memory is nonsense. So avoid nodes not set N_MEMORY > from getting promoted. If you talk about memoryless nodes everybody gets it better IMHO. "Memoryless nodes do not have any memory to migrate to, so stop trying it." > Signed-off-by: Byungchul Park <byungchul@sk.com> > --- > kernel/sched/fair.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index d7a3c63a2171..7ed9ef3c0134 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -1828,6 +1828,13 @@ bool should_numa_migrate_memory(struct task_struct *p, struct folio *folio, > int dst_nid = cpu_to_node(dst_cpu); > int last_cpupid, this_cpupid; > > + /* > + * A node of dst_nid might not have its local memory. Promoting > + * a folio to the node is meaningless. > + */ > + if (!node_state(dst_nid, N_MEMORY)) > + return false; "Cannot migrate to memoryless nodes" seems shorter and more clear. So, what happens when we return true here? will we fail at migrate_pages() I guess? That is quite down the road so I guess this check can save us some time.
On Fri, Feb 16, 2024 at 02:51:24PM +0100, Oscar Salvador wrote: > On Fri, Feb 16, 2024 at 08:40:45PM +0900, Byungchul Park wrote: > > From 150af2f78e19217a1d03e47e3ee5279684590fb4 Mon Sep 17 00:00:00 2001 > > From: Byungchul Park <byungchul@sk.com> > > Date: Fri, 16 Feb 2024 20:18:10 +0900 > > Subject: [PATCH v3] sched/numa, mm: do not promote folios to nodes not set N_MEMORY > > "do not try to promote folios to memoryless nodes" Thinking some more, promote might be misleading, just something like "do not try to migrate memory to memoryless nodes". As this is not a bug fix but an optimization, as we will fail anyways in migrate_misplaced_folio() when migrate_balanced_pgdat() notices that we do not have any memory on that code. With the other comments addressed: Reviewed-by: Oscar Salvador <osalvador@suse.de> > > because AFAICS we are just trying. > Even if should_numa_migrate_memory() returns true, I assume that we will > fail somewhere down the chain e.g: migrate_pages() when we see that this > node does not any memory, right? > > > A numa node might not have its local memory but CPUs. Promoting a folio > > to the node's local memory is nonsense. So avoid nodes not set N_MEMORY > > from getting promoted. > > If you talk about memoryless nodes everybody gets it better IMHO. > "Memoryless nodes do not have any memory to migrate to, so stop trying it." > > > > Signed-off-by: Byungchul Park <byungchul@sk.com> > > --- > > kernel/sched/fair.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index d7a3c63a2171..7ed9ef3c0134 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -1828,6 +1828,13 @@ bool should_numa_migrate_memory(struct task_struct *p, struct folio *folio, > > int dst_nid = cpu_to_node(dst_cpu); > > int last_cpupid, this_cpupid; > > > > + /* > > + * A node of dst_nid might not have its local memory. Promoting > > + * a folio to the node is meaningless. > > + */ > > + if (!node_state(dst_nid, N_MEMORY)) > > + return false; > > "Cannot migrate to memoryless nodes" > > seems shorter and more clear. > > So, what happens when we return true here? will we fail at > migrate_pages() I guess? That is quite down the road so I guess > this check can save us some time. > > > -- > Oscar Salvador > SUSE Labs >
On Fri, Feb 16, 2024 at 02:51:24PM +0100, Oscar Salvador wrote: > On Fri, Feb 16, 2024 at 08:40:45PM +0900, Byungchul Park wrote: > > From 150af2f78e19217a1d03e47e3ee5279684590fb4 Mon Sep 17 00:00:00 2001 > > From: Byungchul Park <byungchul@sk.com> > > Date: Fri, 16 Feb 2024 20:18:10 +0900 > > Subject: [PATCH v3] sched/numa, mm: do not promote folios to nodes not set N_MEMORY > > "do not try to promote folios to memoryless nodes" Thank you. I will. > because AFAICS we are just trying. > Even if should_numa_migrate_memory() returns true, I assume that we will > fail somewhere down the chain e.g: migrate_pages() when we see that this > node does not any memory, right? Yes. > > A numa node might not have its local memory but CPUs. Promoting a folio > > to the node's local memory is nonsense. So avoid nodes not set N_MEMORY > > from getting promoted. > > If you talk about memoryless nodes everybody gets it better IMHO. > "Memoryless nodes do not have any memory to migrate to, so stop trying it." Much better. > > Signed-off-by: Byungchul Park <byungchul@sk.com> > > --- > > kernel/sched/fair.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index d7a3c63a2171..7ed9ef3c0134 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -1828,6 +1828,13 @@ bool should_numa_migrate_memory(struct task_struct *p, struct folio *folio, > > int dst_nid = cpu_to_node(dst_cpu); > > int last_cpupid, this_cpupid; > > > > + /* > > + * A node of dst_nid might not have its local memory. Promoting > > + * a folio to the node is meaningless. > > + */ > > + if (!node_state(dst_nid, N_MEMORY)) > > + return false; > > "Cannot migrate to memoryless nodes" > > seems shorter and more clear. Agree. Byungchul > So, what happens when we return true here? will we fail at > migrate_pages() I guess? That is quite down the road so I guess > this check can save us some time. > > > -- > Oscar Salvador > SUSE Labs
On Sun, Feb 18, 2024 at 08:46:16AM +0100, Oscar Salvador wrote: > On Fri, Feb 16, 2024 at 02:51:24PM +0100, Oscar Salvador wrote: > > On Fri, Feb 16, 2024 at 08:40:45PM +0900, Byungchul Park wrote: > > > From 150af2f78e19217a1d03e47e3ee5279684590fb4 Mon Sep 17 00:00:00 2001 > > > From: Byungchul Park <byungchul@sk.com> > > > Date: Fri, 16 Feb 2024 20:18:10 +0900 > > > Subject: [PATCH v3] sched/numa, mm: do not promote folios to nodes not set N_MEMORY > > > > "do not try to promote folios to memoryless nodes" > > Thinking some more, promote might be misleading, just something like > "do not try to migrate memory to memoryless nodes". Thank you. I will. > As this is not a bug fix but an optimization, as we will fail anyways > in migrate_misplaced_folio() when migrate_balanced_pgdat() notices that > we do not have any memory on that code. > > With the other comments addressed: > > Reviewed-by: Oscar Salvador <osalvador@suse.de> Thank you for reviewing. Byungchul > > because AFAICS we are just trying. > > Even if should_numa_migrate_memory() returns true, I assume that we will > > fail somewhere down the chain e.g: migrate_pages() when we see that this > > node does not any memory, right? > > > > > A numa node might not have its local memory but CPUs. Promoting a folio > > > to the node's local memory is nonsense. So avoid nodes not set N_MEMORY > > > from getting promoted. > > > > If you talk about memoryless nodes everybody gets it better IMHO. > > "Memoryless nodes do not have any memory to migrate to, so stop trying it." > > > > > > > Signed-off-by: Byungchul Park <byungchul@sk.com> > > > --- > > > kernel/sched/fair.c | 7 +++++++ > > > 1 file changed, 7 insertions(+) > > > > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > > index d7a3c63a2171..7ed9ef3c0134 100644 > > > --- a/kernel/sched/fair.c > > > +++ b/kernel/sched/fair.c > > > @@ -1828,6 +1828,13 @@ bool should_numa_migrate_memory(struct task_struct *p, struct folio *folio, > > > int dst_nid = cpu_to_node(dst_cpu); > > > int last_cpupid, this_cpupid; > > > > > > + /* > > > + * A node of dst_nid might not have its local memory. Promoting > > > + * a folio to the node is meaningless. > > > + */ > > > + if (!node_state(dst_nid, N_MEMORY)) > > > + return false; > > > > "Cannot migrate to memoryless nodes" > > > > seems shorter and more clear. > > > > So, what happens when we return true here? will we fail at > > migrate_pages() I guess? That is quite down the road so I guess > > this check can save us some time. > > > > > > -- > > Oscar Salvador > > SUSE Labs > > > > -- > Oscar Salvador > SUSE Labs
On 16.02.24 12:40, Byungchul Park wrote: > Changes from v2: > 1. Rewrite the comment in code and the commit message becasue it > turns out that this patch is not the real fix for the oops > descriped. The real fix goes in another patch below: > > https://lore.kernel.org/lkml/20240216111502.79759-1-byungchul@sk.com/ > > Changes from v1: > 1. Trim the verbose oops in the commit message. (feedbacked by > Phil Auld) > 2. Rewrite a comment in code. (feedbacked by Phil Auld) > > --->8--- > From 150af2f78e19217a1d03e47e3ee5279684590fb4 Mon Sep 17 00:00:00 2001 > From: Byungchul Park <byungchul@sk.com> > Date: Fri, 16 Feb 2024 20:18:10 +0900 > Subject: [PATCH v3] sched/numa, mm: do not promote folios to nodes not set N_MEMORY > > A numa node might not have its local memory but CPUs. Promoting a folio > to the node's local memory is nonsense. So avoid nodes not set N_MEMORY > from getting promoted. So there is no bug/panic that can be triggered and this is not a "fix" but an optimization? > > Signed-off-by: Byungchul Park <byungchul@sk.com> > --- > kernel/sched/fair.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index d7a3c63a2171..7ed9ef3c0134 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -1828,6 +1828,13 @@ bool should_numa_migrate_memory(struct task_struct *p, struct folio *folio, > int dst_nid = cpu_to_node(dst_cpu); > int last_cpupid, this_cpupid; > > + /* > + * A node of dst_nid might not have its local memory. Promoting > + * a folio to the node is meaningless. > + */ > + if (!node_state(dst_nid, N_MEMORY)) > + return false; > + > /* > * The pages in slow memory node should be migrated according > * to hot/cold instead of private/shared. Acked-by: David Hildenbrand <david@redhat.com>
On Mon, Feb 19, 2024 at 11:08:54AM +0900 Byungchul Park wrote: > On Fri, Feb 16, 2024 at 02:51:24PM +0100, Oscar Salvador wrote: > > On Fri, Feb 16, 2024 at 08:40:45PM +0900, Byungchul Park wrote: > > > From 150af2f78e19217a1d03e47e3ee5279684590fb4 Mon Sep 17 00:00:00 2001 > > > From: Byungchul Park <byungchul@sk.com> > > > Date: Fri, 16 Feb 2024 20:18:10 +0900 > > > Subject: [PATCH v3] sched/numa, mm: do not promote folios to nodes not set N_MEMORY > > > > "do not try to promote folios to memoryless nodes" > > Thank you. I will. > > > because AFAICS we are just trying. > > Even if should_numa_migrate_memory() returns true, I assume that we will > > fail somewhere down the chain e.g: migrate_pages() when we see that this > > node does not any memory, right? > > Yes. > > > > A numa node might not have its local memory but CPUs. Promoting a folio > > > to the node's local memory is nonsense. So avoid nodes not set N_MEMORY > > > from getting promoted. > > > > If you talk about memoryless nodes everybody gets it better IMHO. > > "Memoryless nodes do not have any memory to migrate to, so stop trying it." > > Much better. > > > > Signed-off-by: Byungchul Park <byungchul@sk.com> > > > --- > > > kernel/sched/fair.c | 7 +++++++ > > > 1 file changed, 7 insertions(+) > > > > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > > index d7a3c63a2171..7ed9ef3c0134 100644 > > > --- a/kernel/sched/fair.c > > > +++ b/kernel/sched/fair.c > > > @@ -1828,6 +1828,13 @@ bool should_numa_migrate_memory(struct task_struct *p, struct folio *folio, > > > int dst_nid = cpu_to_node(dst_cpu); > > > int last_cpupid, this_cpupid; > > > > > > + /* > > > + * A node of dst_nid might not have its local memory. Promoting > > > + * a folio to the node is meaningless. > > > + */ > > > + if (!node_state(dst_nid, N_MEMORY)) > > > + return false; > > > > "Cannot migrate to memoryless nodes" > > > > seems shorter and more clear. > > Agree. > We clearly have dst_cpu when we call this so I still think a check could be done farther up. But this one still looks reasonable to me. Thanks, Phil Reviewed-by: Phil Auld <pauld@redhat.com> > Byungchul > > > So, what happens when we return true here? will we fail at > > migrate_pages() I guess? That is quite down the road so I guess > > this check can save us some time. > > > > > > -- > > Oscar Salvador > > SUSE Labs > --
On Sun, 18 Feb 2024, Oscar Salvador wrote: >On Fri, Feb 16, 2024 at 02:51:24PM +0100, Oscar Salvador wrote: >> On Fri, Feb 16, 2024 at 08:40:45PM +0900, Byungchul Park wrote: >> > From 150af2f78e19217a1d03e47e3ee5279684590fb4 Mon Sep 17 00:00:00 2001 >> > From: Byungchul Park <byungchul@sk.com> >> > Date: Fri, 16 Feb 2024 20:18:10 +0900 >> > Subject: [PATCH v3] sched/numa, mm: do not promote folios to nodes not set N_MEMORY >> >> "do not try to promote folios to memoryless nodes" > >Thinking some more, promote might be misleading, just something like >"do not try to migrate memory to memoryless nodes". Yes. Does this also want an unlikely()? Not that it would be measurable. >As this is not a bug fix but an optimization, as we will fail anyways >in migrate_misplaced_folio() when migrate_balanced_pgdat() notices that >we do not have any memory on that code. This should be in the changelog and the subject is misleading as well. Reviewed-by: Davidlohr Bueso <dave@stgolabs.net> > >With the other comments addressed: > >Reviewed-by: Oscar Salvador <osalvador@suse.de> > >> >> because AFAICS we are just trying. >> Even if should_numa_migrate_memory() returns true, I assume that we will >> fail somewhere down the chain e.g: migrate_pages() when we see that this >> node does not any memory, right? >> >> > A numa node might not have its local memory but CPUs. Promoting a folio >> > to the node's local memory is nonsense. So avoid nodes not set N_MEMORY >> > from getting promoted. >> >> If you talk about memoryless nodes everybody gets it better IMHO. >> "Memoryless nodes do not have any memory to migrate to, so stop trying it." >> >> >> > Signed-off-by: Byungchul Park <byungchul@sk.com> >> > --- >> > kernel/sched/fair.c | 7 +++++++ >> > 1 file changed, 7 insertions(+) >> > >> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> > index d7a3c63a2171..7ed9ef3c0134 100644 >> > --- a/kernel/sched/fair.c >> > +++ b/kernel/sched/fair.c >> > @@ -1828,6 +1828,13 @@ bool should_numa_migrate_memory(struct task_struct *p, struct folio *folio, >> > int dst_nid = cpu_to_node(dst_cpu); >> > int last_cpupid, this_cpupid; >> > >> > + /* >> > + * A node of dst_nid might not have its local memory. Promoting >> > + * a folio to the node is meaningless. >> > + */ >> > + if (!node_state(dst_nid, N_MEMORY)) >> > + return false; >> >> "Cannot migrate to memoryless nodes" >> >> seems shorter and more clear. >> >> So, what happens when we return true here? will we fail at >> migrate_pages() I guess? That is quite down the road so I guess >> this check can save us some time. >> >> >> -- >> Oscar Salvador >> SUSE Labs >> > >-- >Oscar Salvador >SUSE Labs >
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d7a3c63a2171..7ed9ef3c0134 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1828,6 +1828,13 @@ bool should_numa_migrate_memory(struct task_struct *p, struct folio *folio, int dst_nid = cpu_to_node(dst_cpu); int last_cpupid, this_cpupid; + /* + * A node of dst_nid might not have its local memory. Promoting + * a folio to the node is meaningless. + */ + if (!node_state(dst_nid, N_MEMORY)) + return false; + /* * The pages in slow memory node should be migrated according * to hot/cold instead of private/shared.