Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1040897pxj; Thu, 17 Jun 2021 20:59:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDInT11vsDIWJmqAI+xRKlFr6qvqF240P/7v3VkDSDV+nIfzFtJdlRHRhEjnCpYlk0vqBU X-Received: by 2002:a17:906:f9d1:: with SMTP id lj17mr8866868ejb.345.1623988746367; Thu, 17 Jun 2021 20:59:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623988746; cv=none; d=google.com; s=arc-20160816; b=VKZiACEPj3/RoT6pQ4NQN1xWu68dZnDDe2vu8x/h9I2Wu23ucz/mwC55pz8EFPEPF1 5ZmY1pWEEDilDik53gv5dgPdyzO3IjScI6tA/Hn+j3UEmnkj923RSnBx8SuqgMhfxTTH 0OOQ5ZAiXhy4y0RHP8DKb0QLlZiqATsaEtv5Xs/ebQErWfXVMqZBvv1HJ+nwPqoW9F5+ QrJ/GIFFau/Hs2rdJSgK3o9w60CbZMiYZPcTGFfYmvJHRNccleGel5WIUTAmLqU/fBO+ MVvhza1F6CoCE8uBJpeHKhde7pEhFhvNbvxq75FslVL73xQiWRGEKUzj4yLXaLUIn1hQ 0tVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=/cjRkERHqx5gJf1lPv0SmPf8qc6jFKEQfeKiZ/1nL6A=; b=AMKk3i+gDTUlNzBextwjlBf1akdxukJW/Pd1UAx0fMr3MHLZH4n3Ps4vSIxFEXnHeZ hV67FM3B/aG1HUZTGhCurx8nqUUKTKL4h0upJZKS/EwJC7W6Tv99FEcS0Oo80xhwz/bU waRbsw8aqYPGZBg1R8l864Ct6h8bwfq28ZV7soTQXPkHSMTSokdDl/EjO1uu5h6u6KC2 9pA4YZ0iCeOhhhoTxgUU+z+FfinmSQW+KxTDsOZk+6LQdTW1g/8EvUotNIQIggRB+Wvh mM1TJADU2xgzsp5a55lkviEPNnRvUcwJ0Yts4X5ClTcufK7Qau8RLpq8RidyFVjiZOj8 62RA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si211110edo.399.2021.06.17.20.58.44; Thu, 17 Jun 2021 20:59:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230438AbhFRDrX (ORCPT + 99 others); Thu, 17 Jun 2021 23:47:23 -0400 Received: from mga06.intel.com ([134.134.136.31]:1077 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232110AbhFRDrW (ORCPT ); Thu, 17 Jun 2021 23:47:22 -0400 IronPort-SDR: xeB9BVVqP7L8w1iilhdHea5kZt8NF4+oqmxT0Sj+UUx3wO/r6Db44mS/VOZgGl2TEfaMvVSYXH zAEjFKt8p6XA== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="267636061" X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="267636061" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2021 20:45:13 -0700 IronPort-SDR: qR9+iaQdWzCsE35BjVpypOOMQpvzzJ5mIsIVy9inIGEKYhQQxoiL1om0lw6daoTJlmSyuYX5fL 6H74Bza6j9Ug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="485539914" Received: from shbuild999.sh.intel.com ([10.239.147.94]) by orsmga001.jf.intel.com with ESMTP; 17 Jun 2021 20:45:09 -0700 From: Feng Tang To: linux-mm@kvack.org, Andrew Morton , Michal Hocko , David Rientjes , Dave Hansen , Ben Widawsky Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Andrea Arcangeli , Mel Gorman , Mike Kravetz , Randy Dunlap , Vlastimil Babka , Andi Kleen , Dan Williams , ying.huang@intel.com, Feng Tang Subject: [PATCH v5 -mm 6/6] mm/mempolicy: unify the create() func for bind/interleave/prefer-many policies Date: Fri, 18 Jun 2021 11:44:44 +0800 Message-Id: <1623987884-43576-7-git-send-email-feng.tang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623987884-43576-1-git-send-email-feng.tang@intel.com> References: <1623987884-43576-1-git-send-email-feng.tang@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As they all do the same thing: sanity check and save nodemask info, create one mpol_new_nodemask() to reduce redundancy. Signed-off-by: Feng Tang --- mm/mempolicy.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index d90247d6a71b..e5ce5a7e8d92 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -192,7 +192,7 @@ static void mpol_relative_nodemask(nodemask_t *ret, const nodemask_t *orig, nodes_onto(*ret, tmp, *rel); } -static int mpol_new_interleave(struct mempolicy *pol, const nodemask_t *nodes) +static int mpol_new_nodemask(struct mempolicy *pol, const nodemask_t *nodes) { if (nodes_empty(*nodes)) return -EINVAL; @@ -210,22 +210,6 @@ static int mpol_new_preferred(struct mempolicy *pol, const nodemask_t *nodes) return 0; } -static int mpol_new_preferred_many(struct mempolicy *pol, const nodemask_t *nodes) -{ - if (nodes_empty(*nodes)) - return -EINVAL; - pol->nodes = *nodes; - return 0; -} - -static int mpol_new_bind(struct mempolicy *pol, const nodemask_t *nodes) -{ - if (nodes_empty(*nodes)) - return -EINVAL; - pol->nodes = *nodes; - return 0; -} - /* * mpol_set_nodemask is called after mpol_new() to set up the nodemask, if * any, for the new policy. mpol_new() has already validated the nodes @@ -405,7 +389,7 @@ static const struct mempolicy_operations mpol_ops[MPOL_MAX] = { .rebind = mpol_rebind_default, }, [MPOL_INTERLEAVE] = { - .create = mpol_new_interleave, + .create = mpol_new_nodemask, .rebind = mpol_rebind_nodemask, }, [MPOL_PREFERRED] = { @@ -413,14 +397,14 @@ static const struct mempolicy_operations mpol_ops[MPOL_MAX] = { .rebind = mpol_rebind_preferred, }, [MPOL_BIND] = { - .create = mpol_new_bind, + .create = mpol_new_nodemask, .rebind = mpol_rebind_nodemask, }, [MPOL_LOCAL] = { .rebind = mpol_rebind_default, }, [MPOL_PREFERRED_MANY] = { - .create = mpol_new_preferred_many, + .create = mpol_new_nodemask, .rebind = mpol_rebind_preferred, }, }; -- 2.7.4