Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FDE9C05027 for ; Thu, 2 Feb 2023 22:51:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230432AbjBBWvj (ORCPT ); Thu, 2 Feb 2023 17:51:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231442AbjBBWvf (ORCPT ); Thu, 2 Feb 2023 17:51:35 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A326C6C118; Thu, 2 Feb 2023 14:51:32 -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=wNaqigkQxIukar7avGzK7dviESW0b0iyFkV+nOTVZXI=; b=YJLI29zIn6dVUJAjAkE9q8ztpi gHxij6TvruKtv2kYPv8fiA8fX8hIgk/40xQxFu7tbrUtLoQdssiWrdPsSCWWE/iW5IFtFYXaomcD2 k2EgenkMRZjLFqEDMMUzy3/Snacp65dogGgCCpgnTMAkQFEmefzXKo83u78QhYEToWN5F4PTGMRgB LVSsxLSWjssLl3o2BIpQeb19HNFfHguT3ME/cQXCnIZmK4AiU4gIVwOt9IPOdvX00nNNanHxHAzQv J59t6aOaMUJg/fqNLwx8ptqtiFq8DNM0g1cPeZ38/kAiKESZuWJrc9cCntXfqyKDAs7/x+7sd8KGR bCh+B5HQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNiQS-00DnTW-1U; Thu, 02 Feb 2023 22:51:28 +0000 Date: Thu, 2 Feb 2023 22:51:27 +0000 From: Matthew Wilcox To: Dave Chinner Cc: Marcelo Tosatti , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexander Viro , Christoph Hellwig , Jens Axboe , Frederic Weisbecker , Leonardo Bras , Yair Podemsky , P J P Subject: Re: [PATCH v3] fs/buffer.c: update per-CPU bh_lru cache via RCU Message-ID: References: <20230202223653.GF937597@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230202223653.GF937597@dread.disaster.area> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 03, 2023 at 09:36:53AM +1100, Dave Chinner wrote: > On Wed, Feb 01, 2023 at 01:01:47PM -0300, Marcelo Tosatti wrote: > > > > umount calls invalidate_bh_lrus which IPIs each > > via invalidate_bdev(). So this is only triggered on unmount of > filesystems that use the block device mapping directly, right? > > Or is the problem that userspace is polling the block device (e.g. > udisks, blkid, etc) whilst the filesystem is mounted and populating > the block device mapping with cached pages so invalidate_bdev() > always does work even when the filesystem doesn't actually use the > bdev mapping? > > > CPU that has non empty per-CPU buffer_head cache: > > > > on_each_cpu_cond(has_bh_in_lru, invalidate_bh_lru, NULL, 1); > > > > This interrupts CPUs which might be executing code sensitive > > to interferences. > > > > To avoid the IPI, free the per-CPU caches remotely via RCU. > > Two bh_lrus structures for each CPU are allocated: one is being > > used (assigned to per-CPU bh_lru pointer), and the other is > > being freed (or idle). > > Rather than adding more complexity to the legacy bufferhead code, > wouldn't it be better to switch the block device mapping to use > iomap+folios and get rid of the use of bufferheads altogether? Pretty sure ext4's journalling relies on the blockdev using buffer_heads. At least, I did a conversion of blockdev to use mpage_readahead() and ext4 stopped working.