Re: [PATCH v2] mm/compaction: __compact_pgdat() code cleanuup

From: Joonsoo Kim
Date: Wed Nov 25 2015 - 20:59:27 EST


On Wed, Nov 25, 2015 at 02:45:15AM -0800, David Rientjes wrote:
> On Wed, 25 Nov 2015, Joonsoo Kim wrote:
>
> > This patch uses is_via_compact_memory() to distinguish direct compaction.
>
> When I think of "direct compaction", I think of compaction triggered for
> high-order allocations from the page allocator before direct reclaim.
> This is the opposite of being triggered for is_via_compact_memory().

Okay. Will change it.

>
> > And it also reduces indentation on compaction_defer_reset
> > by filtering failure case. There is no functional change.
> >
> > Acked-by: Yaowei Bai <baiyaowei@xxxxxxxxxxxxxxxxxxxx>
> > Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
> > ---
> > mm/compaction.c | 13 +++++++------
> > 1 file changed, 7 insertions(+), 6 deletions(-)
> >
> > diff --git a/mm/compaction.c b/mm/compaction.c
> > index de3e1e7..01b1e5e 100644
> > --- a/mm/compaction.c
> > +++ b/mm/compaction.c
> > @@ -1658,14 +1658,15 @@ static void __compact_pgdat(pg_data_t *pgdat, struct compact_control *cc)
> > !compaction_deferred(zone, cc->order))
> > compact_zone(zone, cc);
> >
> > - if (cc->order > 0) {
> > - if (zone_watermark_ok(zone, cc->order,
> > - low_wmark_pages(zone), 0, 0))
> > - compaction_defer_reset(zone, cc->order, false);
> > - }
> > -
> > VM_BUG_ON(!list_empty(&cc->freepages));
> > VM_BUG_ON(!list_empty(&cc->migratepages));
> > +
> > + if (is_via_compact_memory(cc->order))
> > + continue;
>
> This will be the third call to is_via_compact_memory() in this function.
> Maybe just do
>
> const bool sysctl = is_via_compact_memory(cc->order);
>
> early in the function since it won't change during the iteration? (And
> maybe get rid of that extra newline that already exists at the beginning
> of the iteration?

I don't it's better. is_via_compact_memory() already express it's
meaning perfectly and no overhead here. Introducing extra variable
would confuse reader more than commonly used is_via_compact_memory().

>
> Otherwise:
>
> Acked-by: David Rientjes <rientjes@xxxxxxxxxx>

Thanks.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/