From patchwork Sun Feb 9 07:41:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11372043 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B25F13A4 for ; Sun, 9 Feb 2020 07:42:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4203A20733 for ; Sun, 9 Feb 2020 07:42:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4203A20733 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5AAB46B0007; Sun, 9 Feb 2020 02:42:43 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 55AF86B0008; Sun, 9 Feb 2020 02:42:43 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46F556B000A; Sun, 9 Feb 2020 02:42:43 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id 2DAAB6B0007 for ; Sun, 9 Feb 2020 02:42:43 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C3F7C281A for ; Sun, 9 Feb 2020 07:42:42 +0000 (UTC) X-FDA: 76469796564.04.fact64_1793ff65e223e X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,richardw.yang@linux.intel.com,:akpm@linux-foundation.org::linux-kernel@vger.kernel.org:shakeelb@google.com:yang.shi@linux.alibaba.com:mgorman@techsingularity.net:richardw.yang@linux.intel.com,RULES_HIT:30054:30070,0,RBL:134.134.136.126:@linux.intel.com:.lbl8.mailshell.net-62.18.0.100 64.95.201.95,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: fact64_1793ff65e223e X-Filterd-Recvd-Size: 3188 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Sun, 9 Feb 2020 07:42:41 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Feb 2020 23:42:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,420,1574150400"; d="scan'208";a="225830659" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga008.jf.intel.com with ESMTP; 08 Feb 2020 23:42:37 -0800 From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, shakeelb@google.com, yang.shi@linux.alibaba.com, mgorman@techsingularity.net, Wei Yang Subject: [RFC Patch] mm/vmscan.c: not inherit classzone_idx from previous reclaim Date: Sun, 9 Feb 2020 15:41:45 +0800 Message-Id: <20200209074145.31389-1-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Before commit e716f2eb24de ("mm, vmscan: prevent kswapd sleeping prematurely due to mismatched classzone_idx"), classzone_idx could have two possibilities on a new loop based on whether there is a wakeup during reclaiming: * 0 if no wakeup * the classzone_idx request by wakeup As described in the changelog, this commit is willing to change the first case to (MAX_NR_ZONES - 1) to avoid some premature sleep. But it does not achieve the goal. There are two versions of kswapd_classzone_idx() since this change: * commit e716f2eb24de ("mm, vmscan: prevent kswapd sleeping prematurely due to mismatched classzone_idx") * commit dffcac2cb88e ("mm/vmscan.c: prevent useless kswapd loops") Both of them would return the classzone_idx we passed as the 2nd parameter when (pgdat->kswapd_classzone_idx == MAX_NR_ZONES). This means if there is no wakeup during reclaiming, we would use classzone_idx in previous round to sleep. This patch fixes the logic by using (MAX_NR_ZONES - 1) for the first case. Signed-off-by: Wei Yang Nacked-by: Mel Gorman --- mm/vmscan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index e7b647f70407..ea2f0abef1d4 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3879,7 +3879,7 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_o static int kswapd(void *p) { unsigned int alloc_order, reclaim_order; - unsigned int classzone_idx = MAX_NR_ZONES - 1; + unsigned int classzone_idx; pg_data_t *pgdat = (pg_data_t*)p; struct task_struct *tsk = current; const struct cpumask *cpumask = cpumask_of_node(pgdat->node_id); @@ -3908,7 +3908,7 @@ static int kswapd(void *p) bool ret; alloc_order = reclaim_order = pgdat->kswapd_order; - classzone_idx = kswapd_classzone_idx(pgdat, classzone_idx); + classzone_idx = kswapd_classzone_idx(pgdat, MAX_NR_ZONES - 1); kswapd_try_sleep: kswapd_try_to_sleep(pgdat, alloc_order, reclaim_order,