Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp421131rwb; Fri, 4 Aug 2023 15:17:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZy7rRHsF+Zc0g3kyQJEuCR/I9CXl5+W6c0x4xxq3ZmKBTvhcoRLh/t48j/gBd9UNUeB/5 X-Received: by 2002:a05:6a21:32a6:b0:13f:e0b0:3578 with SMTP id yt38-20020a056a2132a600b0013fe0b03578mr3520829pzb.49.1691187436958; Fri, 04 Aug 2023 15:17:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691187436; cv=none; d=google.com; s=arc-20160816; b=rV+tQZ2ZDL6zh3mjqb73re8J2nV0lpC1nAH69foIbedEdQ5GZW6JMiaatm6n9jis0Q Uu5irQtehEVzugaWmWBJlwEjv6SCnHJ8K1oyU7bVl4SkuPJCMdFUnWV1mqy2Rf/VgDAX ULnQdfuIUK4nqZtrkW/A2dJLIXSmFPyMVzHrhVIut+7IVVUmrK6vuksYylE9Jgm1BFIw p9fDK/fwd+M4q3J13PULzgPnlhbV5KtZGUIGpWyJNWUanPvpwIfeboV0c/eeUW6Pndgz hN96u2RF4xZmQaxko6JXpCxy8sF/bPnq6fHDAo8GN4RS9xox6ZNetSp/vf+TeGIehBOz 25Xg== 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=7Pqv/DriK/qlhdsJM0kTmmmJJLUYWvgNZUguc6KHiIs=; fh=zAye7c7ps62QTmf1feZ2JuOGQJ4xR26oSwWHmWAREGw=; b=hy54WVVNk7Nst6ys3thpnb14yAf8zh+winX+jsK+oWQ5Vkil7b/AmSnOF6elMEgb0f tmwenj7ldxQokVZgAMdS6k3kD/gj/WdHjmyWMScgAY2JDTJvqCmbWjjvZACL/U7F021d bfE464ob5X2qC5lI504GyoXmLwpqos9VxLUq8Yxdb6b8CgabO5CrZ8he1kg5g1KgTOoE r6ViRYaY8UFRuHLx1pc933pa0c3cTQ7zcSON9eFujXCwT6xgI6nfybnCPcyo3HNIstTE 95BlxVaSVdw8jzxdD3G+n1sl4tG3uYYvCTH89hrK2KxZpcsTWIyToJzn3S5DB6gB7a5F iMWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="nf+/klpi"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c5-20020a656185000000b005526bd0c526si2221943pgv.641.2023.08.04.15.17.05; Fri, 04 Aug 2023 15:17:16 -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=@kernel.org header.s=k20201202 header.b="nf+/klpi"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230483AbjHDWEN (ORCPT + 99 others); Fri, 4 Aug 2023 18:04:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230441AbjHDWEK (ORCPT ); Fri, 4 Aug 2023 18:04:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6FED10D2; Fri, 4 Aug 2023 15:04:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4B04562113; Fri, 4 Aug 2023 22:04:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23805C433C8; Fri, 4 Aug 2023 22:04:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691186642; bh=QQtuqYG6YirPTr9VJ2u4k1MKT/dkwSKduavE+BZI9ZM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nf+/klpiE9Fj+mcS29Buo0CQd4zhmPcucswSJSjvzD72yCaCfNtq70VgsUH+QdglD XZkVS+abxJBddXtFN3yF4qE2LrHTd9/xfQsxKM3Tqau6rVG9hrxAEewvhngjKeRK/E lP0HrjUilCT5RenUIVGKSHD3rc5ep8NL32NSRoI2P+2xvGS8kLJP8cHe989bOfqXB9 5pNDjGGtcYpCdxYwbXWVpZxnnjBQC8oav57byYzP7JFehRBKpUNU7h8R+0RkR8O+Q7 x7iyNxIWKoqOCXux19A/B0IfR8uJyHWwNWTBOrJ9oPpZUD0EIqzNa+fIpF/xKlP18d +vZmXIL+oyNMQ== Date: Sat, 5 Aug 2023 00:03:59 +0200 From: Frederic Weisbecker To: Marcelo Tosatti Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexander Viro , Christian Brauner , Matthew Wilcox , Christoph Hellwig , Jens Axboe , Dave Chinner , Valentin Schneider , Leonardo Bras , Yair Podemsky , P J P Subject: Re: [PATCH] fs/buffer.c: disable per-CPU buffer_head cache for isolated CPUs 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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 Tue, Jun 27, 2023 at 05:08:15PM -0300, Marcelo Tosatti wrote: > > For certain types of applications (for example PLC software or > RAN processing), upon occurrence of an event, it is necessary to > complete a certain task in a maximum amount of time (deadline). > > One way to express this requirement is with a pair of numbers, > deadline time and execution time, where: > > * deadline time: length of time between event and deadline. > * execution time: length of time it takes for processing of event > to occur on a particular hardware platform > (uninterrupted). > > The particular values depend on use-case. For the case > where the realtime application executes in a virtualized > guest, an IPI which must be serviced in the host will cause > the following sequence of events: > > 1) VM-exit > 2) execution of IPI (and function call) > 3) VM-entry > > Which causes an excess of 50us latency as observed by cyclictest > (this violates the latency requirement of vRAN application with 1ms TTI, > for example). > > invalidate_bh_lrus calls an IPI on each CPU that has non empty > per-CPU cache: > > on_each_cpu_cond(has_bh_in_lru, invalidate_bh_lru, NULL, 1); > > The performance when using the per-CPU LRU cache is as follows: > > 42 ns per __find_get_block > 68 ns per __find_get_block_slow > > Given that the main use cases for latency sensitive applications > do not involve block I/O (data necessary for program operation is > locked in RAM), disable per-CPU buffer_head caches for isolated CPUs. So what happens if they ever do I/O then? Like if they need to do some prep work before entering an isolated critical section? Thanks. > > Signed-off-by: Marcelo Tosatti > > diff --git a/fs/buffer.c b/fs/buffer.c > index a7fc561758b1..49e9160ce100 100644 > --- a/fs/buffer.c > +++ b/fs/buffer.c > @@ -49,6 +49,7 @@ > #include > #include > #include > +#include > > #include "internal.h" > > @@ -1289,7 +1290,7 @@ static void bh_lru_install(struct buffer_head *bh) > * failing page migration. > * Skip putting upcoming bh into bh_lru until migration is done. > */ > - if (lru_cache_disabled()) { > + if (lru_cache_disabled() || cpu_is_isolated(smp_processor_id())) { > bh_lru_unlock(); > return; > } > @@ -1319,6 +1320,10 @@ lookup_bh_lru(struct block_device *bdev, sector_t block, unsigned size) > > check_irqs_on(); > bh_lru_lock(); > + if (cpu_is_isolated(smp_processor_id())) { > + bh_lru_unlock(); > + return NULL; > + } > for (i = 0; i < BH_LRU_SIZE; i++) { > struct buffer_head *bh = __this_cpu_read(bh_lrus.bhs[i]); > >