From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABDDCC432C3 for ; Fri, 15 Nov 2019 16:52:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 609AD2072A for ; Fri, 15 Nov 2019 16:52:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dZnOiRST" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 609AD2072A Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0A3AA6B0005; Fri, 15 Nov 2019 11:52:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 054016B0006; Fri, 15 Nov 2019 11:52:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED3636B0007; Fri, 15 Nov 2019 11:52:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0098.hostedemail.com [216.40.44.98]) by kanga.kvack.org (Postfix) with ESMTP id E02146B0005 for ; Fri, 15 Nov 2019 11:52:37 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id A3287181AC1E9 for ; Fri, 15 Nov 2019 16:52:37 +0000 (UTC) X-FDA: 76159105554.08.nail92_6e36b68207528 X-HE-Tag: nail92_6e36b68207528 X-Filterd-Recvd-Size: 8413 Received: from mail-oi1-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 Nov 2019 16:52:37 +0000 (UTC) Received: by mail-oi1-f193.google.com with SMTP id a14so9181611oid.5 for ; Fri, 15 Nov 2019 08:52:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=x9nEfpm4Qn3KUPLEqiBqX+Wd5id0rONEYyby+X9G1pY=; b=dZnOiRSTLZSxks+CVIAANablbHG+rIYQIX3NV7GjDmo/GIrgxmBn8pgMKzhF99Nf8W T37eXKZegY3lpG8kmBVdH3+UpUoxgAzo5EbonaljTE64o96bjQBiNSRYAl/sthMnPi1g g9TiNZzFHEFLJ2eCr+Xa6RHsinhdBYjxEYFd0GOlHCVrOIio9KP0ZQRumTJhosrYcL4F 23cjDvd7e1akEQLnakcYzmmHy58/3Bgd9X/1wCjNiZFpv5sZUO9pXguURYrKJKJ224j8 JOH33/I93oBH8RwMtbsqT4zlw6+wp5KlhZFC4QsIPG904WjC6r+hdpC/QOhqoRIAYckF NlCQ== 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:cc; bh=x9nEfpm4Qn3KUPLEqiBqX+Wd5id0rONEYyby+X9G1pY=; b=cDxgU4qsUiPONED4vS4sYxG4vHfSTXkILjTbKHKvDINiiQnbv+HYfE9VSRrZ2dR+6V XUoYjEnjJocPkaRJn+hoqTBSud/nCE3iH+YB/bRIrPWfSNEotLOUDAcxtFcifs4CB5oU Fnsu3hi00tWLLWSejFxKUmFMs7GPfBpl5Ju0Ats3mkKa1F2hsf0boDmsTfStukhL1Q5X V3R+J/0nduOr/s5d/BEjWd9fep4Khz5jGaNnG6ekRT38zYdnWPzjfBP4W7PiT57Ur8Y8 SvfgdILCK0MTf48Qghi+TAqcPlLe79bF+mxCq1Bq7/ZLmaT50JeJmbExK1rUxqOUYgWd sU2w== X-Gm-Message-State: APjAAAVn6D6fYrCeuAIXjV+D6EEKAgE/ItucJjVQqVr12ESUGZAE5MzI +Qr2dDcJ44vNzJWABQepgo7iP1hrKvReISjNlZbk0g== X-Google-Smtp-Source: APXvYqx2AVq593cMA+4ji4GXv3QAPg+9ct1XuU7Gg2GfBYSTG5+OuzHnoVtVqjmqrRu+pyuUAdg9xFHbBvX7RVKUhaE= X-Received: by 2002:aca:4fce:: with SMTP id d197mr8992480oib.142.1573836755958; Fri, 15 Nov 2019 08:52:35 -0800 (PST) MIME-Version: 1.0 References: <20191107205334.158354-1-hannes@cmpxchg.org> <20191107205334.158354-3-hannes@cmpxchg.org> <20191115160722.GA309754@cmpxchg.org> In-Reply-To: <20191115160722.GA309754@cmpxchg.org> From: Shakeel Butt Date: Fri, 15 Nov 2019 08:52:24 -0800 Message-ID: Subject: Re: [PATCH 2/3] mm: vmscan: detect file thrashing at the reclaim root To: Johannes Weiner Cc: Andrew Morton , Andrey Ryabinin , Suren Baghdasaryan , Rik van Riel , Michal Hocko , Linux MM , Cgroups , LKML , Kernel Team Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Nov 15, 2019 at 8:07 AM Johannes Weiner wrote: > > On Thu, Nov 14, 2019 at 03:47:59PM -0800, Shakeel Butt wrote: > > On Thu, Nov 7, 2019 at 12:53 PM Johannes Weiner wrote: > > > > > > We use refault information to determine whether the cache workingset > > > is stable or transitioning, and dynamically adjust the inactive:active > > > file LRU ratio so as to maximize protection from one-off cache during > > > stable periods, and minimize IO during transitions. > > > > > > With cgroups and their nested LRU lists, we currently don't do this > > > correctly. While recursive cgroup reclaim establishes a relative LRU > > > order among the pages of all involved cgroups, refaults only affect > > > the local LRU order in the cgroup in which they are occuring. As a > > > result, cache transitions can take longer in a cgrouped system as the > > > active pages of sibling cgroups aren't challenged when they should be. > > > > > > [ Right now, this is somewhat theoretical, because the siblings, under > > > continued regular reclaim pressure, should eventually run out of > > > inactive pages - and since inactive:active *size* balancing is also > > > done on a cgroup-local level, we will challenge the active pages > > > eventually in most cases. But the next patch will move that relative > > > size enforcement to the reclaim root as well, and then this patch > > > here will be necessary to propagate refault pressure to siblings. ] > > > > > > This patch moves refault detection to the root of reclaim. Instead of > > > remembering the cgroup owner of an evicted page, remember the cgroup > > > that caused the reclaim to happen. When refaults later occur, they'll > > > correctly influence the cross-cgroup LRU order that reclaim follows. > > > > Can you please explain how "they'll correctly influence"? I see that > > if the refaulted page was evicted due to pressure in some ancestor, > > then that's ancestor's refault distance and active file size will be > > used to decide to activate the refaulted page but how that is > > influencing cross-cgroup LRUs? > > I take it the next patch answered your question: Activating a page > inside a cgroup has an effect on how it's reclaimed relative to pages > in sibling cgroups. So the influence part isn't new with this change - > it's about recognizing that an activation has an effect on a wider > scope than just the local cgroup, and considering that scope when > making the decision whether to activate or not. > Thanks for the clarification. > > > @@ -302,6 +330,17 @@ void workingset_refault(struct page *page, void *shadow) > > > */ > > > refault_distance = (refault - eviction) & EVICTION_MASK; > > > > > > + /* > > > + * The activation decision for this page is made at the level > > > + * where the eviction occurred, as that is where the LRU order > > > + * during page reclaim is being determined. > > > + * > > > + * However, the cgroup that will own the page is the one that > > > + * is actually experiencing the refault event. > > > + */ > > > + memcg = get_mem_cgroup_from_mm(current->mm); > > > > Why not page_memcg(page)? page is locked. > > Nice catch! Indeed, the page is charged and locked at this point, so > we don't have to do another lookup and refcounting dance here. > > Delta patch: > > --- > > From 8984f37f3e88b1b39c7d6470b313730093b24474 Mon Sep 17 00:00:00 2001 > From: Johannes Weiner > Date: Fri, 15 Nov 2019 09:14:04 -0500 > Subject: [PATCH] mm: vmscan: detect file thrashing at the reclaim root fix > > Shakeel points out that the page is locked and already charged by the > time we call workingset_refault(). Instead of doing another cgroup > lookup and reference from current->mm we can simply use page_memcg(). > > Signed-off-by: Johannes Weiner For the complete patch: Reviewed-by: Shakeel Butt > --- > mm/workingset.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/mm/workingset.c b/mm/workingset.c > index f0885d9f41cd..474186b76ced 100644 > --- a/mm/workingset.c > +++ b/mm/workingset.c > @@ -338,7 +338,7 @@ void workingset_refault(struct page *page, void *shadow) > * However, the cgroup that will own the page is the one that > * is actually experiencing the refault event. > */ > - memcg = get_mem_cgroup_from_mm(current->mm); > + memcg = page_memcg(page); > lruvec = mem_cgroup_lruvec(memcg, pgdat); > > inc_lruvec_state(lruvec, WORKINGSET_REFAULT); > @@ -349,7 +349,7 @@ void workingset_refault(struct page *page, void *shadow) > * the memory was available to the page cache. > */ > if (refault_distance > active_file) > - goto out_memcg; > + goto out; > > SetPageActive(page); > advance_inactive_age(memcg, pgdat); > @@ -360,9 +360,6 @@ void workingset_refault(struct page *page, void *shadow) > SetPageWorkingset(page); > inc_lruvec_state(lruvec, WORKINGSET_RESTORE); > } > - > -out_memcg: > - mem_cgroup_put(memcg); > out: > rcu_read_unlock(); > } > -- > 2.24.0 >