Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5629592rdb; Wed, 13 Dec 2023 14:43:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGr5I42LJ84TSupvHsJt/yWvdzfoJQCcJoG9aSm0ykeMyDpvbfFkp8YJiOhsYD8C1c+CY9z X-Received: by 2002:a05:6870:d91:b0:1fa:2f8:c734 with SMTP id mj17-20020a0568700d9100b001fa02f8c734mr9013250oab.5.1702507411919; Wed, 13 Dec 2023 14:43:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702507411; cv=none; d=google.com; s=arc-20160816; b=JT9nVMKiCxcJ4KnOoWqDOt0YmEvk5PELEO9XxT1KDIi8UMbSZ3OmVGX5Gpf4h6bWEU TNQTE8iy8LMjU1xK4gq5N5yT7fVzCMjGjK060AAD2u5ZkQ2dffuHIAaZXoO4cyNGWNFi 9gY4Jh5v1KvrVMOUla7dXoCvfwB5FQa7VN97s5W42USZqoABgoLBl/c9SJ8iQNhNV+50 /MHgrwdrB+4zAh4/4OwkxCr7WtDfdjDPc0Zx6wsd0QvSdzV94hVI/MQJPbjJKznPtF19 RzYzgRId+ueO4BGYrHyATGKJQgdRCdvMng5KyyFKTJDj9X0XnDT96In5FRPmq2eURBBI TYXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kuinRDVwejGOUKweWBi5ia3P52oTVKxYpBkFwLpVf+w=; fh=tBzJ0NKB+DWbP/kk9rYMQt7EghJKLCiF1I+bTxOTDlg=; b=mKScosrf9ahG4KfyiSutccSqG0RraRujGkEfSN/PiPrHUf9zK+lPOoY5Ht2NRY+vgB FDmmvbzOoyjXdOlKq6QrfOtpPRqG+Aj0oDPpRn0X7d3Qs6mjJJeTMbk1mBp+T8ObRtGa PAuzn+RqTD46FOUjHPixBKHNW5Ko4JpyepJIOv4mbHNWhz5yJljtSL9TzAtcwqll5dyu KUS3ghFuRN6z8eh9V8skOtnS0EGR1nQbuVaCi5nAkpYA9DL6pc/LEbMjn0Eig2ohNqDR cYjEAoikybMwDSjeKkpvSgeDZ5kG4JO/tsTvzuEUXvTB2hf4aOGzJNfm23QqOyr7GGh6 wa3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OFd+6VPB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id y21-20020a17090ad71500b00285a3d6ee55si11332272pju.27.2023.12.13.14.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 14:43:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OFd+6VPB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 4FBA781C4A9E; Wed, 13 Dec 2023 14:43:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442891AbjLMWll (ORCPT + 99 others); Wed, 13 Dec 2023 17:41:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442856AbjLMWlh (ORCPT ); Wed, 13 Dec 2023 17:41:37 -0500 Received: from mail-yw1-x1143.google.com (mail-yw1-x1143.google.com [IPv6:2607:f8b0:4864:20::1143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A016FF7; Wed, 13 Dec 2023 14:41:33 -0800 (PST) Received: by mail-yw1-x1143.google.com with SMTP id 00721157ae682-5e2f9e9a2e8so9246787b3.3; Wed, 13 Dec 2023 14:41:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702507293; x=1703112093; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kuinRDVwejGOUKweWBi5ia3P52oTVKxYpBkFwLpVf+w=; b=OFd+6VPBWT0NKrSa40iFNFZ9Fsymh0gee0FX90ynk7NUyN8gYViZCNZoFBnGDksux8 K2czosLyK0bkEQ4thL8yL1v/WBpXdSH6sMh2RzMRw+rOtSRxgPvcIiI0ZzwNu4X9pcCE ozmfU4I/RTzdpomIZ7ZpG9tTuIOUaVNGvXnsiKLfANX5PCs9q3QuNRIVettWPkFRsGL8 H9PK2nFb2HL96PEInUHcJuYPDzyTuuf0Xu+uUCwb32qTYGATfDa5mkIlkrshza/d5ndU dpF+kMI1whPX98lBZXHHjnFLeOaLOV1esdXt8+lU5B1JkZO8Ne/tpx1QkNGB3OywQUyp f0mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702507293; x=1703112093; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kuinRDVwejGOUKweWBi5ia3P52oTVKxYpBkFwLpVf+w=; b=rNmDdNBBfGmsvA3pv30Ebd2yO7xgOE1wtq1upfsbhns+kJz0JDIG121DxxoICl25Lq LcLF1gG6h9FWuNTjxjox8RPWbLr6C7M4dEL6Ohpd17zrqhFMneBA7H3cAaVJfIwzsy1V wft7Ze7I2pXT3Jb6JjFina+Vf+krFUEXdiW6pNZaQ9BQk4YpX4mkeuhD06S9dkXkidXt xYevxeUHjm/gOdDOFG75aJOe6f2iuZGZFggnLqgVDTSE0P6EvvEJIO9SRzHy94IF+OiI jsNv5LosqNJKy8wXiND6UhP9lizjH7Q/9gDXE6CF+8S8Jm5xBEF+XHpeYEwcraS3QTtE KQyQ== X-Gm-Message-State: AOJu0Yyqo4s68wuWwLNX9p6x2M+WHHP1I4eognoBqTvdaRFFMtHicXKO mbXXSgKm5WF4rx01dh4Tnw== X-Received: by 2002:a81:d248:0:b0:5d8:10a1:f504 with SMTP id m8-20020a81d248000000b005d810a1f504mr8354579ywl.82.1702507292772; Wed, 13 Dec 2023 14:41:32 -0800 (PST) Received: from fedora.mshome.net (pool-173-79-56-208.washdc.fios.verizon.net. [173.79.56.208]) by smtp.gmail.com with ESMTPSA id v4-20020a818504000000b005d9729068f5sm5050583ywf.42.2023.12.13.14.41.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 14:41:32 -0800 (PST) From: Gregory Price X-Google-Original-From: Gregory Price To: linux-mm@kvack.org Cc: linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, akpm@linux-foundation.org, arnd@arndb.de, tglx@linutronix.de, luto@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, mhocko@kernel.org, tj@kernel.org, ying.huang@intel.com, gregory.price@memverge.com, corbet@lwn.net, rakie.kim@sk.com, hyeongtak.ji@sk.com, honggyu.kim@sk.com, vtavarespetr@micron.com, peterz@infradead.org, jgroves@micron.com, ravis.opensrc@micron.com, sthanneeru@micron.com, emirakhur@micron.com, Hasan.Maruf@amd.com, seungjun.ha@samsung.com Subject: [PATCH v3 06/11] mm/mempolicy: allow home_node to be set by mpol_new Date: Wed, 13 Dec 2023 17:41:13 -0500 Message-Id: <20231213224118.1949-7-gregory.price@memverge.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231213224118.1949-1-gregory.price@memverge.com> References: <20231213224118.1949-1-gregory.price@memverge.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Dec 2023 14:43:23 -0800 (PST) This patch adds the plumbing into mpol_new() to allow the argument structure's home_node field to be set during mempolicy creation. The syscall sys_set_mempolicy_home_node was added to allow a home node to be registered for a vma. For set_mempolicy2 and mbind2 syscalls, it would be useful to add this as an extension to allow the user to submit a fully formed mempolicy configuration in a single call, rather than require multiple calls to configure a mempolicy. This will become particularly useful if/when pidfd interfaces to change process mempolicies from outside the task appear, as each call to change the mempolicy does an atomic swap of that policy in the task, rather than mutate the policy. Signed-off-by: Gregory Price --- mm/mempolicy.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 7956edcc57fd..705ddf1ccdd9 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -306,7 +306,7 @@ static struct mempolicy *mpol_new(struct mempolicy_args *args) atomic_set(&policy->refcnt, 1); policy->mode = mode; policy->flags = flags; - policy->home_node = NUMA_NO_NODE; + policy->home_node = args->home_node; policy->wil.cur_weight = 0; return policy; @@ -1625,6 +1625,7 @@ static long kernel_set_mempolicy(int mode, const unsigned long __user *nmask, args.mode = lmode; args.mode_flags = mode_flags; args.policy_nodes = &nodes; + args.home_node = NUMA_NO_NODE; return do_set_mempolicy(&args); } @@ -2985,6 +2986,8 @@ void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol) margs.mode = mpol->mode; margs.mode_flags = mpol->flags; margs.policy_nodes = &mpol->w.user_nodemask; + margs.home_node = NUMA_NO_NODE; + /* contextualize the tmpfs mount point mempolicy to this file */ npol = mpol_new(&margs); if (IS_ERR(npol)) @@ -3143,6 +3146,7 @@ void __init numa_policy_init(void) memset(&args, 0, sizeof(args)); args.mode = MPOL_INTERLEAVE; args.policy_nodes = &interleave_nodes; + args.home_node = NUMA_NO_NODE; if (do_set_mempolicy(&args)) pr_err("%s: interleaving failed\n", __func__); @@ -3157,6 +3161,7 @@ void numa_default_policy(void) memset(&args, 0, sizeof(args)); args.mode = MPOL_DEFAULT; + args.home_node = NUMA_NO_NODE; do_set_mempolicy(&args); } @@ -3279,6 +3284,8 @@ int mpol_parse_str(char *str, struct mempolicy **mpol) margs.mode = mode; margs.mode_flags = mode_flags; margs.policy_nodes = &nodes; + margs.home_node = NUMA_NO_NODE; + new = mpol_new(&margs); if (IS_ERR(new)) goto out; -- 2.39.1