Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp714119lqp; Fri, 5 Apr 2024 06:52:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW4q+acGT5SDQtB+xFUm6R8+qlOasUCiWDV/58DDqsNsOprslXw4lqq65Mm5nrkiJRa/rF36OcKWRtt+MFzrZAG+ayD/BWIuOhdLuCZaQ== X-Google-Smtp-Source: AGHT+IEJrYB0YlpznYQ05xE9ycoGpy/6nOHIufPbrAQmhLc8PKHJwIxXk/bFVk6Ky37pQVDgYzFs X-Received: by 2002:a17:902:bf4a:b0:1de:f571:837c with SMTP id u10-20020a170902bf4a00b001def571837cmr3078271pls.28.1712325171076; Fri, 05 Apr 2024 06:52:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712325171; cv=pass; d=google.com; s=arc-20160816; b=JO9xieVSNdPSAilPFGOv+cQA+hnkHvzZTB5ZFs4pVR5i1RURRLpgYRZ8AQmgfo9sgM O0ShPVo2aSmP0XW2+62hvJ+lqGsUBz4B2lTyqkNVDYtzrlpoxLjMuQn4PZHPP5yqqYjt vlFbxyMdv85cVpZy4RotpvEQIo0sfrd1jcBjMRGgwRaRiX52vDndhrpiSoclU1vlp8lQ hsntqxSotFsuqtW1yyFXJh9gwWf8elvY6IcjLzPfj5sfzdfMtZld1lRHBIPfhIodkxSd NhpTwFmOtVghNFzl9bGufETzo8Z+XLHVEfSQPOcPRHzsDaZ77+sTf/xeyG5iyw9waiFn otzg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:dkim-signature :dkim-signature:date; bh=KfinOOmRqv4TiYT3J4ii30g+NwwcvO6ie7kv9r4otrM=; fh=bZ4VAF1Ii97c/xh77aOpCf2v1iK0aMekfu1+cDtScTY=; b=Fbau/PtRSrRmYMkjIbw0B5GGCf/MVWvbidX5hgivqXFMwLiIKRm5vaGGk0xmE20Nd9 GPmiMJidQCGrKANQD3YOB1ecI3p+cHLUNzyZ8Eve6bruR0X516UTvkweWwrYNn/266S5 lYgUt0mh2lTGviNXT683OP+emBpdyFMpR6LOBhqaxS0m53NdiGghhCGwuia53wdKQfTg 2aAhqk7nPoZl0N0jpkMLm9rtWqBgz3NvnNvnw/NVo4RSlK2CBfCA/fgDfc3F7rMO4dvU HmoIh37NzsjATyBurqX9HMZEsVdtAV0EvcPD1sWG2TZKNac13JYCxnc60IQZss47nMrJ 29LQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fxWS8vfT; 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-133094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133094-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e13-20020a170902784d00b001e23e133a76si1374931pln.575.2024.04.05.06.52.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 06:52:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fxWS8vfT; 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-133094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133094-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E58E9B2150B for ; Fri, 5 Apr 2024 13:50:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3306416D9CA; Fri, 5 Apr 2024 13:49:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fxWS8vfT"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="vRvQnvnW" 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 9F5AB2E401; Fri, 5 Apr 2024 13:49:50 +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=1712324992; cv=none; b=q99gJXGBkXYpAkYsXC5wDFNH3Pv3QJ7JBsXDqCtFCfc204p1B7JbSC2541QLiLoXindvbFOrdrjVucf/xHnpv5ShAXRMoQAa35t9rbsfnP5Sn5bYGDX5NWng8CZeiDEk23JKsgUXMq0A1E4Bq+1AbIzSv5/jYh81AGaV8NFyLdo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712324992; c=relaxed/simple; bh=Yh6tb71zvPKChuofRzQ+jAmdGm2HUzLM6pFKbvX9nEs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EBG+UqTPMsAEThxWMVEa18hWt5dXBTZ/UxZ1pppQZvmVXGCqiHCqjdC/eq+hAlLKjs0yDhuHjxjM+7VddA6a6IS1BB4JZ9CPpp1YTgBp3X1SUHA9EjzKUJhzOIDfPWJ/teahKPuMKnbm9KiSZp4yCWxeMJ1S1LQTiUXDn8f5NZ0= 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=fxWS8vfT; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=vRvQnvnW; 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, 5 Apr 2024 15:49:46 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1712324988; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KfinOOmRqv4TiYT3J4ii30g+NwwcvO6ie7kv9r4otrM=; b=fxWS8vfThFgtVfNVrfxto+hy2vU3Cc4H2eBhmROJ8OHw+DRog7DYb4i7coSwQZSsWFAxGV nETxmsR3lByOyCUdHItK90a5yxTqjf4c+oeJ9+ZNchI1mZind/YjdakyGsxiUZ6sC0VtC1 H7jw9BoKFT1R+Wio6Q4Etn+Vn+rQDrVDBwlvVEzAVBT9+cclOXSSIWoEQae/+c7VUF3e+g vI/Up8UoJc8AryokLQfkgNfTf7IVy5UrHEVKppi3Py58a1/1I8AnoHyN1GWWAf8n5S3+uU 2Al7UE1uKNg+Au4lwPCiO3WfAeXMH++x9C6zr8Lo7KtdPAwHLLp3P6jDe7cDSw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1712324988; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KfinOOmRqv4TiYT3J4ii30g+NwwcvO6ie7kv9r4otrM=; b=vRvQnvnWLH1+h/yHjM4QKU6SVZhlNolDRNjj2oV+ctzgEuZeHyDtIuhBzZOmm8soM0eN16 6oPDnpSlQq2c3wDQ== From: Sebastian Andrzej Siewior To: Yan Zhai Cc: paulmck@kernel.org, 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 =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= , Alexei Starovoitov , Steven Rostedt , mark.rutland@arm.com, Jesper Dangaard Brouer , Thomas Gleixner Subject: Re: [PATCH v5 net 1/3] rcu: add a helper to report consolidated flavor QS Message-ID: <20240405134946.NzqmEyX1@linutronix.de> References: <90431d46ee112d2b0af04dbfe936faaca11810a5.1710877680.git.yan@cloudflare.com> <20240322112413.1UZFdBq5@linutronix.de> <123ca494-dc8c-47cc-a6d5-3c529bc7f549@paulmck-laptop> 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 Content-Transfer-Encoding: quoted-printable In-Reply-To: On 2024-03-22 21:02:02 [-0500], Yan Zhai wrote: > On Fri, Mar 22, 2024 at 4:31=E2=80=AFPM Paul E. McKenney wrote: > > > > On Fri, Mar 22, 2024 at 12:24:13PM +0100, Sebastian Andrzej Siewior wro= te: > > > On 2024-03-19 13:44:34 [-0700], Yan Zhai wrote: > > > > + * The macro is not needed when CONFIG_PREEMPT_RT is defined. RT k= ernels would > > > > + * have more chance to invoke schedule() calls and provide necessa= ry quiescent > > > > + * states. As a contrast, calling cond_resched() only won't achiev= e the same > > > > + * effect because cond_resched() does not provide RCU-Tasks quiesc= ent 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. Yes, it is but why does it matter? This is used in the NAPI thread which fully preemptible and does cond_resched(). This should be enough. > By "more chance to invoke schedule()", my thought was that > cond_resched becomes no op on RT or PREEMPT kernel. So it will not > call __schedule(SM_PEREEMPT), which clears the NEED_RESCHED flag. On a It will nop cond_resched(), correct. However once something sends NEED_RESCHED then the receiver of this flag will __schedule(SM_PEREEMPT) as soon as possible. That is either because the scheduler sends an IPI and the CPU will do it in the irq-exit path _or_ the thread does preempt_enable() (which includes local_bh_enable()) and the counter hits zero at which point the same context switch happens. Therefore I don't see a difference between CONFIG_PREEMPT and CONFIG_PREEMPT_RT. > normal irq exit like timer, when NEED_RESCHED is on, > schedule()/__schedule(0) can be called time by time then. This I can not parse. __schedule(0) means the task gives up on its own and goes to sleep. This does not happen for the NAPI-thread loop, kworker loop or any other loop that consumes one work item after the other and relies on cond_resched() in between. > __schedule(0) is good for RCU tasks, __schedule(SM_PREEMPT) is not. Okay and that is why? This means you expect that every thread gives up on its own which may take some time depending on the workload. This should not matter. If I see this right, the only difference is rcu_tasks_classic_qs() and I didn't figure out yet what it does. > But I think this code comment does not take into account frequent > preempt_schedule and irqentry_exit_cond_resched on a PREEMPT kernel. > When returning to these busy kthreads, irqentry_exit_cond_resched is > in fact called now, not schedule(). So likely __schedule(PREEMPT) is > still called frequently, or even more frequently. So the code comment > looks incorrect on the RT argument part. We probably should remove the > "IS_ENABLED" condition really. Paul and Sebastian, does this sound > reasonable to you? Can you walk me through it? Why is it so important for a task to give up voluntary? There is something wrong here with how RCU tasks works. We want to get rid of the sprinkled cond_resched(). This looks like a another variant of it that might be required in places with no explanation except it takes too long.=20 > Yan Sebastian