From patchwork Sat Apr 30 01:10:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wonhyuk Yang X-Patchwork-Id: 12833016 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 79920C433EF for ; Sat, 30 Apr 2022 01:10:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F9AA6B0071; Fri, 29 Apr 2022 21:10:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 780926B0072; Fri, 29 Apr 2022 21:10:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D4006B0073; Fri, 29 Apr 2022 21:10:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 481A86B0071 for ; Fri, 29 Apr 2022 21:10:41 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 206F028F88 for ; Sat, 30 Apr 2022 01:10:41 +0000 (UTC) X-FDA: 79411765482.13.B05CC7D Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf01.hostedemail.com (Postfix) with ESMTP id D65D940023 for ; Sat, 30 Apr 2022 01:10:34 +0000 (UTC) Received: by mail-pl1-f180.google.com with SMTP id n14so1627377plf.3 for ; Fri, 29 Apr 2022 18:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HUvLzatNb0wuRiUwrpeITDjSWvWYxQ7+pBRT10EPG34=; b=U01NK771gyD2u/0rl7aHPLiWERoKiMxFcSbHTVhnjpdpTiWrWb9L6gm/C++rhgZlg0 1N1GxLNkOGpMP4B/I/XQGCdiKKkcyLYu7dZ1cFZ/jm/XVx2Wv8HdIyXnouhMv35oGiH1 5gue7dAzmB5Daqmy1Usl9Hs0ZdTuZjbknpamOf/i5YrHRKGu74pvg1J15/PzSPlw0/oZ 4gTZ0uJmiESJvS1AXeZ69FXr2wZuV/AqxH83LAp9QFrnJLvzQluAJtFJwnDAiwGtEdbE PrYo0QjodS8PNONqo1DwA6S9sOfrmakXxsckHLcpTEE5e04G4ye/zmuwpUQ53+z7V9rt E0VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HUvLzatNb0wuRiUwrpeITDjSWvWYxQ7+pBRT10EPG34=; b=y94zDNnn4jUQnPc41wE3n55KnTjviVpEm9SPHsyZrhNlbZ9ueBBstWGxHLiFmJKzTt HCMRPZjklR3vqdDbKk9EVQ0iiGYovPugftL2RYkpfhbywGkqwPpk3xfRbKVImZOZULiv 2kp5bb7hd0kANRjooRpiEFJARvBrb3+W5U0/Cs/dEG/9FJTi2knpXXaHpe3+vUZXQScS 41hMfh1RliwX1JTw3ih14SbeyAS7vAwvbb89/SkJMxBqS7wbAhAKM7OhL8Ryn4krDF/H rEjWTySHxckY+0HYIH/V88PKKvnFsD+mb90jmVfFeWzzTC4iiAE6Nf28TCI49hv9Jobg N53w== X-Gm-Message-State: AOAM530TyAqH4kd2tJ1+jMIEAvpFVYDAY1cjYVW1ZunSxqiXvmZ6Rsfx PcPqCFXpXPANCunMIZFtXS8= X-Google-Smtp-Source: ABdhPJx0HoYQRpElDgCFT/ew+2skNC5TEP+YatqGOH/IqSVePlSnmKImtIOfqTr9+e6uPnn1Zh7eTQ== X-Received: by 2002:a17:903:240c:b0:153:c8df:7207 with SMTP id e12-20020a170903240c00b00153c8df7207mr1670891plo.44.1651281039758; Fri, 29 Apr 2022 18:10:39 -0700 (PDT) Received: from localhost.localdomain ([125.131.156.123]) by smtp.gmail.com with ESMTPSA id k3-20020a170902694300b0015e8d4eb24fsm212271plt.153.2022.04.29.18.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 18:10:38 -0700 (PDT) From: Wonhyuk Yang To: Mel Gorman , Andrew Morton Cc: Ohhoon Kwon , JaeSang Yoo , Wonhyuk Yang , Jiyoup Kim , Donghyeok Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm/page_alloc: cache the result of node_dirty_ok() Date: Sat, 30 Apr 2022 10:10:32 +0900 Message-Id: <20220430011032.64071-1-vvghjk1234@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Stat-Signature: 16zn5pgexya895iyo853trtosy3eedct X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D65D940023 X-Rspam-User: Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=U01NK771; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of vvghjk1234@gmail.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=vvghjk1234@gmail.com X-HE-Tag: 1651281034-664515 X-Bogosity: Ham, tests=bogofilter, spamicity=0.014310, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: To spread dirty page, nodes are checked whether it reached the dirty limit using the expensive node_dirty_ok(). To reduce the number of calling node_dirty_ok(), last node that hit the dirty limit is cached. Instead of caching the node, caching both node and it's result of node_dirty_ok() can reduce the number of calling node_dirty_ok() more than before. Signed-off-by: Wonhyuk Yang Acked-by: Mel Gorman Acked-by: Johannes Weiner --- mm/page_alloc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0e42038382c1..aba62cf31a0e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4068,7 +4068,8 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, { struct zoneref *z; struct zone *zone; - struct pglist_data *last_pgdat_dirty_limit = NULL; + struct pglist_data *last_pgdat = NULL; + bool last_pgdat_dirty_limit = false; bool no_fallback; retry: @@ -4107,13 +4108,13 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, * dirty-throttling and the flusher threads. */ if (ac->spread_dirty_pages) { - if (last_pgdat_dirty_limit == zone->zone_pgdat) - continue; + if (last_pgdat != zone->zone_pgdat) { + last_pgdat = zone->zone_pgdat; + last_pgdat_dirty_limit = node_dirty_ok(zone->zone_pgdat); + } - if (!node_dirty_ok(zone->zone_pgdat)) { - last_pgdat_dirty_limit = zone->zone_pgdat; + if (!last_pgdat_dirty_limit) continue; - } } if (no_fallback && nr_online_nodes > 1 &&