Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1327560ybh; Sun, 15 Mar 2020 00:16:55 -0700 (PDT) X-Google-Smtp-Source: ADFU+vurw0BqgFw7tGb5cYzfbxrorHg0mgVhA38Aw0B/DeZIPchN3yy+Mt1vPlTbIBbabuRmMHCC X-Received: by 2002:aca:eb4c:: with SMTP id j73mr12633224oih.145.1584256614992; Sun, 15 Mar 2020 00:16:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584256614; cv=none; d=google.com; s=arc-20160816; b=vi1jMuLrMPC2gUQXBhmD9huJ6GpDNbeoyaymQrFz5xiyvBfwkf1NN/Qj14/PMHLSBr 1Da0/pzJdhKu6cHvDVjY/2aLQjwl0XfsiGgUZEV2JUqMlUnmTjpFVak9kC2mOxyGAdn0 x8EBnBhL2Zrhm++TSSYS8/xZyXS+YQg3oEjVrZquKEez7xNTtz+rFOrPhvaedRQOIdFY 9hIBqVuNb+lEN1OS8efrSyGf+xShiKQzGcCw+BRLSnaq3PdkVJ+PqJ2d83K4eUov7Zik kZTq1/E+UeS6cn3h9KLHtBoEY2pT7OR5GtR9JEds5ycLbJQ2Vm3Rkxx3BJUMD5zhJk2K oTeg== 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=wAfYh2xdWxAPIQJMB0mxlXqUYNASxsyPuzu7mvOnmEc=; b=aDO0iktpeBtLbdwN4jwtAvKAgjGbqMdjGubg6/eftFDRPDg9VbYHR5ObpjwTIaRsMs kvK/rb2E0Hb91x2+3s7mGfa5chvQr3bzrzbEuZlkOLuFFjZhZTti3ypgfp6zqb/4tLwL Ykxvs6jxq5AAdg0wSZogHiZoUw1PtmrkMv4hpBsVei4Nnmhe1UvGPxxQtWwG00GsSAA+ 6rArsS6CVLSV5he6GjpGAnvtmRH577Gg7cub4HgyxnFZrakZWg4vDxD47aw3ZVvW5k4A HXK3rohrCsy64p4vZgjWBQmEvlVP+Fti+dYa+0rQrYy7jXHIl5Pc51yKYX5ldMb0OtQQ WOdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="AU/XB7mV"; 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 b68si7959967oii.117.2020.03.15.00.16.43; Sun, 15 Mar 2020 00:16:54 -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="AU/XB7mV"; 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 S1727962AbgCOHQC (ORCPT + 99 others); Sun, 15 Mar 2020 03:16:02 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:49192 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727674AbgCOHPf (ORCPT ); Sun, 15 Mar 2020 03:15:35 -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; bh=wAfYh2xdWxAPIQJMB0mxlXqUYNASxsyPuzu7mvOnmEc=; b=AU/XB7mVJWInyKEADhOo52OrCP mHHs4FpGwJVFsaEJIkwKB7GPlSxFxK5wb8lY/h7k1B2HI8/TEkr5nu6+qzH+meQbqOy+RBLbLEzMk 9fYmB10Qv6zwHhHdlZUG9O6k8w5IYi/7TpGJuqYkAqVdyyT0bjQ6ygAnsKRb9gPfM5sRlcnTnPCbK 2iYLwNUNb8rV7WJLCE/o74fQ9dC9we5VzowkOyE++PUmAj8V16Z1EeO6ce6YjYBTThvu3AlG55kgl 96pb4yEWavmHxUe1+6udBFG6cZbW2IQZohTgCBHmFUUSJ/hKXIntwyV8/kQhr2nyk0+BVsgcfEUMH RyPc/nhQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDKEa-00050h-44; Sun, 15 Mar 2020 03:46:40 +0000 Date: Sat, 14 Mar 2020 20:46:40 -0700 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: <20200315034640.GV22433@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: > As there is no limit for negative dentries, it is possible that a sizeable > portion of system memory can be tied up in dentry cache slabs. Dentry slabs > are generally recalimable if the dentries are in the LRUs. Still having > too much memory used up by dentries can be problematic: > > 1) When a filesystem with too many negative dentries is being unmounted, > the process of draining the dentries associated with the filesystem > can take some time. To users, the system may seem to hang for > a while. The long wait may also cause unexpected timeout error or > other warnings. This can happen when a long running container with > many negative dentries is being destroyed, for instance. > > 2) Tying up too much memory in unused negative dentries means there > are less memory available for other use. Even though the kernel is > able to reclaim unused dentries when running out of free memory, > it will still introduce additional latency to the application > reducing its performance. There's a third problem, which is that having a lot of negative dentries can clog the hash chains. I tried to quantify this, and found a weird result: root@bobo-kvm:~# time for i in `seq 1 10000`; do cat /dev/null >/dev/zero; done real 0m5.402s user 0m4.361s sys 0m1.230s root@bobo-kvm:~# time for i in `seq 1 10000`; do cat /dev/null >/dev/zero; done real 0m5.572s user 0m4.337s sys 0m1.407s root@bobo-kvm:~# time for i in `seq 1 10000`; do cat /dev/null >/dev/zero; done real 0m5.607s user 0m4.522s sys 0m1.342s root@bobo-kvm:~# time for i in `seq 1 10000`; do cat /dev/null >/dev/zero; done real 0m5.599s user 0m4.472s sys 0m1.369s root@bobo-kvm:~# time for i in `seq 1 10000`; do cat /dev/null >/dev/zero; done real 0m5.574s user 0m4.498s sys 0m1.300s Pretty consistent system time, between about 1.3 and 1.4 seconds. root@bobo-kvm:~# grep dentry /proc/slabinfo dentry 20394 21735 192 21 1 : tunables 0 0 0 : slabdata 1035 1035 0 root@bobo-kvm:~# time for i in `seq 1 10000`; do cat /dev/null >/dev/zero; done real 0m5.515s user 0m4.353s sys 0m1.359s At this point, we have 20k dentries allocated. Now, pollute the dcache with names that don't exist: root@bobo-kvm:~# for i in `seq 1 100000`; do cat /dev/null$i >/dev/zero; done 2>/dev/null root@bobo-kvm:~# grep dentry /proc/slabinfo dentry 20605 21735 192 21 1 : tunables 0 0 0 : slabdata 1035 1035 0 Huh. We've kept the number of dentries pretty constant. Still, maybe the bad dentries have pushed out the good ones. root@bobo-kvm:~# time for i in `seq 1 10000`; do cat /dev/null >/dev/zero; done real 0m6.644s user 0m4.921s sys 0m1.946s root@bobo-kvm:~# time for i in `seq 1 10000`; do cat /dev/null >/dev/zero; done real 0m6.676s user 0m5.004s sys 0m1.909s root@bobo-kvm:~# time for i in `seq 1 10000`; do cat /dev/null >/dev/zero; done real 0m6.662s user 0m4.980s sys 0m1.916s root@bobo-kvm:~# time for i in `seq 1 10000`; do cat /dev/null >/dev/zero; done real 0m6.714s user 0m4.973s sys 0m1.986s Well, we certainly made it suck. Up to a pretty consistent 1.9-2.0 seconds of kernel time, or 50% worse. We've also made user time worse, somehow. Anyhow, I should write a proper C program to measure this. But I thought I'd share this raw data with you now to demonstrate that dcache pollution is a real problem today, even on a machine with 2GB.