Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1201265pxb; Fri, 21 Jan 2022 12:07:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGgmcsT65u3LyQTRm+lf4RsH1tOAw4D6AGOgH1amc9pUuJRfOrEUcvUlJ3y/X9neIXwih/ X-Received: by 2002:a17:90b:3e88:: with SMTP id rj8mr2264342pjb.163.1642795651169; Fri, 21 Jan 2022 12:07:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642795651; cv=none; d=google.com; s=arc-20160816; b=XDXxyNjDIcE0ehGzr0uh5whHiLbwzbTVWz9fx/Ry6ANe4lN+GJ0ffZwjZ7D4Q3/bNe a5bgTsbMBzpSiQOiVY6hkSWZmqa4SIc9UEK/I/nAvvaMq+vvr75vir7/RR+94HvvjkMY DT9DLVNn58Y2CD4TCMOm68xbWesViLEwzT0ezAC5lsq4gPldbqJ0ut/l0HVpsTpilmNb TKVPzOows9iMjg1Bn5b3bdZDhawhMyqFcGNx8d1i1+XebV7evLHw3xqzTIuHA539nS5p BDqvIbdvouAhfWCnTkTDHalFYSnFzMmeavQJL5aS8S2TLIwJUNwLA9RhocGqKiUxnlpt 1QZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=/uKZXCGCKuME5AWgHErBCQKAH1vFfSnUlzr7p5Hz55g=; b=et5Na3hUiWdVC91xmTZnbdTzMk+DHuVsH2i+069pY0heW3oVXcoV/ji/GQWEf80KNi JyMkY6l8z29Hi7POwzWS1kIRWsXS8vv5sOszcoOMFoki8GKP4CUKE/mTuUEASqtaLmGD DfrxHHhEg1cjTqOpOcMine7svGfUUHSQFZzkYod493/58mJhCVqeE/2XoXx6lX0T+nud XzHEFp8h5cdEFkyttz9qHp7YP+Y6C6cs0cYVp0ANVvxssLLzWFCf6w6LqiUMOwJNRAdn b+KgBB5Q5bqO5QCAwgatcTfLF8HBRTaCM54zt0RxzbFpHx5rlCp9pED/fymosEGxrzU5 5vVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si7600104plg.130.2022.01.21.12.07.19; Fri, 21 Jan 2022 12:07:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343721AbiASWHy (ORCPT + 99 others); Wed, 19 Jan 2022 17:07:54 -0500 Received: from mail104.syd.optusnet.com.au ([211.29.132.246]:56233 "EHLO mail104.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236813AbiASWHx (ORCPT ); Wed, 19 Jan 2022 17:07:53 -0500 Received: from dread.disaster.area (pa49-179-45-11.pa.nsw.optusnet.com.au [49.179.45.11]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id CA2DB62B732; Thu, 20 Jan 2022 09:07:49 +1100 (AEDT) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1nAJ7L-001pwk-Vj; Thu, 20 Jan 2022 09:07:48 +1100 Date: Thu, 20 Jan 2022 09:07:47 +1100 From: Dave Chinner To: Brian Foster Cc: Al Viro , Ian Kent , "Darrick J. Wong" , Christoph Hellwig , Miklos Szeredi , David Howells , Kernel Mailing List , linux-fsdevel , xfs Subject: Re: [PATCH] vfs: check dentry is still valid in get_link() Message-ID: <20220119220747.GF59729@dread.disaster.area> References: <275358741c4ee64b5e4e008d514876ed4ec1071c.camel@themaw.net> <20220118030041.GB59729@dread.disaster.area> <20220118041253.GC59729@dread.disaster.area> <20220118232547.GD59729@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.4 cv=deDjYVbe c=1 sm=1 tr=0 ts=61e88bb8 a=Eslsx4mF8WGvnV49LKizaA==:117 a=Eslsx4mF8WGvnV49LKizaA==:17 a=kj9zAlcOel0A:10 a=DghFqjY3_ZEA:10 a=7-415B0cAAAA:8 a=ajwNnfqt_jgpfc7MgyAA:9 a=CjuIK1q_8ugA:10 a=biEYGPWJfzWAr4FL6Ov7:22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 19, 2022 at 09:08:22AM -0500, Brian Foster wrote: > On Wed, Jan 19, 2022 at 10:25:47AM +1100, Dave Chinner wrote: > > On Tue, Jan 18, 2022 at 05:58:14AM +0000, Al Viro wrote: > > > On Tue, Jan 18, 2022 at 03:12:53PM +1100, Dave Chinner wrote: > > Unfortunately, the simple fix of adding syncronize_rcu() to > > xfs_iget_recycle() causes significant performance regressions > > because we hit this path quite frequently when workloads use lots of > > temporary files - the on-disk inode allocator policy tends towards > > aggressive re-use of inodes for small sets of temporary files. > > > > The problem XFS is trying to address is that the VFS inode lifecycle > > does not cater for filesystems that need to both dirty and then > > clean unlinked inodes between iput_final() and ->destroy_inode. It's > > too late to be able to put the inode back on the LRU once we've > > decided to drop the inode if we need to dirty it again. ANd because > > evict() is part of the non-blocking memory reclaim, we aren't > > supposed to block for arbitrarily long periods of time or create > > unbound memory demand processing inode eviction (both of which XFS > > can do in inactivation). > > > > IOWs, XFS can't free the inode until it's journal releases the > > internal reference on the dirty inode. ext4 doesn't track inodes in > > it's journal - it only tracks inode buffers that contain the changes > > made to the inode, so once the transaction is committed in > > ext4_evict_inode() the inode can be immediately freed via either > > ->destroy_inode or ->free_inode. That option does not exist for XFS > > because we have to wait for the journal to finish with the inode > > before it can be freed. Hence all the background reclaim stuff. > > > > We've recently solved several of the problems we need to solve to > > reduce the mismatch; avoiding blocking on inode writeback in reclaim > > and background inactivation are two of the major pieces of work we > > needed done before we could even consider more closely aligning XFS > > to the VFS inode cache life cycle model. > > > > The background inactivation work facilitates an incremental improvement > by nature because destroyed inodes go directly to a queue instead of > being processed synchronously. My most recent test to stamp the grace > period info at inode destroy time and conditionally sync at reuse time > shows pretty much no major cost because the common case is that a grace > period has already expired by the time the queue populates, is processed > and said inodes become reclaimable and reallocated. Yup. Remember that I suggested these conditional variants in the first place - I do understand what this code does... > To go beyond just > the performance result, if I open code the conditional sync for tracking > purposes I only see something like 10-15 rcu waits out of the 36k > allocation cycles. If I increase the background workload 4x, the > allocation rate drops to ~33k cycles (which is still pretty much in line > with baseline) and the rcu sync count increases to 70, which again is > relatively nominal over tens of thousands of cycles. Yup. But that doesn't mean that the calls that trigger are free from impact. The cost and latency of waiting for an RCU grace period to expire goes up as the CPU count goes up. e.g. it requires every CPU running a task goes through a context switch before it returns. Hence if we end up with situations like, say, the ioend completion scheduling holdoffs, then that will prevent the RCU sync from returning for seconds. IOWs, we're effectively adding unpredictable and non-deterministic latency into the recycle path that is visible to userspace applications, and those latencies can be caused by subsystem functionality not related to XFS. Hence we need to carefully consider unexpected side-effects of adding a kernel global synchronisation point into a XFS icache lookup fast path, and these issues may not be immediately obvious from testing... > This all requires some more thorough testing, but I'm sure it won't be > absolutely free for every possible workload or environment. But given > that we know this infrastructure is fundamentally broken (by subtle > compatibilities between XFS and the VFS that have evolved over time), > will require some thought and time to fix properly in the filesystem, > that users are running into problems very closely related to it, why not > try to address the fundamental breakage if we can do so with an isolated > change with minimal (but probably not zero) performance impact? > > I agree that the unconditional synchronize_rcu() on reuse approach is > just not viable, but so far tests using cond_synchronize_rcu() seem > fairly reasonable. Is there some other problem or concern with such an > approach? Just that the impact of adding RCU sync points means that bad behaviour outside XFS have a new point where they can adversely impact on applications doing filesystem operations. As a temporary mitigation strategy I think it will probably be fine, but I'd much prefer we get rid of the need for such an RCU sync point rather than try to maintain a mitigation like this in fast path code forever. Cheers, Dave. -- Dave Chinner david@fromorbit.com