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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CD16C64EC4 for ; Fri, 17 Feb 2023 04:45:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229436AbjBQEpx (ORCPT ); Thu, 16 Feb 2023 23:45:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbjBQEoz (ORCPT ); Thu, 16 Feb 2023 23:44:55 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75BDD59712 for ; Thu, 16 Feb 2023 20:44:52 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 0CFA961306 for ; Fri, 17 Feb 2023 04:44:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64468C433D2; Fri, 17 Feb 2023 04:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1676609091; bh=c04oUzVaOsfnOvV8yRlinW31fJ0tvnNFVnZvfu4zvuI=; h=Date:To:From:Subject:From; b=1AaSHxb13qp7S/TqTh6HuitVJ5jG1mVnZJYOBqV89O/Oq17olAfiwPi/h1CtSBx9I N2C6aHnNJ/DoDwYxmDNvZjgCedoFQu7enCUFTi5JAVkgiRAjDfkmcrUC6urG14ZLsV SLMlCSqNd4uI4fFc0jFTv1Xmb5+KnAXLu4gVj5hc= Date: Thu, 16 Feb 2023 20:44:50 -0800 To: mm-commits@vger.kernel.org, tjmercier@google.com, yuzhao@google.com, akpm@linux-foundation.org From: Andrew Morton Subject: [merged mm-stable] mm-multi-gen-lru-avoid-futile-retries.patch removed from -mm tree Message-Id: <20230217044451.64468C433D2@smtp.kernel.org> Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The quilt patch titled Subject: mm: multi-gen LRU: avoid futile retries has been removed from the -mm tree. Its filename was mm-multi-gen-lru-avoid-futile-retries.patch This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm ------------------------------------------------------ From: Yu Zhao Subject: mm: multi-gen LRU: avoid futile retries Date: Mon, 13 Feb 2023 00:53:22 -0700 Recall that the per-node memcg LRU has two generations and they alternate when the last memcg (of a given node) is moved from one to the other. Each generation is also sharded into multiple bins to improve scalability. A reclaimer starts with a random bin (in the old generation) and, if it fails, it will retry, i.e., to try the rest of the bins. If a reclaimer fails with the last memcg, it should move this memcg to the young generation first, which causes the generations to alternate, and then retry. Otherwise, the retries will be futile because all other bins are empty. Link: https://lkml.kernel.org/r/20230213075322.1416966-1-yuzhao@google.com Fixes: e4dde56cd208 ("mm: multi-gen LRU: per-node lru_gen_folio lists") Signed-off-by: Yu Zhao Reported-by: T.J. Mercier Signed-off-by: Andrew Morton --- --- a/mm/vmscan.c~mm-multi-gen-lru-avoid-futile-retries +++ a/mm/vmscan.c @@ -5356,18 +5356,20 @@ static int shrink_one(struct lruvec *lru static void shrink_many(struct pglist_data *pgdat, struct scan_control *sc) { + int op; int gen; int bin; int first_bin; struct lruvec *lruvec; struct lru_gen_folio *lrugen; + struct mem_cgroup *memcg; const struct hlist_nulls_node *pos; - int op = 0; - struct mem_cgroup *memcg = NULL; unsigned long nr_to_reclaim = get_nr_to_reclaim(sc); bin = first_bin = get_random_u32_below(MEMCG_NR_BINS); restart: + op = 0; + memcg = NULL; gen = get_memcg_gen(READ_ONCE(pgdat->memcg_lru.seq)); rcu_read_lock(); @@ -5391,14 +5393,22 @@ restart: op = shrink_one(lruvec, sc); - if (sc->nr_reclaimed >= nr_to_reclaim) - goto success; - rcu_read_lock(); + + if (sc->nr_reclaimed >= nr_to_reclaim) + break; } rcu_read_unlock(); + if (op) + lru_gen_rotate_memcg(lruvec, op); + + mem_cgroup_put(memcg); + + if (sc->nr_reclaimed >= nr_to_reclaim) + return; + /* restart if raced with lru_gen_rotate_memcg() */ if (gen != get_nulls_value(pos)) goto restart; @@ -5407,11 +5417,6 @@ restart: bin = get_memcg_bin(bin + 1); if (bin != first_bin) goto restart; -success: - if (op) - lru_gen_rotate_memcg(lruvec, op); - - mem_cgroup_put(memcg); } static void lru_gen_shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc) _ Patches currently in -mm which might be from yuzhao@google.com are