Received: by 10.213.65.68 with SMTP id h4csp509293imn; Tue, 20 Mar 2018 08:30:49 -0700 (PDT) X-Google-Smtp-Source: AG47ELudiBo51BU/NIlNQUOhKbJf+Ae9HXrzkiVveiHlZwV3inUAcVenzUCQtpn9l5wC7Gb2LVNe X-Received: by 10.98.185.11 with SMTP id z11mr13928338pfe.153.1521559849828; Tue, 20 Mar 2018 08:30:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521559849; cv=none; d=google.com; s=arc-20160816; b=HDFxPwQyKzVRaahndcp+a/vYj060+QcvJHe98Tm82VB4i4M/4QVK4kQubfAszT9fKZ y5DSHyfhAiuxRN1eTVuFv4TILtI+VeUFTiyDjXaU1Cz24T0/FPaWMq+TzDf9TNikS1L9 WlIaGRnSWuwEFZCG7X7QFmhxfHdKLMDEo7nZij066k0f0Nlc0fpKgu99tQ/JIYpdG1zV BrtEssPfjSOsqp7lyQlLSryQlIOJ/sI0nmYg38My2jWLqDVTVkG94UGIriaARoIuNKfi poQNIAXlQypiaxpqWgsabRh/E1NwYNxQoNo3q/U5VD6jkTBBnYiFv9Z1bvhd2WhoWnvi 85oQ== 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:arc-authentication-results; bh=jnjRReYHpG1Jx8eD7DTV0Ied6GCl9saH8R+D2oFyLZ4=; b=OU37e/75pUKNk202miCpbIpDljYSXFWHPQfDDKQNPQfZb0T/lkd7SpemP52JS7G9ca EINAm1wYZUN9/zeW33MkNYUmCSSG97zKJycYdMPu4nJ8fmJFqr+XeSsbOjkslWrSrxQi t7y/Mr1rW/bqCDPFzc8pijXRGZlrCeKJXX8lMrxfgvg79nI3vR4vGIeGLlxWQ3VQt2hB 9rG+ssEUmJ7P8TRRma2aVx77Ro5G4LjYKNamqEsXl3rDK1wNdvVQICUzF1x2Wyt/HtNM Sx21lwW4uncK6KEnHeYrDX6DZJX8dpuQr9hnvRnf08aL7oxtmw7ePjS73bJHr4hz7V8Z AMKQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d81si1483845pfd.210.2018.03.20.08.30.34; Tue, 20 Mar 2018 08:30:49 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751475AbeCTP3L (ORCPT + 99 others); Tue, 20 Mar 2018 11:29:11 -0400 Received: from mx2.suse.de ([195.135.220.15]:40761 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750991AbeCTP3H (ORCPT ); Tue, 20 Mar 2018 11:29:07 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DC66BAB36; Tue, 20 Mar 2018 15:29:05 +0000 (UTC) Date: Tue, 20 Mar 2018 16:29:03 +0100 From: Michal Hocko To: Andrey Ryabinin Cc: Andrew Morton , Mel Gorman , Tejun Heo , Johannes Weiner , linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Subject: Re: [PATCH 6/6] mm/vmscan: Don't mess with pgdat->flags in memcg reclaim. Message-ID: <20180320152903.GA23100@dhcp22.suse.cz> References: <20180315164553.17856-1-aryabinin@virtuozzo.com> <20180315164553.17856-6-aryabinin@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180315164553.17856-6-aryabinin@virtuozzo.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 15-03-18 19:45:53, Andrey Ryabinin wrote: > memcg reclaim may alter pgdat->flags based on the state of LRU lists > in cgroup and its children. PGDAT_WRITEBACK may force kswapd to sleep > congested_wait(), PGDAT_DIRTY may force kswapd to writeback filesystem > pages. But the worst here is PGDAT_CONGESTED, since it may force all > direct reclaims to stall in wait_iff_congested(). Note that only kswapd > have powers to clear any of these bits. This might just never happen if > cgroup limits configured that way. So all direct reclaims will stall > as long as we have some congested bdi in the system. > > Leave all pgdat->flags manipulations to kswapd. kswapd scans the whole > pgdat, so it's reasonable to leave all decisions about node stat > to kswapd. Also add per-cgroup congestion state to avoid needlessly > burning CPU in cgroup reclaim if heavy congestion is observed. > > Currently there is no need in per-cgroup PGDAT_WRITEBACK and PGDAT_DIRTY > bits since they alter only kswapd behavior. > > The problem could be easily demonstrated by creating heavy congestion > in one cgroup: > > echo "+memory" > /sys/fs/cgroup/cgroup.subtree_control > mkdir -p /sys/fs/cgroup/congester > echo 512M > /sys/fs/cgroup/congester/memory.max > echo $$ > /sys/fs/cgroup/congester/cgroup.procs > /* generate a lot of diry data on slow HDD */ > while true; do dd if=/dev/zero of=/mnt/sdb/zeroes bs=1M count=1024; done & > .... > while true; do dd if=/dev/zero of=/mnt/sdb/zeroes bs=1M count=1024; done & > > and some job in another cgroup: > > mkdir /sys/fs/cgroup/victim > echo 128M > /sys/fs/cgroup/victim/memory.max > > # time cat /dev/sda > /dev/null > real 10m15.054s > user 0m0.487s > sys 1m8.505s > > According to the tracepoint in wait_iff_congested(), the 'cat' spent 50% > of the time sleeping there. > > With the patch, cat don't waste time anymore: > > # time cat /dev/sda > /dev/null > real 5m32.911s > user 0m0.411s > sys 0m56.664s > > Signed-off-by: Andrey Ryabinin > --- > include/linux/backing-dev.h | 2 +- > include/linux/memcontrol.h | 2 ++ > mm/backing-dev.c | 19 ++++------ > mm/vmscan.c | 84 ++++++++++++++++++++++++++++++++------------- > 4 files changed, 70 insertions(+), 37 deletions(-) This patch seems overly complicated. Why don't you simply reduce the whole pgdat_flags handling to global_reclaim()? -- Michal Hocko SUSE Labs