Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp54813imm; Thu, 2 Aug 2018 22:49:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfRECq17hSwApIETC7CTdMg36TGRieoK6l243YC1fGGojdyxntiFxaubmrN4KYpEEgX6V7s X-Received: by 2002:a62:591a:: with SMTP id n26-v6mr2818555pfb.94.1533275387439; Thu, 02 Aug 2018 22:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533275387; cv=none; d=google.com; s=arc-20160816; b=hyJO1MOSUIxlCkecCPH3iJd+z+dLro/XjsK1uZY0U16rbjZp1sAOUxLpzA/eHMvYQl 4pGMDuzFB6G0rOdydPCceqfUJfs/j892ncov7/KLWOGB1+hmFjUBxci//DkbujBsriYk O6Yr+f7SRPkSR6U6BtTR5qQ+hmdb4wT19ZEOq62bva487KVBkJn8OqiTZePqZBnB93Rv +jJXYg+Kf2p6p4mI6QZdIEkdyLgVOryn54h4BEyowyUL85s1nVoB+e968KDbNwcMKghA kN/X6CEuoAFm9zscAGHGElGbHqT+W2Anbi/oJnjMr/JZ/wu6CbT4jdI7+gG0fRyDT0kW HUiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:to:from :dkim-signature:arc-authentication-results; bh=fVXWaxwxreKXlqc1RlFh2JofIARKEY7E1agRdUX+U64=; b=YeGkrSeXnDSHYPSuH0aEcsWjod/j3MOzDaqPO1U97lgVK30YK8kvnPdn5JZJeByS+1 /BFr03zQbyOaPueV8IdH8JMFZtIlRB5FheGqf1xdS66NyzE13jb4FWlxKfTa/NzlW+1a OeNOlXG48ULtvdXMvLGnO4kjrn9t/XOJTlnqTlwifbfQrJ/fL/XyPLWWnAal5Z2ds/PW a6/VLwvASdeWXPHZ1yKNJmhD7gDYGDXPbCR5iLukROmfNqLpYtFo65iUgsUtPXcG1/9v R2HQeqphO+kEp7ljtnwAighjTc8Hoo8zOWulZanH6zMX+SpC7brGbKLF3bgaTZCv91cl RPHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cM8AIGcr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2-v6si4308364pgl.140.2018.08.02.22.49.32; Thu, 02 Aug 2018 22:49:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cM8AIGcr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727469AbeHCHmx (ORCPT + 99 others); Fri, 3 Aug 2018 03:42:53 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45084 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726799AbeHCHmx (ORCPT ); Fri, 3 Aug 2018 03:42:53 -0400 Received: by mail-pf1-f193.google.com with SMTP id i26-v6so2619365pfo.12; Thu, 02 Aug 2018 22:48:15 -0700 (PDT) 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-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=fVXWaxwxreKXlqc1RlFh2JofIARKEY7E1agRdUX+U64=; b=Lj0I+8hCgMcoofllXmCzxbQVSrOe38pMynqZ3q0Q5RexoIAWrxpeGO3K1YHBg+UtoP ue2GM7MF8FPOueAvprsMTtgo6aq89HpM9zw51HJt55B1GpDtjt0KIBoGnBtpIBot1xTz UMFQ4UgsEMepj+yYzyxfBnDwSnNh3Et+JYSG27N7FwyAp7U/q7QlJoVjMbLrHbNGpEXl /3sceFStkhM3OQBG0QJQWN2tHS26ff+mSGNckK1RKTg001BlamAfkR8LzWhr4lSE8oWf vpsRLTylMamIgBfDKIUauu2p0265su8rwYqnFPuFYLu0YjH4mQ0afbB7HwS63/UhP7a5 jdIQ== X-Gm-Message-State: AOUpUlFY0Wf5Rcg40NxGK5FoIG0hGDx40sdyUbkZL+IiqfW/HMq188s9 LXHiFU/DKwrmWWdS3VjSelY= 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 1.9.1