Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1914372imm; Thu, 12 Jul 2018 09:51:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpchgx5hokXRtj9vabutmGGIohYXfdKbR9ysdHscF4clfCTsf8iMpEsBgCvlbIUQ2am1bNDS X-Received: by 2002:a17:902:8210:: with SMTP id x16-v6mr2880381pln.307.1531414265086; Thu, 12 Jul 2018 09:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531414265; cv=none; d=google.com; s=arc-20160816; b=EULXWb2ftpSY0bhbkaMLlE7x3hAGqsirt0HxELjbLnmlrl+7fGCsDIfaZHY4vkolqE HCjXNmAb3DcEWVv+BpyIfetlXnaLu03uYVCpK9JtZHogFHJ/4ABps8xoJK5zp/9I8+2Z lfgYcZo3xvH3NDq36NlbMNA+XxtAM2ID3Bg40rZ9IMJkEI8HSKD6L+tOFmgLm86KQItc QeQsMRBaF00N1lhd8W4bmMOZViOojFLerlka+LmbNyVKSD42TjcdxaQdbAZIXHxKCGJu S8fD/TBKVgF+QWxofLetn8NVj5UlfeMBaS6OsEy99mhEfkHzeUwhdfCv/e7RA3aV6OBt 87DQ== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=N7wd4eUrfJZuG+lYRTZKZ1CMnvviF+b+4hdGweq4R2I=; b=yMsZLeOkaelikgZrP0h7XGPgz9ViQnD45nt7yd7dySPL08LUmQlwen9Tpu4oIKgg9I StYAXxAlMwzUOcL9SL4kqyHHAPkrcbaPDFP9HZ466n1NP1NLoUJs8T5eZoXwM4fsCht/ Y9fzxhWpKl+cPohpfHN7HvJJKFlFXATCmtLxTULU5dc3DDPOIcsbp+/EccCM7EkxQ4zP 0QhhshIUXZa1BUwQlNmgx+2jT2/Rd8+RLgbpMESS5v4F5IePz68rFzFqByJ+DqtKHKdj nKgQHCzYhm5C1J963m1m88pABZgUeYTJUbL8DLOBRf9ZpFsGAtP3tSRq/1FMdp0Nk7WA 08SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=WIjEoRWj; 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 t10-v6si22900844pfk.228.2018.07.12.09.50.49; Thu, 12 Jul 2018 09:51:05 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=WIjEoRWj; 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 S1732402AbeGLQ74 (ORCPT + 99 others); Thu, 12 Jul 2018 12:59:56 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:40864 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726925AbeGLQ74 (ORCPT ); Thu, 12 Jul 2018 12:59:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=N7wd4eUrfJZuG+lYRTZKZ1CMnvviF+b+4hdGweq4R2I=; b=WIjEoRWjyIn/yACKSe38FuwUJ iksD4Uk13H1cy9XJzQKI9cmaa9Nyewr7kZ8b7RkOBMz+lr0fKGRUN9bOV3HAeoIREL9xOm1rR2m1T 2WLoXwWsMJ49pEUhSqu1JLszYKnqPLiI72EB2n6tUQ+ShqcG6ETIBfs+wKIO7QZDuTOSKEA3G7dmP Emc1cR53PXs2MAfwIq+hwiW0QnU+4zxLwQM162EcLPzm0U36hHJzGzGbAUSuZDsUiqZKYSpTIfzPV zf+i0C7htlfQN3zJMfxbdBygyijkCqqLO4CuNZg6I6Rr6fSu5GG4FNelAPTZWSXPwZ+44q+wTzYg+ F8lsM74GA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fdema-0006cB-KQ; Thu, 12 Jul 2018 16:49:32 +0000 Date: Thu, 12 Jul 2018 09:49:32 -0700 From: Matthew Wilcox To: James Bottomley Cc: Waiman Long , Michal Hocko , Alexander Viro , Jonathan Corbet , "Luis R. Rodriguez" , Kees Cook , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, Linus Torvalds , Jan Kara , "Paul E. McKenney" , Andrew Morton , Ingo Molnar , Miklos Szeredi , Larry Woodman , "Wangkai (Kevin C)" Subject: Re: [PATCH v6 0/7] fs/dcache: Track & limit # of negative dentries Message-ID: <20180712164932.GA3475@bombadil.infradead.org> References: <62275711-e01d-7dbe-06f1-bf094b618195@redhat.com> <20180710142740.GQ14284@dhcp22.suse.cz> <20180711102139.GG20050@dhcp22.suse.cz> <9f24c043-1fca-ee86-d609-873a7a8f7a64@redhat.com> <1531330947.3260.13.camel@HansenPartnership.com> <18c5cbfe-403b-bb2b-1d11-19d324ec6234@redhat.com> <1531336913.3260.18.camel@HansenPartnership.com> <4d49a270-23c9-529f-f544-65508b6b53cc@redhat.com> <1531411494.18255.6.camel@HansenPartnership.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1531411494.18255.6.camel@HansenPartnership.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 12, 2018 at 09:04:54AM -0700, James Bottomley wrote: > On Thu, 2018-07-12 at 11:54 -0400, Waiman Long wrote: > > It is not that dentry cache is harder to get rid of than the other > > memory. It is that the ability of generate unlimited number of > > negative dentries that will displace other useful memory from the > > system. What the patch is trying to do is to have a warning or > > notification system in place to spot unusual activities in regard to > > the number of negative dentries in the system. The system > > administrators can then decide on what to do next. > > But every cache has this property: I can cause the same effect by doing > a streaming read on a multi gigabyte file: the page cache will fill > with the clean pages belonging to the file until I run out of memory > and it has to start evicting older cache entries. Once we hit the > steady state of minimal free memory, the mm subsytem tries to balance > the cache requests (like my streaming read) against the existing pool > of cached objects. > > The question I'm trying to get an answer to is why does the dentry > cache need special limits when the mm handling of the page cache (and > other mm caches) just works? I don't know that it does work. Or that it works well. When we try to allocate something and there's no memory readily available, we ask all the shrinkers to shrink in order to free up memory. That leads to one kind of allocation (eg dentries) being able to easily kick all the page cache out of the machine. What we could do instead is first call the shrinker for the type of object being allocated. That is, assume the system is more or less in equilibrium between all the different things it could be allocating, and if something needs to be kicked out, it's better to kick out this kind of thing rather than changing the equilibrium. Of course, workloads change over time, and sometimes we should accept we need more dentries and less page cache, or vice versa. So we'd need a scheme for the shrinker to say "this is getting hard, I think we do need more dentries", and then we'd move on to calling the other shrinkers to reclaim inodes or page cache or whatever. I don't think we even try to work at this level today. But it would have the distinct advantage that we can implement this in the slab/slub code rather than touching the page allocator.