Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1053207lqp; Fri, 22 Mar 2024 04:24:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXg/6YoZ+2NRqXuv2bmnhSqVxoKuZrqf1K6JNtZkSfmexd0yiO0t1JuSPl17U+JNKgvCFbaa4s4IXrWqxjuUYD9s10twrHxFZ4HXQFLuw== X-Google-Smtp-Source: AGHT+IHu/cc6NTNZ2MHJRtDBFOCuYY3P7Ay+gvsD5Bjmu4Ka2A2E9Coy+pFtoeN1LV9V36j1/c8G X-Received: by 2002:a05:6808:10cf:b0:3c3:5f71:733 with SMTP id s15-20020a05680810cf00b003c35f710733mr2085339ois.35.1711106672100; Fri, 22 Mar 2024 04:24:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711106672; cv=pass; d=google.com; s=arc-20160816; b=N2Mhy3FP+lRW016JY0b+US+WwgjLmnmycVCqR1wvbYFdtjd4oR/kXf59B6P2eB37ID SA8HMYbXw1NKIj7Fdti4vOgxtjV7YbWEjdL4PPh68q0UEzJMFvhZ6zCrs0eQmuLSfvfR HzRETLV4+5k5r10teAjepTlsmo0VvCCmfHqBY1TPJpxyg2NeYCAsxGUIvtAYmCRuAYuD NefL0OnVGLFuX9GChzbguko+pQyqHOxmIa79rtRX/fyJoVZ7K8lQ/VD5h092QBcL0f9t oS4nXJAzdirtCFb7mfi1CUrxFTLNAIfGcBudqSmnlKlDyhUNMYiXR/6sXYQsTrL+XeDy fEtA== 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:message-id:subject:cc :to:from:dkim-signature:dkim-signature:date; bh=tTCYSECJaDRw2zJqZDfA9T1Nb/hL8dmz0bj0oyPmoJQ=; fh=1gQIsAccneiOPv5uGZdj1SJhcURgSMMXG6cGzGUfse0=; b=JxVWUPgSmnxj6dyyuu92MO7sAyjdS3crmom4FvtS34++xaDLPjTp+B20d6Lw3FUqbY kVv8dzzgedsoHCLYSn9s9iz5uNfkpb5AuHtRJwKl3e/NZtNzg4Zuu38PGXYbwycGJvUs oNLXQk1waeb01C/8Mcb1kg6DDCJTf1QNG3lihk+CZmd3RjG+UR9qKmONCOSy6lJ1D78z tetUK+hK2OXuP6Fz05AvJQoD4/8DGkNOt21Le4d0UWf/a0HBervITmyc5uUvIKHpDq25 P1NKqBg8UI2uzwDvtxHy55b3ZkFjbDVzxjH59Eh+PgTsa4JBz0ryhyZjYSg5SZAhEAIw 7Nbw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OkJ+CH5o; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-111363-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111363-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f9-20020a05622a104900b0043095cd703asi453167qte.405.2024.03.22.04.24.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 04:24:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111363-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OkJ+CH5o; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-111363-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111363-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B7B271C22199 for ; Fri, 22 Mar 2024 11:24:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 21E653F9C7; Fri, 22 Mar 2024 11:24:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="OkJ+CH5o"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="DHoG41s+" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 B5F113EA66; Fri, 22 Mar 2024 11:24:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711106659; cv=none; b=rwNPRLjT8h16KSrxKmtfwZX7WmiPXfOmiA/vbPiR70VFd1R0+aZNpXQxruK6LjhPU/dHQ7C5zCjje/5bnWnQrUp7s48Jkl71SC5dvObI6SEbsgYAGARdZVA6KvUnzdTtvfTOhqAqdStkd5xESP+Wl0rBRHDp9JWYBzLGTy9vxkU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711106659; c=relaxed/simple; bh=+oC+fGntP89wG2FVGQS+dTS5BaJOhf8efmrV699I1qk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rkVpKEK8fgISfKezubyqpC5iF9rNOOwRL8Vr9IPgPkz5xmMXCohB3e93TDdOjEVKN57aIEBEIOhso/JU50aW37a3cIxVs+LeFaSsI2UYTwxhXaenWN7zMHAeBtRS6RqpzMHLThJ7QOlS2C+8lpQL+aA/CR8U7O4AbdglXM7IYYs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=OkJ+CH5o; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=DHoG41s+; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Fri, 22 Mar 2024 12:24:13 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1711106655; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tTCYSECJaDRw2zJqZDfA9T1Nb/hL8dmz0bj0oyPmoJQ=; b=OkJ+CH5okK8fKJ/tI2f6lw1iTxPpCit4ZBOGCrIaFom8TLfSRZXfbSAFLSr832IeMuuVaj ao8pSQrhkDXHYZDa6v/5oZhflyY5wGvOzTp+dTTyLo2oU12knLaXEycRRDAbAysizOsqu2 y/i3B0dafLaGNXlWlB6Fqriosd3RLrcgo0S4LfPf3mYWEgIrHkQ7mJuv1v99NDRXeeoKvd bT8WndvXS0SV2LsBl6RMsg6yAGqwxwa87tPlUk9Ud2950u/22c5EV5K3vxvcKyvZYqcBva gchOFhx1wCw3MVIaH/HwU2Gw4YB/My58WUdxmleko3WwgUPtFtYq98VNIGJD9A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1711106655; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tTCYSECJaDRw2zJqZDfA9T1Nb/hL8dmz0bj0oyPmoJQ=; b=DHoG41s+SLo2p1pHPoZSvaJTTSbmWZY8A1bvlCemaX2bXGzdq6MwSWnoBzDcj+v+dPV+gS rTid4OVkqYuAGUDA== From: Sebastian Andrzej Siewior To: Yan Zhai Cc: 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 , "Paul E. McKenney" , Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= , 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: <20240322112413.1UZFdBq5@linutronix.de> References: <90431d46ee112d2b0af04dbfe936faaca11810a5.1710877680.git.yan@cloudflare.com> 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=utf-8 Content-Disposition: inline In-Reply-To: <90431d46ee112d2b0af04dbfe936faaca11810a5.1710877680.git.yan@cloudflare.com> 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? 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. > +#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