Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp8267327pxb; Fri, 19 Feb 2021 11:32:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrtesWn/QH3JEjr9dzrjTLeyameo2afCJDYT44QSrDEKgn3gH3GeqFFHKN4qxDV/1HrSYg X-Received: by 2002:a17:907:16a4:: with SMTP id hc36mr10121802ejc.127.1613763150588; Fri, 19 Feb 2021 11:32:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613763150; cv=none; d=google.com; s=arc-20160816; b=ulEeja4PZYL0IK2YUxanUi69XTFM6+d83ZKrIdrKUbqddejhI4WRPtf2r6MJyM5LIu IEkqFuQoGpYutxTdx1pDOFSCa8eQO78g6zA3tsgVbyxCcdscBVEyuIpiM4W90fA2M37D 7ClGAHtQSSsd4vx2EYLEqutK6fwfniZZ0z2rlYEnkvRTPdm5RJJPklvgRDwf3IPqjfN6 RyHGG8tsDkKsID2YIzFWEC7bPGF+vFiFd1trnWGPGvTyB3Bhdxa4grm10jtz17DdtEho 5FxHufUHR2ZStu6FtJJSOadZf8kR/sJrNUZxFtPT/73+9T/nGafdTPSMY/0djXAjNOUo Tstw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=C8FBhsZXhSwMtlNRMoWUPDIHseZ/OU8qNcAmCITSDb8=; b=MxfVg38JW8y1scA7wKDNfm400vzGUWY8oJQI4aA0F0e1GUGwYdMVbBEf/6aITw9vaX Xg3AMppRf7GAPXGz7WTQTz7lZBUV2vIRZ57eAZce++Alf2oAqTFdvMqHg2cjVwIUanX4 c2KyEDat2X6Xd5l9uPkhb2YfCOcjWoYpmz5Vez9zp/okyt9Ltf9yaFHPiMPeqwlJCoX2 oTwfh2gnPvenEGtfAIPIn4oYqYt3IBZ0DHgTrnjoUhCFkz5+iUIp2ttVSGllvABHZ6Ay r2tPlHJ5XtswmQdQtBmjvS8Fs4yIe7RTOy74WukWabe3YNYT/q6RInL7oOmJaFAj4vae XXmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r25si7590714edc.395.2021.02.19.11.32.06; Fri, 19 Feb 2021 11:32:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230074AbhBSTaf (ORCPT + 99 others); Fri, 19 Feb 2021 14:30:35 -0500 Received: from mga07.intel.com ([134.134.136.100]:21503 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230071AbhBSTae (ORCPT ); Fri, 19 Feb 2021 14:30:34 -0500 IronPort-SDR: Nm66EkXcQKSmzdEs6qrF8PDCCj/Q/LYi8M3bIQQvJGwlqTtQCk9knoo5ai5oqUy/GUkwxoz0Xg rxRFjju7rNbQ== X-IronPort-AV: E=McAfee;i="6000,8403,9900"; a="248005108" X-IronPort-AV: E=Sophos;i="5.81,189,1610438400"; d="scan'208";a="248005108" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2021 11:28:46 -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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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