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 2F504C433EF for ; Mon, 14 Mar 2022 09:41:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DFFE8D0006; Mon, 14 Mar 2022 05:41:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 98F798D0001; Mon, 14 Mar 2022 05:41:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87EC38D0006; Mon, 14 Mar 2022 05:41:15 -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 7B4238D0001 for ; Mon, 14 Mar 2022 05:41:15 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 5075C6067E for ; Mon, 14 Mar 2022 09:41:15 +0000 (UTC) X-FDA: 79242498510.12.4C1BCE6 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf26.hostedemail.com (Postfix) with ESMTP id A9AD414002B for ; Mon, 14 Mar 2022 09:41:14 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 8385B1F388; Mon, 14 Mar 2022 09:41:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1647250873; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vjCAmfOeIAmJsBLZGTQdftIhcJ0qr7uynuuuQ3TesCo=; b=NzzajjqEfhDUN2nmysnf+Itb4aFQe8SNtcbcddDI3ZQKOLMqLXLomuKFhQbSjmDeW6Lekw 7b5Hl1XvWv8QXxMRHPR6mBKZIsXYiF69jyNsz+nsuhsZ2iZB/auOvRvq5e22Q+WIs2Hc3R DfgIu7LRtH+3wSJn0pEhnJzOMIKDtUE= Received: from suse.cz (unknown [10.163.30.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 624B9A3B92; Mon, 14 Mar 2022 09:41:13 +0000 (UTC) Date: Mon, 14 Mar 2022 10:41:13 +0100 From: Michal Hocko To: Wei Yang Cc: hannes@cmpxchg.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-mm@kvack.org Subject: Re: [Patch v2 3/3] mm/memcg: add next_mz back to soft limit tree if not reclaimed yet Message-ID: References: <20220312071623.19050-1-richard.weiyang@gmail.com> <20220312071623.19050-3-richard.weiyang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220312071623.19050-3-richard.weiyang@gmail.com> X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A9AD414002B X-Stat-Signature: 1kr9zhkzkep43irm4puqtr1r343qhazn Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=NzzajjqE; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf26.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com X-Rspam-User: X-HE-Tag: 1647250874-363009 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 12-03-22 07:16:23, Wei Yang wrote: > When memory reclaim failed for a maximum number of attempts and we bail > out of the reclaim loop, we forgot to put the target mem_cgroup chosen > for next reclaim back to the soft limit tree. This prevented pages in > the mem_cgroup from being reclaimed in the future even though the > mem_cgroup exceeded its soft limit. > > Let's say there are two mem_cgroup and both of them exceed the soft > limit, while the first one is more active then the second. Since we add > a mem_cgroup to soft limit tree every 1024 event, the second one just > get a rare chance to be put on soft limit tree even it exceeds the > limit. yes, 1024 could be just 4MB of memory or 2GB if all the charged pages are THPs. So the excess can build up considerably. > As time goes on, the first mem_cgroup was kept close to its soft limit > due to reclaim activities, while the memory usage of the second > mem_cgroup keeps growing over the soft limit for a long time due to its > relatively rare occurrence. > > This patch adds next_mz back to prevent this sceanrio. > > Signed-off-by: Wei Yang Even though your changelog is different the change itself is identical to https://lore.kernel.org/linux-mm/8d35206601ccf0e1fe021d24405b2a0c2f4e052f.1613584277.git.tim.c.chen@linux.intel.com/ In those cases I would preserve the the original authorship by From: Tim Chen and add his s-o-b before yours. Acked-by: Michal Hocko Thanks! > --- > mm/memcontrol.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 344a7e891bc5..e803ff02aae2 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -3493,8 +3493,13 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order, > loop > MEM_CGROUP_MAX_SOFT_LIMIT_RECLAIM_LOOPS)) > break; > } while (!nr_reclaimed); > - if (next_mz) > + if (next_mz) { > + spin_lock_irq(&mctz->lock); > + excess = soft_limit_excess(next_mz->memcg); > + __mem_cgroup_insert_exceeded(next_mz, mctz, excess); > + spin_unlock_irq(&mctz->lock); > css_put(&next_mz->memcg->css); > + } > return nr_reclaimed; > } > > -- > 2.33.1 -- Michal Hocko SUSE Labs