From patchwork Tue Dec 17 11:29:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11297355 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E947D6C1 for ; Tue, 17 Dec 2019 11:31:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B5F75207FF for ; Tue, 17 Dec 2019 11:31:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rFBgOLw5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B5F75207FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AA3468E0058; Tue, 17 Dec 2019 06:31:28 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A78DF8E0040; Tue, 17 Dec 2019 06:31:28 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B6FF8E0058; Tue, 17 Dec 2019 06:31:28 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id 8730F8E0040 for ; Tue, 17 Dec 2019 06:31:28 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 40D60180AD807 for ; Tue, 17 Dec 2019 11:31:28 +0000 (UTC) X-FDA: 76274417856.01.knot12_29e499528860c X-Spam-Summary: 2,0,0,ca26ec6a9f0125c2,d41d8cd98f00b204,laoar.shao@gmail.com,:hannes@cmpxchg.org:mhocko@kernel.org:vdavydov.dev@gmail.com:akpm@linux-foundation.org:viro@zeniv.linux.org.uk::linux-fsdevel@vger.kernel.org:laoar.shao@gmail.com:chris@chrisdown.name,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2393:2553:2559:2562:2693:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3870:3871:3874:5007:6261:6653:7514:9413:10004:11026:11473:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12895:13069:13161:13229:13311:13357:14096:14181:14384:14394:14687:14721:21080:21444:21451:21627:21666:21990:30054:30070:30090,0,RBL:209.85.215.195:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: knot12_29e499528860c X-Filterd-Recvd-Size: 4241 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Tue, 17 Dec 2019 11:31:27 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id k197so5504542pga.10 for ; Tue, 17 Dec 2019 03:31:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PfAZz+7YFL5P4jlslEzjz2qfIRhr8Qk9D33rUR/m3Pc=; b=rFBgOLw5GBbA5M6JYtyuopWqCS7rTgK8GrRgyaJZh1EwcwoZ4adsA7i45dxIH3ks1E cA2ShGT5a87N90+9y/AWBHgw7Lf9duh3wh6k7jK23S5xE38qGx7w/tTaPsAgKYDeCbgR qXasE3JU3WZBesFJ+CLsGJzaVeKYysjUCV32mI8wvz0bafDNCtRXZgdXXvXc/huTpRk5 VF+QSU/YyBf3afiP4m8kPjHDwt+ETnPXi9fap5jkKdx6Nw+j2uHfk6PZ+Cheyd2oXDEN 2/wLFGhXHmWHa1niJ7qkuiAbDyQr1Gc4aj+s0FOfPe95qklSqw9a/gvAPNINJ6cLkkoS atDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PfAZz+7YFL5P4jlslEzjz2qfIRhr8Qk9D33rUR/m3Pc=; b=RiJrx+QmfJdP6c18ze9H45FPZIy8xUS82O94qvSDnJ0ldfza+vJYf6vQpo1BFdUWH+ T+bM31e72szQqGTGiQm0TirYqa3GSG3GJf/H4yfySkWa7igPAYVA73MkrUptvqpbxZ68 DufVxL3FQvxYE/9vcL9CcJhNuQGOn0VDCNz4dwL8CDNvt/h1Bh3ZwiT20TyWu+BN+8Xg JzP9s8lIklI64CrxOQB+XuuPNsOTvtBS7y6CaNppHJLvfSryZQH00DyIxzCBfKw7zFLH eu8cPKmZo0U/FdVJxwc7kUlcDqQYGAtPVtzdyXnZmbBHm8T32WjpixrR+ZmnfFaIOIU6 JvZg== X-Gm-Message-State: APjAAAX3pI/IUYj21S69fKbLVxK0z6zymg6NQq0wbzJOdBOZm4MsO0/g e3UqCht7e3IAfYY8H1JbBo4/HwcAB4U= X-Google-Smtp-Source: APXvYqxKC4uL4weF1OEd7OR+j+1clxzVjXRygLvMNhVRBcvixxJuond5I2PkqDo/eiZsiVduAVa7ZA== X-Received: by 2002:a65:56c6:: with SMTP id w6mr25047436pgs.167.1576582286912; Tue, 17 Dec 2019 03:31:26 -0800 (PST) Received: from dev.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id q21sm26246460pff.105.2019.12.17.03.31.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 03:31:26 -0800 (PST) From: Yafang Shao To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, viro@zeniv.linux.org.uk Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Yafang Shao , Chris Down Subject: [PATCH 3/4] mm, memcg: reset memcg's memory.{min, low} for reclaiming itself Date: Tue, 17 Dec 2019 06:29:18 -0500 Message-Id: <1576582159-5198-4-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1576582159-5198-1-git-send-email-laoar.shao@gmail.com> References: <1576582159-5198-1-git-send-email-laoar.shao@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.005788, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: memory.{emin, elow} are set in mem_cgroup_protected(), and the values of them won't be changed until next recalculation in this function. After either or both of them are set, the next reclaimer to relcaim this memcg may be a different reclaimer, e.g. this memcg is also the root memcg of the new reclaimer, and then in mem_cgroup_protection() in get_scan_count() the old values of them will be used to calculate scan count, that is not proper. We should reset them to zero in this case. Cc: Chris Down Signed-off-by: Yafang Shao --- mm/memcontrol.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index f35fcca..234370c 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6287,8 +6287,17 @@ enum mem_cgroup_protection mem_cgroup_protected(struct mem_cgroup *root, if (!root) root = root_mem_cgroup; - if (memcg == root) + if (memcg == root) { + /* + * Reset memory.(emin, elow) for reclaiming the memcg + * itself. + */ + if (memcg != root_mem_cgroup) { + memcg->memory.emin = 0; + memcg->memory.emin = 0; + } return MEMCG_PROT_NONE; + } usage = page_counter_read(&memcg->memory); if (!usage)