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 X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2127CC433E0 for ; Fri, 19 Feb 2021 19:28:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 95C1264E77 for ; Fri, 19 Feb 2021 19:28:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 95C1264E77 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0F1B66B006E; Fri, 19 Feb 2021 14:28:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A1CC6B0070; Fri, 19 Feb 2021 14:28:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED3516B0071; Fri, 19 Feb 2021 14:28:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0174.hostedemail.com [216.40.44.174]) by kanga.kvack.org (Postfix) with ESMTP id D2EF06B006E for ; Fri, 19 Feb 2021 14:28:51 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 9FBF58E63 for ; Fri, 19 Feb 2021 19:28:51 +0000 (UTC) X-FDA: 77836004862.18.B8236F6 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf13.hostedemail.com (Postfix) with ESMTP id D9937E00010D for ; Fri, 19 Feb 2021 19:28:47 +0000 (UTC) IronPort-SDR: BUCktYsHl9B+di923nH3CjNN9vKMgvblFemQsoSzw0ubF2F/CgpYD3FGXePNhKReVyj7WHSf37 pXHSDqsQIffw== X-IronPort-AV: E=McAfee;i="6000,8403,9900"; a="163721473" X-IronPort-AV: E=Sophos;i="5.81,189,1610438400"; d="scan'208";a="163721473" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2021 11:28:48 -0800 IronPort-SDR: L2XGn9Zo4R2llyAxs8pq98hgkcxha5oZsJ9Cb1JbjidupriGbJGd4F8sD201lr4MZGN7XwtfrW d1Lg3B7g0aTw== X-IronPort-AV: E=Sophos;i="5.81,189,1610438400"; d="scan'208";a="379000055" Received: from schen9-mobl.amr.corp.intel.com ([10.251.10.112]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2021 11:28:47 -0800 Subject: Re: [PATCH v2 3/3] mm: Fix missing mem cgroup soft limit tree updates To: Michal Hocko Cc: Andrew Morton , Johannes Weiner , Vladimir Davydov , Dave Hansen , Ying Huang , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Tim Chen Message-ID: <1ecd277e-c236-08e1-f068-3dd65ee0e640@linux.intel.com> Date: Fri, 19 Feb 2021 11:28:47 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Stat-Signature: schn77nnjexdibxemikbiunqikfwgucd X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D9937E00010D Received-SPF: none (linux.intel.com>: No applicable sender policy available) receiver=imf13; identity=mailfrom; envelope-from=""; helo=mga17.intel.com; client-ip=192.55.52.151 X-HE-DKIM-Result: none/none X-HE-Tag: 1613762927-15649 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 2/19/21 1:16 AM, Michal Hocko wrote: >> >> Something like this? >> >> diff --git a/mm/memcontrol.c b/mm/memcontrol.c >> index 8bddee75f5cb..b50cae3b2a1a 100644 >> --- a/mm/memcontrol.c >> +++ b/mm/memcontrol.c >> @@ -3472,6 +3472,14 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order, >> if (!mz) >> break; >> >> + /* >> + * Soft limit tree is updated based on memcg events sampling. >> + * We could have missed some updates on page uncharge and >> + * the cgroup is below soft limit. Skip useless soft reclaim. >> + */ >> + if (!soft_limit_excess(mz->memcg)) >> + continue; >> + >> nr_scanned = 0; >> reclaimed = mem_cgroup_soft_reclaim(mz->memcg, pgdat, > > Yes I meant something like this but then I have looked more closely and > this shouldn't be needed afterall. __mem_cgroup_largest_soft_limit_node > already does all the work > if (!soft_limit_excess(mz->memcg) || > !css_tryget(&mz->memcg->css)) > goto retry; > so this shouldn't really happen. > Ah, that's true. The added check for soft_limit_excess is not needed. Do you think it is still a good idea to add patch 3 to restrict the uncharge update in page batch of the same node and cgroup? I am okay with dropping patch 3 and let the inaccuracies in the ordering of soft limit tree be cleared out by an occasional soft reclaim. These inaccuracies will still be there even with patch 3 fix due to the memcg event sampling. Patch 3 does help to keep the soft reclaim tree ordering more up to date. Thanks. Tim