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 6FD8FC433F5 for ; Thu, 6 Jan 2022 12:03:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E85166B0087; Thu, 6 Jan 2022 07:03:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E350F6B0088; Thu, 6 Jan 2022 07:03:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD5AF6B0089; Thu, 6 Jan 2022 07:03:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0239.hostedemail.com [216.40.44.239]) by kanga.kvack.org (Postfix) with ESMTP id C0DA26B0087 for ; Thu, 6 Jan 2022 07:03:47 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7FEE1180301A2 for ; Thu, 6 Jan 2022 12:03:47 +0000 (UTC) X-FDA: 78999728094.17.7D8B641 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by imf05.hostedemail.com (Postfix) with ESMTP id 232C2100012 for ; Thu, 6 Jan 2022 12:03:46 +0000 (UTC) Received: by mail-wr1-f44.google.com with SMTP id w20so4298880wra.9 for ; Thu, 06 Jan 2022 04:03:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=npqnSRFaqTG8o+cxUeN3GZfyCv3xZD6P4Yk0HwVV8bQ=; b=KE4Xp00e/JzUe50/FTAnwwVdW+9ao6IQv2wjaX8p+tQbSpU4z4UnH6POGxtRjDKLkp DNjYATk++cxEC577Zm3WjP7H5QBZQaHXsYhMUHIVT/IZQfIXrb8ylvU5by0S0bnQJEa7 19IjpJxYk2SHvEI5m0MtvAHHD1etKI0lGxC1rGlTzG3UIPwp/hEtCxYVNtrqCGLW4Lhs 26LM8nCOc/LpqB1JN1YcnBYiE6pJzOhWWVxJUBV6TF0fUCcIG0uuKVSCMOFpz4GUkvVi M6fef0qm+bjS4n5Oob80i2R+5Ly2lpcDFweciXMLWqrutz2zbA7MpMgUiu5zIRUpVW7e u37g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=npqnSRFaqTG8o+cxUeN3GZfyCv3xZD6P4Yk0HwVV8bQ=; b=puRmPaVhMlv/Q3vRN4RkVZoLHg1ZvodPPEiXqiObyp0QfO2vdVTvfFqpyYppJREu/c qXtJbbP0eB/pks9Y2+5IwsTJwkzN1BtL0RBas8N7ysOQND8GkvwsVkco5gGRWhSucWjL uilvqvOs6HvqTHg/xKuWSBfcxPUIoD0Cp8BzcMtAqG6kuNvUXB59BHVm/gBOiNg/lXZ0 n2iA2/mdSDZyYd80OlnKwGm1kZqrnznGh6isogTWaw1ZfaxUrNF+UpEdXcD4XmRE5UKX FfQfKzgmxEDXu5dzBo6X8ZSyZGycIaUcIj1Zh5PrKGFt28IILCf8GKmAcFI2AgmPv80q MlZg== X-Gm-Message-State: AOAM533uP2re0HK2ZBHfYQNFPHSX4HgAKFSIucewKQZYwB429Byf3zHq 6np4swuFFIM2sNXOAHqbCpeFbOQJKMG7CThFAQs= X-Google-Smtp-Source: ABdhPJyBOyB7PdKBHGSsXV4wwFxJBkvHHrU7Rz8Cv5j+BgIyvaW8RjMtw06EmnHNLgokIw1a6YHuBW3stkzyrMVouN8= X-Received: by 2002:a5d:55c2:: with SMTP id i2mr38717983wrw.216.1641470625631; Thu, 06 Jan 2022 04:03:45 -0800 (PST) MIME-Version: 1.0 References: <20220102033129.12913-1-skseofh@gmail.com> <20220106094650.GX3366@techsingularity.net> In-Reply-To: <20220106094650.GX3366@techsingularity.net> From: DaeRo Lee Date: Thu, 6 Jan 2022 21:03:34 +0900 Message-ID: Subject: Re: [PATCH] mm/vmscan.c: no need to double-check if free pages are under high-watermark To: Mel Gorman Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 232C2100012 X-Stat-Signature: 3w55sfauh6bw37jo3qzrkwy9umotmgkt Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=KE4Xp00e; spf=pass (imf05.hostedemail.com: domain of skseofh@gmail.com designates 209.85.221.44 as permitted sender) smtp.mailfrom=skseofh@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1641470626-878572 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: > > @@ -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()) > > While this does avoid calling prepare_kswapd_sleep() twice if the pgdat > is balanced on the first try, it then does not restore the vmstat > thresholds and doesn't call schedul() for kswapd to go to sleep. I intended not to call prepare_kswapd_sleep() twice when the pgdat is NOT balanced on the first try:) > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 700434db5735..40784693c840 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -4355,7 +4355,8 @@ 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; > + bool balanced; > DEFINE_WAIT(wait); > > if (freezing(current) || kthread_should_stop()) > @@ -4370,7 +4371,8 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_o > * eligible zone balanced that it's also unlikely that compaction will > * succeed. > */ > - if (prepare_kswapd_sleep(pgdat, reclaim_order, highest_zoneidx)) { > + balanced = prepare_kswapd_sleep(pgdat, reclaim_order, highest_zoneidx); > + if (balanced) { > /* > * Compaction records what page blocks it recently failed to > * isolate pages from and skips them in the future scanning. > @@ -4387,6 +4389,10 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_o > > remaining = schedule_timeout(HZ/10); > > + /* Is pgdat balanced after a short sleep? */ > + balanced = prepare_kswapd_sleep(pgdat, reclaim_order, > + highest_zoneidx); > + > /* > * If woken prematurely then reset kswapd_highest_zoneidx and > * order. The values will either be from a wakeup request or > @@ -4406,11 +4412,11 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_o > } > > /* > - * After a short sleep, check if it was a premature sleep. If not, then > - * go fully to sleep until explicitly woken up. > + * If balanced to the high watermark, restore vmstat thresholds and > + * kswapd goes to sleep. If kswapd remains awake, account whether > + * the low or high watermark was hit quickly. > */ > - if (!remaining && > - prepare_kswapd_sleep(pgdat, reclaim_order, highest_zoneidx)) { > + if (balanced) { > trace_mm_vmscan_kswapd_sleep(pgdat->node_id); > > /* But, I think what you did is more readable and nice. Thanks! > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index 700434db5735..1217ecec5bbb 100644 > > --- 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 > > * remain at the higher level. > > */ > > return sc.order; > > This hunk just adds a typo, drop it. Sorry about that;;