Skip to content

Commit

Permalink
mm/compaction.c: micro-optimization remove unnecessary branch
Browse files Browse the repository at this point in the history
The same code can work both for 'zone->compact_considered > defer_limit'
and 'zone->compact_considered >= defer_limit'.  In the latter there is one
branch less which is more effective considering performance.

Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Mel Gorman <mgorman@suse.de>
Cc: David Rientjes <rientjes@google.com>
Link: https://lkml.kernel.org/r/20200913190448.28649-1-mateusznosek0@gmail.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Mateusz Nosek authored and Linus Torvalds committed Oct 14, 2020
1 parent 1860129 commit 62b35fe
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mm/compaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,10 @@ bool compaction_deferred(struct zone *zone, int order)
return false;

/* Avoid possible overflow */
if (++zone->compact_considered > defer_limit)
if (++zone->compact_considered >= defer_limit) {
zone->compact_considered = defer_limit;

if (zone->compact_considered >= defer_limit)
return false;
}

trace_mm_compaction_deferred(zone, order);

Expand Down

0 comments on commit 62b35fe

Please sign in to comment.