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=-12.7 required=3.0 tests=BAYES_00, 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 3867FC55179 for ; Fri, 30 Oct 2020 19:02:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BAC012072C for ; Fri, 30 Oct 2020 19:02:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BAC012072C 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 BA0186B006C; Fri, 30 Oct 2020 15:02:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD4FF6B0074; Fri, 30 Oct 2020 15:02:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86E486B006C; Fri, 30 Oct 2020 15:02:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0193.hostedemail.com [216.40.44.193]) by kanga.kvack.org (Postfix) with ESMTP id 4021F6B006C for ; Fri, 30 Oct 2020 15:02:50 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D7847180AD811 for ; Fri, 30 Oct 2020 19:02:49 +0000 (UTC) X-FDA: 77429513658.10.field54_3213e4a27298 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id B40AC16A0D2 for ; Fri, 30 Oct 2020 19:02:49 +0000 (UTC) X-HE-Tag: field54_3213e4a27298 X-Filterd-Recvd-Size: 4273 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Fri, 30 Oct 2020 19:02:47 +0000 (UTC) IronPort-SDR: /D4/VYnpYKaoz/IDXthytD8oqA8XokHbFopo3beuPHSTXKbKcnW6Fk9wRGJcYegoL4LWYHsq60 fo1oW/31KMsg== X-IronPort-AV: E=McAfee;i="6000,8403,9790"; a="155629105" X-IronPort-AV: E=Sophos;i="5.77,434,1596524400"; d="scan'208";a="155629105" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2020 12:02:46 -0700 IronPort-SDR: zY1RkexspqZ2jaT18JTEukY09sP8wM6SQZf5xmso6brYs57D0yspOYtauXox2ibu/NZUbEVPQk ma8aZhUijPmg== X-IronPort-AV: E=Sophos;i="5.77,434,1596524400"; d="scan'208";a="537167672" Received: from kingelix-mobl.amr.corp.intel.com (HELO bwidawsk-mobl5.local) ([10.252.139.120]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2020 12:02:46 -0700 From: Ben Widawsky To: linux-mm , Andrew Morton Cc: Dave Hansen , Dave Hansen , Michal Hocko , Ben Widawsky , linux-kernel@vger.kernel.org Subject: [PATCH 05/12] mm/mempolicy: refactor rebind code for PREFERRED_MANY Date: Fri, 30 Oct 2020 12:02:31 -0700 Message-Id: <20201030190238.306764-6-ben.widawsky@intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201030190238.306764-1-ben.widawsky@intel.com> References: <20201030190238.306764-1-ben.widawsky@intel.com> MIME-Version: 1.0 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: From: Dave Hansen Again, this extracts the "only one node must be set" behavior of MPOL_PREFERRED. It retains virtually all of the existing code so it can be used by MPOL_PREFERRED_MANY as well. v2: Fixed typos in commit message. (Ben) Merged bits from other patches. (Ben) annotate mpol_rebind_preferred_many as unused (Ben) Link: https://lore.kernel.org/r/20200630212517.308045-6-ben.widawsky@inte= l.com Signed-off-by: Dave Hansen Signed-off-by: Ben Widawsky --- mm/mempolicy.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index b1b43e511d6f..1b88c133f5c5 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -359,14 +359,11 @@ static void mpol_rebind_nodemask(struct mempolicy *= pol, const nodemask_t *nodes) pol->v.nodes =3D tmp; } =20 -static void mpol_rebind_preferred(struct mempolicy *pol, - const nodemask_t *nodes) +static void mpol_rebind_preferred_common(struct mempolicy *pol, + const nodemask_t *preferred_nodes, + const nodemask_t *nodes) { nodemask_t tmp; - nodemask_t preferred_node; - - /* MPOL_PREFERRED uses only the first node in the mask */ - preferred_node =3D nodemask_of_node(first_node(*nodes)); =20 if (pol->flags & MPOL_F_STATIC_NODES) { int node =3D first_node(pol->w.user_nodemask); @@ -381,12 +378,30 @@ static void mpol_rebind_preferred(struct mempolicy = *pol, pol->v.preferred_nodes =3D tmp; } else if (!(pol->flags & MPOL_F_LOCAL)) { nodes_remap(tmp, pol->v.preferred_nodes, - pol->w.cpuset_mems_allowed, preferred_node); + pol->w.cpuset_mems_allowed, *preferred_nodes); pol->v.preferred_nodes =3D tmp; pol->w.cpuset_mems_allowed =3D *nodes; } } =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) +{ + mpol_rebind_preferred_common(pol, nodes, nodes); +} + +static void mpol_rebind_preferred(struct mempolicy *pol, + const nodemask_t *nodes) +{ + nodemask_t preferred_node; + + /* MPOL_PREFERRED uses only the first node in 'nodes' */ + preferred_node =3D nodemask_of_node(first_node(*nodes)); + + mpol_rebind_preferred_common(pol, &preferred_node, nodes); +} + /* * mpol_rebind_policy - Migrate a policy to a different set of nodes * --=20 2.29.2