From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EED5EC433E1 for ; Fri, 19 Jun 2020 16:25:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BB1E121707 for ; Fri, 19 Jun 2020 16:25:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB1E121707 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4D6A48D00D8; Fri, 19 Jun 2020 12:24:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A03F8D00E0; Fri, 19 Jun 2020 12:24:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E723A8D00D8; Fri, 19 Jun 2020 12:24:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0163.hostedemail.com [216.40.44.163]) by kanga.kvack.org (Postfix) with ESMTP id B98598D00DE for ; Fri, 19 Jun 2020 12:24:36 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 6BF5B180AD81D for ; Fri, 19 Jun 2020 16:24:36 +0000 (UTC) X-FDA: 76946484552.28.glue19_3601ac826e1a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 493E115B0C0 for ; Fri, 19 Jun 2020 16:24:36 +0000 (UTC) X-HE-Tag: glue19_3601ac826e1a X-Filterd-Recvd-Size: 7359 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Fri, 19 Jun 2020 16:24:35 +0000 (UTC) IronPort-SDR: 3zdJ184yCuDNmkgYHnRnPD3wuyphEFzSgo+WtNfIq8se7OpVdNOOqI9yByE2chWtsdN7DFpdCE Pdy45copx58A== X-IronPort-AV: E=McAfee;i="6000,8403,9657"; a="130375201" X-IronPort-AV: E=Sophos;i="5.75,256,1589266800"; d="scan'208";a="130375201" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:24:33 -0700 IronPort-SDR: dVbg4TDZtx5ZKdztee7fN0NUM7eJavq1g9hepFwo5Ys59JRMtQ6xsL5j7Tz7kjKImgU3NeeJVq FXhxNIHuwO/A== X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="264368591" Received: from sjiang-mobl2.ccr.corp.intel.com (HELO bwidawsk-mobl5.local) ([10.252.131.131]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 09:24:32 -0700 From: Ben Widawsky To: linux-mm Cc: Ben Widawsky , Andrew Morton , Dave Hansen , David Hildenbrand , Jonathan Corbet , Michal Hocko , Vlastimil Babka Subject: [PATCH 18/18] mm/mempolicy: Advertise new MPOL_PREFERRED_MANY Date: Fri, 19 Jun 2020 09:24:25 -0700 Message-Id: <20200619162425.1052382-19-ben.widawsky@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619162425.1052382-1-ben.widawsky@intel.com> References: <20200619162425.1052382-1-ben.widawsky@intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 493E115B0C0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: See comments in code, and previous commit messages for details of implementation and usage. Fix whitespace while here. Cc: Andrew Morton Cc: Dave Hansen Cc: David Hildenbrand Cc: Jonathan Corbet Cc: Michal Hocko Cc: Vlastimil Babka Signed-off-by: Ben Widawsky --- .../admin-guide/mm/numa_memory_policy.rst | 16 ++++++++++++---- include/uapi/linux/mempolicy.h | 6 +++--- mm/mempolicy.c | 14 ++++++-------- mm/page_alloc.c | 3 --- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Documentation/admin-guide/mm/numa_memory_policy.rst b/Docume= ntation/admin-guide/mm/numa_memory_policy.rst index 1ad020c459b8..b69963a37fc8 100644 --- a/Documentation/admin-guide/mm/numa_memory_policy.rst +++ b/Documentation/admin-guide/mm/numa_memory_policy.rst @@ -245,6 +245,14 @@ MPOL_INTERLEAVED address range or file. During system boot up, the temporary interleaved system default policy works in this mode. =20 +MPOL_PREFERRED_MANY + This mode specifies that the allocation should be attempted from= the + nodemask specified in the policy. If that allocation fails, the = kernel + will search other nodes, in order of increasing distance from th= e first + set bit in the nodemask based on information provided by the pla= tform + firmware. It is similar to MPOL_PREFERRED with the main exceptio= n that + is is an error to have an empty nodemask. + NUMA memory policy supports the following optional mode flags: =20 MPOL_F_STATIC_NODES @@ -253,10 +261,10 @@ MPOL_F_STATIC_NODES nodes changes after the memory policy has been defined. =20 Without this flag, any time a mempolicy is rebound because of a - change in the set of allowed nodes, the node (Preferred) or - nodemask (Bind, Interleave) is remapped to the new set of - allowed nodes. This may result in nodes being used that were - previously undesired. + change in the set of allowed nodes, the preferred nodemask (Pref= erred + Many), preferred node (Preferred) or nodemask (Bind, Interleave)= is + remapped to the new set of allowed nodes. This may result in no= des + being used that were previously undesired. =20 With this flag, if the user-specified nodes overlap with the nodes allowed by the task's cpuset, then the memory policy is diff --git a/include/uapi/linux/mempolicy.h b/include/uapi/linux/mempolic= y.h index 3354774af61e..ad3eee651d4e 100644 --- a/include/uapi/linux/mempolicy.h +++ b/include/uapi/linux/mempolicy.h @@ -16,13 +16,13 @@ */ =20 /* Policies */ -enum { - MPOL_DEFAULT, +enum { MPOL_DEFAULT, MPOL_PREFERRED, MPOL_BIND, MPOL_INTERLEAVE, MPOL_LOCAL, - MPOL_MAX, /* always last member of enum */ + MPOL_PREFERRED_MANY, + MPOL_MAX, /* always last member of enum */ }; =20 /* Flags for set_mempolicy */ diff --git a/mm/mempolicy.c b/mm/mempolicy.c index fb49bea41ab8..07e916f8f6b7 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -108,8 +108,6 @@ =20 #include "internal.h" =20 -#define MPOL_PREFERRED_MANY MPOL_MAX - /* Internal flags */ #define MPOL_MF_DISCONTIG_OK (MPOL_MF_INTERNAL << 0) /* Skip checks for = continuous vmas */ #define MPOL_MF_INVERT (MPOL_MF_INTERNAL << 1) /* Invert check for node= mask */ @@ -180,7 +178,7 @@ struct mempolicy *get_task_policy(struct task_struct = *p) static const struct mempolicy_operations { int (*create)(struct mempolicy *pol, const nodemask_t *nodes); void (*rebind)(struct mempolicy *pol, const nodemask_t *nodes); -} mpol_ops[MPOL_MAX + 1]; +} mpol_ops[MPOL_MAX]; =20 static inline int mpol_store_user_nodemask(const struct mempolicy *pol) { @@ -385,8 +383,8 @@ static void mpol_rebind_preferred_common(struct mempo= licy *pol, } =20 /* MPOL_PREFERRED_MANY allows multiple nodes to be set in 'nodes' */ -static void __maybe_unused mpol_rebind_preferred_many(struct mempolicy *= pol, - const nodemask_t *nodes) +static void mpol_rebind_preferred_many(struct mempolicy *pol, + const nodemask_t *nodes) { mpol_rebind_preferred_common(pol, nodes, nodes); } @@ -448,7 +446,7 @@ void mpol_rebind_mm(struct mm_struct *mm, nodemask_t = *new) mmap_write_unlock(mm); } =20 -static const struct mempolicy_operations mpol_ops[MPOL_MAX + 1] =3D { +static const struct mempolicy_operations mpol_ops[MPOL_MAX] =3D { [MPOL_DEFAULT] =3D { .rebind =3D mpol_rebind_default, }, @@ -466,8 +464,8 @@ static const struct mempolicy_operations mpol_ops[MPO= L_MAX + 1] =3D { }, /* MPOL_LOCAL is converted to MPOL_PREFERRED on policy creation */ [MPOL_PREFERRED_MANY] =3D { - .create =3D NULL, - .rebind =3D NULL, + .create =3D mpol_new_preferred_many, + .rebind =3D mpol_rebind_preferred_many, }, }; =20 diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0f90419fe0d8..b89c9c2637bf 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4867,9 +4867,6 @@ struct zonelist *preferred_zonelist(gfp_t gfp_mask,= const nodemask_t *prefmask, nodemask_t pref; int nid, local_node =3D numa_mem_id(); =20 - /* Multi nodes not supported yet */ - VM_BUG_ON(prefmask && nodes_weight(*prefmask) !=3D 1); - #define _isset(mask, node) = \ (!(mask) || nodes_empty(*(mask)) ? 1 : node_isset(node, *(mask))) /* --=20 2.27.0