Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp16816878rwd; Mon, 26 Jun 2023 15:55:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5SE1COeCW8a/DkHz4dCvZztNo8F51VgyFQn9jOojI60syKNEoTL4u0p0F3QkNB3tRS3gJR X-Received: by 2002:a17:90a:fd8f:b0:262:fde9:21ea with SMTP id cx15-20020a17090afd8f00b00262fde921eamr1953544pjb.29.1687820133844; Mon, 26 Jun 2023 15:55:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687820133; cv=none; d=google.com; s=arc-20160816; b=GodIZvmFwrmCBdtKcRGt9vz16wYlJFLYy/G2P52hHXi0oCAxzXipZzyKLjytdGJL/w Z8/whVbC2acAO9G2UpPq1u3mIBjwAYA4pp+eFRa87MPg1dCQTdx/aa1wXKBanVv4gnTk DLZuYz9pCg/2NG2GjfuIqqF4g4z88C6ZFoZs5I2hrDS1w61QbtaAmNxjlK0NGWfR86YS PS7p0PrhdaUk8GmXC6jBcMA1xbOkxNseVf/0UH7OJBA0SmN7Saj+aDW0HFGEcAQf4cvd y7d4SnmLZMhTdLXvhweZey5CaUuz6U/5SmgLFTz3JdjIfmgVR5h0WxNyzFbz7Xnpn6AQ h+rQ== 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=A5+/776suwjWNImbh9uLIA8Agdi2BtVsAJ4alJSyX5E=; fh=UZ+PgBGMWfPg1dTti712t1AreOE9soTZWTgevXqlzKg=; b=aq4peYJmSN4XJsNP+H1bxTfO5wy8iaIjDdpXOarBR6e+oD3vVKXbYvTtFhrUHMk0AO IdkX0GZJyhs5lHO2PUq+mHGW+4NB+mdhtZrR1Trl7uPJrMT/ZaudWED9ShNRoBmw1MsL apfEvMQ3/T+57jxy+Lq9vfbkORM8dgjOS8W3SRe0LzTTm6pbN5uFWsdl5hOLK28Rleid 50K4fzlu9T49ySfzQbn5tn/5PAYDsFz7Bqg7STTyD50KDC0sGCcdsC5ybvWbdYHzq00S MkQsMuf+XvYybKgj3SPY+j/YHht+QNkXc1LR71pUI2hkjfadYJY02pNBiBu8hBhA9ZDL 6xRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Qt4imOlF; 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 m129-20020a632687000000b005537e4e7d59si6100919pgm.84.2023.06.26.15.55.22; Mon, 26 Jun 2023 15:55:33 -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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Qt4imOlF; 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 S230167AbjFZWXh (ORCPT + 99 others); Mon, 26 Jun 2023 18:23:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230088AbjFZWXe (ORCPT ); Mon, 26 Jun 2023 18:23:34 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D85F12E; Mon, 26 Jun 2023 15:23:32 -0700 (PDT) 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=A5+/776suwjWNImbh9uLIA8Agdi2BtVsAJ4alJSyX5E=; b=Qt4imOlFVKaYa+N24wYZ4Mfnke iga8ldSUJlp1ji5VInVNkg4/mf3YxqfqFPZuY5NZVf8aEpJIrkT/vd5wN5l7tfl5PrM1Q3/2nciEx xzOMIbZF9sF4rFb0OIceqlC1kyQmInc7IfFZORR+G/Pz+Bby210dbl8fJMJMGaaHIEKwGbmII1/+p FZVJL8+KUmCiyrFjjV6/5IEZl5XhdVeqCkBPPAuXliqbr24iUIM5CHvIroOyrXc8+9cr85lGKhGn1 yC1143Dv3JCjSokFh7FC2/qG/INorydYFtJSo/hZO4BiYzI6IAvIfLHSg6rg+TwH5yckuEjvrW/GX vpnCHHcQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qDucL-0026sN-1h; Mon, 26 Jun 2023 22:23:29 +0000 Date: Mon, 26 Jun 2023 23:23:29 +0100 From: Matthew Wilcox To: Marcelo Tosatti Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexander Viro , Christian Brauner , Christoph Hellwig , Jens Axboe , Frederic Weisbecker , Dave Chinner , Valentin Schneider , Leonardo Bras , Yair Podemsky , P J P Subject: Re: [PATCH] fs/buffer.c: remove per-CPU buffer_head lookup cache Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Mon, Jun 26, 2023 at 03:04:53PM -0300, Marcelo Tosatti wrote: > Upon closer investigation, it was found that in current codebase, lookup_bh_lru > is slower than __find_get_block_slow: > > 114 ns per __find_get_block > 68 ns per __find_get_block_slow > > So remove the per-CPU buffer_head caching. > > Test program: > > #define NRLOOPS 200000 > static int __init example_init(void) > { > ktime_t s, e; > s64 delta; > int i, suc; > > bdev = blkdev_get_by_path("/dev/loop0", FMODE_READ, NULL); > if (IS_ERR(bdev)) { > printk(KERN_ERR "failed to load /dev/loop0\n"); > return -ENODEV; > } > > suc = 0; > delta = 0; > for (i=0; i < NRLOOPS; i++) { > struct buffer_head *bh; > > s = ktime_get(); > bh = __find_get_block(bdev, 1, 512); > e = ktime_get(); > if (bh) { > suc++; > __brelse(bh); > } > delta = delta + ktime_to_ns(ktime_sub(e, s)); > > } > printk(KERN_ERR "%lld ns per __find_get_block (suc=%d)\n", delta/NRLOOPS, suc); > > suc = 0; > delta = 0; > for (i=0; i < NRLOOPS; i++) { > struct buffer_head *bh; > > s = ktime_get(); > bh = __find_get_block_slow(bdev, 1); > e = ktime_get(); > if (bh) { > suc++; > __brelse(bh); > } > delta = delta + ktime_to_ns(ktime_sub(e, s)); > } > printk(KERN_ERR "%lld ns per __find_get_block_slow (suc=%d)\n", delta/NRLOOPS, suc); It occurs to me that this is close to being the best-case scenario for page-cache lookup as well as for lru lookup. Can you re-run it with block 4UL * 1024 * 1024 * 1024 instead of block 1?