Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp43757ybf; Wed, 26 Feb 2020 08:31:35 -0800 (PST) X-Google-Smtp-Source: APXvYqwPVrgHfOY0w/mCg/pnBOugiWjoEfuBSXre6zrYtzsdEHSgpRCXYC7FvopAw/ZaYKpL7AJh X-Received: by 2002:a9d:7083:: with SMTP id l3mr3602250otj.193.1582734695163; Wed, 26 Feb 2020 08:31:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582734695; cv=none; d=google.com; s=arc-20160816; b=kgmJ2tGt+VniY4TNCpR26ImIuVkYOTA9ToKJ6TrTHUS9mbOumSzYJNnKNhAfgmQ2Ll JcNKnNWEKzGmCx1IyEyMNOTT+s/6kw5yla1zVQTLNO2RGFdoEtBvzYOaMoSh9tB52G9X 9j0RRcNAHNEZbXaVPIShCDXm6vLKixCmLzNRzujuQzVGDyzjdTU6FvqRR09oHjrI6zyo 0MWrPswvouAH8UADA7X3ibFA5fXAghGOYAgeYCSQHGiQPGBZfsW+m5Tb0j0mQwSZmmEi 9PJP1BxpjY3pG5KiCDdETMoc2Lm4awFj6MqiT69W+DvmcLv6+j2TDm2+RTN9/m4MgSYU AiSQ== 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=f1bv7k+aR95JLaRnibgjh33tWs/5T1jZciQ/wlmBMxs=; b=WMHCY619kYEL4Q+W9XNQRFoyJRNwYpLjiudGgomp5QdS6goKbVrLtE1v/uG976cZ+J Mnc+vOL8SKUZNHjRe8qLKxMaL+YXV5hjKUvKrhFm3wWEAtFrwEa801M4Z6CimpppeBVN wFwkH9Ez15D9cY74uWbLdSxWDR8IZuDTxcgr+Mb5WkzBs+r+HD8xxvqClPfrYrxSF5k3 6BAW6MgcjtYMaCgavTLYeujnk3dft4xG6woVT7UJMe6lsg2pKrNv7wqGV9Y41HUaARvK d2otcqhUa++ECT4yxdHqGO7fUYS38UB5fi4oQR8Uq2O6OGaylGGy2r88WbbMxoHlHLpl jCyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=drlUX7Ct; 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 t25si1527723oic.183.2020.02.26.08.31.23; Wed, 26 Feb 2020 08:31:35 -0800 (PST) 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=drlUX7Ct; 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 S1727554AbgBZQ36 (ORCPT + 99 others); Wed, 26 Feb 2020 11:29:58 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:59040 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726148AbgBZQ36 (ORCPT ); Wed, 26 Feb 2020 11:29:58 -0500 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; bh=f1bv7k+aR95JLaRnibgjh33tWs/5T1jZciQ/wlmBMxs=; b=drlUX7Cthr4H9sggJz4h6/3Y5G mo/5uBnR1hfM10WWin7v8ZrcDr7KIs1mpcF6JYjbDP8axE8K12+2yE1dRgEoe0JkNdBVR6konO36L v3FvtY2daDQI3Gxc6w0U1zAJaYE5qtmKV9inPLcETf2TyHgRdeS9kfssNNk9mpuPmtIEmOX0yrQIQ yG1PVIGbktpGvcMbun68CEcwUVIut75rKPT3wx1/X5WQiCz0SF/+G0iN43AS5VQqvGKzrN33qoWRY uCiTaJkuWH3Ve0ffsRDJDWjzD68U4huwGUTkXyUiK713MvpoLADsSp5G/y3jyvL0y2l36IORoC94R FUg4DiEA==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6zZK-0008I8-Rs; Wed, 26 Feb 2020 16:29:54 +0000 Date: Wed, 26 Feb 2020 08:29:54 -0800 From: Matthew Wilcox To: Waiman Long Cc: Alexander Viro , Jonathan Corbet , Luis Chamberlain , Kees Cook , Iurii Zaikin , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, Mauro Carvalho Chehab , Eric Biggers , Dave Chinner , Eric Sandeen Subject: Re: [PATCH 00/11] fs/dcache: Limit # of negative dentries Message-ID: <20200226162954.GC24185@bombadil.infradead.org> References: <20200226161404.14136-1-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200226161404.14136-1-longman@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 26, 2020 at 11:13:53AM -0500, Waiman Long wrote: > A new sysctl parameter "dentry-dir-max" is introduced which accepts a > value of 0 (default) for no limit or a positive integer 256 and up. Small > dentry-dir-max numbers are forbidden to avoid excessive dentry count > checking which can impact system performance. This is always the wrong approach. A sysctl is just a way of blaming the sysadmin for us not being very good at programming. I agree that we need a way to limit the number of negative dentries. But that limit needs to be dynamic and depend on how the system is being used, not on how some overworked sysadmin has configured it. So we need an initial estimate for the number of negative dentries that we need for good performance. Maybe it's 1000. It doesn't really matter; it's going to change dynamically. Then we need a metric to let us know whether it needs to be increased. Perhaps that's "number of new negative dentries created in the last second". And we need to decide how much to increase it; maybe it's by 50% or maybe by 10%. Perhaps somewhere between 10-100% depending on how high the recent rate of negative dentry creation has been. We also need a metric to let us know whether it needs to be decreased. I'm reluctant to say that memory pressure should be that metric because very large systems can let the number of dentries grow in an unbounded way. Perhaps that metric is "number of hits in the negative dentry cache in the last ten seconds". Again, we'll need to decide how much to shrink the target number by. If the number of negative dentries is at or above the target, then creating a new negative dentry means evicting an existing negative dentry. If the number of negative dentries is lower than the target, then we can just create a new one. Of course, memory pressure (and shrinking the target number) should cause negative dentries to be evicted from the old end of the LRU list. But memory pressure shouldn't cause us to change the target number; the target number is what we think we need to keep the system running smoothly.