Message ID | 20240126132240.24518-1-luochunsheng@ustc.edu |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-40129-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:e09d:b0:103:945f:af90 with SMTP id gm29csp654302dyb; Fri, 26 Jan 2024 05:23:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhkq+nedS8F+1rsXX+z02cWPne8QW7E493FDNa37uRGZW0nMbhssLrAqJMxIi6GpUfWaaF X-Received: by 2002:a17:906:f9c9:b0:a31:58fc:bd83 with SMTP id lj9-20020a170906f9c900b00a3158fcbd83mr837971ejb.10.1706275400097; Fri, 26 Jan 2024 05:23:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706275400; cv=pass; d=google.com; s=arc-20160816; b=G8K85kLo4u7ewokjYdf6RIWdGQ/ovJUKKryf8dxw/ZmTvrs9h2766Irm4pVkFHdVte WtiSYv2p4wFKfjK2LMagGt7BQgpvBaaH2CAqn+SsiyOclfa5InBYUFFq9pHbcmBn0PNV gTlSBao1VK54cYfnEXCtyyWgN2SLde2p/v97jCt5kTkdJYeLuSIestUsnang2zbRwaJO mdoRzSgMf+UxCrCOMJHm2Djyrh6/jfkLHbmC8rpoT0u3s/5w9jiUtzUTujRZfai9fwdl iFdYvE5cKQXTk+2xAq4b2K/nlLjJwQfYoZ04xFNLNDV/nvW0GfCLzbTYJhA5NVZ/R2S3 TpGA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=14wpf6z8IKq3p4uqbz679bnQzGIxLBIASvO13vfqTvM=; fh=Gps2WlHT2FGWyEretgDsroJjmn2OHGl9PDc8SLKwie8=; b=NA4NwOv+ksHzt7i0xYWTMwl9pQNYlnxtfh/WUNRUKk32fUQdbu/pVx/KdY2aT71apK BhOAe0f3xddDvO0vMFBUL6e7z0doxaAydeXlb1/eviHEBcvsrj+lMa9tLYyTIo5ZLgkf ATiGNBm29ZNXIij1MI/4HRwR7svHtGPKfJ0SS1uhimIJTrXS6rOwZL+wIWi3RgLuhXA9 xTv9jk/B/Kftnpf0Yue/DV59U6Urg/fajSEuO5gboKlAGD5TdlFqvd0g/5AwSaOr+9nS CUxBmt/krA78eremM2tMirMzY8m/hDXgNCk6oBjp9X5ATGuNG4fIEY99nq9hyUOV9qeB NtgQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=ustc.edu dmarc=pass fromdomain=ustc.edu); spf=pass (google.com: domain of linux-kernel+bounces-40129-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40129-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ustc.edu Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id k7-20020a17090627c700b00a31074e5d35si598027ejc.79.2024.01.26.05.23.19 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 05:23:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40129-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=ustc.edu dmarc=pass fromdomain=ustc.edu); spf=pass (google.com: domain of linux-kernel+bounces-40129-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40129-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ustc.edu 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 am.mirrors.kernel.org (Postfix) with ESMTPS id AF2CD1F224E0 for <ouuuleilei@gmail.com>; Fri, 26 Jan 2024 13:23:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A687E1B971; Fri, 26 Jan 2024 13:23:05 +0000 (UTC) Received: from mail-m49197.qiye.163.com (mail-m49197.qiye.163.com [45.254.49.197]) (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 E181A1B940 for <linux-kernel@vger.kernel.org>; Fri, 26 Jan 2024 13:22:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706275384; cv=none; b=nXQBNXajGqLuMzdzI815GgBTXxnMo2WbL0qj7qyMTOwRoAgN1vr7065MXYj6rGD9BJCAxTvUjB9SDH9RtT0QgvxXa4dTuUiHucAtdpHAaJ5XfH6SGQ9KPtwyfM6MDC7FrDFXWS1D3M+F0M/BErTKubuPCs+PtRRQJ7PC9rIpxKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706275384; c=relaxed/simple; bh=iHHNC/KB9/++EkjfGa817hv7W5M7/4V/utIeoP4fako=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tCVsQ7Aow3xACOBpCsal+5s5aX7kgKJaxMcf9dAthDaD94LglBvwyIAv4D8+3N9oBXQvnQmPzNyg3TrCa5+rQkJ9dmPm059u+MzhD5cMF4SQWr0ko6MPxNVXF4R3+JXRLdjTiGQZb8Lg7HPSGf+8xp8lp68s3T2koQ1Tjm2IZb0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ustc.edu; spf=pass smtp.mailfrom=ustc.edu; arc=none smtp.client-ip=45.254.49.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ustc.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ustc.edu Received: from localhost.localdomain (unknown [61.151.228.146]) by smtp.qiye.163.com (Hmail) with ESMTPA id 84CB97E011A; Fri, 26 Jan 2024 21:22:44 +0800 (CST) From: Chunsheng Luo <luochunsheng@ustc.edu> To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chunsheng Luo <luochunsheng@ustc.edu> Subject: [PATCH] mempolicy: check home_node is in the nodes of policy Date: Fri, 26 Jan 2024 08:22:40 -0500 Message-ID: <20240126132240.24518-1-luochunsheng@ustc.edu> X-Mailer: git-send-email 2.43.0 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> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlDQk0YVkpPShlMTE4YTUhOSFUTARMWGhIXJBQOD1 lXWRgSC1lBWU1KVUpOSlVJSUNVSk9NWVdZFhoPEhUdFFlBWU9LSFVKSktISkNVSktLVUtZBg++ X-HM-Tid: 0a8d45efdf7703a2kunm84cb97e011a X-HM-MType: 10 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Mz46TBw5LjMKNg0QLREjHQ8V PzgaFEpVSlVKTEtNSUxOSE1OSk9LVTMWGhIXVRcOFBgTDhUIEx4VHDsOCA8YVR4fDkVZV1kSC1lB WU1KVUpOSlVJSUNVSk9NWVdZCAFZQUpPQkI3Bg++ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789159434020469900 X-GMAIL-MSGID: 1789159434020469900 |
Series |
mempolicy: check home_node is in the nodes of policy
|
|
Commit Message
Chunsheng Luo
Jan. 26, 2024, 1:22 p.m. UTC
set_mempolicy_home_node should be used after setting the memory
policy. If the home_node isn't in the nodes of policy, we should
return failure to avoid misunderstanding.
Signed-off-by: Chunsheng Luo <luochunsheng@ustc.edu>
---
mm/mempolicy.c | 6 ++++++
1 file changed, 6 insertions(+)
Comments
On Fri, 26 Jan 2024 08:22:40 -0500 Chunsheng Luo <luochunsheng@ustc.edu> wrote: > set_mempolicy_home_node should be used after setting the memory > policy. If the home_node isn't in the nodes of policy, we should > return failure to avoid misunderstanding. Thanks. Under what circumstances does userspace trigger this issue?
For example, In a system with NUMA nodes 0,1,2,3, i mbind process to node 0-2 and set home_node to node 3, it will not be allocated from node 3, then from node closer to node 3. But i think home_node should be set directly from node 0-2, which makes more sense. So i think it needs to return failure to prompt user. On 2024/1/28 16:29, Andrew Morton wrote: > On Fri, 26 Jan 2024 08:22:40 -0500 Chunsheng Luo <luochunsheng@ustc.edu> wrote: > >> set_mempolicy_home_node should be used after setting the memory >> policy. If the home_node isn't in the nodes of policy, we should >> return failure to avoid misunderstanding. > Thanks. Under what circumstances does userspace trigger this issue? >
On Fri, Jan 26, 2024 at 08:22:40AM -0500, Chunsheng Luo wrote: > set_mempolicy_home_node should be used after setting the memory > policy. If the home_node isn't in the nodes of policy, we should > return failure to avoid misunderstanding. > > Signed-off-by: Chunsheng Luo <luochunsheng@ustc.edu> > --- > mm/mempolicy.c | 6 ++++++ > 1 file changed, 6 insertions(+) > Since it's not possible to add/remove a node to a mask without also erasing the home node, this seems reasonable. e.g. this is what happens presently mbind(0-2) : mask(0,1,2), home_node(NUMA_NO_NODE) home_node(3) : mask(0,1,2), home_node(3) mbind(0-3) : mask(0,1,2,3), home_node(NUMA_NO_NODE) However, it is possible for a cgroup migration or a change to cpusets.mems_allowed to change a nodemask without somping the home_node. e.g.: mbind(2-3) : mask(2-3), home_node(NUMA_NO_NODE) home_node(3) : mask(2-3), home_node(3) cpusets(0-1) : mask(0-1), home_node(3) Should the rebind code also shift the home-node or un-set it accordingly to keep the mask/home_node behavior consistent with the syscalls? (see mpol_rebind_nodemask) > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > index 10a590ee1c89..9282be2ae18e 100644 > --- a/mm/mempolicy.c > +++ b/mm/mempolicy.c > @@ -1536,6 +1536,12 @@ SYSCALL_DEFINE4(set_mempolicy_home_node, unsigned long, start, unsigned long, le > err = -EOPNOTSUPP; > break; > } > + > + if (!node_isset(home_node, old->nodes)) { > + err = -EINVAL; > + break; > + } > + > new = mpol_dup(old); > if (IS_ERR(new)) { > err = PTR_ERR(new); > -- > 2.43.0 > >
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 10a590ee1c89..9282be2ae18e 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1536,6 +1536,12 @@ SYSCALL_DEFINE4(set_mempolicy_home_node, unsigned long, start, unsigned long, le err = -EOPNOTSUPP; break; } + + if (!node_isset(home_node, old->nodes)) { + err = -EINVAL; + break; + } + new = mpol_dup(old); if (IS_ERR(new)) { err = PTR_ERR(new);