Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp73718imm; Thu, 2 Aug 2018 23:12:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeLsrvuu44E+pMJ701EtGHtWr7sCVzeA1cfyfZk4EKTt7mnFSAUn1xIncSfDUoIZQSAKXBB X-Received: by 2002:a62:843:: with SMTP id c64-v6mr2908215pfd.14.1533276761196; Thu, 02 Aug 2018 23:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533276761; cv=none; d=google.com; s=arc-20160816; b=JkmuzJxqugiYoeOG/0x1xOkKaAnUnxOLmEpwNcGTTPLUejQJ1krTyFRkUiNKVTL9uH 3WKr9Ue4bExk7LAJ2i12AuA5QCdzFLtgiVgtzDJuWo5sG+MuYSBvPoGbC8oG61AMhDy2 D3tNO6M5ye0Vem1PCYAcI3kyQMBR6YoyzJHtTpdrJbx/Ygd0qxlN3oXK8p7yfyLkgOER HFk26ujhn3Sd9VbUjnRA9Np0P9znIfxNFkT0rNTH6dYXz2xkVlhPHVS0bz+6VnO5Ax26 Tm/qSoJyv7vaTiQM9RkqodAdJVs4MHhp1cfN81F/5J9aI+DIbZq6t8NFv8/cGL0N50LF cZ8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=no/jOIE21X8Xkokb0gVPzfOsDFcu8RUDjm0Ga7io9Zk=; b=Tp6mfOq2uALKovAOw4B28JJhhL5SbNaOO3R84IfVhMPEwSZNjSNGUbmNtaCFP7dfsT ZnuGgdseZMkNu/qiVkskQiMoxdGI4fGs/hAFtzHqJ35zYGXuCcOaVv/UN2NPQq9T0OQq iC1WG0x9G+VdNdk+9zYlfu/O6SKuDlWd0R4bzdme++Wt7xD9DOtrtaZuJDWsu5rwDhlI jz5W+ZukL95cq1+yZ2+MfnUpd01AbCPloDJCmpcwZXBv3inr5QVBee78578L3g/xSCcO ZRSuUDUPyr2OzROIBld0n/BV3im4SBXh8HEwj0CUDXolz69PxxID2tdGYehmd8Id4Eul w+SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CXhm0Clj; 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 u6-v6si3160982plz.423.2018.08.02.23.12.26; Thu, 02 Aug 2018 23:12:41 -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=CXhm0Clj; 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 S1727712AbeHCIGV (ORCPT + 99 others); Fri, 3 Aug 2018 04:06:21 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:40799 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726833AbeHCIGV (ORCPT ); Fri, 3 Aug 2018 04:06:21 -0400 Received: by mail-qk0-f195.google.com with SMTP id c126-v6so3299180qkd.7; Thu, 02 Aug 2018 23:11:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=no/jOIE21X8Xkokb0gVPzfOsDFcu8RUDjm0Ga7io9Zk=; b=CXhm0CljIHNp3DHVN0JP+B2UimdHHtw/jxqq6WT1GXwlwjXTxQRQoK5QsiS+zP2zCE WsA+6Qlj/b0EuJ+5sNwP4pZHrmxO8kwrXW07P7W7e8zdEVRFg7xnTDPUoDR22jUwDDJS vDgKSkjh+oZ+U/NHBuWzzGv12dEoYC/d9Zat4NAis7koJxXvWQdxz5XiglaoVihZ0bOV RV/mUOKKEnokQQ4zkpZpUA7fnmFbMe36LRqZ+jOm1+FXi9cIsDwK0afnUD/9txSTR3K9 nmHgPrZGITSTAtRGvKF9N6S+xgTZa6q/WkpmpVJ5QrGDy0YGtoNOaGgo7NZK7F30nduO vPAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=no/jOIE21X8Xkokb0gVPzfOsDFcu8RUDjm0Ga7io9Zk=; b=AuNNhdJjG+6Q+dnK4byhjpEBJeH0WHMH3NV6o64ZAfnhBljm1GeKYrNuXcYo/rM1+0 QtmJOQXQ3a78KbkOhKmBizjM9YjpA2/fCL6QeH7sVImX610jI0krHVBNhg5+WWLYs8O2 G8pASQxdiscscnvxyfkYctLQBuWDiY720ngnjQmCOWna1JSbNbDeykpXh73fvGoOZcPk 3mHw0cKE0/qAfj3BUdVF0ad2gsKLXu5WCuHKB1cH/cctleCu4G8sIt6h7OaPJcrFNOO3 NOhAZ3jhSad6JYr+nVkp4gj0mTMPSQqa74jv98N1BVEKeCroXEr5oei3rM9OSTbyuqZe pFlA== X-Gm-Message-State: AOUpUlEF7ua6D1FRvz379PVvD5GuDqdIa63MqYIYDhPHzdcmjtyAq6q/ 6/HKVCfMSFuL1sPbmyvpuw+dMp9uKIrDH1bhk1s= X-Received: by 2002:a37:3515:: with SMTP id c21-v6mr2364432qka.355.1533276698112; Thu, 02 Aug 2018 23:11:38 -0700 (PDT) MIME-Version: 1.0 References: <1533275285-12387-1-git-send-email-zhaoyang.huang@spreadtrum.com> In-Reply-To: <1533275285-12387-1-git-send-email-zhaoyang.huang@spreadtrum.com> From: Zhaoyang Huang Date: Fri, 3 Aug 2018 14:11:26 +0800 Message-ID: Subject: Re: [PATCH v1] mm:memcg: skip memcg of current in mem_cgroup_soft_limit_reclaim To: Steven Rostedt , Ingo Molnar , Johannes Weiner , Michal Hocko , Vladimir Davydov , "open list:MEMORY MANAGEMENT" , cgroups@vger.kernel.org, LKML , kernel-patch-test@lists.linaro.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 3, 2018 at 1:48 PM Zhaoyang Huang wrote: > > for the soft_limit reclaim has more directivity than global reclaim, we40960 > have current memcg be skipped to avoid potential page thrashing. > The patch is tested in our android system with 2GB ram. The case mainly focus on the smooth slide of pictures on a gallery, which used to stall on the direct reclaim for over several hundred millionseconds. By further debugging, we find that the direct reclaim spend most of time to reclaim pages on its own with softlimit set to 40960KB. I add a ftrace event to verify that the patch can help escaping such scenario. Furthermore, we also measured the major fault of this process(by dumpsys of android). The result is the patch can help to reduce 20% of the major fault during the test. > 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 >