Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp837781pxb; Thu, 31 Mar 2022 19:59:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1g2cRBDeXsa5lR8E3ayIBWLDbHuhN2i8BGeMpPRsjRee7rEVDBcmFY7mCfiWRwc2HFMx9 X-Received: by 2002:a17:90b:3b50:b0:1c7:5d55:3cb8 with SMTP id ot16-20020a17090b3b5000b001c75d553cb8mr9410247pjb.78.1648781980487; Thu, 31 Mar 2022 19:59:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648781980; cv=none; d=google.com; s=arc-20160816; b=O5ty2OWqKRCei/J23U+JxGDsZqyRhJqj/2voCeRWAC2shbsKc+kpjsjtAsMyvkW+Yv 8mVzrxzVM4M+UjvE/HQ/K2wR/VgFYYhr8lsGwq8/8P3Ru2seQB7rnyY1OqQjVUa6sqXA dOVNC2pI08akQZMcMpqhzoc3iHrGzgzfgeEUl8n4s7am79rupjS8c9JxQQxJrSt2U2Uc gOhF9q+u1gs4cf6O096MtM7Mck19AlJxrlLU29bvX8q89+X21FMo1NqNNqSAsnZJtiaJ 5c+quXaa1AVH5RCR4jC/jg2aCPEAb1ff18+eYOfSbdaoFIdwQHGll0/arPVeeJ8UGIiV KcKw== 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; bh=W9WHqE1GQJwTqjlNKuoqSOVNwkUTQuhia+Ivp3BU2Pg=; b=qAx75pjxrbqzwTQfpGrlJTSGPueG+YSjALggNRw4J2pb6QlIC1AY4L8Z3AXE5qlzBX C8mrKv/1+RsNqAOW0V2OPUWYL4ii3Jji/8PL486qYsm/exGl8dnF3goBmOzZn8a6sYTy Xu5B6fyrtSjiVR0QR47fnGNDqYo2QhnO4aDQzv4JHNzS7tBKZqYOAVWpaxASdbOU4LCs kB24ZLPP4fulhRZIh1e2ajr5qCYB/c7su+eIsI5HM5arN8wOOKfHqujVNQaMcTgJoxCm H1JvGhPVFR7kme+BxfnUM2XqIss6vGrD+iV681H3guMc3vFF2a7MekosYnwfC3sgCgva kmbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t32-20020a634620000000b00398a0cb6022si1230001pga.198.2022.03.31.19.59.26; Thu, 31 Mar 2022 19:59:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241043AbiCaTsR (ORCPT + 99 others); Thu, 31 Mar 2022 15:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234814AbiCaTr6 (ORCPT ); Thu, 31 Mar 2022 15:47:58 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D441F63526; Thu, 31 Mar 2022 12:46:07 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1na0jt-001HLx-Ti; Thu, 31 Mar 2022 19:45:50 +0000 Date: Thu, 31 Mar 2022 19:45:49 +0000 From: Al Viro To: Stephen Brennan Cc: Andrew Morton , Luis Chamberlain , Arnd Bergmann , Matthew Wilcox , James Bottomley , Gao Xiang , Dave Chinner , Roman Gushchin , Colin Walters , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 2/2] fs/dcache: Add negative-dentry-ratio config Message-ID: References: <20220331190827.48241-1-stephen.s.brennan@oracle.com> <20220331190827.48241-3-stephen.s.brennan@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220331190827.48241-3-stephen.s.brennan@oracle.com> Sender: Al Viro X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 31, 2022 at 12:08:27PM -0700, Stephen Brennan wrote: > Negative dentry bloat is a well-known problem. For systems without > memory pressure, some workloads (like repeated stat calls) can create an > unbounded amount of negative dentries quite quickly. In the best case, > these dentries could speed up a subsequent name lookup, but in the worst > case, they are never used and their memory never freed. > > While systems without memory pressure may not need that memory for other > purposes, negative dentry bloat can have other side-effects, such as > soft lockups when traversing the d_subdirs list or general slowness with > managing them. It is a good idea to have some sort of mechanism for > controlling negative dentries, even outside memory pressure. > > This patch attempts to do so in a fair way. Workloads which create many > negative dentries must create many dentries, or convert dentries from > positive to negative. Thus, negative dentry management is best done > during these same operations, as it will amortize its cost, and > distribute the cost to the perpetrators of the dentry bloat. We > introduce a sysctl "negative-dentry-ratio" which sets a maximum number > of negative dentries per positive dentry, N:1. When a dentry is created > or unlinked, the next N+1 dentries of the parent are scanned. If no > positive dentries are found, then a candidate negative dentry is killed. Er... So what's to stop d_move() from leaving you with your cursor pointer poiting into the list of children of another parent? What's more, your dentry_unlist() logics will be defeated by that - if victim used to have a different parent, got moved, then evicted, it looks like you could end up with old parent cursor pointing to the victim and left unmodified by dentry_unlist() (since it looks only at the current parent's cursor). Wait for it to be freed and voila - access to old parent's cursor will do unpleasant things. What am I missing here?