linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [mempolicy] remove unnecessary is_valid_nodemask()
@ 2014-11-16  2:49 Zhihui Zhang
  2014-11-17 23:08 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Zhihui Zhang @ 2014-11-16  2:49 UTC (permalink / raw)
  To: akpm, mgorman, oleg; +Cc: linux-kernel

When nodes is true, nsc->mask2 has already been filtered by nsc->mask1, which has
already factored in node_states[N_MEMORY].

Signed-off-by: Zhihui Zhang <zzhsuny@gmail.com>
---
 mm/mempolicy.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index e58725a..f22c559 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -162,12 +162,6 @@ static const struct mempolicy_operations {
 			enum mpol_rebind_step step);
 } mpol_ops[MPOL_MAX];
 
-/* Check that the nodemask contains at least one populated zone */
-static int is_valid_nodemask(const nodemask_t *nodemask)
-{
-	return nodes_intersects(*nodemask, node_states[N_MEMORY]);
-}
-
 static inline int mpol_store_user_nodemask(const struct mempolicy *pol)
 {
 	return pol->flags & MPOL_MODE_FLAGS;
@@ -202,7 +196,7 @@ static int mpol_new_preferred(struct mempolicy *pol, const nodemask_t *nodes)
 
 static int mpol_new_bind(struct mempolicy *pol, const nodemask_t *nodes)
 {
-	if (!is_valid_nodemask(nodes))
+	if (nodes_empty(*nodes))
 		return -EINVAL;
 	pol->v.nodes = *nodes;
 	return 0;
@@ -234,7 +228,7 @@ static int mpol_set_nodemask(struct mempolicy *pol,
 		nodes = NULL;	/* explicit local allocation */
 	else {
 		if (pol->flags & MPOL_F_RELATIVE_NODES)
-			mpol_relative_nodemask(&nsc->mask2, nodes,&nsc->mask1);
+			mpol_relative_nodemask(&nsc->mask2, nodes, &nsc->mask1);
 		else
 			nodes_and(nsc->mask2, *nodes, nsc->mask1);
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] [mempolicy] remove unnecessary is_valid_nodemask()
  2014-11-16  2:49 [PATCH] [mempolicy] remove unnecessary is_valid_nodemask() Zhihui Zhang
@ 2014-11-17 23:08 ` Andrew Morton
  2014-11-18  0:55   ` Zhihui Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2014-11-17 23:08 UTC (permalink / raw)
  To: Zhihui Zhang; +Cc: mgorman, oleg, linux-kernel

On Sat, 15 Nov 2014 21:49:57 -0500 Zhihui Zhang <zzhsuny@gmail.com> wrote:

> When nodes is true, nsc->mask2 has already been filtered by nsc->mask1, which has
> already factored in node_states[N_MEMORY].
> 

Please be more specific.  Where does that filtering occur?


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [mempolicy] remove unnecessary is_valid_nodemask()
  2014-11-17 23:08 ` Andrew Morton
@ 2014-11-18  0:55   ` Zhihui Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Zhihui Zhang @ 2014-11-18  0:55 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Mel Gorman, oleg, linux-kernel

The filtering occurs in mpol_set_nodemask(), it reads like this:

                if (pol->flags & MPOL_F_RELATIVE_NODES)
                        mpol_relative_nodemask(&nsc->mask2, nodes,&nsc->mask1);
                else
                        nodes_and(nsc->mask2, *nodes, nsc->mask1);

so mask2 is based on mask1. mask2 is only used when nodes is not NULL
later. so we don't care the
case of (pol->mode == MPOL_PREFERRED && nodes_empty(*nodes)).

-Zhihui

On Mon, Nov 17, 2014 at 6:08 PM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Sat, 15 Nov 2014 21:49:57 -0500 Zhihui Zhang <zzhsuny@gmail.com> wrote:
>
>> When nodes is true, nsc->mask2 has already been filtered by nsc->mask1, which has
>> already factored in node_states[N_MEMORY].
>>
>
> Please be more specific.  Where does that filtering occur?
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-18  0:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-16  2:49 [PATCH] [mempolicy] remove unnecessary is_valid_nodemask() Zhihui Zhang
2014-11-17 23:08 ` Andrew Morton
2014-11-18  0:55   ` Zhihui Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).