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=-3.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 3B154C433E2 for ; Thu, 10 Sep 2020 17:51:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 87BDB20795 for ; Thu, 10 Sep 2020 17:51:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="han8RrIQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 87BDB20795 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EF81C6B0081; Thu, 10 Sep 2020 13:51:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA71C8E0001; Thu, 10 Sep 2020 13:51:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6E906B0087; Thu, 10 Sep 2020 13:51:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0081.hostedemail.com [216.40.44.81]) by kanga.kvack.org (Postfix) with ESMTP id C23F46B0081 for ; Thu, 10 Sep 2020 13:51:52 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 737DF3629 for ; Thu, 10 Sep 2020 17:51:52 +0000 (UTC) X-FDA: 77247894864.27.deer89_1003f2a270e8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id 4B4B23D66B for ; Thu, 10 Sep 2020 17:51:52 +0000 (UTC) X-HE-Tag: deer89_1003f2a270e8 X-Filterd-Recvd-Size: 6272 Received: from mail-qv1-f65.google.com (mail-qv1-f65.google.com [209.85.219.65]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Sep 2020 17:51:51 +0000 (UTC) Received: by mail-qv1-f65.google.com with SMTP id j10so3760046qvk.11 for ; Thu, 10 Sep 2020 10:51:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Z7WGp/osfapiuNJrta4mkaaasL0vGqrH3BVPB/bzeHc=; b=han8RrIQfCqQWH64u3lhalgdRtLuZ7WI21ODSCMTTkM4YZgkKt6uoIYTV/7NEg3tcQ c4HZcxinyB676euhbsSzbxgsLUyM7LtYD/QtvH3pZRVlb9XKAgx7OyScx3qDT/+G9SYD UrWA6lALmVQHoNfO9Y0CW0wnwkTKvVgIHDC2f3FZIcljJOEs759gt8+Vw41U77zL6oh6 5vfO8EMIFwXowzu0HdQ93Wv8gmUTriYzvJno/lvcgEwHCKaELOhYEzlTtx9LSjyniTKY 4k0nZKjNl2Hs7RXHNtIzHpgFY0Sg3kurAzuenHmSWNYOV5s4Pm4ZMrRg3wgezkOLdqVt hSQg== 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=Z7WGp/osfapiuNJrta4mkaaasL0vGqrH3BVPB/bzeHc=; b=O22+ZjIrwQIvbDDFfKgy9Hh+uinW13yhSRAMNUTSCpjKllqsrNAxGS3EV7th4LpjWu y7X/RQGyIAOchabtGTL2lLdYk8EUzDFQTlSf3uDVRL/QXHCaH0PXN/F36gpmEgqsNksX y1xjy+XuH6f4EB+7xzBwbyvtqmxotzM4+uL2ZVj81p8cRjgtw1k3TalMs2GM2ryakeV/ vji5HifrfjNR4088xnLMnfUIBm/zaBGi7veLXIbem79QPycdbadgHoPtttXSKs8b0sbM GJEPZEFE+ODtqEgZcx4qNO/f7il+h2OSazCAY+Rrp6rV5eBIl5+g1U0dFFXThlO8re18 TTjw== X-Gm-Message-State: AOAM533sSwHPhqwGqa0f+53ajXhgCX0RREcDjM1iRMEXG6O3/Vh7zcB+ rf8UNeNjfxWxLhy9rJJBPcsmRgoY2riq5A== X-Google-Smtp-Source: ABdhPJzpK7AeLxWHOKCbaz/UO5jOLKIevTlSltTLiEFDmhFBw0vJ33y26TscyqHU/oirreQYkxMdGA== X-Received: by 2002:a0c:f984:: with SMTP id t4mr9825178qvn.18.1599760310881; Thu, 10 Sep 2020 10:51:50 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:d901]) by smtp.gmail.com with ESMTPSA id w128sm7202350qkb.6.2020.09.10.10.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 10:51:50 -0700 (PDT) Date: Thu, 10 Sep 2020 13:50:26 -0400 From: Johannes Weiner To: Roman Gushchin Cc: Andrew Morton , linux-mm@kvack.org, =Shakeel Butt , Michal Hocko , kernel-team@fb.com, linux-kernel@vger.kernel.org, Michal Hocko Subject: Re: [PATCH] mm: workingset: ignore slab memory size when calculating shadows pressure Message-ID: <20200910175026.GA107346@cmpxchg.org> References: <20200903230055.1245058-1-guro@fb.com> <20200909145534.GA100698@cmpxchg.org> <20200909165520.GA1163084@carbon.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200909165520.GA1163084@carbon.dhcp.thefacebook.com> X-Rspamd-Queue-Id: 4B4B23D66B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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 Wed, Sep 09, 2020 at 09:55:20AM -0700, Roman Gushchin wrote: > On Wed, Sep 09, 2020 at 10:55:34AM -0400, Johannes Weiner wrote: > > On Thu, Sep 03, 2020 at 04:00:55PM -0700, Roman Gushchin wrote: > > > In the memcg case count_shadow_nodes() sums the number of pages in lru > > > lists and the amount of slab memory (reclaimable and non-reclaimable) > > > as a baseline for the allowed number of shadow entries. > > > > > > It seems to be a good analogy for the !memcg case, where > > > node_present_pages() is used. However, it's not quite true, as there > > > two problems: > > > > > > 1) Due to slab reparenting introduced by commit fb2f2b0adb98 ("mm: > > > memcg/slab: reparent memcg kmem_caches on cgroup removal") local > > > per-lruvec slab counters might be inaccurate on non-leaf levels. > > > It's the only place where local slab counters are used. > > > > Hm, that sounds like a bug tbh. We're reparenting the kmem caches and > > the individual objects on the list_lru when a cgroup is removed - > > shouldn't we also reparent the corresponding memory counters? > > It's definitely an option too, the question is if the added code complexity > is really worth it. I'd say no had we talk only about slab counters, > but when we'll eventually start reparenting pagecache, we'll need to reparent > other counters as well, so we'll need it anyway. So, ok, let's drop > this patch for now. > > > > > > 2) Shadow nodes by themselves are backed by slabs. So there is a loop > > > dependency: the more shadow entries are there, the less pressure the > > > kernel applies to reclaim them. > > > > This effect is negligible in practice. > > > > The permitted shadow nodes are a tiny percentage of memory consumed by > > the cgroup. If shadow nodes make up a significant part of the cgroup's > > footprint, or are the only thing left, they will be pushed out fast. > > > > The formula is max_nodes = total_pages >> 3, and one page can hold 28 > > nodes. So if the cgroup holds nothing but 262,144 pages (1G) of shadow > > nodes, the shrinker target is 32,768 nodes, which is 32,768 pages > > (128M) in the worst packing case and 1,170 pages (4M) at best. > > > > However, if you don't take slab into account here, it can evict shadow > > entries with undue aggression when they are needed the most. If, say, > > the inode or dentry cache explode temporarily and displace the page > > cache, it would be a big problem to drop the cache's non-resident info > > at the same time! This is when it's at its most important. > > Just curious, have you seen this in the real life? I have seen it with anon pages back when we targeted the page cache instead of the total memory footprint. Especially in the context of psi it missed thrashing situations, see: commit 95f9ab2d596e8cbb388315e78c82b9a131bf2928 Author: Johannes Weiner Date: Fri Oct 26 15:05:59 2018 -0700 mm: workingset: don't drop refault information prematurely I can't remember if I saw slabs doing the same, but it's equally plausible.