Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1419652lqp; Fri, 22 Mar 2024 14:31:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVjzHDcXAB6/KLH0rQCb9j4X6ejFuvHnKBH3Ed2g8XZaOKPRmIMHfbF3aK351z94zQ+QD5e94FeUsG7D+LeKRXNKgt/CqzqmTT4XJyu2w== X-Google-Smtp-Source: AGHT+IG72XIBvy2JZdAODRkXCXJAFu5nVn9sDtFblUOIldheTLGHOQhnosHNfveWnsefYZNCOXW1 X-Received: by 2002:a17:90a:c28c:b0:29a:9ed9:56fc with SMTP id f12-20020a17090ac28c00b0029a9ed956fcmr843158pjt.32.1711143075289; Fri, 22 Mar 2024 14:31:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711143075; cv=pass; d=google.com; s=arc-20160816; b=K58FZzcz7G7EikRurB6ZpkyHQA/jOi5jlDmEmNkwKJ6/LqhasYHzA1sdllJ17Uqi3b ECdqx42Q/r0laUTeSRGOuP/ql34U+2ZGKyrMWvtbP17Mm69DnaTweJRS2nPdLUFIuAmq jHxY+Gyg0rOCEPblmtVe0xMpUavR1frTXDMOJVCaSe+s/QzUDFRVNWO9nxiA2K5G9h8p UAzBrUcWEXT5uknWbOqydPoXckLjZu8XjJAxa5sBH3MRaZbE67D1rYujJgv73KEU9I45 2LhczD3y3rayD7Mis6G/9mdgz1bdfDmVlGIZKBBYPukqb1g9ZWpapQA2UWFtDjFNvuxH LgyA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=3831SSnNWMWA4we8GAgII7vrL0XEygfy7QIJJktUxI0=; fh=CIMTSB54zIYnu8L9p3jpNSZeCfdWuGR9mZ0zrtFjtIQ=; b=AyY+A/JFC9krmh+I1xOagIxhGPvvNPUbUP2pDHwBHp4BSeK+FwZNe1F3YGNO/gQZJb 5ytyXOGpIj1R7zktOLLWZGgPKDGEhhs4/RsbfpfksO0Xeg0oEuwwLo8zUL4eJxCOxDf9 W/x92AVcXaoW20ZGC2VSIpPa2Kl3wTCDrxdxH9VfbvI95jPeYYcKo6e9+NzfbUOVOGEu ZoA9nx0eUyhwsFCSvlZQd31OTDJY2HDRz2j5DC5e5gM3aN9DUOwaJ4AoV754xogj7NHS SR+974YTUuc4uO0EdMZ/Kz/700347BHxErG6QcfSr2Zw1kettICHvx8QpZQdqjjkpuYt CgpA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WmzxdeE2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112036-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112036-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 91-20020a17090a09e400b002a03864ce2bsi2355392pjo.171.2024.03.22.14.31.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 14:31:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112036-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WmzxdeE2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112036-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112036-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6541FB21F59 for ; Fri, 22 Mar 2024 21:31:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E94E8002A; Fri, 22 Mar 2024 21:31:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WmzxdeE2" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 840F81E53A; Fri, 22 Mar 2024 21:31:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711143060; cv=none; b=nzb34XmbTfo/1ipd/GTgkxpQ+FUrmCzreAmzgUxMUBIUgvtS79JkCFkU7kS+6rjs73Sumv+kUl9xqWWhSdNbXl7EooC4Dbzzz8Z+MXwkacY6p96UoGLN4SZBx2FH3mbldjz5UoCrCzeeHXVvnqRilC2f9EjEm1a2lr9hTpgQqxs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711143060; c=relaxed/simple; bh=ECEO3PjP3QStSZLb8LE77MInaomRvbZCiEaNdgA8l2M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=C3Kje5hgzTpdeaTLpdehnauOzmekFp374msH9VTlE1a7faCSfzkjgGlyxh840wl51YPjbFOCpqxBuPdl4Y/CPDqu+Eb8BUU4rJCHoomVjlzF/FvFRoEKN6M7/oX/JhOFryKcPsr5pOf2j/6pelFtxafl10h7zGUdQmd1rQ7kYGE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WmzxdeE2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2A92C43390; Fri, 22 Mar 2024 21:30:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711143060; bh=ECEO3PjP3QStSZLb8LE77MInaomRvbZCiEaNdgA8l2M=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=WmzxdeE2HW1827vkrRyC/M2mxciIaLWNMBukRXveZutUoMVLwh40y+WXLWV5QLWrS N/FuVAvJy74rD80I6YsZ+SA7ekThHUUKjUtrdNaULmKAvdzlTx89VUc9w/WzZTjB6P ayGWnmSr+jQrbbuTe8UxhfCujK7ehaN+Tvc4P1dTTCkNjkrDxleqC7zZXbMN4/woxF rcxwAfA1uo9ApZSbNo22+ThVQ1JCaO/LYIf2QSzQWnClGhcDXrvyiRZSu0DwC9Bg1V N8fC6Lyxzh06UOKBX2OhQrlLT5moAV07lViGObdX9DpfsBx4EvDKMGkTNloxMXjqhV VGpOMxgg14InQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 968DFCE04C1; Fri, 22 Mar 2024 14:30:59 -0700 (PDT) Date: Fri, 22 Mar 2024 14:30:59 -0700 From: "Paul E. McKenney" To: Sebastian Andrzej Siewior Cc: Yan Zhai , netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Simon Horman , Daniel Borkmann , Lorenzo Bianconi , Coco Li , Wei Wang , Alexander Duyck , linux-kernel@vger.kernel.org, rcu@vger.kernel.org, bpf@vger.kernel.org, kernel-team@cloudflare.com, Joel Fernandes , Toke =?iso-8859-1?Q?H=F8iland-J=F8rgensen?= , Alexei Starovoitov , Steven Rostedt , mark.rutland@arm.com, Jesper Dangaard Brouer Subject: Re: [PATCH v5 net 1/3] rcu: add a helper to report consolidated flavor QS Message-ID: <123ca494-dc8c-47cc-a6d5-3c529bc7f549@paulmck-laptop> Reply-To: paulmck@kernel.org References: <90431d46ee112d2b0af04dbfe936faaca11810a5.1710877680.git.yan@cloudflare.com> <20240322112413.1UZFdBq5@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240322112413.1UZFdBq5@linutronix.de> On Fri, Mar 22, 2024 at 12:24:13PM +0100, Sebastian Andrzej Siewior wrote: > On 2024-03-19 13:44:34 [-0700], Yan Zhai wrote: > > index 16f519914415..17d7ed5f3ae6 100644 > > --- a/include/linux/rcupdate.h > > +++ b/include/linux/rcupdate.h > > @@ -247,6 +247,37 @@ do { \ > > cond_resched(); \ > > } while (0) > > > > +/** > > + * rcu_softirq_qs_periodic - Report RCU and RCU-Tasks quiescent states > > + * @old_ts: jiffies at start of processing. > > + * > > + * This helper is for long-running softirq handlers, such as NAPI threads in > > + * networking. The caller should initialize the variable passed in as @old_ts > > + * at the beginning of the softirq handler. When invoked frequently, this macro > > + * will invoke rcu_softirq_qs() every 100 milliseconds thereafter, which will > > + * provide both RCU and RCU-Tasks quiescent states. Note that this macro > > + * modifies its old_ts argument. > > + * > > + * Because regions of code that have disabled softirq act as RCU read-side > > + * critical sections, this macro should be invoked with softirq (and > > + * preemption) enabled. > > + * > > + * The macro is not needed when CONFIG_PREEMPT_RT is defined. RT kernels would > > + * have more chance to invoke schedule() calls and provide necessary quiescent > > + * states. As a contrast, calling cond_resched() only won't achieve the same > > + * effect because cond_resched() does not provide RCU-Tasks quiescent states. > > + */ > > Paul, so CONFIG_PREEMPTION is affected but CONFIG_PREEMPT_RT is not. > Why does RT have more scheduling points? In RT, isn't BH-disabled code preemptible? But yes, this would not help RCU Tasks. > The RCU-Tasks thread is starving and yet there is no wake-up, correct? > Shouldn't cond_resched() take care of RCU-Tasks's needs, too? > This function is used by napi_threaded_poll() which is not invoked in > softirq it is a simple thread which does disable BH but this is it. Any > pending softirqs are served before the cond_resched(). > > This napi_threaded_poll() case _basically_ a busy thread doing a lot of > work and delaying RCU-Tasks as far as I understand. The same may happen > to other busy-worker which have cond_resched() between works, such as > the kworker. Therefore I would expect to have some kind of timeout at > which point NEED_RESCHED is set so that cond_resched() can do its work. A NEED_RESCHED with a cond_resched() would still be counted as a preemption. If we were intending to keep cond_resched(), I would be thinking in terms of changing that, but only for Tasks RCU. Given no cond_resched(), I would be thinking in terms of removing the check for CONFIG_PREEMPT_RT. Thoughts? Thanx, Paul > > +#define rcu_softirq_qs_periodic(old_ts) \ > > +do { \ > > + if (!IS_ENABLED(CONFIG_PREEMPT_RT) && \ > > + time_after(jiffies, (old_ts) + HZ / 10)) { \ > > + preempt_disable(); \ > > + rcu_softirq_qs(); \ > > + preempt_enable(); \ > > + (old_ts) = jiffies; \ > > + } \ > > +} while (0) > > + > > /* > > * Infrastructure to implement the synchronize_() primitives in > > * TREE_RCU and rcu_barrier_() primitives in TINY_RCU. > > Sebastian