Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp436254pxk; Wed, 9 Sep 2020 09:07:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzYO7QCGz3pTe+BgcJncLbCCRmAwYjSVhZluIERFrnhnFwd7AJCStUDeAPhNO2IYh/aN5p X-Received: by 2002:a17:906:a153:: with SMTP id bu19mr4317141ejb.142.1599667678827; Wed, 09 Sep 2020 09:07:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599667678; cv=none; d=google.com; s=arc-20160816; b=LAGTOO2rKEsqFd4Flxe/t1qBD7ahz7rZLzDOrhJGTqp3/dT3RG3bEp7e0PUlD0NYWK CI9iw4aRYOdnbWYjZB2KVYQtt/3bV8uI5oKg0jiKgghidGuhiiaUQlfnJsM6RL1wRqxv x3LInOKFJtH8Cs3kgt3vgW9ta2+LkUFlJh0Xi+ggCU2Tc9xt2tZ9NKSGMxuTSR9x675m pEnMoPf0Cp5pFPQYB9S28pzz4VLeXPLEa51WWiVEsShR959AY62/LSWi2jijwJlrPuAH 3oWNnYbRaVVoepIJcysjz65a3EEj0JwPzGJYdFi2tOslo8bNEfCBGLctyGkIJq3fgYRA 3g1g== 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; bh=bAr5DveSt2j6c3Ji2Xpkc3bdZPC9ueaRBHJ+E2ddcbI=; b=fK3uOGhiPN7GSK5bTTteNywd0ooq8O3KoH1v18N7CLW2FCL5WbbWE8DPGvWTU8k0Ni dYm4+sO6J03pV6sMdgcnLpY15dQorBYxYUfnWsBmvjD4Wqw8U6cHUI3OrU2JCeiV2oY1 R9kpjFdi/2IfOjzrkYKrT4hKlFlYUnm79a2ixRsJu0mTsbdmZUhBlETvWVSc3+GheHI2 UpuAZPkkF5EVD9CCmUww+ZjSe8j3C4h3a35xL/bagJc6gFpo7k+QaDMOhLJT4QBJDdmD H2OxLfUC/BZXALYTQEVdkcMwfif61+TA4KF/mrZ3H4xfYrjAwrMrrOw64UlRwVEXqIi3 O7Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=rK7l2L6B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d19si1937423edj.40.2020.09.09.09.07.34; Wed, 09 Sep 2020 09:07:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=rK7l2L6B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730809AbgIIQCv (ORCPT + 99 others); Wed, 9 Sep 2020 12:02:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730567AbgIIP5U (ORCPT ); Wed, 9 Sep 2020 11:57:20 -0400 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA6DEC061239 for ; Wed, 9 Sep 2020 07:56:57 -0700 (PDT) Received: by mail-qv1-xf44.google.com with SMTP id di5so1619129qvb.13 for ; Wed, 09 Sep 2020 07:56:57 -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=bAr5DveSt2j6c3Ji2Xpkc3bdZPC9ueaRBHJ+E2ddcbI=; b=rK7l2L6Ba2JCzvKHKa2SJN5u2fNNGcz+xX5FS2fVzlzE39G8QwlSi/S9fdbWoWAxte lRCguLhNf5RYuc9lo5f3oE4Vg8A5hPxuxXsJdR2PC1c2dJzcKAd1xdT+aiqPbVFA2G+c NeXiQNVqrVoihFGdA17ilFkkFzBmfhBUldl7oOfmkoDbT8QG9KI/IuOhFH2SWcD6oNS/ 2g3NyQLRJuVPWj6iFMdDrGMoGxZFkRrepBFTsyENh17ExzZib5VUsUcKLuD/b/oTNTfu Da44+gz/P7k+oDOGzPrpBwvn8NpegUiR/09kLs5DB137Mbv5KbiO+WssE1W8pTn4BGwN DAbg== 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=bAr5DveSt2j6c3Ji2Xpkc3bdZPC9ueaRBHJ+E2ddcbI=; b=GNMPzBfplch9D7F7lmyC9kXw6b9uvYCftS4qriiNViVEp1wfngZq6OEHjplHXrg2Vz 4N5r5WuVw6we8QLuNLsVuhVeMwaIVLKOELlFa7uSz8Vh5ClYH83rwlvbCcq6I1gV2QtL bLFq5WFvc7PiqH1W3nTVXP+bO4LNUZMJRqdVAKIvDluTQeILaxJWJsFsw7WL4Ws/SPF3 DLCLUhFPTlKzTJ8zbU6uG1FNkACAPE1JXB0XMdefyWyyUQy5QeUFdp7oVqhykGZ3bUSD quphhpHcOvzWsh3S8uIi9Ouhi6kR+/8gJQVX2/xygYoO375vIHKmKK1F2t3Zpav3poxY dCDw== X-Gm-Message-State: AOAM530/2JRY2EOfCT6JTmQm1ksDRix/kKVEKQVIhTPPurXR55gZ2Vdg gkpyvqn0T+uJOuNNss5Ywr6VCg== X-Received: by 2002:a05:6214:bce:: with SMTP id ff14mr4374172qvb.32.1599663416747; Wed, 09 Sep 2020 07:56:56 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:755a]) by smtp.gmail.com with ESMTPSA id q35sm3172982qtd.75.2020.09.09.07.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 07:56:55 -0700 (PDT) Date: Wed, 9 Sep 2020 10:55:34 -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: <20200909145534.GA100698@cmpxchg.org> References: <20200903230055.1245058-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200903230055.1245058-1-guro@fb.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > 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. Let's drop this patch, please.