Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6774737imu; Wed, 30 Jan 2019 22:48:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN4SxPgQFm7naOAoZMSo0jITVx/Ngl9pgEDOTo6JY9zdKMZW/xAOOhsRPo/hi8gE5Z64Jsij X-Received: by 2002:a63:de46:: with SMTP id y6mr30295957pgi.198.1548917303990; Wed, 30 Jan 2019 22:48:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548917303; cv=none; d=google.com; s=arc-20160816; b=pL1wSUQ3hGygmptVaHyCsSVnE9ETYqAMwh2wVA3rrPujsiV9H6feMoYP0YZWjWg6/t /oRCCIG0ZsDkJSXITJ4ZlovMUZbSYJy6jsg8NG65bmvSuDlITzJciPtgXMQMlcbwmb9Z dbgfN0uL21gqAY6YlJQBk6nnC4GtVSDn+JLfzagn4feFTS6IGt6xNenAnot4Vmchqt6s FbvV4KHWSZJemwQtchKF+reQRhqGNCzM9S7bWV9bxhADHxtWHXCqCWUCHkNdmXpgVlG8 f6VOzNPQsX3KNGHs5QeOlsZOXtWCMPWFLhft/6POqc5b1wpLj1jkK6NySQ0ItKoLpSiY wOBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=8Bl2/VI7OFywD7LEFPhh6EmryvSnC/C/hrVp2tQ+wJA=; b=nxMQ0wiZWzO4OQBp5nZO/BzBictllHgb7BqMdtXSciUueMsDzrDb0+cQQSZx0NvL7R fNs7CYa2yPq7KhgnQdIRAtnxrEJSbl7iJ3y6j4Te1UuCb2UIdRoakV5nwBmtjhfRMz1o TZPuqThSoZTPLK3AO9ZcX3Mf8JSRYu3VvXNXGmKXP3hNvkSZ+f0eZKYFO056uiX4z8sR 54mGuYq3QLLb8JdTM0kCKL41+UIIMed7kkGoFhesrKq8myTfsYSMPhGMsUmGSbufhySY e6HKjVwpWu23BzUZXyuMH3r2ux++5Vz29FMkOxN8VYWGFEsnCJcKJPB1Ca0zGJhAAS/s Jyjw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10si3601597pgt.343.2019.01.30.22.48.08; Wed, 30 Jan 2019 22:48:23 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727623AbfAaGrg (ORCPT + 99 others); Thu, 31 Jan 2019 01:47:36 -0500 Received: from mx2.suse.de ([195.135.220.15]:40694 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725863AbfAaGrg (ORCPT ); Thu, 31 Jan 2019 01:47:36 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C6088B0EF; Thu, 31 Jan 2019 06:47:34 +0000 (UTC) Date: Thu, 31 Jan 2019 07:47:33 +0100 From: Michal Hocko To: Yang Shi Cc: hannes@cmpxchg.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC v2 PATCH] mm: vmscan: do not iterate all mem cgroups for global direct reclaim Message-ID: <20190131064733.GL18811@dhcp22.suse.cz> References: <1548799877-10949-1-git-send-email-yang.shi@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1548799877-10949-1-git-send-email-yang.shi@linux.alibaba.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 30-01-19 06:11:17, Yang Shi wrote: > In current implementation, both kswapd and direct reclaim has to iterate > all mem cgroups. It is not a problem before offline mem cgroups could > be iterated. But, currently with iterating offline mem cgroups, it > could be very time consuming. In our workloads, we saw over 400K mem > cgroups accumulated in some cases, only a few hundred are online memcgs. > Although kswapd could help out to reduce the number of memcgs, direct > reclaim still get hit with iterating a number of offline memcgs in some > cases. We experienced the responsiveness problems due to this > occassionally. > > A simple test with pref shows it may take around 220ms to iterate 8K memcgs > in direct reclaim: > dd 13873 [011] 578.542919: vmscan:mm_vmscan_direct_reclaim_begin > dd 13873 [011] 578.758689: vmscan:mm_vmscan_direct_reclaim_end > So for 400K, it may take around 11 seconds to iterate all memcgs. > > Here just break the iteration once it reclaims enough pages as what > memcg direct reclaim does. This may hurt the fairness among memcgs. But > the cached iterator cookie could help to achieve the fairness more or > less. > > Cc: Johannes Weiner > Cc: Michal Hocko > Signed-off-by: Yang Shi Acked-by: Michal Hocko > --- > v2: Added some test data in the commit log > Updated commit log about iterator cookie could maintain fairness > Dropped !global_reclaim() since !current_is_kswapd() is good enough > > mm/vmscan.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index a714c4f..5e35796 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -2764,16 +2764,15 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc) > sc->nr_reclaimed - reclaimed); > > /* > - * Direct reclaim and kswapd have to scan all memory > - * cgroups to fulfill the overall scan target for the > - * node. > + * Kswapd have to scan all memory cgroups to fulfill > + * the overall scan target for the node. > * > * Limit reclaim, on the other hand, only cares about > * nr_to_reclaim pages to be reclaimed and it will > * retry with decreasing priority if one round over the > * whole hierarchy is not sufficient. > */ > - if (!global_reclaim(sc) && > + if (!current_is_kswapd() && > sc->nr_reclaimed >= sc->nr_to_reclaim) { > mem_cgroup_iter_break(root, memcg); > break; > -- > 1.8.3.1 > -- Michal Hocko SUSE Labs