linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mempolicy: remove redundant check
@ 2010-03-16 13:55 Bob Liu
  2010-03-16 21:35 ` David Rientjes
  0 siblings, 1 reply; 2+ messages in thread
From: Bob Liu @ 2010-03-16 13:55 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, andi, rientjes, lee.schermerhorn, Bob Liu

From: Bob Liu <lliubbo@gmail.com>

1. Lee's patch "mempolicy: use MPOL_PREFERRED for system-wide
default policy" has made the MPOL_DEFAULT only used in the
memory policy APIs. So, no need to check in __mpol_equal also.

2. In policy_zonelist() mode MPOL_INTERLEAVE shouldn't happen,
so fall through to BUG() instead of break to return.I also fix
the comment.

Signed-off-by: Bob Liu <lliubbo@gmail.com>
---
 mm/mempolicy.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 643f66e..c4b16c9 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1441,15 +1441,15 @@ static struct zonelist *policy_zonelist(gfp_t gfp, struct mempolicy *policy)
 		/*
 		 * Normally, MPOL_BIND allocations are node-local within the
 		 * allowed nodemask.  However, if __GFP_THISNODE is set and the
-		 * current node is part of the mask, we use the zonelist for
+		 * current node isn't part of the mask, we use the zonelist for
 		 * the first node in the mask instead.
 		 */
 		if (unlikely(gfp & __GFP_THISNODE) &&
 				unlikely(!node_isset(nd, policy->v.nodes)))
 			nd = first_node(policy->v.nodes);
 		break;
-	case MPOL_INTERLEAVE: /* should not happen */
-		break;
+	case MPOL_INTERLEAVE:
+		/* Should not happen, so fall through to BUG()*/
 	default:
 		BUG();
 	}
@@ -1806,7 +1806,7 @@ int __mpol_equal(struct mempolicy *a, struct mempolicy *b)
 		return 0;
 	if (a->mode != b->mode)
 		return 0;
-	if (a->mode != MPOL_DEFAULT && !mpol_match_intent(a, b))
+	if (!mpol_match_intent(a, b))
 		return 0;
 	switch (a->mode) {
 	case MPOL_BIND:
-- 
1.5.6.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mempolicy: remove redundant check
  2010-03-16 13:55 [PATCH] mempolicy: remove redundant check Bob Liu
@ 2010-03-16 21:35 ` David Rientjes
  0 siblings, 0 replies; 2+ messages in thread
From: David Rientjes @ 2010-03-16 21:35 UTC (permalink / raw)
  To: Bob Liu; +Cc: akpm, linux-mm, andi, lee.schermerhorn

On Tue, 16 Mar 2010, Bob Liu wrote:

> From: Bob Liu <lliubbo@gmail.com>
> 
> 1. Lee's patch "mempolicy: use MPOL_PREFERRED for system-wide
> default policy" has made the MPOL_DEFAULT only used in the
> memory policy APIs. So, no need to check in __mpol_equal also.
> 
> 2. In policy_zonelist() mode MPOL_INTERLEAVE shouldn't happen,
> so fall through to BUG() instead of break to return.I also fix
> the comment.
> 

These are two seperate functional changes, so you'll need to break them 
out into individual patches.

> Signed-off-by: Bob Liu <lliubbo@gmail.com>
> ---
>  mm/mempolicy.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 643f66e..c4b16c9 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -1441,15 +1441,15 @@ static struct zonelist *policy_zonelist(gfp_t gfp, struct mempolicy *policy)
>  		/*
>  		 * Normally, MPOL_BIND allocations are node-local within the
>  		 * allowed nodemask.  However, if __GFP_THISNODE is set and the
> -		 * current node is part of the mask, we use the zonelist for
> +		 * current node isn't part of the mask, we use the zonelist for
>  		 * the first node in the mask instead.
>  		 */
>  		if (unlikely(gfp & __GFP_THISNODE) &&
>  				unlikely(!node_isset(nd, policy->v.nodes)))
>  			nd = first_node(policy->v.nodes);
>  		break;
> -	case MPOL_INTERLEAVE: /* should not happen */
> -		break;
> +	case MPOL_INTERLEAVE:
> +		/* Should not happen, so fall through to BUG()*/
>  	default:
>  		BUG();
>  	}

Looks good.

> @@ -1806,7 +1806,7 @@ int __mpol_equal(struct mempolicy *a, struct mempolicy *b)
>  		return 0;
>  	if (a->mode != b->mode)
>  		return 0;
> -	if (a->mode != MPOL_DEFAULT && !mpol_match_intent(a, b))
> +	if (!mpol_match_intent(a, b))
>  		return 0;
>  	switch (a->mode) {
>  	case MPOL_BIND:

Ok.  Could you also get rid of mpol_match_intent() and move its logic 
directly into __mpol_equal() with the other comparison tests?

Thanks.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2010-03-16 21:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-16 13:55 [PATCH] mempolicy: remove redundant check Bob Liu
2010-03-16 21:35 ` David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox