Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp535265pxb; Fri, 28 Jan 2022 04:50:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwaOd/gnFQzzCtr5c+GV36O/kIwBHhQCyJLKFx4gSv8Zav9hvYxNcosWncvikT0Z/7jgjMY X-Received: by 2002:a05:6402:787:: with SMTP id d7mr8198785edy.390.1643374257771; Fri, 28 Jan 2022 04:50:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643374257; cv=none; d=google.com; s=arc-20160816; b=K7qCcqlLfMkiTirCjdurx7tnsVtnHdd1FhvcTuil/JyH8PUpTtf/c3x7zRYOscM7q/ kG4Vm/oUsDhTNfPveBMajk+smxtXWutyesqSZzHvu5mRal0i3l3om+EaFbMUL/v1T+n4 VMy7Nt8ys6j8t3ZQNAgxsxBOwjmfmblvgEeQJoeZNG1ePhCfSHe0AE61r1JoHypqy3xm tHZXNZh6bk2K2Ic9uWC0YlJu6nKH9Jn31D+sRTEg3tPX1laXZ+w4xHWkaPVCwVbafO0Q BffdtLBWUxXuyAr5mvac83D7HEXOm2SdLMASUQT2S+nPqL/xgHr1qW/I73ZYFvZzzVMI MLFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jHtNfX0taWqkpJnC0jHA9lMQ2a6mn+9DZhnFOM5pdVk=; b=Ns6PPpEuIbYUVbnXggdR8kR2QRwjX5bKOBTzkIsvtUUhUsGdvT6sbnxfqsOUPojrYe f/2vzTbrP0AaOlU0Gh0DPH2XWW8CVUPhhzGNBKvV0yZcUv06ewCREATPryBUPvCdXYB3 9RFu/WsHewBHSbL1P+6sYVaUtQpIHhRDftNI/RPw+c1nRVrxln/HfcUnYF3tFMEhc322 hkfm2CTpVwuIe/uEJtkN5lwOBqDWT2QpoN1InLO8ZZyXm8a/1hWWD9usfbv89Ff4Zmyg ksMhiaeGq14D9/qV0bDFrEgnwUY5mrV012MgjuVeIRsbi7hypT2PodNtelq4CFajoENO +RtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SCKANevs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m15si2032875edd.154.2022.01.28.04.50.33; Fri, 28 Jan 2022 04:50:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SCKANevs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244717AbiA0Rz0 (ORCPT + 99 others); Thu, 27 Jan 2022 12:55:26 -0500 Received: from mga12.intel.com ([192.55.52.136]:65462 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240185AbiA0RzP (ORCPT ); Thu, 27 Jan 2022 12:55:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643306115; x=1674842115; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ER6JviQv6ox2UPy2iIeHIKlZtZEKY0Z2BX0fYT7NB20=; b=SCKANevs47lIrsZziijA2bCoDRTQ1HeG2HfYJAYrZjN+yJ0gOBcSE8aq xyvVJYbD63JNRrHLd6y3psaUouLp0E2hqAu0VW3iaGPUbATdzFuDb5Smk 7rJvNwUjJvrX+ZTwzil3j60i086qmqwGtZVM+ofc2xINVcmbhjjlMo6Rc kfjn9U4g8mwjM1MjInsulSO1seWubzB5Yqkit5zp6xv4OpQ/8xPNOIk5Q Y0w8ne7dN9mjz/N1ws+rGKnEEvKo52hAKy/tQ6cuvL1Dpd477mg2KCxc2 WqkeXt/4iJkBLZry7N9wXHZWA0heFDVT2AnEY1YFA+J6BjJNhylSkfPLB g==; X-IronPort-AV: E=McAfee;i="6200,9189,10239"; a="226899115" X-IronPort-AV: E=Sophos;i="5.88,321,1635231600"; d="scan'208";a="226899115" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2022 09:55:07 -0800 X-IronPort-AV: E=Sophos;i="5.88,321,1635231600"; d="scan'208";a="674796044" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2022 09:55:07 -0800 From: ira.weiny@intel.com To: Dave Hansen , "H. Peter Anvin" , Dan Williams Cc: Ira Weiny , Fenghua Yu , Rick Edgecombe , linux-kernel@vger.kernel.org Subject: [PATCH V8 01/44] entry: Create an internal irqentry_exit_cond_resched() call Date: Thu, 27 Jan 2022 09:54:22 -0800 Message-Id: <20220127175505.851391-2-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220127175505.851391-1-ira.weiny@intel.com> References: <20220127175505.851391-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ira Weiny The call to irqentry_exit_cond_resched() was not properly being overridden when called from xen_pv_evtchn_do_upcall(). Define __irqentry_exit_cond_resched() as the static call and place the override logic in irqentry_exit_cond_resched(). Cc: Peter Zijlstra (Intel) Signed-off-by: Ira Weiny --- Because this was found via code inspection and it does not actually fix any seen bug I've not added a fixes tag. But for reference: Fixes: 40607ee97e4e ("preempt/dynamic: Provide irqentry_exit_cond_resched() static call") --- include/linux/entry-common.h | 5 ++++- kernel/entry/common.c | 23 +++++++++++++-------- kernel/sched/core.c | 40 ++++++++++++++++++------------------ 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h index 2e2b8d6140ed..ddaffc983e62 100644 --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@ -455,10 +455,13 @@ irqentry_state_t noinstr irqentry_enter(struct pt_regs *regs); * Conditional reschedule with additional sanity checks. */ void irqentry_exit_cond_resched(void); + +void __irqentry_exit_cond_resched(void); #ifdef CONFIG_PREEMPT_DYNAMIC -DECLARE_STATIC_CALL(irqentry_exit_cond_resched, irqentry_exit_cond_resched); +DECLARE_STATIC_CALL(__irqentry_exit_cond_resched, __irqentry_exit_cond_resched); #endif + /** * irqentry_exit - Handle return from exception that used irqentry_enter() * @regs: Pointer to pt_regs (exception entry regs) diff --git a/kernel/entry/common.c b/kernel/entry/common.c index bad713684c2e..490442a48332 100644 --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -380,7 +380,7 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs) return ret; } -void irqentry_exit_cond_resched(void) +void __irqentry_exit_cond_resched(void) { if (!preempt_count()) { /* Sanity check RCU and thread stack */ @@ -392,9 +392,20 @@ void irqentry_exit_cond_resched(void) } } #ifdef CONFIG_PREEMPT_DYNAMIC -DEFINE_STATIC_CALL(irqentry_exit_cond_resched, irqentry_exit_cond_resched); +DEFINE_STATIC_CALL(__irqentry_exit_cond_resched, __irqentry_exit_cond_resched); #endif +void irqentry_exit_cond_resched(void) +{ + if (IS_ENABLED(CONFIG_PREEMPTION)) { +#ifdef CONFIG_PREEMPT_DYNAMIC + static_call(__irqentry_exit_cond_resched)(); +#else + __irqentry_exit_cond_resched(); +#endif + } +} + noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state) { lockdep_assert_irqs_disabled(); @@ -420,13 +431,7 @@ noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state) } instrumentation_begin(); - if (IS_ENABLED(CONFIG_PREEMPTION)) { -#ifdef CONFIG_PREEMPT_DYNAMIC - static_call(irqentry_exit_cond_resched)(); -#else - irqentry_exit_cond_resched(); -#endif - } + irqentry_exit_cond_resched(); /* Covers both tracing and lockdep */ trace_hardirqs_on(); instrumentation_end(); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 848eaa0efe0e..7197c33beb39 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6562,29 +6562,29 @@ EXPORT_STATIC_CALL_TRAMP(preempt_schedule_notrace); * SC:might_resched * SC:preempt_schedule * SC:preempt_schedule_notrace - * SC:irqentry_exit_cond_resched + * SC:__irqentry_exit_cond_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 * * 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 * * 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 */ enum { @@ -6620,7 +6620,7 @@ void sched_dynamic_update(int mode) static_call_update(might_resched, __cond_resched); static_call_update(preempt_schedule, __preempt_schedule_func); static_call_update(preempt_schedule_notrace, __preempt_schedule_notrace_func); - static_call_update(irqentry_exit_cond_resched, irqentry_exit_cond_resched); + static_call_update(__irqentry_exit_cond_resched, __irqentry_exit_cond_resched); switch (mode) { case preempt_dynamic_none: @@ -6628,7 +6628,7 @@ void sched_dynamic_update(int mode) static_call_update(might_resched, (void *)&__static_call_return0); static_call_update(preempt_schedule, NULL); static_call_update(preempt_schedule_notrace, NULL); - static_call_update(irqentry_exit_cond_resched, NULL); + static_call_update(__irqentry_exit_cond_resched, NULL); pr_info("Dynamic Preempt: none\n"); break; @@ -6637,7 +6637,7 @@ void sched_dynamic_update(int mode) static_call_update(might_resched, __cond_resched); static_call_update(preempt_schedule, NULL); static_call_update(preempt_schedule_notrace, NULL); - static_call_update(irqentry_exit_cond_resched, NULL); + static_call_update(__irqentry_exit_cond_resched, NULL); pr_info("Dynamic Preempt: voluntary\n"); break; @@ -6646,7 +6646,7 @@ void sched_dynamic_update(int mode) static_call_update(might_resched, (void *)&__static_call_return0); static_call_update(preempt_schedule, __preempt_schedule_func); static_call_update(preempt_schedule_notrace, __preempt_schedule_notrace_func); - static_call_update(irqentry_exit_cond_resched, irqentry_exit_cond_resched); + static_call_update(__irqentry_exit_cond_resched, __irqentry_exit_cond_resched); pr_info("Dynamic Preempt: full\n"); break; } -- 2.31.1