Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2466795ybv; Sat, 8 Feb 2020 23:47:18 -0800 (PST) X-Google-Smtp-Source: APXvYqy8vsFsJ8NFfZg0RuSD+6qd9640XgSTsPQ0lXt8OXXA3O2oSSoc/AiakGMhZryM7X2eLCqU X-Received: by 2002:aca:b187:: with SMTP id a129mr7447264oif.175.1581234438746; Sat, 08 Feb 2020 23:47:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581234438; cv=none; d=google.com; s=arc-20160816; b=NbTMtpBDpCcjMrAedCzTzgwRsO7QtT7nt5jfCxZH+gzxVdTt/58DTW6wtezK7AbKAi dZQXu/jbIJFp7J4H0MgCtIiFOaRiTZtz4ltYjGlopdLsTHMjEqm9VcoOi67+TGvCVeeX igqNjim5NPIHnME6gO3ei26ckZ6hhW3O46lSYXgzPpEziTPeYhyobKVVRb0YA9kogsx2 39mT+hyKAQ8lvcfYeRoTb8iQElqGkA2+9UY12iRbZM/yDAbqCiE8WJeLg3FHuB3A5pKE b3FYQJWiRQWlmaVI2AzJpccBFaZirm0IEfZ7FwQfvpM4akG0wIpGjFzUyMIdm7m/1iaD M47w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=nvZQP6tdoa1brlmPjRGeVSXHrWgbjg4aD9gjCZmQOYU=; b=dWhB29Qd5ty88tLJmWzAQXI2S2RCmf6tDb1F8Bd1HteowF6o6ejCvTLzODnDLr0Kfa VHmuyClgI30UDpi+pvV45dp9FvAAq67HvBty4Wzxg7y4DJOXR9MZCEw9bDJTAznrmFLz /52Clf06SXUiJ/suxr7OUlnLd3cC31QuBpMlHvu5D/QnFt9u28OE5/RHuApiUY6J95GL LBxPWRMjuh0j5SUwkni+VNOKjD1iZt9FONlXSszD31jt6qeAZEZwZ2c0/LyMGl0fciJz 6Gz007p+OjPzbrzVD/1kzbAurqfN0pbmyMt35rvFWbIcHhfAxMAk6o0Zse61+NHYJAS5 A7uw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d28si6718879oic.47.2020.02.08.23.46.41; Sat, 08 Feb 2020 23:47:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726378AbgBIHmk (ORCPT + 99 others); Sun, 9 Feb 2020 02:42:40 -0500 Received: from mga05.intel.com ([192.55.52.43]:36277 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbgBIHmj (ORCPT ); Sun, 9 Feb 2020 02:42:39 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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, -- 2.17.1