From patchwork Tue Oct 19 07:29:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaoyang Huang X-Patchwork-Id: 12568827 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6D2EC433EF for ; Tue, 19 Oct 2021 07:29:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 38F726137F for ; Tue, 19 Oct 2021 07:29:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 38F726137F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id C6D82900002; Tue, 19 Oct 2021 03:29:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C1D866B0071; Tue, 19 Oct 2021 03:29:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0B9E900002; Tue, 19 Oct 2021 03:29:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0245.hostedemail.com [216.40.44.245]) by kanga.kvack.org (Postfix) with ESMTP id A51C46B006C for ; Tue, 19 Oct 2021 03:29:55 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 5B4BD181DA57B for ; Tue, 19 Oct 2021 07:29:55 +0000 (UTC) X-FDA: 78712362750.09.8919537 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by imf21.hostedemail.com (Postfix) with ESMTP id 802C1D042B5B for ; Tue, 19 Oct 2021 07:29:53 +0000 (UTC) Received: by mail-pg1-f178.google.com with SMTP id e7so18585172pgk.2 for ; Tue, 19 Oct 2021 00:29:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id; bh=vfd7MBPWblBhEd3Hxz8uuyeSEGwRnXcHNr8PPXrICm0=; b=hpagPFkUsa8FOypcLEmDs1wbh88Ft0/DruwIK09BQVN3bQ4noR0rXBxlOZW8DmHFZQ b3MjkT60YMfKmzxim2vhqj0TdhGIo1wob4BDrcMyhbGWUi0GVD9iDCk7E6dT3zoSA7Ex mDWmwGRnusmaa5XIAZRHKi5tTfXx/gAm0AK0kAu/eBakW5+pzqECVLu5NK7id0M12gNY 2PcGXjrOf/OgsqCovyF+k5dr+4Gl5FAcg7CG6ESzrleGt8jn9uFRV8Mu0QKuMzR95Llt SDF3sR/hhnvnR8pCEZUcnVbasWenW5578jGEeNj1ow/t7mEfpwuD15xH+d4NGhGIl5nt ya1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id; bh=vfd7MBPWblBhEd3Hxz8uuyeSEGwRnXcHNr8PPXrICm0=; b=PpukoLYP5eYG3yqIge21hGuv1XMfO+MQeceDBrk3nX/px/8hS7VQ9719hyw6alUPvE 1jM9LYBb0EV574svSQ9pHQI2fCvKQvxBWpsOTntnaO1G3FzZPbFeVejd04mThJrEQJvM NaFSoh7D8JwVzWlV3Rruvw5ymJhNYhwwOxSC1hMCEvojMtAfr82rOQ54dmNxAqs6VBvT cOhtCBkTtXkPDXi/lTbM9QBrtwLlBzkQVvgneE+vVKN3rVL8ydAwrp6+PqVYVUKfT7r5 1gGZrpgmqEIte/dQHGj9prgyrfBTLXY9+KJh+zNPIUUOm0LschvwVf2iI68dMkTopfaD lJRA== X-Gm-Message-State: AOAM532AfFrQHw2YBfuf774fP29elalCrBkYOcFsxMlzD8LUTnH/E24r DTl00oQk0F3Xoo+iQ+uhjFY= X-Google-Smtp-Source: ABdhPJxC38FjB4+wdFAFEgy6+wIgbNqF69SDSFiEpOVNLV/BPBhJAohyBjKvZFE7KPC1UZbUljEzvA== X-Received: by 2002:aa7:8198:0:b0:44b:e191:7058 with SMTP id g24-20020aa78198000000b0044be1917058mr34323872pfi.39.1634628594029; Tue, 19 Oct 2021 00:29:54 -0700 (PDT) Received: from bj03382pcu.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id u3sm15146220pfl.155.2021.10.19.00.29.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Oct 2021 00:29:53 -0700 (PDT) From: Huangzhaoyang To: Andrew Morton , Johannes Weiner , Michal Hocko , Vladimir Davydov , Zhaoyang Huang , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] mm: skip current when memcg reclaim Date: Tue, 19 Oct 2021 15:29:36 +0800 Message-Id: <1634628576-27448-1-git-send-email-huangzhaoyang@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 802C1D042B5B X-Stat-Signature: 59kyqtryby9qynxmxa71nd3koa4wzaxf Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=hpagPFkU; spf=pass (imf21.hostedemail.com: domain of huangzhaoyang@gmail.com designates 209.85.215.178 as permitted sender) smtp.mailfrom=huangzhaoyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1634628593-269457 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: From: Zhaoyang Huang Reclaiming pages from current LRU will introduce page thrashing during direct reclaiming. Have all memory contraint groups steal pages from the processes under root(Non-memory sensitive) or other groups with lower thresholds(high memory tolerance) or the one totally sleeping(not busy for the time being, borrow some pages).With regard to all groups trapping into direct reclaim, retry if first round failed and all groups still compete fairly. Signed-off-by: Zhaoyang Huang --- patch v2: grant current second chance if previous reclaiming failed --- --- mm/vmscan.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/vmscan.c b/mm/vmscan.c index 5199b96..c17ef60 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2841,6 +2841,13 @@ static void shrink_node_memcgs(pg_data_t *pgdat, struct scan_control *sc) sc->memcg_low_skipped = 1; continue; } + /* + * Don't bother current when its memcg is below low + */ + if (get_mem_cgroup_from_mm(current->mm) == memcg) { + sc->memcg_low_skipped = 1; + continue; + } memcg_memory_event(memcg, MEMCG_LOW); }