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=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 DE7A3C38A2A for ; Fri, 8 May 2020 14:57:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A4AB5216FD for ; Fri, 8 May 2020 14:57:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="tYAv3EZi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4AB5216FD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3CA8D8E0005; Fri, 8 May 2020 10:57:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 353168E0003; Fri, 8 May 2020 10:57:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21AB68E0005; Fri, 8 May 2020 10:57:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id 0587B8E0003 for ; Fri, 8 May 2020 10:57:09 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B8B3A824805A for ; Fri, 8 May 2020 14:57:08 +0000 (UTC) X-FDA: 76793854536.05.magic53_788e0d963334a X-HE-Tag: magic53_788e0d963334a X-Filterd-Recvd-Size: 3341 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Fri, 8 May 2020 14:57:08 +0000 (UTC) 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=LHxKO+UrbR4+N0mrKQD3SVjztItTGAPxETGyiyCS0KY=; b=tYAv3EZiihxSVIyjLOo2dQQ7a9 Bl/iA0wlNBAcurTP2/8JqFqwEiJij4LmdgLOHMQW1Lqi6DFGUhEvTU/wyN4pbsTMjx2HcVm7FMqWY U6UXavvfgjdbsJPeDSfV9eG/eoVMrohfDnyXXrkH+oCnvAzZRsV/3dEgizbxIgBq9Uyl2OsTebpPY VJNy3L2drtIqgfxSpUiY77XbXu2bkKFIpuiq1WUgEXEiNd0ecij/1runxNHl3qoDntIuAxWCyn0t4 0X7zDJQqo+b2dehNS/V0SXyaQ4Oet0TSd8ApfQsnfaVFKmWboZrCku77ZeD0E3VD9vwCVfWaHvLzt lXiahHTA==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jX4Qt-0002IW-AC; Fri, 08 May 2020 14:56:59 +0000 Date: Fri, 8 May 2020 07:56:59 -0700 From: Matthew Wilcox To: Konstantin Khlebnikov Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Alexander Viro , Waiman Long Subject: Re: [PATCH RFC 8/8] dcache: prevent flooding with negative dentries Message-ID: <20200508145659.GQ16070@bombadil.infradead.org> References: <158893941613.200862.4094521350329937435.stgit@buzz> <158894061332.200862.9812452563558764287.stgit@buzz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <158894061332.200862.9812452563558764287.stgit@buzz> 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 Fri, May 08, 2020 at 03:23:33PM +0300, Konstantin Khlebnikov wrote: > This patch implements heuristic which detects such scenarios and prevents > unbounded growth of completely unneeded negative dentries. It keeps up to > three latest negative dentry in each bucket unless they were referenced. > > At first dput of negative dentry when it swept to the tail of siblings > we'll also clear it's reference flag and look at next dentries in chain. > Then kill third in series of negative, unused and unreferenced denries. > > This way each hash bucket will preserve three negative dentry to let them > get reference and survive. Adding positive or used dentry into hash chain > also protects few recent negative dentries. In result total size of dcache > asymptotically limited by count of buckets and positive or used dentries. > > This heuristic isn't bulletproof and solves only most practical case. > It's easy to deceive: just touch same random name twice. I'm not sure if that's "easy to deceive" ... My concern with limiting negative dentries is something like a kernel compilation where there are many (11 for mm/mmap.c, 9 in general) and there will be a lot of places where does not exist -isystem /usr/lib/gcc/x86_64-linux-gnu/9/include -I../arch/x86/include -I./arch/x86/include/generated -I../include -I./include -I../arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I../include/uapi -I./include/generated/uapi -I ../mm -I ./mm So it'd be good to know that kernel compilation times are unaffected by this patch.