From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752675AbcGFAaN (ORCPT ); Tue, 5 Jul 2016 20:30:13 -0400 Received: from LGEAMRELO12.lge.com ([156.147.23.52]:39093 "EHLO lgeamrelo12.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752568AbcGFAaG (ORCPT ); Tue, 5 Jul 2016 20:30:06 -0400 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: minchan@kernel.org X-Original-SENDERIP: 165.244.98.150 X-Original-MAILFROM: minchan@kernel.org X-Original-SENDERIP: 10.177.223.161 X-Original-MAILFROM: minchan@kernel.org Date: Wed, 6 Jul 2016 09:30:54 +0900 From: Minchan Kim To: Mel Gorman CC: Andrew Morton , Linux-MM , Rik van Riel , Vlastimil Babka , Johannes Weiner , LKML Subject: Re: [PATCH 08/31] mm, vmscan: simplify the logic deciding whether kswapd sleeps Message-ID: <20160706003054.GC12570@bbox> References: <1467403299-25786-1-git-send-email-mgorman@techsingularity.net> <1467403299-25786-9-git-send-email-mgorman@techsingularity.net> <20160705055931.GC28164@bbox> <20160705102639.GG11498@techsingularity.net> MIME-Version: 1.0 In-Reply-To: <20160705102639.GG11498@techsingularity.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB08/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/07/06 09:30:02, Serialize by Router on LGEKRMHUB08/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/07/06 09:30:02, Serialize complete at 2016/07/06 09:30:02 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 05, 2016 at 11:26:39AM +0100, Mel Gorman wrote: > > > @@ -3418,10 +3426,10 @@ void wakeup_kswapd(struct zone *zone, int order, enum zone_type classzone_idx) > > > if (!cpuset_zone_allowed(zone, GFP_KERNEL | __GFP_HARDWALL)) > > > return; > > > pgdat = zone->zone_pgdat; > > > - if (pgdat->kswapd_max_order < order) { > > > - pgdat->kswapd_max_order = order; > > > - pgdat->classzone_idx = min(pgdat->classzone_idx, classzone_idx); > > > - } > > > + if (pgdat->kswapd_classzone_idx == -1) > > > + pgdat->kswapd_classzone_idx = classzone_idx; > > > > It's tricky. Couldn't we change kswapd_classzone_idx to integer type > > and remove if above if condition? > > > > It's tricky and not necessarily better overall. It's perfectly possible > to be woken up for zone index 0 so it's changing -1 to another magic > value. I don't get it. What is a problem with this? diff --git a/mm/vmscan.c b/mm/vmscan.c index c538a8c..6eb23f5 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3413,9 +3413,7 @@ void wakeup_kswapd(struct zone *zone, int order, enum zone_type classzone_idx) if (!cpuset_zone_allowed(zone, GFP_KERNEL | __GFP_HARDWALL)) return; pgdat = zone->zone_pgdat; - if (pgdat->kswapd_classzone_idx == -1) - pgdat->kswapd_classzone_idx = classzone_idx; - pgdat->kswapd_classzone_idx = max(pgdat->kswapd_classzone_idx, classzone_idx); + pgdat->kswapd_classzone_idx = max_t(int, pgdat->kswapd_classzone_idx, classzone_idx); pgdat->kswapd_order = max(pgdat->kswapd_order, order); if (!waitqueue_active(&pgdat->kswapd_wait)) return;