Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp628327lqp; Wed, 12 Jun 2024 11:11:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/Ve4cKyDqKfqUDIpnpn9DE36b4sF84dUJkSOQbE2sWsI37GvhWS18QP0+7D1lXZWLm1a0Vcb0HO98POUu7fSPH10f5Yt5zCX3gTr25Q== X-Google-Smtp-Source: AGHT+IHmRV65vXa0cX+AwYiPZDAYjal1+DHmGfkTRJULBMKqiQGnalPzkHTnO1dp7StXN8IxVXWf X-Received: by 2002:a05:6512:36c2:b0:52c:7fbf:39f6 with SMTP id 2adb3069b0e04-52c9a3d26a7mr1745950e87.26.1718215880040; Wed, 12 Jun 2024 11:11:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718215880; cv=pass; d=google.com; s=arc-20160816; b=rlV/fM3UVFNliJBSGUur+hlvKw2WJrcRYVP4VO9EFzb823FA+iBfR1cL+RaAP6hBfE hfRkiHXgW6iMVrufDlPylbudOTPtrbWuvKrHE6ccVkywB1URnWIIq4BE9MiuRa10u2oV s78j1AYdNZEiC9pSbqTj/LO5h2fPmXqdnvOg4NrZ6DpreWfcne24jAOVBi+g+AE7Uz2D 9XE694xqrPf8JairlLN5Zkk8seO6ni+gdvTPUQlsWXW1HUKsLbaSKOBaE4JLkR8wGMSl CL53iAxEsF1i9P29PDld6uaWWf3CHUA5yulsjLFtw95ZDvTkfBhj/Tx6Vd5jdz9TDpUl tj2g== 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=n9P9ZKresxSacykvAdVL+cPp4BZNp8yNyZKN5P1c1pE=; fh=3rSVSgt54mqvPl1A7FxupWP3QSmVkrcsOXNVhsGZu+o=; b=IGD1GNPpZrLdT8YWIrnl9kpiCkucPpze8gPMWlRR9CPZ6V+MuDu1jE9ZwDGlhyp9Oh ESiCQ6h5L/FgV7XnMGKq44B/WswwDC5WD80VnHN6z0TPDcRDYxlRIL8LF5bQgk3n+AgZ QpUehimHkB8OfKlOqa1on6XUj9fExKpi+t657fRx7DruVNILg5aWhY+A7a03xUchLqe2 Bsgq4LmCgq/aoCwsWO3uwLOhqeyQQWGmrabSftU8stQZT1JGHv76pn5Qde2U5tqYY1yr Edvj296tDu/S4tCQQfVytn+HxaZenq/P1yjTuwoJa1RCvd0I4ODHxvEdwgtRg4ZIHyQw jpzA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gMslw1kM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-212045-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212045-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f201c12f1si331726866b.356.2024.06.12.11.11.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 11:11:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212045-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gMslw1kM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-212045-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212045-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 819CF1F22ABB for ; Wed, 12 Jun 2024 18:11:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D90E1836DF; Wed, 12 Jun 2024 18:10:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gMslw1kM" 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 5650818309D for ; Wed, 12 Jun 2024 18:10:55 +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=1718215855; cv=none; b=RDe8it6FlKUiSgbqLYBCOAuU8B10snYMj5Ots2oGISsSOtJMA5mBsS4Rbk2IGN/itjiis6JNz8TK/zxIqzzmXVXQR+bCCtTcJoVVbpUqrj9L8Nd+myEYtpsOZSrpG3utEIB3HcYzOwLMGDgNdk8SyY9Czk5to3sgSNPkTRSY5pw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718215855; c=relaxed/simple; bh=SqV7Q9/x2YZSDMfPGfsV1yJAT7awWqzlHlOMVv8cLh8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FmUoMnsMk0e+vGv9duXErvGz0ggSemn3K9PKisSPolyQQAmANP8fPW/p0ww3zVdqfPLoc0CF/CQkglTW9H6F8QkEH5In1R4vKQc9Pz7Rwe9PxmisHSUAS9oFwdkIrhwtpXZKioZZdQbYffcAupzLhvpN7ErzKfZmHdXPjC4E7d0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gMslw1kM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE48DC116B1; Wed, 12 Jun 2024 18:10:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718215854; bh=SqV7Q9/x2YZSDMfPGfsV1yJAT7awWqzlHlOMVv8cLh8=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=gMslw1kMWn30pa75ei+/+bMEaMAwzg+JqSBQqRr3YbO7ctXDF9g2rYJBLan25UjHS lRvR3ecW/zowY/zpOO8slFFdh6+vA6qkx5GbSfAWBOBla0CtDcGfVoDWD9A7I4zDia vMpsuNdm821GYoNYAttWud6d5zbGyofE4SjmWnkcNy9LIL+SorLt+1F4KbQpyIVSa3 wqvrDhhMyCi/c019QeenkpYrtnDQsKWn5HgCugXmFsWM9Qv2TjCYUHgYW4CvX97s/q BiDgbjZdb4jq0nll+K22zOWbms56nRD7lpy2ujq2Wzw/RBKZaM30TuERof/a5yAeXn FdxDXVGISLoRg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 7EDB7CE0DEA; Wed, 12 Jun 2024 11:10:54 -0700 (PDT) Date: Wed, 12 Jun 2024 11:10:54 -0700 From: "Paul E. McKenney" To: Ankur Arora Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, tglx@linutronix.de, torvalds@linux-foundation.org, rostedt@goodmis.org, mark.rutland@arm.com, juri.lelli@redhat.com, joel@joelfernandes.org, raghavendra.kt@amd.com, sshegde@linux.ibm.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com, Ingo Molnar , Vincent Guittot Subject: Re: [PATCH v2 13/35] sched: allow runtime config for PREEMPT_AUTO Message-ID: <652b1be3-e154-4902-b7aa-f9151ed5cf75@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20240528003521.979836-1-ankur.a.arora@oracle.com> <20240528003521.979836-14-ankur.a.arora@oracle.com> <20240528162725.GH26599@noisy.programming.kicks-ass.net> <87ttif641i.fsf@oracle.com> <20240606115101.GC8774@noisy.programming.kicks-ass.net> <87ikymw1g2.fsf@oracle.com> <20240606173218.GH8774@noisy.programming.kicks-ass.net> <87frtnt02l.fsf@oracle.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=us-ascii Content-Disposition: inline In-Reply-To: <87frtnt02l.fsf@oracle.com> On Sat, Jun 08, 2024 at 05:46:26PM -0700, Ankur Arora wrote: > Peter Zijlstra writes: > > On Thu, Jun 06, 2024 at 08:11:41AM -0700, Ankur Arora wrote: > >> Peter Zijlstra writes: > >> > On Thu, May 30, 2024 at 02:29:45AM -0700, Ankur Arora wrote: > >> >> Peter Zijlstra writes: > >> >> > On Mon, May 27, 2024 at 05:34:59PM -0700, Ankur Arora wrote: > >> >> >> Reuse sched_dynamic_update() and related logic to enable choosing > >> >> >> the preemption model at boot or runtime for PREEMPT_AUTO. > >> >> >> > >> >> >> The interface is identical to PREEMPT_DYNAMIC. > >> >> > > >> >> > Colour me confused, why?!? What are you doing and why aren't just just > >> >> > adding AUTO to the existing DYNAMIC thing? > >> >> > >> >> You mean have a single __sched_dynamic_update()? AUTO doesn't use any > >> >> of the static_call/static_key stuff so I'm not sure how that would work. > >> > > >> > *sigh*... see the below, seems to work. > >> > >> Sorry, didn't mean for you to have to do all that work to prove the > >> point. > > > > Well, for a large part it was needed for me to figure out what your > > patches were actually doing anyway. Peel away all the layers and this is > > what remains. > > > >> I phrased it badly. I do understand how lazy can be folded in as > >> you do here: > >> > >> > + case preempt_dynamic_lazy: > >> > + if (!klp_override) > >> > + preempt_dynamic_disable(cond_resched); > >> > + preempt_dynamic_disable(might_resched); > >> > + preempt_dynamic_enable(preempt_schedule); > >> > + preempt_dynamic_enable(preempt_schedule_notrace); > >> > + preempt_dynamic_enable(irqentry_exit_cond_resched); > >> > + preempt_dynamic_key_enable(preempt_lazy); > >> > + if (mode != preempt_dynamic_mode) > >> > + pr_info("Dynamic Preempt: lazy\n"); > >> > + break; > >> > } > >> > >> But, if the long term goal (at least as I understand it) is to get rid > >> of cond_resched() -- to allow optimizations that needing to call cond_resched() > >> makes impossible -- does it make sense to pull all of these together? > > > > It certainly doesn't make sense to add yet another configurable thing. We > > have one, so yes add it here. > > > >> Say, eventually preempt_dynamic_lazy and preempt_dynamic_full are the > >> only two models left. Then we will have (modulo figuring out how to > >> switch over klp from cond_resched() to a different unwinding technique): > >> > >> static void __sched_dynamic_update(int mode) > >> { > >> preempt_dynamic_enable(preempt_schedule); > >> preempt_dynamic_enable(preempt_schedule_notrace); > >> preempt_dynamic_enable(irqentry_exit_cond_resched); > >> > >> switch (mode) { > >> case preempt_dynamic_full: > >> preempt_dynamic_key_disable(preempt_lazy); > >> if (mode != preempt_dynamic_mode) > >> pr_info("%s: full\n", PREEMPT_MODE); > >> break; > >> > >> case preempt_dynamic_lazy: > >> preempt_dynamic_key_enable(preempt_lazy); > >> if (mode != preempt_dynamic_mode) > >> pr_info("Dynamic Preempt: lazy\n"); > >> break; > >> } > >> > >> preempt_dynamic_mode = mode; > >> } > >> > >> Which is pretty similar to what the PREEMPT_AUTO code was doing. > > > > Right, but without duplicating all that stuff in the interim. > > Yeah, that makes sense. Joel had suggested something on these lines > earlier [1], to which I was resistant. > > However, the duplication (and the fact that the voluntary model > was quite thin) should have told me that (AUTO, preempt=voluntary) > should just be folded under PREEMPT_DYNAMIC. > > I'll rework the series to do that. > > That should also simplify RCU related choices which I think Paul will > like. Given that the lazy model is meant to eventually replace > none/voluntary, so PREEMPT_RCU configuration can just be: > > --- a/kernel/rcu/Kconfig > +++ b/kernel/rcu/Kconfig > @@ -18,7 +18,7 @@ config TREE_RCU > > config PREEMPT_RCU > bool > - default y if PREEMPTION > + default y if PREEMPTION && !PREEMPT_LAZY Given that PREEMPT_DYNAMIC selects PREEMPT_BUILD which in turn selects PREEMPTION, this should work. > Or, maybe we should instead have this: > > --- a/kernel/rcu/Kconfig > +++ b/kernel/rcu/Kconfig > @@ -18,7 +18,7 @@ config TREE_RCU > > config PREEMPT_RCU > bool > - default y if PREEMPTION > + default y if PREEMPT || PREEMPT_RT > select TREE_RCU > > Though this would be a change in behaviour for current PREEMPT_DYNAMIC > users. Which I believe to be a no-go. I believe that PREEMPT_DYNAMIC users really need their preemptible kernels to include preemptible RCU. If PREEMPT_LAZY causes PREEMPT_DYNAMIC non-preemptible kernels to become lazily preemptible, that is a topic to discuss with PREEMPT_DYNAMIC users. On the other hand, if PREEMPT_LAZY does not cause PREEMPT_DYNAMIC kernels to become lazily preemptible, then I would expect there to be hard questions about removing cond_resched() and might_sleep(), or, for that matter changing their semantics. Which I again must leave to PREEMPT_DYNAMIC users. Thanx, Paul > [1] https://lore.kernel.org/lkml/fd48ea5c-bc74-4914-a621-d12c9741c014@joelfernandes.org/ > > Thanks > -- > ankur