Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6795774pxb; Wed, 17 Feb 2021 13:46:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJznYsS7eGKTdEBAhg2J3QBJCQy9FsHzmHqPFnf7M5eeama+A/4RsNBNnBWL3n5Nk9ug2Nu7 X-Received: by 2002:a05:6402:5:: with SMTP id d5mr836072edu.121.1613598408659; Wed, 17 Feb 2021 13:46:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613598408; cv=none; d=google.com; s=arc-20160816; b=n8C9Rbp5S8E8nk6sdpZD1e6ymOPaN+Cv+7pdeaAldNZ/RfoXz6sqzH0fLylptJe7lp EIz9ziGu9qFHNrSpAj5NjGjkC7xvcJqMJdM64zOSsYwVrCieLeRqdn4ZF3v29OV5R79b YlV4kdceROZ5b1sevEQoPFB5mplImKeNT6ho6oDrRVkGAYcGKlmSJW2Rsy64gz2vuQzU PwDkxUY5+fC5RjYYW+nXTEKfSz3y9EprNYi9xrLjJ8Qq+o3cIp8dL8WaKLt7emkv3UCm we/g5DChCESQtdc+hc767yxusgZLBE5w9XtzwZ6wzKBqvIqbEK/eIZP2m6SoEaEBluNI yHtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=+DVKs7jAZNKqlblqPazHt3SZJNkiKb89oOVRg5NIn48=; b=et6FwGyTsCRZKpJ1wnv6GOE7kSU6KtUNqapMn8Dj5dUnp9g8B1DAWej3lgsbbwjWYb 56/MUtcGpP7HBfyCp/XYIRH/qWpxyqIXm1IxpToubSYyMAeICowAKIxsmC0UmkLg7fAw M+qHnT6yS2KkYP0WaiDIyVsC5ifkyDZ6E4tA5xLYTcErjFPFon7MyEUARfL5oxoFxhzN vqLFuL6f0e8Mvz/FAWLfsv5a3FbictTUh6KclhFmPllR4aU+e+U3g0IPD5oJB2pT8any g2tivhf8evGJcwwEWhoG7KNIxrJ/KoOR2nEwIRLx8JKUSvQgzFSBKcf/QSsNoSEnmRZR snyw== 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 gb10si2185241ejc.75.2021.02.17.13.46.24; Wed, 17 Feb 2021 13:46:48 -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 S232435AbhBQVnm (ORCPT + 99 others); Wed, 17 Feb 2021 16:43:42 -0500 Received: from mga14.intel.com ([192.55.52.115]:37248 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232355AbhBQVnl (ORCPT ); Wed, 17 Feb 2021 16:43:41 -0500 IronPort-SDR: 0PQl3/aoqTkDfyZ3aZKKMZaR+2RMND3GZqkeJEIVH7/J/4hhJOTeStJkfRBQzFlgMXwhGyB2Bi bb8MMKCB02Cw== X-IronPort-AV: E=McAfee;i="6000,8403,9898"; a="182538752" X-IronPort-AV: E=Sophos;i="5.81,185,1610438400"; d="scan'208";a="182538752" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2021 13:41:52 -0800 IronPort-SDR: gQswESc8jFJCnGPHICQznAp1G92RTJTrzHTvajwRGCPDLpJzqZfkC8RbeDPAX+SmqhuWKVZuxY gvB7cnNEntVg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,185,1610438400"; d="scan'208";a="401430707" Received: from skl-02.jf.intel.com ([10.54.74.28]) by orsmga007.jf.intel.com with ESMTP; 17 Feb 2021 13:41:52 -0800 From: Tim Chen To: Andrew Morton , Johannes Weiner , Michal Hocko , Vladimir Davydov Cc: Tim Chen , Dave Hansen , Ying Huang , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] mm: Fix dropped memcg from mem cgroup soft limit tree Date: Wed, 17 Feb 2021 12:41:34 -0800 Message-Id: <8d35206601ccf0e1fe021d24405b2a0c2f4e052f.1613584277.git.tim.c.chen@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org During soft limit memory reclaim, we will temporarily remove the target mem cgroup from the cgroup soft limit tree. We then perform memory reclaim, update the memory usage excess count and re-insert the mem cgroup back into the mem cgroup soft limit tree according to the new memory usage excess count. However, 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. Fix the logic and put the mem cgroup back on the tree when page reclaim failed for the mem cgroup. Reviewed-by: Ying Huang Signed-off-by: Tim Chen --- mm/memcontrol.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index ed5cc78a8dbf..a51bf90732cb 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3505,8 +3505,12 @@ 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); + __mem_cgroup_insert_exceeded(next_mz, mctz, excess); + spin_unlock_irq(&mctz->lock); css_put(&next_mz->memcg->css); + } return nr_reclaimed; } -- 2.20.1