Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2184641pxy; Mon, 2 Aug 2021 23:01:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdNakFyKxm3VPev/DJFipvq6+ZJ2VVXSuqXArD7Wk7Tf/DB4v4urw6A3Qo3hViQIecUGgc X-Received: by 2002:a5d:9617:: with SMTP id w23mr389989iol.115.1627970481678; Mon, 02 Aug 2021 23:01:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627970481; cv=none; d=google.com; s=arc-20160816; b=CqSWtGmZUUl3JDL/3wSZGoDWwwcjAfrpK/mJCH/0pIHfmkxXz3wFGlAP67U5iDSAVR SEcWH3wD7VaX2p+0Pl9gvZy/+1hj+eGhroKiKfxQ3ArG8/8/mj5jyc4LjqjdmP9U2bCK J5BKbRL0kGpAB5KIkvq8EKXQDJVO+0DwIFNKpHNMd8VLK0v74p1hUPccVqN0r2AkEH7n UGJD2f3aNwu56BlEY834RtHGk38k/Zhn70NhXfbYHu5AfXvAVqGsvSjYntbFXVfwP6V8 d5Wzt7TZtfkH2vMvEz188kQHaqTRer7XwmzrE9sgW0YHoXyjtV8z1Bgn8gLA4ntXmu5d TR9g== 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; bh=ILtXXV9Znn8pkqCC1zTXxwQboJMrGLByH6Nd3b6aHNA=; b=FrYoQMknq4mN0+3j5pDIqSxlVoq3skGgFBylrzUj2pdqbrmsJLdzog53EGOMKfzPL8 uUTeZFSC9LgqNY5q6XwMV9kOECSDMvox99WRcXabPUpP4iMzynldsD939OJw/dyQDPDR ifHmquPaRhyt35wEiIU7xsYkVZvDtkjAJHABy0LMr4GFv1MDg4omS/GP2ZjiosDm6BOB U9FrekjdeOoRhL+uzW2Se+7sQDqnpDrRgVAniILQg0SDXrY6KLaxIE7/pDOIY7wJscXg lCsWEnIS7Uvj8w14uLRyTiR+CeEFglE/vCdZZ2O06YqzQvsd5MaLI0cNImCHAgrwnNHf ImRg== 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 d22si1263143ioo.71.2021.08.02.23.01.09; Mon, 02 Aug 2021 23:01:21 -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 S233804AbhHCGAE (ORCPT + 99 others); Tue, 3 Aug 2021 02:00:04 -0400 Received: from mga01.intel.com ([192.55.52.88]:34948 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234106AbhHCF74 (ORCPT ); Tue, 3 Aug 2021 01:59:56 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10064"; a="235529266" X-IronPort-AV: E=Sophos;i="5.84,291,1620716400"; d="scan'208";a="235529266" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2021 22:59:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,291,1620716400"; d="scan'208";a="479233401" Received: from shbuild999.sh.intel.com ([10.239.146.151]) by fmsmga008.fm.intel.com with ESMTP; 02 Aug 2021 22:59:43 -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 v7 5/5] mm/mempolicy: unify the create() func for bind/interleave/prefer-many policies Date: Tue, 3 Aug 2021 13:59:22 +0800 Message-Id: <1627970362-61305-6-git-send-email-feng.tang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1627970362-61305-1-git-send-email-feng.tang@intel.com> References: <1627970362-61305-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 Acked-by: Michal Hocko --- mm/mempolicy.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index e437fe96acd0..14710960d1d4 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.14.1