Commit 8a87d695 authored by Wonhyuk Yang's avatar Wonhyuk Yang Committed by Andrew Morton
Browse files

mm/page_alloc: cache the result of node_dirty_ok()

To spread dirty pages, nodes are checked whether they have reached the
dirty limit using the expensive node_dirty_ok().  To reduce the frequency
of calling node_dirty_ok(), the last node that hit the dirty limit can be
cached.

Instead of caching the node, caching both the node and its node_dirty_ok()
status can reduce the number of calle to node_dirty_ok().

[akpm@linux-foundation.org: rename last_pgdat_dirty_limit to last_pgdat_dirty_ok]
Link: https://lkml.kernel.org/r/20220430011032.64071-1-vvghjk1234@gmail.com


Signed-off-by: default avatarWonhyuk Yang <vvghjk1234@gmail.com>
Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Acked-by: default avatarMel Gorman <mgorman@suse.de>
Cc: Donghyeok Kim <dthex5d@gmail.com>
Cc: JaeSang Yoo <jsyoo5b@gmail.com>
Cc: Jiyoup Kim <lakroforce@gmail.com>
Cc: Ohhoon Kwon <ohkwon1043@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 81a84182
Loading
Loading
Loading
Loading
+7 −6
Original line number Original line Diff line number Diff line
@@ -4021,7 +4021,8 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,
{
{
	struct zoneref *z;
	struct zoneref *z;
	struct zone *zone;
	struct zone *zone;
	struct pglist_data *last_pgdat_dirty_limit = NULL;
	struct pglist_data *last_pgdat = NULL;
	bool last_pgdat_dirty_ok = false;
	bool no_fallback;
	bool no_fallback;


retry:
retry:
@@ -4060,14 +4061,14 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,
		 * dirty-throttling and the flusher threads.
		 * dirty-throttling and the flusher threads.
		 */
		 */
		if (ac->spread_dirty_pages) {
		if (ac->spread_dirty_pages) {
			if (last_pgdat_dirty_limit == zone->zone_pgdat)
			if (last_pgdat != zone->zone_pgdat) {
				continue;
				last_pgdat = zone->zone_pgdat;
				last_pgdat_dirty_ok = node_dirty_ok(zone->zone_pgdat);
			}


			if (!node_dirty_ok(zone->zone_pgdat)) {
			if (!last_pgdat_dirty_ok)
				last_pgdat_dirty_limit = zone->zone_pgdat;
				continue;
				continue;
		}
		}
		}


		if (no_fallback && nr_online_nodes > 1 &&
		if (no_fallback && nr_online_nodes > 1 &&
		    zone != ac->preferred_zoneref->zone) {
		    zone != ac->preferred_zoneref->zone) {