Received: by 2002:ac8:156:0:b0:3e0:cd10:60c8 with SMTP id f22csp519749qtg; Wed, 5 Apr 2023 13:28:14 -0700 (PDT) X-Google-Smtp-Source: AKy350YQmlabE2JMJzDIFZsEMmHul1xzEXY/+SriSIShQt54ocd7YXQNGOTz1vW4cSCsF5mW3mXt X-Received: by 2002:a17:903:11c4:b0:1a1:bff4:4a06 with SMTP id q4-20020a17090311c400b001a1bff44a06mr8602985plh.24.1680726494669; Wed, 05 Apr 2023 13:28:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680726494; cv=none; d=google.com; s=arc-20160816; b=moq3m+gaB3h/vjr5ZMhnMcre89y0z/C1cNJiiGatbp2D0Gx6wvCPfHPO8mh7cycLCs XCh3BT/FeymVQd/xtZyplvKLR4VFPorGZUKt/LbmfCPdxrbuc3KH3T9O/0WySB9yckxT 912EiNe4Quw2LlsMtxr8t9OPLDXuRrhWvmLics+Y0RPatL1VdQ2ItsW26IewRCGZn93T adolACMElSrHIEhJyXYWLidq/uRFq+vPLC5hj/wFPlW9pUhRfwUsUGaTXg8cwXf4Crqo QScVw8wCzOaCHX6f0BV5ELlVJGxfXn1zek9SvORZTZH+QvSn93VmQy2TAV66LUmN3pPj +XEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=jTyEKh3ikb2Y8N6HrOFo1BDcfkQEm1X8lIi0hGITVng=; b=nSey/Gkc8J72HFVdSlmXN1eSpDE71Vjom9yTZXFDrckX698HcvRj/VaYAzHVs2n7U+ ovcSiJE6M6MEneVCa5s9x91Gns42uaXbaW8BElqtADZxjE575tIuHLsr4KI6PZrJI7Bp jlKt2WnO0XbAjL+telruXMRZ8HRg9JWcWRP+ycw2zYav3vyWhXe2buYR0rumJXJCI56F 0oYxgUnI5NA5d3P5qDu4LRcXDob8cqKQcPy1sAhWX6bwlbgf4YMeyR/altsC0l6foOMd qFtu6iOC/pbQ6ZWvK0VgXYaT7lO3E2VggTrvwB2JNafXICx64AHVTjHkKYvkV3SBJx0g /ppQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=XTupqCO+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t19-20020a170902b21300b001a220a984f9si12459721plr.546.2023.04.05.13.27.59; Wed, 05 Apr 2023 13:28:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=XTupqCO+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231269AbjDEUXW (ORCPT + 99 others); Wed, 5 Apr 2023 16:23:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229731AbjDEUXV (ORCPT ); Wed, 5 Apr 2023 16:23:21 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF18349D6 for ; Wed, 5 Apr 2023 13:23:19 -0700 (PDT) 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=jTyEKh3ikb2Y8N6HrOFo1BDcfkQEm1X8lIi0hGITVng=; b=XTupqCO+XwlbIgTKxvumTFGBhV MJqn1OAnoaBGTSgj/ecXpNI5rsgMiCpyDPjAoPmysJbiXlBnsAukc+1cGSPSO35ACyxM0llBie+tf 857X8AQ0vi2K1KQ23uaBYE0DirbsswN1Mw45XqtatYg3YYZKeD/rV6bo+4a77rJfXel1FSCPy/g6S 57TWlYt/cSXtczrwmR64DohndY9jStgKd/Ch9vi9wpExBgdvaQvJaHGdVzlQic2QxbEGW6j5PMm5U IvRGmYx7CX4NTaLXABnTs3l8WA5gaTrl6z/iDCan3/s9WpGwGXlUdxzio6fbEuzc7pdRN6/WVZ29E I0HZGqMQ==; 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 1pk9eT-00A4qm-13; Wed, 05 Apr 2023 20:22:47 +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)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 3084B300202; Wed, 5 Apr 2023 22:22:40 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 18EDB27985545; Wed, 5 Apr 2023 22:22:40 +0200 (CEST) Date: Wed, 5 Apr 2023 22:22:40 +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: <20230405202240.GE365912@hirez.programming.kicks-ass.net> References: <20230403052233.1880567-1-ankur.a.arora@oracle.com> <20230403052233.1880567-9-ankur.a.arora@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230403052233.1880567-9-ankur.a.arora@oracle.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 02, 2023 at 10:22:32PM -0700, Ankur Arora wrote: > Allow threads marked TIF_ALLOW_RESCHED to be rescheduled in irqexit. > > This is only necessary under !preempt_model_preemptible() for which > we reuse the same logic as irqentry_exit_code_resched(). > > Signed-off-by: Ankur Arora > --- > kernel/entry/common.c | 8 ++++++++ > kernel/sched/core.c | 36 +++++++++++++++++++++--------------- > 2 files changed, 29 insertions(+), 15 deletions(-) > > diff --git a/kernel/entry/common.c b/kernel/entry/common.c > index be61332c66b5..f1005595ebe7 100644 > --- a/kernel/entry/common.c > +++ b/kernel/entry/common.c > @@ -390,6 +390,9 @@ void raw_irqentry_exit_cond_resched(void) > preempt_schedule_irq(); > } > } > + > +void irqentry_exit_allow_resched(void) __alias(raw_irqentry_exit_cond_resched); Because typing raw_irqentry_exit_cond_resched() was too much effort? > + > #ifdef CONFIG_PREEMPT_DYNAMIC > #if defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL) > DEFINE_STATIC_CALL(irqentry_exit_cond_resched, raw_irqentry_exit_cond_resched); > @@ -431,6 +434,11 @@ noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state) > instrumentation_begin(); > if (IS_ENABLED(CONFIG_PREEMPTION)) > irqentry_exit_cond_resched(); > + /* > + * We care about this clause only in the dynamic !preemptible case. > + */ > + if (unlikely(!preempt_model_preemptible() && resched_allowed())) > + irqentry_exit_allow_resched(); This is wrong, if we have dynamic preemption then we have CONFIG_PREEMPTION and we'll have that irqentry_exit_cond_resched() call. Basically what you've written above is something like: static_call(foo); // raw_foo() when A, NOP if !A if (!A) raw_foo(); And yeah, you've got the extra resched_allowed() thing in there, but that doesn't make it any better -- this is all quite horrible. What you really care about is the CONFIG_PREEMPTION=n case, but that you don't actually handle. > /* Covers both tracing and lockdep */ > trace_hardirqs_on(); > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 0d18c3969f90..11845a91b691 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -8597,28 +8599,32 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write); > * SC:preempt_schedule > * SC:preempt_schedule_notrace > * SC:irqentry_exit_cond_resched > + * SC:irqentry_exit_allow_resched > * > * > * NONE: > - * cond_resched <- __cond_resched > - * might_resched <- RET0 > - * preempt_schedule <- NOP > - * preempt_schedule_notrace <- NOP > - * irqentry_exit_cond_resched <- NOP > + * cond_resched <- __cond_resched > + * might_resched <- RET0 > + * preempt_schedule <- NOP > + * preempt_schedule_notrace <- NOP > + * irqentry_exit_cond_resched <- NOP > + * irqentry_exit_allow_resched <- irqentry_exit_allow_resched > * > * VOLUNTARY: > - * cond_resched <- __cond_resched > - * might_resched <- __cond_resched > - * preempt_schedule <- NOP > - * preempt_schedule_notrace <- NOP > - * irqentry_exit_cond_resched <- NOP > + * cond_resched <- __cond_resched > + * might_resched <- __cond_resched > + * preempt_schedule <- NOP > + * preempt_schedule_notrace <- NOP > + * irqentry_exit_cond_resched <- NOP > + * irqentry_exit_allow_resched <- irqentry_exit_allow_resched > * > * FULL: > - * cond_resched <- RET0 > - * might_resched <- RET0 > - * preempt_schedule <- preempt_schedule > - * preempt_schedule_notrace <- preempt_schedule_notrace > - * irqentry_exit_cond_resched <- irqentry_exit_cond_resched > + * cond_resched <- RET0 > + * might_resched <- RET0 > + * preempt_schedule <- preempt_schedule > + * preempt_schedule_notrace <- preempt_schedule_notrace > + * irqentry_exit_cond_resched <- irqentry_exit_cond_resched > + * irqentry_exit_allow_resched <- NOP > */ This ^ is all complete nonsense.. irqentry_exit_allow_resched() is not a static call. It's an alias of raw_irqentry_exit_cond_resched which circumvents the static call entirely.