From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757227AbbIUQTx (ORCPT ); Mon, 21 Sep 2015 12:19:53 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:35607 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757037AbbIUQTv (ORCPT ); Mon, 21 Sep 2015 12:19:51 -0400 Date: Mon, 21 Sep 2015 18:19:49 +0200 From: Michal Hocko To: Yaowei Bai Cc: akpm@linux-foundation.org, mgorman@suse.de, rientjes@google.com, hannes@cmpxchg.org, vdavydov@parallels.com, oleg@redhat.com, vbabka@suse.cz, iamjoonsoo.kim@lge.com, zhangyanfei@cn.fujitsu.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] mm/compaction: add an is_via_compact_memory helper function Message-ID: <20150921161949.GG19811@dhcp22.suse.cz> References: <1442404800-4051-1-git-send-email-bywxiaobai@163.com> <1442404800-4051-3-git-send-email-bywxiaobai@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442404800-4051-3-git-send-email-bywxiaobai@163.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 16-09-15 20:00:00, Yaowei Bai wrote: > Introduce is_via_compact_memory helper function indicating compacting > via /proc/sys/vm/compact_memory to improve readability. > > To catch this situation in __compaction_suitable, use order as parameter > directly instead of using struct compact_control. > > This patch has no functional changes. This is a similar case as for the sysrq_oom. I do not like the name that much though. I am not familiar with the compaction too much to help you with a better name, unfortunatelly. Maybe is_global_compaction()... > > Signed-off-by: Yaowei Bai > --- > mm/compaction.c | 26 ++++++++++++++------------ > 1 file changed, 14 insertions(+), 12 deletions(-) > > diff --git a/mm/compaction.c b/mm/compaction.c > index c5c627a..a8e6593 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -1197,6 +1197,15 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone, > return cc->nr_migratepages ? ISOLATE_SUCCESS : ISOLATE_NONE; > } > > +/* > + * order == -1 is expected when compacting via > + * /proc/sys/vm/compact_memory > + */ > +static inline bool is_via_compact_memory(int order) > +{ > + return order == -1; > +} > + > static int __compact_finished(struct zone *zone, struct compact_control *cc, > const int migratetype) > { > @@ -1223,11 +1232,7 @@ static int __compact_finished(struct zone *zone, struct compact_control *cc, > return COMPACT_COMPLETE; > } > > - /* > - * order == -1 is expected when compacting via > - * /proc/sys/vm/compact_memory > - */ > - if (cc->order == -1) > + if (is_via_compact_memory(cc->order)) > return COMPACT_CONTINUE; > > /* Compaction run is not finished if the watermark is not met */ > @@ -1290,11 +1295,7 @@ static unsigned long __compaction_suitable(struct zone *zone, int order, > int fragindex; > unsigned long watermark; > > - /* > - * order == -1 is expected when compacting via > - * /proc/sys/vm/compact_memory > - */ > - if (order == -1) > + if (is_via_compact_memory(order)) > return COMPACT_CONTINUE; > > watermark = low_wmark_pages(zone); > @@ -1658,10 +1659,11 @@ static void __compact_pgdat(pg_data_t *pgdat, struct compact_control *cc) > * this makes sure we compact the whole zone regardless of > * cached scanner positions. > */ > - if (cc->order == -1) > + if (is_via_compact_memory(cc->order)) > __reset_isolation_suitable(zone); > > - if (cc->order == -1 || !compaction_deferred(zone, cc->order)) > + if (is_via_compact_memory(cc->order) || > + !compaction_deferred(zone, cc->order)) > compact_zone(zone, cc); > > if (cc->order > 0) { > -- > 1.9.1 > > > -- > 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: email@kvack.org -- Michal Hocko SUSE Labs