Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp46305pxu; Tue, 24 Nov 2020 18:09:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJyaP7e2IaQTi8hFTJu0Pc9xEFRPJzArnxIUk+e3yHNwpC2gf0i0cxBZ4kGNxkN3MheP6YCi X-Received: by 2002:a17:906:7690:: with SMTP id o16mr1167811ejm.159.1606270143276; Tue, 24 Nov 2020 18:09:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606270143; cv=none; d=google.com; s=arc-20160816; b=mYbh1q5sPvWjt4AdWNPaRv9iwbAnSPntyncnkyiEkf24F7cnHT6CWIZoiHgDegYmSo 7zqoraoRT2JnDLYjrPF5mvwiUxtZ10ss9XrCHxjycATNLKNbXXm7j9+p07yc8DOnTtb6 rjq60PIi5xjkF+g2H5LWUoIJBgtc5j6W97Fr3hYYhSqu0o/T2w+rvI60OlJ9IwbKlGr5 QPx7pTKUe40jmTL2B4s/6pjieBD6ZJ0JKELJhXL7bIBxgsc4yhGiiz4vfJHyDSXa6otl 22G5u1TbWR7YWYBdbJayCKthtAOD99/2Wgj0ciiuSKihBN4ZYv1zAFxsV3sCnJYPR8FC xoYA== 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:dkim-signature; bh=SLTr7gkogpE89SCBqk7FGHjrc8WhupZCrsw5gAPvAgs=; b=iAdZUoae5mSM13TL62RwHdbD1E0Fdj8HOYOgkMdkj/qk+0fm4lHX1n1QtCdVjsOB2D MrxnX2wRnWe22TbBwZ7/jSNu+wcfwtiuThLD1usA5HmxE35QNnJpZhFNMD0mjUykC25C KUIFuDTWyYPRHW05RZF+76OHVR5AExtCwvPHk2xTzjogQZi2WVS2HjttVIAs05GL96ZY fRGLkXMtGdcyC12KexAKtkU9DIQdcHQuOgvoDvw82kGKGLeuEfd2LCkG1RIQixmJbiv+ wpDE4dmt7kXGQpUzt2OXaPAsm36/R1E1G2K4NdvvBfZe06TxR2ZW5EyzQr1XJ46Y7DIl pBaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=u974Tdae; 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 c11si388250ejd.748.2020.11.24.18.08.40; Tue, 24 Nov 2020 18:09:03 -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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=u974Tdae; 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 S2389865AbgKXPjS (ORCPT + 99 others); Tue, 24 Nov 2020 10:39:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389795AbgKXPjR (ORCPT ); Tue, 24 Nov 2020 10:39:17 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99F6FC0613D6; Tue, 24 Nov 2020 07:39:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=SLTr7gkogpE89SCBqk7FGHjrc8WhupZCrsw5gAPvAgs=; b=u974TdaeuqLYVbQHjVb5RtODQa lp/+o73306/8RYVtwzBmiQq7A6Y2DF5ll+prf+lj5hXOuJSAU34957L/R5qaCEPMh1XkdkZ8FNRBl 2Zq5Il5MaDJhFBDvvkKfp5VEJ4z7O7IB/cWQxZSFyrru+GlhqZMj6RWSyoyEyNOvOjhdO/lBXBDQD oEYiivABA6GsBr2Ln7cGRjMlbprmty9uQOzjyBZXvAijjEYT7NvmmZ8wCmtNLTprN5htEOQqQFRsL O+XliY7CiJW76kDlDMImr6kpP+z3thiAaxKMPIrJNVoQPQmlciMZE4Fa88+i+qN4rRYn69HOOgkAQ 6X3UIkKw==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1khaPQ-0007vF-TP; Tue, 24 Nov 2020 15:39:13 +0000 Date: Tue, 24 Nov 2020 15:39:12 +0000 From: Matthew Wilcox To: Chris Goldsworthy Cc: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, david@redhat.com, Laura Abbott Subject: Re: [PATCH] fs/buffer.c: Revoke LRU when trying to drop buffers Message-ID: <20201124153912.GC4327@casper.infradead.org> References: <1fe5d53722407a2651eeeada3a422c117041bf1d.1606194703.git.cgoldswo@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1fe5d53722407a2651eeeada3a422c117041bf1d.1606194703.git.cgoldswo@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 23, 2020 at 10:49:38PM -0800, Chris Goldsworthy wrote: > +static void __evict_bh_lru(void *arg) > +{ > + struct bh_lru *b = &get_cpu_var(bh_lrus); > + struct buffer_head *bh = arg; > + int i; > + > + for (i = 0; i < BH_LRU_SIZE; i++) { > + if (b->bhs[i] == bh) { > + brelse(b->bhs[i]); > + b->bhs[i] = NULL; > + goto out; That's an odd way to spell 'break' ... > + } > + } > +out: > + put_cpu_var(bh_lrus); > +} ... > @@ -3245,8 +3281,15 @@ drop_buffers(struct page *page, struct buffer_head **buffers_to_free) > > bh = head; > do { > - if (buffer_busy(bh)) > - goto failed; > + if (buffer_busy(bh)) { > + /* > + * Check if the busy failure was due to an > + * outstanding LRU reference > + */ > + evict_bh_lrus(bh); > + if (buffer_busy(bh)) > + goto failed; Do you see any performance problems with this? I'm concerned that we need to call all CPUs for each buffer on a page, so with a 4kB page and 512-byte block, we'd call each CPU eight times (with a 64kB page size and 4kB page, we'd call each CPU 16 times!). We might be better off just calling invalidate_bh_lrus() -- we'd flush the entire LRU, but we'd only need to do it once, not once per buffer head. We could have a more complex 'evict' that iterates each busy buffer on a page so transforming: for_each_buffer for_each_cpu for_each_lru_entry to: for_each_cpu for_each_buffer for_each_lru_entry (and i suggest that way because it's more expensive to iterate the buffers than it is to iterate the lru entries)