Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1342622rdb; Wed, 6 Dec 2023 16:28:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8HwAAqNsmNn6UeGZGtGOvsj/2oreFKtttktS6yGZiHqvAd2B4ZJTXrfx6nWiVM+iBJTwO X-Received: by 2002:a05:6a00:4205:b0:6ce:80e9:5e19 with SMTP id cd5-20020a056a00420500b006ce80e95e19mr2000164pfb.29.1701908933607; Wed, 06 Dec 2023 16:28:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701908933; cv=none; d=google.com; s=arc-20160816; b=OA+Yhj2bPzKuE9VmRJOHfy+JrlT86Ej9DhK2KsDTMbNX+2o2PZW1s2KcI+SYTr5lLF 37zS7BfygXMlDZhAPzfUiDhpNn49N4zbMbGAprJ0QZ5bW+VQyDhZ4RHkvmjZ+iOY+il5 ea21FkbYcye8Q6YCxdiTvBTEyBE+053Fs/jI7Q66qkt4FJ3VpA9tqUgPVoL0XmJGEvxU 5dRqdsSqGIJPf9s+iFhnIdxnFC2rbUH2ugUAlp/9g6gVpaoLBL8XCeiuz/Lw4IQRF2TK mQ7/csLUTfuk/DynExq6rZPCdfIFO40pI+VZ7c0CStST44eXSYCOmADMeaS7Oix2Q5/L 0TLA== 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=LtcIT3+1Vvf1IPQzjETz2qs5AIWZRfMHd/0ujKiNxjc=; fh=OPZt+TfCasQcFfjtcVitIxrj3KymWieGBJWA0LtZmYU=; b=OVBXArgQcd+erlTP1K0BiRwfelOEu2wby7Zm+nm3bgtZ6vWlLIKCSBP826fDspTDuF RgB9zrC+wCtMO16ABzo++xQemT+GOuKIK59DMdx4ryC6uXxrTjGYM08FxOfmwy0TbIJA iXbb4o/fWt390O2caKw8EU9UDtMwlSmmR5dU/hmJmXgbJtUZG8r1u7nsQIWW3+uJV4zn kvJPNh/oYTL2EiRJ6zNb3C2aZJ22mlvD+u8qJQbsWH6enTs0UhDfq8PzqzkcKG1aUSu4 m7NVaY12GktOLbi81gA4wbCUTifQZnNrPEYoc3mY8/AOux7rfhpJ8ulD9N8eXjCoIul4 CqUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AvAGigHs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id z6-20020a056a00240600b006c0e02cdadcsi191324pfh.208.2023.12.06.16.28.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 16:28:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AvAGigHs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 1D845801E738; Wed, 6 Dec 2023 16:28:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441977AbjLGA2c (ORCPT + 99 others); Wed, 6 Dec 2023 19:28:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232370AbjLGA2S (ORCPT ); Wed, 6 Dec 2023 19:28:18 -0500 Received: from mail-yw1-x1141.google.com (mail-yw1-x1141.google.com [IPv6:2607:f8b0:4864:20::1141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AD6910C4; Wed, 6 Dec 2023 16:28:22 -0800 (PST) Received: by mail-yw1-x1141.google.com with SMTP id 00721157ae682-5d7b1a8ec90so819167b3.2; Wed, 06 Dec 2023 16:28:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701908901; x=1702513701; 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=LtcIT3+1Vvf1IPQzjETz2qs5AIWZRfMHd/0ujKiNxjc=; b=AvAGigHsIaQj0KF+YJNWdgVdg/RwkGvr+0yuC2i/nZt2+SC80H5h+7H6yaNJd2/dO+ dlAWQKSl3PzCem9BgAjIhMdt/eMLI++mI0lV1kzIiruUqqtm/o6Ts5Eq95q4qM2Fr/Dp GK3we/jOv+jyLZhGHcAGUwBR/dd5oFVLAycZYLnylxiTOqdo9ZREUp1NGVdrWoj4nhc6 lokgAyeSVe5BOS/qKYQ1lV4eMUh1MEKct7JCikljgKWWZpU2jcXDBJIXJJOc9SfHK10q jzqTLgMVz1Ign/7pDKC5YkZpTY0lUfzlXGwI+pp2YyNf8nKGte43rIFIj24U8/Jr+FwW p8HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701908901; x=1702513701; 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=LtcIT3+1Vvf1IPQzjETz2qs5AIWZRfMHd/0ujKiNxjc=; b=hLNUeYrH/HDB6GbuupeJO0cC7vrR5Qecyd3nszZImMpcAQMFY9R1izmrr5SyePVgU7 8LAyFzIpLJi0b3CRsNQCsoyuyYKElmLiYURtMh2ju95SLqw2OoBo8mJX1zrcWp9GYbZm ChlfdyV8BuOq9ohkxh72wDsNSkVpMnUqY2wssNr5VQQ57KBM78GoL++Jc7qyzsRUk6VY lZa4tatjLW67a9GwIkGiQ0o9V/W9j4gLwzxC2IXB3Vu7wCg6Ixi1MdFGutopoehvE6jw FBZumcrNp7Z3TsS3Y9iPi5qU/GJrRK+8poVhZqxeBxsT81drnTvRneL2j02miruJVBVM PNLw== X-Gm-Message-State: AOJu0YxA/KPQjvM8pzW+0+WPAarGUB9vtMDUGlv83WeVy/SCHWxrGnO8 EbPPomYRpmwK1p/HEMJrsnSo9es5UDc1 X-Received: by 2002:a05:690c:a06:b0:5d7:1940:8dd5 with SMTP id cg6-20020a05690c0a0600b005d719408dd5mr1208041ywb.60.1701908901467; Wed, 06 Dec 2023 16:28:21 -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 x145-20020a81a097000000b005d82fc8cc92sm19539ywg.105.2023.12.06.16.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 16:28:21 -0800 (PST) From: Gregory Price X-Google-Original-From: Gregory Price To: linux-mm@kvack.org, jgroves@micron.com, ravis.opensrc@micron.com, sthanneeru@micron.com, emirakhur@micron.com, Hasan.Maruf@amd.com Cc: linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.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, x86@kernel.org, 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 Subject: [RFC PATCH 06/11] mm/mempolicy: allow home_node to be set by mpol_new Date: Wed, 6 Dec 2023 19:27:54 -0500 Message-Id: <20231207002759.51418-7-gregory.price@memverge.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231207002759.51418-1-gregory.price@memverge.com> References: <20231207002759.51418-1-gregory.price@memverge.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 06 Dec 2023 16:28:52 -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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index fecdc781b6a0..4be63547a4b3 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -311,6 +311,7 @@ static struct mempolicy *mpol_new(struct mempolicy_args *args) policy->flags = flags; policy->home_node = NUMA_NO_NODE; policy->wil.cur_weight = 0; + policy->home_node = args->home_node; return policy; } @@ -1624,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); } @@ -2967,6 +2969,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)) @@ -3125,6 +3129,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__); @@ -3139,6 +3144,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); } @@ -3261,6 +3267,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