Skip to content

Commit 7be12fc

Browse files
mina86torvalds
authored andcommitted
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>
1 parent 4f7c6b4 commit 7be12fc

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

‎mm/page_alloc.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,15 +1257,11 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order,
12571257
void drain_zone_pages(struct zone *zone, struct per_cpu_pages *pcp)
12581258
{
12591259
unsigned long flags;
1260-
int to_drain;
1261-
unsigned long batch;
1260+
int to_drain, batch;
12621261

12631262
local_irq_save(flags);
12641263
batch = ACCESS_ONCE(pcp->batch);
1265-
if (pcp->count >= batch)
1266-
to_drain = batch;
1267-
else
1268-
to_drain = pcp->count;
1264+
to_drain = min(pcp->count, batch);
12691265
if (to_drain > 0) {
12701266
free_pcppages_bulk(zone, to_drain, pcp);
12711267
pcp->count -= to_drain;

0 commit comments

Comments
 (0)