From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754508AbdGSPCk (ORCPT ); Wed, 19 Jul 2017 11:02:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59454 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753945AbdGSPCi (ORCPT ); Wed, 19 Jul 2017 11:02:38 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D45EAC0587EA Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=longman@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D45EAC0587EA Subject: Re: [PATCH 1/4] fs/dcache: Limit numbers of negative dentries To: Miklos Szeredi Cc: Alexander Viro , Jonathan Corbet , lkml , linux-doc@vger.kernel.org, linux-fsdevel , "Paul E. McKenney" , Andrew Morton , Ingo Molnar References: <1500298773-7510-1-git-send-email-longman@redhat.com> <1500298773-7510-2-git-send-email-longman@redhat.com> From: Waiman Long Organization: Red Hat Message-ID: Date: Wed, 19 Jul 2017 11:02:36 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 19 Jul 2017 15:02:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/19/2017 10:39 AM, Miklos Szeredi wrote: > On Mon, Jul 17, 2017 at 3:39 PM, Waiman Long wrote: >> The number of positive dentries is limited by the number of files >> in the filesystems. The number of negative dentries, however, >> has no limit other than the total amount of memory available in >> the system. So a rogue application that generates a lot of negative >> dentries can potentially exhaust most of the memory available in the >> system impacting performance on other running applications. >> >> To prevent this from happening, the dcache code is now updated to limit >> the amount of the negative dentries in the LRU lists that can be kept >> as a percentage of total available system memory. The default is 5% >> and can be changed by specifying the "neg_dentry_pc=" kernel command >> line option. > AFAICS the implementation is counter to the concept of LRU since it > will get rid of the most recently used negative dentry after passing > the limit. Which in itself is a source of DoS (keep rouge negative > dentries at just about the limit, so normal application are prevented > from getting their negatives cached). > > Thanks, > Miklos Yes, you are right. That is exactly the problem with patch 1 alone. That is why I have patches 3 & 4 to enable automatic trimming to decrease the number of negative dentries before the limit is reached assuming the rate of increase of negative dentries isn't faster that the reduction rate of the automatic trimming process. Cheers, Longman