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 54FFDC433EF for ; Sat, 30 Apr 2022 18:38:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AFFD06B0072; Sat, 30 Apr 2022 14:38:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AAFA46B0073; Sat, 30 Apr 2022 14:38:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 977B76B0074; Sat, 30 Apr 2022 14:38:48 -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 84A0E6B0072 for ; Sat, 30 Apr 2022 14:38:48 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 51FCB282F7 for ; Sat, 30 Apr 2022 18:38:48 +0000 (UTC) X-FDA: 79414406736.06.977D58E Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf10.hostedemail.com (Postfix) with ESMTP id 2D516C0071 for ; Sat, 30 Apr 2022 18:38:35 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (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 88277B8077F; Sat, 30 Apr 2022 18:38:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04EACC385AA; Sat, 30 Apr 2022 18:38:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1651343924; bh=0kM/bEs+g1gOFSB9VF1SRjrnl2Jg+odHTRMiA+YRZbU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=mgeN3VVmKBNqS5F1fJjP+uFVBus1BjgNrNcklhgB//33m4Njw7MXJgdIUJa1dbzqJ bzghRIti9rqpT6dvLHFpwoUm+gQLWw6zY2O/XSV11j8SqP1C0EahIZrbgtVI7sTpnk NHGSzOm7di8TftrCHI0S4cGJc3KgAyR2mEB7hWNU= Date: Sat, 30 Apr 2022 11:38:43 -0700 From: Andrew Morton To: Wonhyuk Yang Cc: Mel Gorman , Ohhoon Kwon , JaeSang Yoo , Jiyoup Kim , Donghyeok Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/page_alloc: cache the result of node_dirty_ok() Message-Id: <20220430113843.7350160cf329e2a732e1cb94@linux-foundation.org> In-Reply-To: <20220430011032.64071-1-vvghjk1234@gmail.com> References: <20220430011032.64071-1-vvghjk1234@gmail.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Stat-Signature: jqe6mxeiy3ekj3ize1ye3harnrykepsw X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2D516C0071 X-Rspam-User: Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=mgeN3VVm; dmarc=none; spf=pass (imf10.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-HE-Tag: 1651343915-178118 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 Sat, 30 Apr 2022 10:10:32 +0900 Wonhyuk Yang wrote: > 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. > > ... > > --- 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 && Looks reasonable to me. Hopefully Mel and Johannes can review. I think last_pgdat_dirty_limit isn't a great name. It records the dirty_ok state of last_pgdat. So why not call it last_pgdat_dirty_ok? --- a/mm/page_alloc.c~mm-page_alloc-cache-the-result-of-node_dirty_ok-fix +++ a/mm/page_alloc.c @@ -4022,7 +4022,7 @@ get_page_from_freelist(gfp_t gfp_mask, u struct zoneref *z; struct zone *zone; struct pglist_data *last_pgdat = NULL; - bool last_pgdat_dirty_limit = false; + bool last_pgdat_dirty_ok = false; bool no_fallback; retry: @@ -4063,10 +4063,10 @@ retry: if (ac->spread_dirty_pages) { if (last_pgdat != zone->zone_pgdat) { last_pgdat = zone->zone_pgdat; - last_pgdat_dirty_limit = node_dirty_ok(zone->zone_pgdat); + last_pgdat_dirty_ok = node_dirty_ok(zone->zone_pgdat); } - if (!last_pgdat_dirty_limit) + if (!last_pgdat_dirty_ok) continue; } _