From patchwork Fri Aug 3 05:48:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaoyang Huang X-Patchwork-Id: 10554571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 75B0115A6 for ; Fri, 3 Aug 2018 05:48:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5965A2C353 for ; Fri, 3 Aug 2018 05:48:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 490052C361; Fri, 3 Aug 2018 05:48:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F17C2C353 for ; Fri, 3 Aug 2018 05:48:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4BC076B0007; Fri, 3 Aug 2018 01:48:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4421C6B0008; Fri, 3 Aug 2018 01:48:17 -0400 (EDT) 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 2E3096B000A; Fri, 3 Aug 2018 01:48:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id DFF5C6B0007 for ; Fri, 3 Aug 2018 01:48:16 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id q12-v6so2143529pgp.6 for ; Thu, 02 Aug 2018 22:48:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:subject:date:message-id; bh=fVXWaxwxreKXlqc1RlFh2JofIARKEY7E1agRdUX+U64=; b=E4IPSS3WRwO44eseoeujcP2sdAK0bieuUWUmSKi7ZtNpur6/uHCYp42GL2j5AwwAxv T03nRnzj47/MtE1IYj5f9HmQFF8KWuRlgcBrvXNDWMnErl7b2vT3grUTNf2UtVeMnim2 ZtEPA2kdQSN9oH4exyw+sWx7fqN4CvY8QkuonWVmRTc4RYl4CqZWNAJhp2W5Uak8bQTn csuhidsfuAWOWFMs4/BgJ27+GflHtZMCtlYHevd7canhE20MOWx9rAJ/M7ZJk2zotxlI 81KJ6bjfOAB+QV3STQehKt2QfdNRyRwpTRmWPG6YYwKY4Y6gppBr9Szfv9nSye7W0KSw U1vw== X-Gm-Message-State: AOUpUlFyRcr/G6d7hVUW3nG75YaV2y8tBG6yvz85UpdC1xyTIH3CCzwW X/c9znNDKShFCzAY/ZoZvHmqhQfH804RYwn2GRUpN1PHOktudHFSPqL3TYcWKzy2fv/TctIG2x5 UKl/YOHReX5yAfIR30mBy+Ap2Na2Fcsfl0Eqi5xlLsQnHKqTqvfrrgvfgwgmJ44kv1MKOoV7UrC 7CJO+QsLerWX6ZDNIbDL8FlbE6+F7UtCZo2cFtqprhxA94ShCEK9Be4UO/WSCObkUej7/DyJ1ek NtJnUe/C+TywA7FZLFWZ/YnWcHY6pFX+VOgQYkAZRHpmSNOx46iDyDKH+kPR2rn1NzSQX8wZ/65 qy/ZBTBAB4EmsS79fuQ4nkMR9cRXw8ymvXrmHZ7loqBC+/n9hK+n+VE2aDpeOmWBf7eM4qqKOYw s X-Received: by 2002:a63:9619:: with SMTP id c25-v6mr2235860pge.75.1533275296588; Thu, 02 Aug 2018 22:48:16 -0700 (PDT) X-Received: by 2002:a63:9619:: with SMTP id c25-v6mr2235829pge.75.1533275295692; Thu, 02 Aug 2018 22:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533275295; cv=none; d=google.com; s=arc-20160816; b=n1nrzQiYTZXhqkyrMgp/KKuBOrQ72gCozVulgsXMbqo2DczSMbBCEdsuDn6CGSRwVq +gEZgb+t2l6F6W487NaiBdnZ+KNAIHUq1aY6CtZo+K4+oQcbafmgiTMGiUB7I8O8SKVw mHt/YaA/yf3ubq1DSRBYgu7u1YeVBbHQADlYxm7zRwIYTrCjJLVrdrz+F6q/FI+EUKRD uKQdQwSBEf7JZwah8WF6pl5m+Ki21YWvRxEZv5jK6EHtwAMWOmnlR4/RpaJz1pfvc3bl +RuxEh+MGAQku/V4dpSzkR3dayZBk3LXu7LLRgZqQPekwc6VnfoSKcMRkjX+pQs22Vpl bfhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:dkim-signature :arc-authentication-results; bh=fVXWaxwxreKXlqc1RlFh2JofIARKEY7E1agRdUX+U64=; b=bNQoBPKjHU11rWq3J9RKsgMt+If9jH0UWJ+6MzXJM8awIy8Q5y+Hj3wz09QHwesr8n 6q44NWh8geBe4OIVm/SIErVMR49+5xpCkLNPc705fdplI2r9eohpLN1gfvCw3nNw3Jc6 IapFSRd95eCyjQqCjMuYiMNw+AO9v9Gk/83iRnijOIPcGF2GU0cwCeRP6BR1xazFG+Tu 8wcOLnnl1NLoQaKvV64SBGmCWQ94Cj1GjBpDbTTDdAAqATn4fyGnfnfek5vVUTJTsQIQ gQcaY8zhlEzgKelW3OyXA6WL50ihZvZNCJSVc/Vbo1Oilr8TQ94fVcUCwAWjn5HjCKQs +p2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cM8AIGcr; spf=pass (google.com: domain of huangzhaoyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=huangzhaoyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id o19-v6sor973708pgk.118.2018.08.02.22.48.15 for (Google Transport Security); Thu, 02 Aug 2018 22:48:15 -0700 (PDT) Received-SPF: pass (google.com: domain of huangzhaoyang@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cM8AIGcr; spf=pass (google.com: domain of huangzhaoyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=huangzhaoyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=fVXWaxwxreKXlqc1RlFh2JofIARKEY7E1agRdUX+U64=; b=cM8AIGcr923zdMpdIzff6uaGULx90HD6/pb1SzOlHNxmQn3SGmQgrKeg3Nlb4SdcOH cq/h+mPUPhUuKOv2G+0z5sEW6+V/MAalhyHs20OWjxCoeA5ptfJnK7IEg1RwzULhiUsw wVcWZUts+sDYXxQIkEzwX1NwC8rstIp4/7nfOB7OwGVhnOF8Iacuyx3n9YDEw7fwikdo a6W9Ioie7idm4r/niISTiosCax+bavEPBe4jK8TqhvOcvztd7ONwFBKwZ3zBgafUMXmZ UCWFU3UAsgx5SttmwJsyiVKdSBGSjwk39mCpgaz6LZ/K2RgIwBPFtxPcGP23CIqVd1vP wXjA== X-Google-Smtp-Source: AAOMgpff9xUqLAOcRmaS8c3fp6Evd7fn7eGWFKdzyKW8WHn3t7iUoYp4tVAK4BPLb3Ht30kiUl6aiA== X-Received: by 2002:a63:1360:: with SMTP id 32-v6mr2305914pgt.159.1533275295349; Thu, 02 Aug 2018 22:48:15 -0700 (PDT) Received: from bj03382pcu.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 16-v6sm5357284pfp.6.2018.08.02.22.48.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Aug 2018 22:48:14 -0700 (PDT) From: Zhaoyang Huang X-Google-Original-From: Zhaoyang Huang To: Steven Rostedt , Ingo Molnar , Johannes Weiner , Michal Hocko , Vladimir Davydov , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-patch-test@lists.linaro.org Subject: [PATCH v1] mm:memcg: skip memcg of current in mem_cgroup_soft_limit_reclaim Date: Fri, 3 Aug 2018 13:48:05 +0800 Message-Id: <1533275285-12387-1-git-send-email-zhaoyang.huang@spreadtrum.com> X-Mailer: git-send-email 1.7.9.5 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: X-Virus-Scanned: ClamAV using ClamSMTP for the soft_limit reclaim has more directivity than global reclaim, we have current memcg be skipped to avoid potential page thrashing. Signed-off-by: Zhaoyang Huang --- mm/memcontrol.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 8c0280b..9d09e95 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2537,12 +2537,21 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order, mz = mem_cgroup_largest_soft_limit_node(mctz); if (!mz) break; - + /* + * skip current memcg to avoid page thrashing, for the + * mem_cgroup_soft_reclaim has more directivity than + * global reclaim. + */ + if (get_mem_cgroup_from_mm(current->mm) == mz->memcg) { + reclaimed = 0; + goto next; + } nr_scanned = 0; reclaimed = mem_cgroup_soft_reclaim(mz->memcg, pgdat, gfp_mask, &nr_scanned); nr_reclaimed += reclaimed; *total_scanned += nr_scanned; +next: spin_lock_irq(&mctz->lock); __mem_cgroup_remove_exceeded(mz, mctz);