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/[email protected] Signed-off-by: Feng Tang <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: Ben Widawsky <[email protected]> Cc: Dan Williams <[email protected]> Cc: Dave Hansen <[email protected]> Cc: David Rientjes <[email protected]> Cc: Huang Ying <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Randy Dunlap <[email protected]> Cc: Vlastimil Babka <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent a38a59f commit be897d4

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

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)