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 99A16C433EF for ; Tue, 29 Mar 2022 02:05:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1AA9B8D0002; Mon, 28 Mar 2022 22:05:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 155448D0001; Mon, 28 Mar 2022 22:05:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F37338D0002; Mon, 28 Mar 2022 22:05:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id E5AD18D0001 for ; Mon, 28 Mar 2022 22:05:27 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 93220603BF for ; Tue, 29 Mar 2022 02:05:27 +0000 (UTC) X-FDA: 79295781894.01.6CC975C Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf02.hostedemail.com (Postfix) with ESMTP id 1A1F480010 for ; Tue, 29 Mar 2022 02:05:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648519526; x=1680055526; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=CD43qK+AfcCULQ1+tD6UAMseC0SXJNBZ8tTh+WUghbQ=; b=JZEMUtzoSgzyHhypl2TpY++t+he6Mylqo5lJJZdsy/9ET04zQzXE3BbE HyAPzcnaAsne1of27NjJDD7FYlxCrOeczXYnOed+9RVKm6BXuqLZ99iWW imDE/p5EO4CPdZpBnJ3IGOfDl6dAY/MgjLBRTLxdpB9lDnFcXWnzMlyeX y5DDMFX3W9E4aQq7MMQG097iNmp73GiJRCGX1gsaAGzdm2+Y4GdkTpRy5 4ZowmQR2zyCoqkf9zhc0RgsGQ4aA/BJ3hGIqgD8xPkxr4nDfL5aBy5dba C70lQJ2LELfPOQXONinUtO07WU3M/Pc7LhSQJJIOZJmQb3X5YZU8j7g47 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10300"; a="239737259" X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="239737259" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 19:05:24 -0700 X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="564196031" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.239.13.94]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 19:05:22 -0700 From: "Huang, Ying" To: Wei Yang Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, mgorman@techsingularity.net Subject: Re: [PATCH 2/2] mm/vmscan: make sure wakeup_kswapd with managed zone References: <20220327024101.10378-1-richard.weiyang@gmail.com> <20220327024101.10378-2-richard.weiyang@gmail.com> <8735j2opd9.fsf@yhuang6-desk2.ccr.corp.intel.com> <20220329004146.2xdswvrm2qu7f47x@master> <875ynxh9lg.fsf@yhuang6-desk2.ccr.corp.intel.com> <20220329015230.hneciyfxoxtvfytl@master> Date: Tue, 29 Mar 2022 10:05:20 +0800 In-Reply-To: <20220329015230.hneciyfxoxtvfytl@master> (Wei Yang's message of "Tue, 29 Mar 2022 01:52:30 +0000") Message-ID: <871qylfr8f.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1A1F480010 X-Rspam-User: Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=JZEMUtzo; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf02.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.151) smtp.mailfrom=ying.huang@intel.com X-Stat-Signature: t37iopt3tn1smcunxrtgwgq6g13ic969 X-HE-Tag: 1648519525-836564 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: Wei Yang writes: > On Tue, Mar 29, 2022 at 08:43:23AM +0800, Huang, Ying wrote: > [...] >>>>> --- a/mm/migrate.c >>>>> +++ b/mm/migrate.c >>>>> @@ -2046,7 +2046,7 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) >>>>> if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING)) >>>>> return 0; >>>>> for (z = pgdat->nr_zones - 1; z >= 0; z--) { >>>>> - if (populated_zone(pgdat->node_zones + z)) >>>>> + if (managed_zone(pgdat->node_zones + z)) >>>> >>>>This looks good to me! Thanks! It seems that we can replace >>>>populated_zone() in migrate_balanced_pgdat() too. Right? >>>> >>> >>> Yes, you are right. I didn't spot this. >>> >>> While this patch comes from the clue of wakeup_kswapd(), I am not sure it is >>> nice to put it in this patch together. >>> >>> Which way you prefer to include this: merge the change into this one, or a >>> separate one? >> >>Either is OK for me. >> > > After reading the code, I am willing to do a little simplification. Does this > look good to you? > > From 85c8a5cd708ada3e9f5b0409413407b7be1bc446 Mon Sep 17 00:00:00 2001 > From: Wei Yang > Date: Tue, 29 Mar 2022 09:24:36 +0800 > Subject: [PATCH] mm/migrate.c: return valid zone for wakeup_kswapd from > migrate_balanced_pgdat() > > To wakeup kswapd, we need to iterate pgdat->node_zones and get the > proper zone. While this work has already been done in > migrate_balanced_pgdat(). > > Let's return the valid zone directly instead of do the iteration again. > > Signed-off-by: Wei Yang > --- > mm/migrate.c | 21 ++++++++------------- > 1 file changed, 8 insertions(+), 13 deletions(-) > > diff --git a/mm/migrate.c b/mm/migrate.c > index 5adc55b5347c..b086bd781956 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -1973,7 +1973,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages, > * Returns true if this is a safe migration target node for misplaced NUMA > * pages. Currently it only checks the watermarks which is crude. > */ > -static bool migrate_balanced_pgdat(struct pglist_data *pgdat, > +static struct zone *migrate_balanced_pgdat(struct pglist_data *pgdat, > unsigned long nr_migrate_pages) > { > int z; > @@ -1985,14 +1985,13 @@ static bool migrate_balanced_pgdat(struct pglist_data *pgdat, > continue; > > /* Avoid waking kswapd by allocating pages_to_migrate pages. */ > - if (!zone_watermark_ok(zone, 0, > + if (zone_watermark_ok(zone, 0, > high_wmark_pages(zone) + > nr_migrate_pages, > ZONE_MOVABLE, 0)) > - continue; > - return true; > + return zone; > } > - return false; > + return NULL; > } > > static struct page *alloc_misplaced_dst_page(struct page *page, > @@ -2032,6 +2031,7 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) > int page_lru; > int nr_pages = thp_nr_pages(page); > int order = compound_order(page); > + struct zone *zone; > > VM_BUG_ON_PAGE(order && !PageTransHuge(page), page); > > @@ -2040,16 +2040,11 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) > return 0; > > /* Avoid migrating to a node that is nearly full */ > - if (!migrate_balanced_pgdat(pgdat, nr_pages)) { > - int z; > - > + if ((zone = migrate_balanced_pgdat(pgdat, nr_pages))) { I think that this reverses the original semantics. Originally, we give up and wake up kswapd if there's no enough free pages on the target node. But now, you give up and wake up if there's enough free pages. Best Regards, Huang, Ying > if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING)) > return 0; > - for (z = pgdat->nr_zones - 1; z >= 0; z--) { > - if (managed_zone(pgdat->node_zones + z)) > - break; > - } > - wakeup_kswapd(pgdat->node_zones + z, 0, order, ZONE_MOVABLE); > + > + wakeup_kswapd(zone, 0, order, ZONE_MOVABLE); > return 0; > } > > -- > > 2.33.1