From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751915AbcDUHJn (ORCPT ); Thu, 21 Apr 2016 03:09:43 -0400 Received: from out4433.biz.mail.alibaba.com ([47.88.44.33]:56483 "EHLO out4433.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751693AbcDUHJm (ORCPT ); Thu, 21 Apr 2016 03:09:42 -0400 X-Greylist: delayed 12670 seconds by postgrey-1.27 at vger.kernel.org; Thu, 21 Apr 2016 03:09:42 EDT X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R961e4;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e02c03282;MF=hillf.zj@alibaba-inc.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_----4j19ExJ_1461222535; Reply-To: "Hillf Danton" From: "Hillf Danton" To: "'Michal Hocko'" , "'Andrew Morton'" Cc: "'Linus Torvalds'" , "'Johannes Weiner'" , "'Mel Gorman'" , "'David Rientjes'" , "'Tetsuo Handa'" , "'Joonsoo Kim'" , "'Vlastimil Babka'" , , "'LKML'" , "'Michal Hocko'" References: <1461181647-8039-1-git-send-email-mhocko@kernel.org> <1461181647-8039-5-git-send-email-mhocko@kernel.org> In-Reply-To: <1461181647-8039-5-git-send-email-mhocko@kernel.org> Subject: Re: [PATCH 04/14] mm, compaction: distinguish COMPACT_DEFERRED from COMPACT_SKIPPED Date: Thu, 21 Apr 2016 15:08:55 +0800 Message-ID: <02d501d19b9c$ab7fd4e0$027f7ea0$@alibaba-inc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQG1HgS+iScJ1ld6BkmHPkLx52RrNAEV4ol/n8RN0AA= Content-Language: zh-cn Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > From: Michal Hocko > > try_to_compact_pages can currently return COMPACT_SKIPPED even when the > compaction is defered for some zone just because zone DMA is skipped > in 99% of cases due to watermark checks. This makes COMPACT_DEFERRED > basically unusable for the page allocator as a feedback mechanism. > > Make sure we distinguish those two states properly and switch their > ordering in the enum. This would mean that the COMPACT_SKIPPED will be > returned only when all eligible zones are skipped. > > As a result COMPACT_DEFERRED handling for THP in __alloc_pages_slowpath > will be more precise and we would bail out rather than reclaim. > > Acked-by: Vlastimil Babka > Signed-off-by: Michal Hocko > --- Acked-by: Hillf Danton > include/linux/compaction.h | 7 +++++-- > include/trace/events/compaction.h | 2 +- > mm/compaction.c | 8 +++++--- > 3 files changed, 11 insertions(+), 6 deletions(-) > > diff --git a/include/linux/compaction.h b/include/linux/compaction.h > index 4458fd94170f..7e177d111c39 100644 > --- a/include/linux/compaction.h > +++ b/include/linux/compaction.h > @@ -4,13 +4,16 @@ > /* Return values for compact_zone() and try_to_compact_pages() */ > /* When adding new states, please adjust include/trace/events/compaction.h */ > enum compact_result { > - /* compaction didn't start as it was deferred due to past failures */ > - COMPACT_DEFERRED, > /* > * compaction didn't start as it was not possible or direct reclaim > * was more suitable > */ > COMPACT_SKIPPED, > + /* compaction didn't start as it was deferred due to past failures */ > + COMPACT_DEFERRED, > + /* compaction not active last round */ > + COMPACT_INACTIVE = COMPACT_DEFERRED, > + > /* compaction should continue to another pageblock */ > COMPACT_CONTINUE, > /* > diff --git a/include/trace/events/compaction.h b/include/trace/events/compaction.h > index e215bf68f521..6ba16c86d7db 100644 > --- a/include/trace/events/compaction.h > +++ b/include/trace/events/compaction.h > @@ -10,8 +10,8 @@ > #include > > #define COMPACTION_STATUS \ > - EM( COMPACT_DEFERRED, "deferred") \ > EM( COMPACT_SKIPPED, "skipped") \ > + EM( COMPACT_DEFERRED, "deferred") \ > EM( COMPACT_CONTINUE, "continue") \ > EM( COMPACT_PARTIAL, "partial") \ > EM( COMPACT_COMPLETE, "complete") \ > diff --git a/mm/compaction.c b/mm/compaction.c > index b06de27b7f72..13709e33a2fc 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -1637,7 +1637,7 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order, > int may_perform_io = gfp_mask & __GFP_IO; > struct zoneref *z; > struct zone *zone; > - enum compact_result rc = COMPACT_DEFERRED; > + enum compact_result rc = COMPACT_SKIPPED; > int all_zones_contended = COMPACT_CONTENDED_LOCK; /* init for &= op */ > > *contended = COMPACT_CONTENDED_NONE; > @@ -1654,8 +1654,10 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order, > enum compact_result status; > int zone_contended; > > - if (compaction_deferred(zone, order)) > + if (compaction_deferred(zone, order)) { > + rc = max_t(enum compact_result, COMPACT_DEFERRED, rc); > continue; > + } > > status = compact_zone_order(zone, order, gfp_mask, mode, > &zone_contended, alloc_flags, > @@ -1726,7 +1728,7 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order, > * If at least one zone wasn't deferred or skipped, we report if all > * zones that were tried were lock contended. > */ > - if (rc > COMPACT_SKIPPED && all_zones_contended) > + if (rc > COMPACT_INACTIVE && all_zones_contended) > *contended = COMPACT_CONTENDED_LOCK; > > return rc; > -- > 2.8.0.rc3