Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3310448imm; Thu, 17 May 2018 06:53:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZofoi3gZMUJOyMup58SntUBGPuYlUG+SuGsI9gH7pfOTaKnOuHXioYUL+w3ay1VqA1NiAkY X-Received: by 2002:a65:65d5:: with SMTP id y21-v6mr4057382pgv.277.1526565216207; Thu, 17 May 2018 06:53:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526565216; cv=none; d=google.com; s=arc-20160816; b=ECC91EhYTnsIX/DzbPl7dmfvx/SiWdGgq07qusVxmAjpAYDW0R8c/GYZ32xzYwyVYO wlBqH3jGdNox6EJ8xIWHyHZ8iVxJzfGxhxa0WuJogZ/rZrLYyc4nFvYPX3oJ91mUUS70 qBWvZIWr9FNkgvhyOdQ/vIk2r58w3CyMlNT01iW4reKUEbxwOM17n/rkGJtw3SPjlqKC 94lp8YUg+pAO4alTQZcmaXalQj5pfX9AQrSiCcVV/djfRIoS8FOThSswckXTyFQ6iN7c mZdFn+gt4iT1JoWg+5LnLCZl4RlyO8oYRVteJkNFj9QNpEIfLq2cIRjvuxULnJzwvgtY aq1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=nMVgZF6WDAF3M4s6hOq2abtYZfhwqYffzQyyvsq3Nfo=; b=Uo2sFHz3mb7mDjamPhlPyiamGIUXDXdqv7tb8wSLCWTF5McoS//eH5bmbC9pA26Mq1 ervyrSKu0d+mRwWiU8kw091FdIhlweawLdUmSTuIp2hZWSUJD3sJR/cyOsOHWtRotbg8 WxrH9awH0PbFRrO+ozl3UQe3v/+kOy7yupFzErcZjoioeWEYxV6ien3BnfUxucKX6opq ZeVLzX4VySjrgIaPaK5QhyWBNoxmz146aJFlX4j+GEQkhQt8CBMYQip8Q26jDjCOWUHm uzC277QzMk0GDt4SlFlqJVzlWjp2kxh/K+rq9Op/K+J/SVz++VqWgBeTOQa+Qf3gxOo3 3xRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MITynNe8; 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 a7-v6si2707176pgu.26.2018.05.17.06.53.21; Thu, 17 May 2018 06:53:36 -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=MITynNe8; 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 S1752263AbeEQNv1 (ORCPT + 99 others); Thu, 17 May 2018 09:51:27 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:45886 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751017AbeEQNv0 (ORCPT ); Thu, 17 May 2018 09:51:26 -0400 Received: by mail-lf0-f66.google.com with SMTP id w202-v6so8847751lff.12 for ; Thu, 17 May 2018 06:51:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=nMVgZF6WDAF3M4s6hOq2abtYZfhwqYffzQyyvsq3Nfo=; b=MITynNe8lXmaLVvsvdxWD/Db7BjxoNdzQr5f8NJcEZNEie2NtvgqWVikF/OdV/lMzQ 7UpsvyxbnNuwlGNeudAQ5I1baIBln0QrRQZXYgrn3vuUwdvJzIaSqLLeuUCv0sYka604 DfHsEiUi5nOBa+qA21bvs3IWgAoFQgTj5kMvl0nll/ob6uDzSsGzUgawfQK5h9xspR2m f9KJSR2mqgvFDWikkJI/0xpvE+IlebOW7W5I4wA5t0CpOB1RUBa3pVe1tdKqxzSEgwpz UfNxnbABNjjdNKnG4lUzeE17GqPd4GrefaWZFagqlB8uKegzmArw5HFN4D8WI0o3pFu9 Olpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=nMVgZF6WDAF3M4s6hOq2abtYZfhwqYffzQyyvsq3Nfo=; b=Vk1BfjLPWB8okS3XVn7Opc8+MrOTcwj3Vdposrjlm3yWMoqRf0J7wxDHdPOIpv1XEM 4qEUzzVfxh6pOSTQGcJELFRrHshIg1j3mDN6CNo9PsJKE0Y+rAQ2T5YQcV/DfuCvyxnO xY9VjqgLzZVxh65cqgbLAIKG+1MQtDXXdZr+2wKY+/LckeXJeugdFBsUkokpBa9Q18dT bg9R6/isjC8oAbpDC/SYJGKCCevdQOdj1Dscspb8aksXIa9qCoyLvYYn5qBZS/tUUuj/ c9t3Ff617m/SJqCbbgPbtHowKHpSIWN1E/YVVxTNKOYnmwpSuWo049hXDSCiHHbjkbJs kxhw== X-Gm-Message-State: ALKqPwcmxDwdx/eqjc+XzmBaQIkUnhKUpBCBuNoBm+UDti9uv/Noi4Z9 DT5ox3QgD/2iiQg0lNw1YLA= X-Received: by 2002:a19:9e12:: with SMTP id h18-v6mr17508171lfe.101.1526565084953; Thu, 17 May 2018 06:51:24 -0700 (PDT) Received: from esperanza ([185.6.245.156]) by smtp.gmail.com with ESMTPSA id c1-v6sm860620ljk.80.2018.05.17.06.51.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 May 2018 06:51:24 -0700 (PDT) Date: Thu, 17 May 2018 16:51:21 +0300 From: Vladimir Davydov To: Kirill Tkhai Cc: akpm@linux-foundation.org, shakeelb@google.com, viro@zeniv.linux.org.uk, hannes@cmpxchg.org, mhocko@kernel.org, tglx@linutronix.de, pombredanne@nexb.com, stummala@codeaurora.org, gregkh@linuxfoundation.org, sfr@canb.auug.org.au, guro@fb.com, mka@chromium.org, penguin-kernel@I-love.SAKURA.ne.jp, chris@chris-wilson.co.uk, longman@redhat.com, minchan@kernel.org, ying.huang@intel.com, mgorman@techsingularity.net, jbacik@fb.com, linux@roeck-us.net, linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org, lirongqing@baidu.com, aryabinin@virtuozzo.com Subject: Re: [PATCH v5 11/13] mm: Iterate only over charged shrinkers during memcg shrink_slab() Message-ID: <20180517135121.wtaiuj6pqxzodrlr@esperanza> References: <152594582808.22949.8353313986092337675.stgit@localhost.localdomain> <152594603565.22949.12428911301395699065.stgit@localhost.localdomain> <20180515054445.nhe4zigtelkois4p@esperanza> <5c0dbd12-8100-61a2-34fd-8878c57195a3@virtuozzo.com> <20180517041634.lgkym6gdctya3oq6@esperanza> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 17, 2018 at 02:49:26PM +0300, Kirill Tkhai wrote: > On 17.05.2018 07:16, Vladimir Davydov wrote: > > On Tue, May 15, 2018 at 05:49:59PM +0300, Kirill Tkhai wrote: > >>>> @@ -589,13 +647,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, > >>>> .memcg = memcg, > >>>> }; > >>>> > >>>> - /* > >>>> - * If kernel memory accounting is disabled, we ignore > >>>> - * SHRINKER_MEMCG_AWARE flag and call all shrinkers > >>>> - * passing NULL for memcg. > >>>> - */ > >>>> - if (memcg_kmem_enabled() && > >>>> - !!memcg != !!(shrinker->flags & SHRINKER_MEMCG_AWARE)) > >>>> + if (!!memcg != !!(shrinker->flags & SHRINKER_MEMCG_AWARE)) > >>>> continue; > >>> > >>> I want this check gone. It's easy to achieve, actually - just remove the > >>> following lines from shrink_node() > >>> > >>> if (global_reclaim(sc)) > >>> shrink_slab(sc->gfp_mask, pgdat->node_id, NULL, > >>> sc->priority); > >> > >> This check is not related to the patchset. > > > > Yes, it is. This patch modifies shrink_slab which is used only by > > shrink_node. Simplifying shrink_node along the way looks right to me. > > shrink_slab() is used not only in this place. drop_slab_node() doesn't really count as it is an extract from shrink_node() > I does not seem a trivial change for me. > > >> Let's don't mix everything in the single series of patches, because > >> after your last remarks it will grow at least up to 15 patches. > > > > Most of which are trivial so I don't see any problem here. > > > >> This patchset can't be responsible for everything. > > > > I don't understand why you balk at simplifying the code a bit while you > > are patching related functions anyway. > > Because this function is used in several places, and we have some particulars > on root_mem_cgroup initialization, and this function called from these places > with different states of root_mem_cgroup. It does not seem trivial fix for me. Let me do it for you then: diff --git a/mm/vmscan.c b/mm/vmscan.c index 9b697323a88c..e778569538de 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -486,10 +486,8 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl, * @nid is passed along to shrinkers with SHRINKER_NUMA_AWARE set, * unaware shrinkers will receive a node id of 0 instead. * - * @memcg specifies the memory cgroup to target. If it is not NULL, - * only shrinkers with SHRINKER_MEMCG_AWARE set will be called to scan - * objects from the memory cgroup specified. Otherwise, only unaware - * shrinkers are called. + * @memcg specifies the memory cgroup to target. Unaware shrinkers + * are called only if it is the root cgroup. * * @priority is sc->priority, we take the number of objects and >> by priority * in order to get the scan target. @@ -554,6 +552,7 @@ void drop_slab_node(int nid) struct mem_cgroup *memcg = NULL; freed = 0; + memcg = mem_cgroup_iter(NULL, NULL, NULL); do { freed += shrink_slab(GFP_KERNEL, nid, memcg, 0); } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL); @@ -2557,9 +2556,8 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc) shrink_node_memcg(pgdat, memcg, sc, &lru_pages); node_lru_pages += lru_pages; - if (memcg) - shrink_slab(sc->gfp_mask, pgdat->node_id, - memcg, sc->priority); + shrink_slab(sc->gfp_mask, pgdat->node_id, + memcg, sc->priority); /* Record the group's reclaim efficiency */ vmpressure(sc->gfp_mask, memcg, false, @@ -2583,10 +2581,6 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc) } } while ((memcg = mem_cgroup_iter(root, memcg, &reclaim))); - if (global_reclaim(sc)) - shrink_slab(sc->gfp_mask, pgdat->node_id, NULL, - sc->priority); - if (reclaim_state) { sc->nr_reclaimed += reclaim_state->reclaimed_slab; reclaim_state->reclaimed_slab = 0; Seems simple enough to fold it into this patch, doesn't it?