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 79C78C77B75 for ; Tue, 18 Apr 2023 23:34:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231590AbjDRXeq (ORCPT ); Tue, 18 Apr 2023 19:34:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbjDRXeK (ORCPT ); Tue, 18 Apr 2023 19:34:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AD9C9EEE for ; Tue, 18 Apr 2023 16:34:04 -0700 (PDT) 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 695CB615E4 for ; Tue, 18 Apr 2023 23:34:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3C0FC433EF; Tue, 18 Apr 2023 23:34:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1681860843; bh=RT7VQuWAGh3sLNoiMEz2+XmaM1pR5l+Z0RyWgLGGy4g=; h=Date:To:From:Subject:From; b=NYWktxgpH16LtBGyAk6BqrIZN0XQLP67UzSjiKSTpxC8uI3aRKuHEDotzqPomG4Cg Jf5ELxrybgtOBPG9CtCPvl6uIZmkr43zRlAyho2EbQ5POuDq1zDPBLUjLyqpi54gft pPQwYFwv/N5Le77DCBbibleGLkt9n81g9sLZkSGg= Date: Tue, 18 Apr 2023 16:34:03 -0700 To: mm-commits@vger.kernel.org, vasily.averin@linux.dev, tj@kernel.org, shakeelb@google.com, roman.gushchin@linux.dev, muchun.song@linux.dev, mkoutny@suse.com, mhocko@suse.com, mhocko@kernel.org, lizefan.x@bytedance.com, josef@toxicpanda.com, hannes@cmpxchg.org, axboe@kernel.dk, yosryahmed@google.com, akpm@linux-foundation.org From: Andrew Morton Subject: [merged mm-stable] memcg-do-not-flush-stats-in-irq-context.patch removed from -mm tree Message-Id: <20230418233403.C3C0FC433EF@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: memcg: do not flush stats in irq context has been removed from the -mm tree. Its filename was memcg-do-not-flush-stats-in-irq-context.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: Yosry Ahmed Subject: memcg: do not flush stats in irq context Date: Thu, 30 Mar 2023 19:17:56 +0000 Currently, the only context in which we can invoke an rstat flush from irq context is through mem_cgroup_usage() on the root memcg when called from memcg_check_events(). An rstat flush is an expensive operation that should not be done in irq context, so do not flush stats and use the stale stats in this case. Arguably, usage threshold events are not reliable on the root memcg anyway since its usage is ill-defined. Link: https://lkml.kernel.org/r/20230330191801.1967435-4-yosryahmed@google.com Signed-off-by: Yosry Ahmed Suggested-by: Johannes Weiner Suggested-by: Shakeel Butt Acked-by: Shakeel Butt Acked-by: Johannes Weiner Acked-by: Michal Hocko Cc: Jens Axboe Cc: Josef Bacik Cc: Michal Hocko Cc: Michal Koutný Cc: Muchun Song Cc: Roman Gushchin Cc: Tejun Heo Cc: Vasily Averin Cc: Zefan Li Signed-off-by: Andrew Morton --- mm/memcontrol.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) --- a/mm/memcontrol.c~memcg-do-not-flush-stats-in-irq-context +++ a/mm/memcontrol.c @@ -3670,7 +3670,21 @@ static unsigned long mem_cgroup_usage(st unsigned long val; if (mem_cgroup_is_root(memcg)) { - mem_cgroup_flush_stats(); + /* + * We can reach here from irq context through: + * uncharge_batch() + * |--memcg_check_events() + * |--mem_cgroup_threshold() + * |--__mem_cgroup_threshold() + * |--mem_cgroup_usage + * + * rstat flushing is an expensive operation that should not be + * done from irq context; use stale stats in this case. + * Arguably, usage threshold events are not reliable on the root + * memcg anyway since its usage is ill-defined. + */ + if (in_task()) + mem_cgroup_flush_stats(); val = memcg_page_state(memcg, NR_FILE_PAGES) + memcg_page_state(memcg, NR_ANON_MAPPED); if (swap) _ Patches currently in -mm which might be from yosryahmed@google.com are memcg-replace-stats_flush_lock-with-an-atomic.patch memcg-sleep-during-flushing-stats-in-safe-contexts.patch workingset-memcg-sleep-when-flushing-stats-in-workingset_refault.patch vmscan-memcg-sleep-when-flushing-stats-during-reclaim.patch memcg-do-not-modify-rstat-tree-for-zero-updates.patch memcg-page_cgroup_ino-get-memcg-from-the-pages-folio.patch mm-vmscan-ignore-non-lru-based-reclaim-in-memcg-reclaim.patch mm-vmscan-move-set_task_reclaim_state-near-flush_reclaim_state.patch mm-vmscan-refactor-updating-current-reclaim_state.patch