From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7ACC6C433F5 for ; Thu, 6 Jan 2022 00:17:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E73706B0085; Wed, 5 Jan 2022 19:17:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DFC236B0087; Wed, 5 Jan 2022 19:17:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C76EB6B0088; Wed, 5 Jan 2022 19:17:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id B02BB6B0085 for ; Wed, 5 Jan 2022 19:17:11 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 6899C181DA54F for ; Thu, 6 Jan 2022 00:17:11 +0000 (UTC) X-FDA: 78997947462.07.CC7E98A Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf11.hostedemail.com (Postfix) with ESMTP id 9DF2F40005 for ; Thu, 6 Jan 2022 00:17:06 +0000 (UTC) Received: from mail.kernel.org (unknown [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B76A8B81E7F; Thu, 6 Jan 2022 00:17:09 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 3524E60E9C; Thu, 6 Jan 2022 00:17:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1641428228; bh=bBatHOpdNSaaESTIT2TeqAUEVF3cTHVp4THfZpdxJVA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UkjF2UpuXgFhRDP86iYGb0F4DACratLWx4P7peG5mDqn/7kqwqQQMd6XP7E0vfzKl 3w6/tfI+GDWJ4h1wqexP5aKHF/su0wv+x4FjyuRWCZ5uMoAGjZFdZjt9i5mwEIEunG IKG6vWaMVOO3CEOjh365P3jbKgLaUR6pzSe4/lf4= Date: Wed, 5 Jan 2022 16:17:06 -0800 From: Andrew Morton To: skseofh@gmail.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mel Gorman , Joonsoo Kim Subject: Re: [PATCH] mm/vmscan.c: no need to double-check if free pages are under high-watermark Message-Id: <20220105161706.625b7b58d79eddaf38567568@linux-foundation.org> In-Reply-To: <20220102033129.12913-1-skseofh@gmail.com> References: <20220102033129.12913-1-skseofh@gmail.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=UkjF2Upu; dmarc=none; spf=pass (imf11.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 9DF2F40005 X-Stat-Signature: frwcqddszx9inr8j1zz7w6z974fncth1 X-HE-Tag: 1641428226-661499 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: On Sun, 2 Jan 2022 12:31:29 +0900 skseofh@gmail.com wrote: > From: Daero Lee > > In kswapd_try_to_sleep function, to check whether kswapd can sleep, > the prepare_kswapd_sleep function is called twice. > > If free pages are below high-watermark in the first call, > the @remaining variable is not updated at 0 and the > prepare_kswapd_sleep function is called for the second time. > > I think it is necessary to set the initial value of the > @remaining to a non-zero value to prevent consecutive calls > to the same function. Seems right. Mel & Joonsoo, could you please check? > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -4331,7 +4331,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int highest_zoneidx) > /* > * Return the order kswapd stopped reclaiming at as > * prepare_kswapd_sleep() takes it into account. If another caller > - * entered the allocator slow path while kswapd was awake, order will > + * entered the allqocator slow path while kswapd was awake, order will whoops. > * remain at the higher level. > */ > return sc.order; > @@ -4355,7 +4355,7 @@ static enum zone_type kswapd_highest_zoneidx(pg_data_t *pgdat, > static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_order, > unsigned int highest_zoneidx) > { > - long remaining = 0; > + long remaining = ~0; > DEFINE_WAIT(wait); > > if (freezing(current) || kthread_should_stop())