From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEB06C4167D for ; Wed, 8 Nov 2023 10:46:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5AB8E8D00B8; Wed, 8 Nov 2023 05:46:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5350F8D00AD; Wed, 8 Nov 2023 05:46:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3AE478D00B8; Wed, 8 Nov 2023 05:46:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 285988D00AD for ; Wed, 8 Nov 2023 05:46:52 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E96CC1408CD for ; Wed, 8 Nov 2023 10:46:51 +0000 (UTC) X-FDA: 81434459022.29.F9C6AF0 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf14.hostedemail.com (Postfix) with ESMTP id 26AD1100006 for ; Wed, 8 Nov 2023 10:46:47 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b="j6aB/r9A"; spf=none (imf14.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699440410; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ztB9pBHiFR07Il8Vv5GBfT7IWnf46mh1rpUe76Z1+FE=; b=yB/emADoTayuUJfUtCytQ0mlxr1skXk/FhnSuZnXs+LlvpcuPZSIyhsy1grHNEFNzstLOJ O8hJxtoqRG/XHmHjGND2uToIZdfO0F6FggsuUr989d3oTX0lmYHsQPtv6gXqQ60raU0GCq vmdEzt3Wn6Cz9lTnv+aH00VVMmQNZdk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699440410; a=rsa-sha256; cv=none; b=O8Dxzar/Y6thxc9Wq0BgLY+Lu3ox0BmvLF5F5fzomfSB6VoThJoOI9G9z5mY3OEPOybFIF kn/jgIlWnQvLd5xiGg9lG9Jo5VgAiUY+wgJCuHfpOvcNRyybUNUnueGjuQBrUTHyCkFNhl YBzGCGVsI8nrwBmM0iBgEC8wpFvWXR0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b="j6aB/r9A"; spf=none (imf14.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=ztB9pBHiFR07Il8Vv5GBfT7IWnf46mh1rpUe76Z1+FE=; b=j6aB/r9AvPhSHnZ2k8Xnwo+0Yy pdqDyjhNVN1LOPglg8yHSd5dWVGtI094Cxa4G6FozEGClloZHH8QezTIOo1b0oHPY7dWwvnoysMIP habOzZdjI+IebmFt1ZBHYd60uuY4En7eoedJZptanwhjLlWAfYfo/qGgNhLIleiSm4AyjzZL8oZ39 0Vl/vQvDRG1S32H3qyvEcXRsK5uZF/3YOeNXVoayP4o5WF6/Tv+najNJhrHXPy6trzwbWaBnKqoZB 2tGC0/19M6GHaQBPzH/8imiZMqKayhx0wq6SNXPM9OnL0B2a6owhtyd4xpN4ABtG2IXSYNcoWm1O3 PscoOjHw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1r0g4e-00DPVe-0N; Wed, 08 Nov 2023 10:46:16 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id BBC2330049D; Wed, 8 Nov 2023 11:46:15 +0100 (CET) Date: Wed, 8 Nov 2023 11:46:15 +0100 From: Peter Zijlstra To: Ankur Arora Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, torvalds@linux-foundation.org, paulmck@kernel.org, linux-mm@kvack.org, x86@kernel.org, akpm@linux-foundation.org, luto@kernel.org, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, willy@infradead.org, mgorman@suse.de, jon.grimm@amd.com, bharata@amd.com, raghavendra.kt@amd.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com, jgross@suse.com, andrew.cooper3@citrix.com, mingo@kernel.org, bristot@kernel.org, mathieu.desnoyers@efficios.com, geert@linux-m68k.org, glaubitz@physik.fu-berlin.de, anton.ivanov@cambridgegreys.com, mattst88@gmail.com, krypton@ulrich-teichert.org, rostedt@goodmis.org, David.Laight@aculab.com, richard@nod.at, mjguzik@gmail.com Subject: Re: [RFC PATCH 41/86] sched: handle resched policy in resched_curr() Message-ID: <20231108104615.GO8262@noisy.programming.kicks-ass.net> References: <20231107215742.363031-1-ankur.a.arora@oracle.com> <20231107215742.363031-42-ankur.a.arora@oracle.com> <20231108093645.GL8262@noisy.programming.kicks-ass.net> <87fs1gk0bm.fsf@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87fs1gk0bm.fsf@oracle.com> X-Rspamd-Queue-Id: 26AD1100006 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: qkh8eg71rqgxiy19st88zo6yoeeef7mb X-HE-Tag: 1699440407-552129 X-HE-Meta: U2FsdGVkX18qqA1tG4SH6o8QivG6/cBUuZ8TwbbQ1qaiXts3zAkkY04ltEFlfttNP21Q0EuVMr3jv9ySUMHWe2Glh2a0FYpXaAExPono6dG3sUfjphl57I4eC9Zfd8cm4pnziKoOIMVPWjdN5/H+6oAdgVedlgxEEZmMjK7VgVNvg+jXB73+QkEwiLh3c3NuUIAd4aWcaUeS5nG1+cZlxWk08JUFV0oq5n57f7n72ngiN4+6z07snYmr5PJ6ealUZLqTNcn5uctEHMYSWRF4k9BxDVKosC1lbCye6ek5cmJhyP63EM6lgX7zBW84zUn4GF8r/PLDS/AkbdXizYT9ERqx0+i5cUobOO26YbC2LVL6scvQb82kQzaqsJqoxO45rAznn71yMSAqEadvAFmhe5hOBPw3lxmt25p7CAYG8glg7xzrrNC9C+O7lnyJsDEFb4kdT3+7ZM80A2zga1ce7Tuz0nyygUHzKWBoDv1RXgNpsisO7Q7D6EADjXggL9zH2D3Qy4Ksr3jIH0GfOUVh3/7ZGCDXaVK/BMjNey9IE3iCC7llVruRlQbryd/LByE2astckWKXbJ4GDfhbQEaswbZCFEN4CwC3t+mh7gMZ9lMbYUtBCC85wUpysK6IJlLaIwlZbY1qfwHPE7uPgRSJaGpkupImuLKNdUh7T7QOoi5a65u4jjl41qw8oIsCXT7I6bdYFVmgelK+LiXAEsyYvFPuptC8gwBW7cs91eJTgMbKrvGVE8awEKSt/oJz/wdv1o+GgnnKCRJPjkyBMae5/rXzhlyil/Pxjg50QcLycMTyvaXLTGx698oJzogLTzSyAfB+5kjPqr11Ogsxyiz6meihTkG9SFDr8qvgDnOnbQlZTKKk1V7XThVI6oPaGud9CVjOLfImwLWG9EVPAp1o4uUR1d0/uQIqAoz1Q5H65TKI/LD114noqb1fFTW71/aamCUBmcAHQKswdssR4zX 2z9amHc9 ljLdOjStrzSBuDqMnh6hrmgp5xlTrMm5UR8agDgGHwc8jhYgTnLnW6EvG7rDNpGKluJyjiF69A3X2UQuytYoBAE+8OjNNPZlOaa804St+1frBXMRU8fAp+rxJnsJdnr/4W09bnv/GF0dRq0U4dWMyQRG4MgU9W1Xn1z3C/faxSlqYnTtCKvvuITDZLKfhWYmRobehjHu0lmzKhIV5bB3Un9762VyOMO2nRqIV682QdOyi3AgmB8iABXf+CQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Nov 08, 2023 at 02:26:37AM -0800, Ankur Arora wrote: > > Peter Zijlstra writes: > > > On Tue, Nov 07, 2023 at 01:57:27PM -0800, Ankur Arora wrote: > > > >> --- a/kernel/sched/core.c > >> +++ b/kernel/sched/core.c > >> @@ -1027,13 +1027,13 @@ void wake_up_q(struct wake_q_head *head) > >> } > >> > >> /* > >> - * resched_curr - mark rq's current task 'to be rescheduled now'. > >> + * __resched_curr - mark rq's current task 'to be rescheduled'. > >> * > >> - * On UP this means the setting of the need_resched flag, on SMP it > >> - * might also involve a cross-CPU call to trigger the scheduler on > >> - * the target CPU. > >> + * On UP this means the setting of the need_resched flag, on SMP, for > >> + * eager resched it might also involve a cross-CPU call to trigger > >> + * the scheduler on the target CPU. > >> */ > >> -void resched_curr(struct rq *rq) > >> +void __resched_curr(struct rq *rq, resched_t rs) > >> { > >> struct task_struct *curr = rq->curr; > >> int cpu; > >> @@ -1046,17 +1046,77 @@ void resched_curr(struct rq *rq) > >> cpu = cpu_of(rq); > >> > >> if (cpu == smp_processor_id()) { > >> - set_tsk_need_resched(curr, RESCHED_eager); > >> - set_preempt_need_resched(); > >> + set_tsk_need_resched(curr, rs); > >> + if (rs == RESCHED_eager) > >> + set_preempt_need_resched(); > >> return; > >> } > >> > >> - if (set_nr_and_not_polling(curr, RESCHED_eager)) > >> - smp_send_reschedule(cpu); > >> - else > >> + if (set_nr_and_not_polling(curr, rs)) { > >> + if (rs == RESCHED_eager) > >> + smp_send_reschedule(cpu); > > > > I think you just broke things. > > > > Not all idle threads have POLLING support, in which case you need that > > IPI to wake them up, even if it's LAZY. > > Yes, I was concerned about that too. But doesn't this check against the > idle_sched_class in resched_curr() cover that? I that's what that was. Hmm, maybe. I mean, we have idle-injection too, those don't as FIFO, but as such, they can only get preempted from RT/DL, and those will already force preempt anyway. The way you've split and structured the code makes it very hard to follow. Something like: if (set_nr_and_not_polling(curr, rs) && (rs == RESCHED_force || is_idle_task(curr))) smp_send_reschedule(); is *far* clearer, no?