mm: page_alloc: simplify drain_zone_pages by using min()
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> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
4f7c6b49c4
commit
7be12fc9f8
1 changed files with 2 additions and 6 deletions
|
@ -1257,15 +1257,11 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order,
|
||||||
void drain_zone_pages(struct zone *zone, struct per_cpu_pages *pcp)
|
void drain_zone_pages(struct zone *zone, struct per_cpu_pages *pcp)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int to_drain;
|
int to_drain, batch;
|
||||||
unsigned long batch;
|
|
||||||
|
|
||||||
local_irq_save(flags);
|
local_irq_save(flags);
|
||||||
batch = ACCESS_ONCE(pcp->batch);
|
batch = ACCESS_ONCE(pcp->batch);
|
||||||
if (pcp->count >= batch)
|
to_drain = min(pcp->count, batch);
|
||||||
to_drain = batch;
|
|
||||||
else
|
|
||||||
to_drain = pcp->count;
|
|
||||||
if (to_drain > 0) {
|
if (to_drain > 0) {
|
||||||
free_pcppages_bulk(zone, to_drain, pcp);
|
free_pcppages_bulk(zone, to_drain, pcp);
|
||||||
pcp->count -= to_drain;
|
pcp->count -= to_drain;
|
||||||
|
|
Loading…
Reference in a new issue