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 B2164C76196 for ; Fri, 7 Apr 2023 10:23:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18AD0900003; Fri, 7 Apr 2023 06:23:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 11455900002; Fri, 7 Apr 2023 06:23:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF6D1900003; Fri, 7 Apr 2023 06:23:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DAA3C900002 for ; Fri, 7 Apr 2023 06:23:55 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AE1341C6DED for ; Fri, 7 Apr 2023 10:23:55 +0000 (UTC) X-FDA: 80654209230.09.B344E7E Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf11.hostedemail.com (Postfix) with ESMTP id 42CB64000A for ; Fri, 7 Apr 2023 10:23:53 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=Dq04D9zz; spf=none (imf11.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=1680863034; 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=ugJQ22P2VM2xtxPkMIbImarOlCvwMytzlwoGMDfly34=; b=L37z4BZ85IQ2BT3lb7g67DNuPNq4JH49X22bO0B4ev/2GQ5AgnIzmwrSc2K9Zzc0ZYAU2Q I6ZvsRlvytZYIEgcxRrrfueSJs8YdyPLzRvnh3/n2vUyuchvXOlI8zpBwry59AZt3KtOMa nABowB3xhmjOUIXIs4OsCnUhjj2F6PQ= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=Dq04D9zz; spf=none (imf11.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680863034; a=rsa-sha256; cv=none; b=3Fl+s638k7QJqXp4XuUHodAlLDMem1B8NRPUbPTTLh4CITGZYVcfVq9iTMHCH/jrjjcNd3 VTMT3gxFIO7WswMRdkRRlWJV62rrqIP0YjDmI6Q5WG7qNcJNygtNgDlSBsHNtO2TNM1Cma 9duhxXKkfHP1evsdQwqNvy+qUCL+6DI= 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=ugJQ22P2VM2xtxPkMIbImarOlCvwMytzlwoGMDfly34=; b=Dq04D9zzLKR5wp+izPIbSqfWCk JAAhGmLVvloKx2ozZj7RJhMd07cDz4txUxVYEkzAXEuhNf1AUqnO5dmLiYcXBnRMssPmqc4bwhmVt w77odgN7jSLHMOKgWUpkEqEiEHH5NiFtgYP/kmU5G+LUDZvvvUUzFYBDdWbQFJHcghWhQceDHzQZz 5PglCFe0ALwx0AYdsU6/aE+WHomHgBfTRKQapZDSd5LunGJcJjO85XsjsgFK/LTPHeTAV+gBge++T fExC6DFfYRJbh9o8qZ85DRxdVszqecBdf7iJDFAA1z/VRZq9qVRVcdsjD1sZ0JHAM6iCXVYWQMtXI Xw+ru7qQ==; 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 1pkjFi-00AzzU-1W; Fri, 07 Apr 2023 10:23:31 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 42B36300070; Fri, 7 Apr 2023 12:23:23 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 2A1342625093E; Fri, 7 Apr 2023 12:23:23 +0200 (CEST) Date: Fri, 7 Apr 2023 12:23:23 +0200 From: Peter Zijlstra To: Ankur Arora Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, torvalds@linux-foundation.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, willy@infradead.org, mgorman@suse.de, rostedt@goodmis.org, tglx@linutronix.de, vincent.guittot@linaro.org, jon.grimm@amd.com, bharata@amd.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com Subject: Re: [PATCH 8/9] irqentry: define irqentry_exit_allow_resched() Message-ID: <20230407102323.GA430894@hirez.programming.kicks-ass.net> References: <20230403052233.1880567-1-ankur.a.arora@oracle.com> <20230403052233.1880567-9-ankur.a.arora@oracle.com> <20230405202240.GE365912@hirez.programming.kicks-ass.net> <87o7o1lzko.fsf@oracle.com> <20230406201359.GC405948@hirez.programming.kicks-ass.net> <87lej4ifvc.fsf@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87lej4ifvc.fsf@oracle.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 42CB64000A X-Stat-Signature: tmsrgga4aokkres3aejrgrcfad6rqn4h X-Rspam-User: X-HE-Tag: 1680863033-842557 X-HE-Meta: U2FsdGVkX1+sROcVU9DLFoBTzAzLwk7BeovOpxUReJAUyY7g5R20020eqBeY7e1ZDr5cI9lcGYLa/FVKs+OTpS3fer0WkYzGlNndfBWhsHre3eU0tZ2+D/T82aHoE39m1k3xuEKJGOoWGzUd3GE8OjbMSoAjhiV9OI+Hc+8AOFmXMYQQ9yRUnDPD8qwN9XO6oCtgS+hwME8XXJMWU2M8LApyRACY1a1/QLe/Ku66nMHFjiZ9CINMfPC+iYheCXBHAvzqLQJMc2sYzEp5hrBj+dfMyHfTPa4GjWF5XmuozBVtyoxAcdV4hRoAYKpi2O8e3mxHxIPEj8pEMtNqev8+GNMzQAn2NHFo6aqEh+ku66qogyO/NkAYnY71BHt5TpsIb/vvFbdl6UxcIdV3qPi319HwyvOA69VD2/qywF9pmzWM2rhi4vE12f5/CXYMFkua4OOD+Fo9IlegQ6Yc01bfgN3omE5QSPps9pzvPjDmNRhMYQVSzBsuKP/T+8hA5KWUQc2kc4SzOcpMWKIjVy4yZ/u5A46wgnEEmqXiosDjCVfknHWV9Us4nBvBw4jcZGY8iJIrC8elwUjCCQIY2lYfJ26JCDYXGt+CfOR5iE6hK/Kb2wiCwe+PXNE5V8YcR6g2smdfuO3CEdd5FKtB/gCdRUvmHvT/kJ0sCUNigORYTyg4wf8EQEyqZfDlzO1nki6UHaWarL55qIO5Jccxba7/dioUVRrVaXxMgLbi5SDXI1+oKSDDYXlyexTVVDpJ/OrD0Hv0/QjUX36lkzB/sIZAWt6xzxVSRqFye74/dp4c+MtvKuuUE6Mekm3XWtPdhFilDXMKt2dsAABlUPWot4kPYPl92LT+Li8bylSkm8hY6Els14Oa0UOF+w0LFvxoq84d4IommRC4Ykv/0KWTGZpSYcA1fDPDnnDdWXS0Sv9TI6zzKRnjotj1UPK29GELmS1DE1i7nucYVd/2zPD5Wiw TBfIgMLg SKqKQr0hkfob0eXsfAOJqbx4hSsSNycTyNVJXygdwBYnBGG5pyMT4YWklJU89W0pR8cczVb/uMDNfHlkmeoo7sC7tq0cN/vkCOmRoWqoQQ0LgLEBmmQWwWMIHgqP6PigdMsQD/cLEN781zQPZmx74yphOrg5I8vhJn47V7EnRh/c7DcwvLa8Mwk+J91HVxN9KRTwXOPns+TGN9qC8WaywX7lX0W+ZCUKY2axocY9Gjg9qb9VhCqK1FN9DDV/ZWmpHeWs4 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: On Thu, Apr 06, 2023 at 07:29:59PM -0700, Ankur Arora wrote: > Peter Zijlstra writes: > > Something like the below perhaps? > > > > --- > > include/linux/entry-common.h | 6 ++++++ > > kernel/entry/common.c | 23 +++++++++++++++++++++-- > > 2 files changed, 27 insertions(+), 2 deletions(-) > > > > diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h > > index d95ab85f96ba..0c365dc1f1c2 100644 > > --- a/include/linux/entry-common.h > > +++ b/include/linux/entry-common.h > > @@ -415,10 +415,16 @@ irqentry_state_t noinstr irqentry_enter(struct pt_regs *regs); > > * Conditional reschedule with additional sanity checks. > > */ > > void raw_irqentry_exit_cond_resched(void); > > +void irqentry_exit_cond_resched_tif(void); > > + > > #ifdef CONFIG_PREEMPT_DYNAMIC > > #if defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL) > > #define irqentry_exit_cond_resched_dynamic_enabled raw_irqentry_exit_cond_resched > > +#ifdef TIF_RESCHED_ALLOW > > +#define irqentry_exit_cond_resched_dynamic_disabled irqentry_exit_cond_resched_tif > > +#else > > #define irqentry_exit_cond_resched_dynamic_disabled NULL > > +#endif > > So this is clever. Essentially this would toggle between the two kinds > for the preempt_model_preemptible()/!preempt_model_preemptible() dynamic > case. Do I have that right? Exactly! > > DECLARE_STATIC_CALL(irqentry_exit_cond_resched, raw_irqentry_exit_cond_resched); > > #define irqentry_exit_cond_resched() static_call(irqentry_exit_cond_resched)() > > #elif defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY) > > diff --git a/kernel/entry/common.c b/kernel/entry/common.c > > index be61332c66b5..211d118aa672 100644 > > --- a/kernel/entry/common.c > > +++ b/kernel/entry/common.c > > @@ -390,6 +390,21 @@ void raw_irqentry_exit_cond_resched(void) > > preempt_schedule_irq(); > > } > > } > > + > > +void irqentry_exit_cond_resched_tif(void) > > +{ > > +#ifdef TIF_RESCHED_ALLOW > > + if (resched_allowed()) { > > + /* Sanity check RCU and thread stack */ > > + rcu_irq_exit_check_preempt(); > > + if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) > > + WARN_ON_ONCE(!on_thread_stack()); > > + if (need_resched()) > > + preempt_schedule_irq(); > > + } > > +#endif > > +} > > + > > #ifdef CONFIG_PREEMPT_DYNAMIC > > #if defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL) > > DEFINE_STATIC_CALL(irqentry_exit_cond_resched, raw_irqentry_exit_cond_resched); > > @@ -397,8 +412,10 @@ DEFINE_STATIC_CALL(irqentry_exit_cond_resched, raw_irqentry_exit_cond_resched); > > DEFINE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched); > > void dynamic_irqentry_exit_cond_resched(void) > > { > > - if (!static_branch_unlikely(&sk_dynamic_irqentry_exit_cond_resched)) > > - return; > > + if (!static_branch_unlikely(&sk_dynamic_irqentry_exit_cond_resched)) { > > + irqentry_exit_cond_resched_tif(); > > + return > > + } > > raw_irqentry_exit_cond_resched(); > > } > > #endif > > @@ -431,6 +448,8 @@ noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state) > > instrumentation_begin(); > > if (IS_ENABLED(CONFIG_PREEMPTION)) > > irqentry_exit_cond_resched(); > > + else > > + irqentry_exit_cond_resched_tif(); > > And, if we choose between the two resched modes at compile time then this > would work. Just so. > Might massage the names a little but this should work as is. Yeah, I'm not liking the naming either, perhaps your irqentry_exit_allow_resched() would've been better, dunno, see what works. > Okay if I use your Codeveloped-by/Suggested-by on this patch? Yep.