All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: page_alloc: simplify drain_zone_pages by using min()
@ 2014-06-16 21:08 ` Michal Nazarewicz
  0 siblings, 0 replies; 6+ messages in thread
From: Michal Nazarewicz @ 2014-06-16 21:08 UTC (permalink / raw
  To: Christoph Lameter, Andrew Morton
  Cc: linux-mm, linux-kernel, Michal Nazarewicz

Instead of open-coding getting minimal value of two, just use min macro.
That is why it is there for.  While changing the function also change
type of batch local variable to match type of per_cpu_pages::batch
(which is int).

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
---
 mm/page_alloc.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 5dba293..26aa003 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1224,15 +1224,11 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order,
 void drain_zone_pages(struct zone *zone, struct per_cpu_pages *pcp)
 {
 	unsigned long flags;
-	int to_drain;
-	unsigned long batch;
+	int to_drain, batch;
 
 	local_irq_save(flags);
 	batch = ACCESS_ONCE(pcp->batch);
-	if (pcp->count >= batch)
-		to_drain = batch;
-	else
-		to_drain = pcp->count;
+	to_drain = min(pcp->count, batch);
 	if (to_drain > 0) {
 		free_pcppages_bulk(zone, to_drain, pcp);
 		pcp->count -= to_drain;
-- 
2.0.0.526.g5318336


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

* [PATCH] mm: page_alloc: simplify drain_zone_pages by using min()
@ 2014-06-16 21:08 ` Michal Nazarewicz
  0 siblings, 0 replies; 6+ messages in thread
From: Michal Nazarewicz @ 2014-06-16 21:08 UTC (permalink / raw
  To: Christoph Lameter, Andrew Morton
  Cc: linux-mm, linux-kernel, Michal Nazarewicz

Instead of open-coding getting minimal value of two, just use min macro.
That is why it is there for.  While changing the function also change
type of batch local variable to match type of per_cpu_pages::batch
(which is int).

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
---
 mm/page_alloc.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 5dba293..26aa003 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1224,15 +1224,11 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order,
 void drain_zone_pages(struct zone *zone, struct per_cpu_pages *pcp)
 {
 	unsigned long flags;
-	int to_drain;
-	unsigned long batch;
+	int to_drain, batch;
 
 	local_irq_save(flags);
 	batch = ACCESS_ONCE(pcp->batch);
-	if (pcp->count >= batch)
-		to_drain = batch;
-	else
-		to_drain = pcp->count;
+	to_drain = min(pcp->count, batch);
 	if (to_drain > 0) {
 		free_pcppages_bulk(zone, to_drain, pcp);
 		pcp->count -= to_drain;
-- 
2.0.0.526.g5318336

--
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 related	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm: page_alloc: simplify drain_zone_pages by using min()
  2014-06-16 21:08 ` Michal Nazarewicz
@ 2014-06-16 23:07   ` David Rientjes
  -1 siblings, 0 replies; 6+ messages in thread
From: David Rientjes @ 2014-06-16 23:07 UTC (permalink / raw
  To: Michal Nazarewicz
  Cc: Christoph Lameter, Andrew Morton, linux-mm, linux-kernel

On Mon, 16 Jun 2014, Michal Nazarewicz wrote:

> Instead of open-coding getting minimal value of two, just use min macro.
> That is why it is there for.  While changing the function also change
> type of batch local variable to match type of per_cpu_pages::batch
> (which is int).
> 
> Signed-off-by: Michal Nazarewicz <mina86@mina86.com>

Acked-by: David Rientjes <rientjes@google.com>

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

* Re: [PATCH] mm: page_alloc: simplify drain_zone_pages by using min()
@ 2014-06-16 23:07   ` David Rientjes
  0 siblings, 0 replies; 6+ messages in thread
From: David Rientjes @ 2014-06-16 23:07 UTC (permalink / raw
  To: Michal Nazarewicz
  Cc: Christoph Lameter, Andrew Morton, linux-mm, linux-kernel

On Mon, 16 Jun 2014, Michal Nazarewicz wrote:

> Instead of open-coding getting minimal value of two, just use min macro.
> That is why it is there for.  While changing the function also change
> type of batch local variable to match type of per_cpu_pages::batch
> (which is int).
> 
> Signed-off-by: Michal Nazarewicz <mina86@mina86.com>

Acked-by: David Rientjes <rientjes@google.com>

--
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] 6+ messages in thread

* Re: [PATCH] mm: page_alloc: simplify drain_zone_pages by using min()
  2014-06-16 21:08 ` Michal Nazarewicz
@ 2014-06-16 23:13   ` Andrew Morton
  -1 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2014-06-16 23:13 UTC (permalink / raw
  To: Michal Nazarewicz; +Cc: Christoph Lameter, linux-mm, linux-kernel

On Mon, 16 Jun 2014 23:08:14 +0200 Michal Nazarewicz <mina86@mina86.com> wrote:

> Instead of open-coding getting minimal value of two, just use min macro.
> That is why it is there for.  While changing the function also change
> type of batch local variable to match type of per_cpu_pages::batch
> (which is int).
> 

I'm not sure why we made all the per_cpu_pages mambers `int'.  Unsigned
would make more sense.



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

* Re: [PATCH] mm: page_alloc: simplify drain_zone_pages by using min()
@ 2014-06-16 23:13   ` Andrew Morton
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2014-06-16 23:13 UTC (permalink / raw
  To: Michal Nazarewicz; +Cc: Christoph Lameter, linux-mm, linux-kernel

On Mon, 16 Jun 2014 23:08:14 +0200 Michal Nazarewicz <mina86@mina86.com> wrote:

> Instead of open-coding getting minimal value of two, just use min macro.
> That is why it is there for.  While changing the function also change
> type of batch local variable to match type of per_cpu_pages::batch
> (which is int).
> 

I'm not sure why we made all the per_cpu_pages mambers `int'.  Unsigned
would make more sense.


--
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] 6+ messages in thread

end of thread, other threads:[~2014-06-16 23:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-16 21:08 [PATCH] mm: page_alloc: simplify drain_zone_pages by using min() Michal Nazarewicz
2014-06-16 21:08 ` Michal Nazarewicz
2014-06-16 23:07 ` David Rientjes
2014-06-16 23:07   ` David Rientjes
2014-06-16 23:13 ` Andrew Morton
2014-06-16 23:13   ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.