Skip to content

Commit be897d4

Browse files
ftang1torvalds
authored andcommitted
mm/mempolicy: unify the create() func for bind/interleave/prefer-many policies
As they all do the same thing: sanity check and save nodemask info, create one mpol_new_nodemask() to reduce redundancy. Link: https://lkml.kernel.org/r/1627970362-61305-6-git-send-email-feng.tang@intel.com Signed-off-by: Feng Tang <feng.tang@intel.com> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Ben Widawsky <ben.widawsky@intel.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: David Rientjes <rientjes@google.com> Cc: Huang Ying <ying.huang@intel.com> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Michal Hocko <mhocko@kernel.org> Cc: Mike Kravetz <mike.kravetz@oracle.com> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a38a59f commit be897d4

1 file changed

Lines changed: 4 additions & 20 deletions

File tree

mm/mempolicy.c

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static void mpol_relative_nodemask(nodemask_t *ret, const nodemask_t *orig,
192192
nodes_onto(*ret, tmp, *rel);
193193
}
194194

195-
static int mpol_new_interleave(struct mempolicy *pol, const nodemask_t *nodes)
195+
static int mpol_new_nodemask(struct mempolicy *pol, const nodemask_t *nodes)
196196
{
197197
if (nodes_empty(*nodes))
198198
return -EINVAL;
@@ -210,22 +210,6 @@ static int mpol_new_preferred(struct mempolicy *pol, const nodemask_t *nodes)
210210
return 0;
211211
}
212212

213-
static int mpol_new_preferred_many(struct mempolicy *pol, const nodemask_t *nodes)
214-
{
215-
if (nodes_empty(*nodes))
216-
return -EINVAL;
217-
pol->nodes = *nodes;
218-
return 0;
219-
}
220-
221-
static int mpol_new_bind(struct mempolicy *pol, const nodemask_t *nodes)
222-
{
223-
if (nodes_empty(*nodes))
224-
return -EINVAL;
225-
pol->nodes = *nodes;
226-
return 0;
227-
}
228-
229213
/*
230214
* mpol_set_nodemask is called after mpol_new() to set up the nodemask, if
231215
* any, for the new policy. mpol_new() has already validated the nodes
@@ -405,22 +389,22 @@ static const struct mempolicy_operations mpol_ops[MPOL_MAX] = {
405389
.rebind = mpol_rebind_default,
406390
},
407391
[MPOL_INTERLEAVE] = {
408-
.create = mpol_new_interleave,
392+
.create = mpol_new_nodemask,
409393
.rebind = mpol_rebind_nodemask,
410394
},
411395
[MPOL_PREFERRED] = {
412396
.create = mpol_new_preferred,
413397
.rebind = mpol_rebind_preferred,
414398
},
415399
[MPOL_BIND] = {
416-
.create = mpol_new_bind,
400+
.create = mpol_new_nodemask,
417401
.rebind = mpol_rebind_nodemask,
418402
},
419403
[MPOL_LOCAL] = {
420404
.rebind = mpol_rebind_default,
421405
},
422406
[MPOL_PREFERRED_MANY] = {
423-
.create = mpol_new_preferred_many,
407+
.create = mpol_new_nodemask,
424408
.rebind = mpol_rebind_preferred,
425409
},
426410
};

0 commit comments

Comments
 (0)