Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp24981pxb; Wed, 30 Mar 2022 21:52:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR+HIzqc0M/ZtCop86fbkdxlzHrSsv/ZdSzvYh3NU3a3BYGcyhdBcm96zd1AOMVbtaAo/f X-Received: by 2002:a05:6a00:1501:b0:4fb:2d19:b6a8 with SMTP id q1-20020a056a00150100b004fb2d19b6a8mr3488624pfu.21.1648702358237; Wed, 30 Mar 2022 21:52:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648702358; cv=none; d=google.com; s=arc-20160816; b=l8ommH+PRHRTDiMA3MVDxRAukWD5svu8YGNlEc+9epdQ+Pf2pGEsZnBklqDahpnGVL MZ/JvTTpW1HCgnLIpjKA4Jjgvwbu44OMt/9JCTSe0Vhbl4RBbhj15pF8yBDflsry/GEO USXYoGEwjnwC3ok9cQL6tkAZFI8jsW2a5vUj8bq6A9UYoYZE+8Lv66kisMbaq8YfyX99 VYaS44s5avBQ/fOM6bUB0I8JXzHCV0EgH8fNDrIEPoOvpePFwNfTS48ApUHzRXzYoD6Y JQ2YaI/K6uyhU8MfM5WpNKFPTVrHe2B89G7sCZt8+gbgWB32kGCYdPqe9CIJ2lF+1EhE qOCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=6BYILNTIPfnQ80tiRFzGN+1Svgk8JVvXymct2OKtnuQ=; b=dMEBIAJxhldu9gd2ubJpOtVHtgPsRIUj9+3ZVUnomXBQAMtve8Kos2og3dGhPn/FK7 P0FWZro5TJ0VWJxbv0Od5gstl0Lm7WSEGCvv4Y2u7nZ6awMWq/zmI+ZLNMPXNGDkaObL 24xQvEfN4yQyRGKW3u2ds33+qSIk+iapF87MAM8Dnn/IaRDL/BxqBteGTeo7rv6jkP8T 863sVQHgieHu3s4RVJaWRbbSim1tWy5jz7hO53My5F+OehZupgrXVEvuDsAkK2f1rcQz HQL3bJefq/eTq53Z1JGqpt7nEEoPl30+8xY9HkPJ0OAGlhJ+UuXZ0pFuJMHlxRm4u8KD cgSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UCDZcK2f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m9-20020aa79009000000b004faf1d84ebcsi22175390pfo.279.2022.03.30.21.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 21:52:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UCDZcK2f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5E83D214F98; Wed, 30 Mar 2022 20:32:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241411AbiC3AQP (ORCPT + 99 others); Tue, 29 Mar 2022 20:16:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231715AbiC3AQO (ORCPT ); Tue, 29 Mar 2022 20:16:14 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62BD7689AE for ; Tue, 29 Mar 2022 17:14:30 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id z92so22494867ede.13 for ; Tue, 29 Mar 2022 17:14:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to:user-agent; bh=6BYILNTIPfnQ80tiRFzGN+1Svgk8JVvXymct2OKtnuQ=; b=UCDZcK2fFmQwYa7X6zFZApqicwxlkir//PRkL9ogxK42ls2ScTKTrLGQrT0Bm11kXr EAStHTYWOEPXBIxErv6aSydMHy/iIXxnvgSh2Knrync2dq8cwxIH2TNfPiFwEhF+65NB fg00t2THz619b2X/8q1EbsExjQdDEBVsn0LtPJ8TDOFL+2P+6MpekFE6gomkXF8Tf6vu DdBnzkZojCOJAPEx1k2YvrV1AfevfG+oIz9Yw/jZCumaBms7hOU6UGlGHh7D0WC+t0Rn f/Qit8I0PKz59uWJUHmbsLSZptuKEutMp8DOxXzaBjpSewjXZPf92VLVT9czDq/2HTNc TfnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=6BYILNTIPfnQ80tiRFzGN+1Svgk8JVvXymct2OKtnuQ=; b=6NSkQM4vc02wjRI7vS7ZJCaGsOtT66ziOGWbKqWloeK4UQNfAOm4qwQGtJ2tgWKll6 gPGNnPO8PCiLY4j4LvKeKPwxJFthpChRGLeYyd/m6dOEDafJii0NEkpxjV5GeQJAcnWE s4oKlckwFxAxZIrLeB7xcrhDt/Tyyf5Jn8wKM5rCyZGy60rpRsO25GSw694KHRNQXzsy 3puxLxv1ps+5emRGtqV0Pgs9mFortIW6a61Ca6ToG7PbhHARKPYK9yakZqTTesKG9ECu z0wUnDiLOzQnYmiPBY0HkgCWchCjwxObBMHCPmc/637L6GOpZVOpnbShsYd0HH8T5Hrn 1u4Q== X-Gm-Message-State: AOAM5307AAG6nxL89QuSt3xHPeSh14/ZFAxvDiVr1tloOiOR7KaDKIb6 9il9ci4OgLjMYRu+h9lBQyI= X-Received: by 2002:a05:6402:40cb:b0:419:42de:65b6 with SMTP id z11-20020a05640240cb00b0041942de65b6mr7845399edb.66.1648599268830; Tue, 29 Mar 2022 17:14:28 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id z13-20020a17090674cd00b006df78d85eabsm7663465ejl.111.2022.03.29.17.14.28 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Mar 2022 17:14:28 -0700 (PDT) Date: Wed, 30 Mar 2022 00:14:27 +0000 From: Wei Yang To: "Huang, Ying" Cc: Wei Yang , 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 Message-ID: <20220330001427.a745zl3qej2fajmf@master> Reply-To: Wei Yang 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> <871qylfr8f.fsf@yhuang6-desk2.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <871qylfr8f.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: NeoMutt/20170113 (1.7.2) X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 29, 2022 at 10:05:20AM +0800, Huang, Ying wrote: >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. > You are right, I misunderstand it. Sorry -- Wei Yang Help you, Help me