Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2804127rdb; Fri, 8 Dec 2023 23:00:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IGY6RVSeLENfHnvLMWa7lVw4dWiZsDISY5hYqaJv06slgKcMk0Zb2ueJgEMly7z1N6S+rwj X-Received: by 2002:a05:6870:f155:b0:1fb:412:c2eb with SMTP id l21-20020a056870f15500b001fb0412c2ebmr1707574oac.50.1702105259534; Fri, 08 Dec 2023 23:00:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702105259; cv=none; d=google.com; s=arc-20160816; b=JqseZ6jofWBZqDrV3mIo3qSb5fO/GVOGrWmEEdB1LHWyZQ42vO7AxiI4lXlZH0QakI 3lbt3Lys5Lfx6iLrKx8+RHuIWmVcprgshBJb9sftn8NY2+o4XostL7P9WgBumQTXuXjR WP8q7OGrkz5OBakcE/CswVBq1nTczatTtfhx49T2WZZJ9eXsjH1nw18MjCfR2TGZ8Ihq 93harlAZ6T4DjGDxiCJ6fRN4NWU8s1cPm1yHN1CepCFl+RzLg+iJSV3dbAdtjEWqjxzP dLMfLjl/Vpo0yXsdAzUIgG+1jcVStQ5ZtTU7yPJbEow2mJoDnhpnqs3mZ2dTJf8Zl1dh bw/Q== 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=/jpJNV10Y4Aq3La+SspO/hMcopvAOMbrsn8P/kGKMEU=; fh=4h+lNWaGBWwAMYFT/XL3+M1KasTuMR4ccJCo5oEuKdU=; b=SNA+U2XdRB7rRczBicKXJeuH3/PBdh+o+RqmPnhyO6sA86OMmDF2rLaJ6khphc6+DY B24vBgqb/yNG/O9jY9uHprcDp/eg9icG1SKei3edy1WZE+GXVae1JS3+nk08KZiQMPKl uyGYuGPYeo4MzzRnn90SdaJmcVHFH10WqhOFhjVLddU5XPf6AFConthYJae7MgZen5qn c4Zm3XbSD919HXkdKuZgOS1w1AtkgELuQFVBvdYmHpeBrmqgPUr3ria5Sk0lyW/1U8tE sys/5YQOTWj+SKi+L79yunXuB2oDCcMre5C6EktKSKb9ybevQf8LexAARsRYBaswxRQR 6BbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nEJuVWm9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id b14-20020a17090a7ace00b002861c962e15si2741571pjl.15.2023.12.08.23.00.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 23:00:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nEJuVWm9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 4FDBB805CCCD; Fri, 8 Dec 2023 23:00:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234507AbjLIHA2 (ORCPT + 99 others); Sat, 9 Dec 2023 02:00:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234493AbjLIHAD (ORCPT ); Sat, 9 Dec 2023 02:00:03 -0500 Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08C9719AC; Fri, 8 Dec 2023 22:59:56 -0800 (PST) Received: by mail-qv1-xf41.google.com with SMTP id 6a1803df08f44-67adac40221so18310316d6.2; Fri, 08 Dec 2023 22:59:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702105195; x=1702709995; 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=/jpJNV10Y4Aq3La+SspO/hMcopvAOMbrsn8P/kGKMEU=; b=nEJuVWm9ToQyex+z6jFKMTLatqoMtbPQIl5prMit2E/NVm8EWHIUytJNBKYY+McwLX XVd3B4QVCDPkNXyjVkcS2ihPPV5Lg4tsAj4608p7blqgIQ1V0WgfqCYqRsjVbVvzSAnx BMJqglHYiFkZPXsIrYUqTrVdjspIl6aHoo7xfY77QMRGekkFsXvdh5EPtFZ50LavXaFt tvUqvZrqEg1trihThRi1e+SGCFPAXWw+1LeujEn+nmR0vXYxzIjxf1Cj6r2G513ioJ50 xUdNFnOzauGfbS8U2vQH5LJkp8hEmuLpBPfEsNvXwSdCINig3+Pkt+r2uc+HvIw4EBWv +bDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702105195; x=1702709995; 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=/jpJNV10Y4Aq3La+SspO/hMcopvAOMbrsn8P/kGKMEU=; b=RN49pTpSrhrFqB8DMYT3PJnWUIEYOTIEHvsOiRp2VnQhcK96hFnB1Wi45QpEwvHODD 0U0OwGXWgPd/ILAmb7QnLFYwVS683k5nMHytsfBvsNEfuZN5NUsoC+bx6/IVSH++7cIW 4E4pt38nMO4tm0obVfn4S/tJ3n5K87OPjq//4ihgA+s4LqulZNu/O8/AQFytZeVx2O/I 37yvBE+vL+kjIGmz1t5sO91DMwjlhM32TB1/MMY1TlmOBLKU0PXCP5xgSSpfTxnHMR2i wd7GEmctYZsOFAkSLYv/9ne0WynF3PJErZoUzn76wYk/qI2/iDS1YfPDSSXoWqypvGU2 AvQQ== X-Gm-Message-State: AOJu0YzwC/Ekalt84X4tRs4Z/hZtWeXSUzM3L+NoSxrO9+bP95Lmj3h3 2qOjFEowPPw9eU0tF0mtxw== X-Received: by 2002:a05:620a:2a10:b0:77f:3161:9147 with SMTP id o16-20020a05620a2a1000b0077f31619147mr1748373qkp.19.1702105195576; Fri, 08 Dec 2023 22:59:55 -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 x8-20020a81b048000000b005df5d592244sm326530ywk.78.2023.12.08.22.59.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 22:59:55 -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-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, jgroves@micron.com, ravis.opensrc@micron.com, sthanneeru@micron.com, emirakhur@micron.com, Hasan.Maruf@amd.com, seungjun.ha@samsung.com, Frank van der Linden Subject: [PATCH v2 07/11] mm/mempolicy: add userland mempolicy arg structure Date: Sat, 9 Dec 2023 01:59:27 -0500 Message-Id: <20231209065931.3458-8-gregory.price@memverge.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231209065931.3458-1-gregory.price@memverge.com> References: <20231209065931.3458-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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 08 Dec 2023 23:00:56 -0800 (PST) This patch adds the new user-api argument structure intended for set_mempolicy2 and mbind2. struct mpol_args { __u16 mode; __u16 mode_flags; __s32 home_node; /* mbind2: policy home node */ __aligned_u64 *pol_nodes; __u64 pol_maxnodes; __u64 addr; /* get_mempolicy: policy address */ __s32 policy_node; /* get_mempolicy: policy node info */ __s32 addr_node; /* get_mempolicy: memory range policy */ }; This structure is intended to be extensible as new mempolicy extensions are added. For example, set_mempolicy_home_node was added to allow vma mempolicies to have a preferred/home node assigned. This structure allows the addition of that setting at the time the mempolicy is set, rather than requiring additional calls to modify the policy. Full breakdown of arguments as of this patch: mode: Mempolicy mode (MPOL_DEFAULT, MPOL_INTERLEAVE) mode_flags: Flags previously or'd into mode in set_mempolicy (e.g.: MPOL_F_STATIC_NODES, MPOL_F_RELATIVE_NODES) home_node: for mbind2. Allows the setting of a policy's home with the use of MPOL_MF_HOME_NODE pol_nodes: Policy nodemask pol_maxnodes: Max number of nodes in the policy nodemask policy_node: for get_mempolicy2. Returns extended information about a policy that was previously reported by passing MPOL_F_NODE to get_mempolicy. Instead of overriding the mode value, simply add a field. addr: for get_mempolicy2. Used with MPOL_F_ADDR to run get_mempolicy against the vma the address belongs to instead of the task. addr_node: for get_mempolicy2. Returns the node the address belongs to. Previously get_mempolicy() would override the output value of (mode) if MPOL_F_ADDR and MPOL_F_NODE were set. Instead, we extend mpol_args to do this by default if MPOL_F_ADDR is set and do away with MPOL_F_NODE. Suggested-by: Frank van der Linden Suggested-by: Vinicius Tavares Petrucci Suggested-by: Hasan Al Maruf Signed-off-by: Gregory Price Co-developed-by: Vinicius Tavares Petrucci Signed-off-by: Vinicius Tavares Petrucci --- .../admin-guide/mm/numa_memory_policy.rst | 20 +++++++++++++++++++ include/uapi/linux/mempolicy.h | 12 +++++++++++ 2 files changed, 32 insertions(+) diff --git a/Documentation/admin-guide/mm/numa_memory_policy.rst b/Documentation/admin-guide/mm/numa_memory_policy.rst index d2c8e712785b..64c5804dc40f 100644 --- a/Documentation/admin-guide/mm/numa_memory_policy.rst +++ b/Documentation/admin-guide/mm/numa_memory_policy.rst @@ -482,6 +482,26 @@ closest to which page allocation will come from. Specifying the home node overri the default allocation policy to allocate memory close to the local node for an executing CPU. +Extended Mempolicy Arguments:: + + struct mpol_args { + __u16 mode; + __u16 mode_flags; + __s32 home_node; /* mbind2: policy home node */ + __aligned_u64 pol_nodes; /* nodemask pointer */ + __u64 pol_maxnodes; + __u64 addr; /* get_mempolicy2: policy address */ + __s32 policy_node; /* get_mempolicy2: policy node information */ + __s32 addr_node; /* get_mempolicy2: memory range policy */ + }; + +The extended mempolicy argument structure is defined to allow the mempolicy +interfaces future extensibility without the need for additional system calls. + +The core arguments (mode, mode_flags, pol_nodes, and pol_maxnodes) apply to +all interfaces relative to their non-extended counterparts. Each additional +field may only apply to specific extended interfaces. See the respective +extended interface man page for more details. Memory Policy Command Line Interface ==================================== diff --git a/include/uapi/linux/mempolicy.h b/include/uapi/linux/mempolicy.h index 1f9bb10d1a47..00a673e30047 100644 --- a/include/uapi/linux/mempolicy.h +++ b/include/uapi/linux/mempolicy.h @@ -27,6 +27,18 @@ enum { MPOL_MAX, /* always last member of enum */ }; +struct mpol_args { + /* Basic mempolicy settings */ + __u16 mode; + __u16 mode_flags; + __s32 home_node; /* mbind2: policy home node */ + __aligned_u64 pol_nodes; + __u64 pol_maxnodes; + __u64 addr; + __s32 policy_node; /* get_mempolicy: policy node info */ + __s32 addr_node; /* get_mempolicy: memory range policy */ +}; + /* Flags for set_mempolicy */ #define MPOL_F_STATIC_NODES (1 << 15) #define MPOL_F_RELATIVE_NODES (1 << 14) -- 2.39.1