Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp539830lqt; Thu, 6 Jun 2024 10:33:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU76z274uYRoQWGa7kWxsBNFL/CtH/uSbVxqwIdfF3GkgMsslxCL6Djs8Nipiye3yaDk5r000ZVrQG/MuZ5mNsjt1QRMn7bz44ux7cy8A== X-Google-Smtp-Source: AGHT+IGcBjhIpWC05kYCMNc/8YVWD/cFpua6u0poTciETuvQelqole0HaSbePjPhWF7PP6jyBjE0 X-Received: by 2002:a1f:7206:0:b0:4eb:2550:ef36 with SMTP id 71dfb90a1353d-4eb562198f2mr366695e0c.2.1717695186184; Thu, 06 Jun 2024 10:33:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717695186; cv=pass; d=google.com; s=arc-20160816; b=zS+ZlZC0NW9BRRd6/Zt+zs3T+xeGS6Vqi2o47U3Y4+cCbBdiQ+azVKmaPqdKOwu/tS iJAc2u+4MX8LrMFS/8hymddNblqcSQEcKINXvEMYK3ZVJVaTyGW69DD3OGhFNzSYo8no CI3KLqj5cPd2aGhOUMAO1w9nKbjtIf+9+10oBj4X0yj+hWH4vC07uzVNO+TJGEreB9kb qD3cYnkuLqwrp4Q3fsflORzZun1R6OFXN40YlY18YKRsoiKQyXVk/vq5nJtPeWYCSaea ku5UgjjqVmicVl/omASvvrzDlB2K7oJl6BPHOTIynXUD8Hg2BB3S7L975UxpcblgE+Ox kWsA== 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:date:dkim-signature; bh=HH8pCn4DL4peY1ACh84eGN/5aYBN7dsVAbiZCE/SC3E=; fh=E6nMY2SCCK07HbGulrZp7JUfPuXw9pDP0AaUuxDtGK0=; b=bOuF1PqEEyM8U287kN8jppF3Es8hkMvylbEZ3gXIvu1ZwWpn0gO5ADdYfFwCrgg0Qc 9jW6DoZ1CdeO/0ZVQdcjik9wFu9JnxnqUBqYHiBzIqATuI/Y9i1v4WeyFOBN7k/erLJ/ 1bgBgjjxA31oayrIVC49XOyzC8ZvZdj+L2JqzoBXCFQEpzD9HQB+iqsfO4DJSiVgN5xC q+kM8tDRIjST5kYR9vsx9hcgar/teXEAJH12F13onKNWYWSCNGC5LRMCFqxZ5SIoiw4A zKENwBgZeDV9nSmGy1iWpZuD9poZKNOCQetqey5uYBeFnOymvDP1txLPuDpZWrdypa2n Etug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=pHqsDa9b; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-204811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204811-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 71dfb90a1353d-4eb4ad34409si465543e0c.161.2024.06.06.10.33.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 10:33:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=pHqsDa9b; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-204811-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204811-linux.lists.archive=gmail.com@vger.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 469EE1C272AD for ; Thu, 6 Jun 2024 17:32:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ECCB21991B9; Thu, 6 Jun 2024 17:32:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="pHqsDa9b" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 CBE8F197A6A for ; Thu, 6 Jun 2024 17:32:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717695149; cv=none; b=TrWTK7rGskRexjGt2c8xdH+GEmt64nz05PTdt2VS6m6Bbmvdv6posjaEpHDXosO4FjlVXGKJI61rci6HLhze5FVVwBLwTThXLRWZ0LNvVy2XCInZBBRfxYBMJDopWh5ZOW5r/fIXf3yTNnzBWy4w5TkQDVapCZu2ZGSe43zY4Ms= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717695149; c=relaxed/simple; bh=dlYFinXfCkxNrRnud10X4800BIN5HA363aSLpULQkTY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Q0LokOjNPSjoHzduoszze4vkxMOYi5RbULD0JTqULF2Od5OTgCdJm/PGy/dHzs14AxDlwSn9Tq280gkBf9pC26W+tw3L43Cv0Ha/Ix11SYMlOJGwwpdgp3u/OKL2AW1w8PdNvIFiCJakrkSnNJ3Ul1RAoPMC5nqDeHxPnzLggHo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=pHqsDa9b; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=HH8pCn4DL4peY1ACh84eGN/5aYBN7dsVAbiZCE/SC3E=; b=pHqsDa9bCO8k4DpIEEZZiEQSj1 T4WO23ahJ4Mo7ulaAkoBzMkK8MWD1SPMNQlQWhb+YngEqCzHZQ0l3UUCpy3+b/CplLiy3ECYKiNXv 6nuHEQGA/GmiLA530F/dYTnDTgboTJhEesws29D9b9Q0zKnTH13s52V2EkS3xnvrCW2VmrcJu9WB/ hLcCPkg7OuAGHdvIM77dFuPLSFpIf6Ti+Mi6S8LTT817rgu/HiTzmnFrdtYXDxZKa17gNINsJz9Oq 2zj74dWgtihfDVl74/KeTR5DHVqeb6vtynL7OndhXnDmR5cjaD3ihg5SHI9ehVIlIsUNAm06hwHGq BPRMU+Sg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFGyI-00000001fvU-3mnB; Thu, 06 Jun 2024 17:32:19 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 87E3D30047C; Thu, 6 Jun 2024 19:32:18 +0200 (CEST) Date: Thu, 6 Jun 2024 19:32:18 +0200 From: Peter Zijlstra To: Ankur Arora Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, torvalds@linux-foundation.org, paulmck@kernel.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: <20240606173218.GH8774@noisy.programming.kicks-ass.net> 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> 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: <87ikymw1g2.fsf@oracle.com> 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.