Received: by 10.213.65.68 with SMTP id h4csp1415781imn; Mon, 19 Mar 2018 03:39:52 -0700 (PDT) X-Google-Smtp-Source: AG47ELsg5y1HPOpnQLU/0g9whL8hxjIMuc7+z2DSegYybNLV2sB8Y6HjUTZ841UDBhUsP/vmx4L4 X-Received: by 2002:a17:902:10c:: with SMTP id 12-v6mr11688481plb.405.1521455991964; Mon, 19 Mar 2018 03:39:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521455991; cv=none; d=google.com; s=arc-20160816; b=YYY7pIdeTmakeVrm3uc9J9rNLYXij/DUYOWMuqHra7mGK/ICJSub9FMsl3W80tr1kS iG/EhtNv+lu8B5Fqh0iGg5Takc5h5kqCBdcP4DbxhWBiTdmGkAJG9F+q/6LUrXS/NlYR QImVImtDw0mFsX9S98xuK2px3lOoI+w1j+zdlQHtbm0FUJziG/nGsautcLxlh/cONa5z 0E/jj7qOOlJn5GSDugnNeEhijrVkB5UwKETWKQOubBGglz+y6exFIHHjWTd6LJBikE/9 XW3Q05YCNeCrUx57elwHVRb6dggNpVIObo81aGjGQZ7qiJGMHokurSSqB1CNzPUL4Nlm su8A== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=IhZ8K0b4N/wau6uC22KbSoJFIk+rJ4zTzIOht/9n7dA=; b=xl9Rs+mnMdV+RZi18fqxLvM2wh+d8X5Tf8sa9hXk/U5I458MYcJcR19qhRWvrtVlHh SnPkFIquUeMknCoFmdd2g3vVwN/nYOPuWV8Gm7SPWgNt+Yqy+cdaqgCBA4BokKKuefLk 9/IDlYBkNJB333pO/KxVg+MPDxi2N/Nl4zLLmM+WW/TLwnbS3m8GY/XPHpuH2srg1zBQ VwhgoOdsJT0ZUce4j9LToh7eXgPMnqDLZQYVcSUBJjHwWiKZr/XDhJz5fYz7BZPXnWVS EDcHjgsITscXlZMc2If3/rtFpVppoZrG8gSz4GUePhB2Iy2EcsA7HK8pyyeyZKbLEK0G BuFw== 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 h187si7375826pgc.294.2018.03.19.03.39.37; Mon, 19 Mar 2018 03:39:51 -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 S932734AbeCSKiJ (ORCPT + 99 others); Mon, 19 Mar 2018 06:38:09 -0400 Received: from mx2.suse.de ([195.135.220.15]:44313 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932415AbeCSKh7 (ORCPT ); Mon, 19 Mar 2018 06:37:59 -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 D48BBACF0; Mon, 19 Mar 2018 10:37:57 +0000 (UTC) Date: Mon, 19 Mar 2018 11:37:56 +0100 From: Michal Hocko To: "Li,Rongqing" Cc: "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "cgroups@vger.kernel.org" , "hannes@cmpxchg.org" , Andrey Ryabinin Subject: Re: =?utf-8?B?562U5aSNOiBbUEFUQ0g=?= =?utf-8?Q?=5D?= mm/memcontrol.c: speed up to force empty a memory cgroup Message-ID: <20180319103756.GV23100@dhcp22.suse.cz> References: <1521448170-19482-1-git-send-email-lirongqing@baidu.com> <20180319085355.GQ23100@dhcp22.suse.cz> <2AD939572F25A448A3AE3CAEA61328C23745764B@BC-MAIL-M28.internal.baidu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2AD939572F25A448A3AE3CAEA61328C23745764B@BC-MAIL-M28.internal.baidu.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 Mon 19-03-18 10:00:41, Li,Rongqing wrote: > > > > -----邮件原件----- > > 发件人: Michal Hocko [mailto:mhocko@kernel.org] > > 发送时间: 2018年3月19日 16:54 > > 收件人: Li,Rongqing > > 抄送: linux-kernel@vger.kernel.org; linux-mm@kvack.org; > > cgroups@vger.kernel.org; hannes@cmpxchg.org; Andrey Ryabinin > > > > 主题: Re: [PATCH] mm/memcontrol.c: speed up to force empty a memory > > cgroup > > > > On Mon 19-03-18 16:29:30, Li RongQing wrote: > > > mem_cgroup_force_empty() tries to free only 32 (SWAP_CLUSTER_MAX) > > > pages on each iteration, if a memory cgroup has lots of page cache, it > > > will take many iterations to empty all page cache, so increase the > > > reclaimed number per iteration to speed it up. same as in > > > mem_cgroup_resize_limit() > > > > > > a simple test show: > > > > > > $dd if=aaa of=bbb bs=1k count=3886080 > > > $rm -f bbb > > > $time echo 100000000 >/cgroup/memory/test/memory.limit_in_bytes > > > > > > Before: 0m0.252s ===> after: 0m0.178s > > > > Andrey was proposing something similar [1]. My main objection was that his > > approach might lead to over-reclaim. Your approach is more conservative > > because it just increases the batch size. The size is still rather arbitrary. Same > > as SWAP_CLUSTER_MAX but that one is a commonly used unit of reclaim in > > the MM code. > > > > I would be really curious about more detailed explanation why having a > > larger batch yields to a better performance because we are doingg > > SWAP_CLUSTER_MAX batches at the lower reclaim level anyway. > > > > Although SWAP_CLUSTER_MAX is used at the lower level, but the call stack of > try_to_free_mem_cgroup_pages is too long, increase the nr_to_reclaim can reduce > times of calling function[do_try_to_free_pages, shrink_zones, hrink_node ] > > mem_cgroup_resize_limit > --->try_to_free_mem_cgroup_pages: .nr_to_reclaim = max(1024, SWAP_CLUSTER_MAX), > ---> do_try_to_free_pages > ---> shrink_zones > --->shrink_node > ---> shrink_node_memcg > ---> shrink_list <-------loop will happen in this place [times=1024/32] > ---> shrink_page_list Can you actually measure this to be the culprit. Because we should rethink our call path if it is too complicated/deep to perform well. Adding arbitrary batch sizes doesn't sound like a good way to go to me. -- Michal Hocko SUSE Labs