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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFB2DC433F5 for ; Tue, 9 Nov 2021 17:26:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8E4AC611BF for ; Tue, 9 Nov 2021 17:26:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8E4AC611BF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=S6cbZjgoj647KM7NmEdYaozKg3o7bTccUNzbcPhmU4I=; b=x8UUbepM2DEB4n kVqXGKgnMDO2EEOiPBIkhMgdnMJ+OB4JkaguDJ5fADbFNf4GKtavacuARO6VxjD1vdGWwZ4MXs8UD 4JaDxzwiNd7Eodek/Wwif0kR2FTmXhwXGbgqWkDJ9J4z8HH4+NxkWthjz/gcyjrwk9qxsEbNLX+cc 8MpFUl0IhVbfFSnTGgTund7t9ObvHEHjAt+2MttY2AlswfmALofqkC/oBTSNi0J3pwCgnyCCdt6Su 1dl3EpNckka09oobiC4YfyNVqq45gjpz2B1IQrjJdXmdMKfnXMRp2mq9V9JgvBgUq2pk9MFmJQeRQ koF1iK0DbrceOsjutgSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkUsK-002rZz-4a; Tue, 09 Nov 2021 17:25:36 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkUrJ-002rCt-K0 for linux-arm-kernel@lists.infradead.org; Tue, 09 Nov 2021 17:24:35 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 92299ED1; Tue, 9 Nov 2021 09:24:32 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 424913F800; Tue, 9 Nov 2021 09:24:31 -0800 (PST) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: ardb@kernel.org, catalin.marinas@arm.com, frederic@kernel.org, juri.lelli@redhat.com, linux-kernel@vger.kernel.org, mark.rutland@arm.com, mingo@redhat.com, peterz@infradead.org, will@kernel.org Subject: [PATCH 6/6] arm64: support PREEMPT_DYNAMIC Date: Tue, 9 Nov 2021 17:24:08 +0000 Message-Id: <20211109172408.49641-7-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211109172408.49641-1-mark.rutland@arm.com> References: <20211109172408.49641-1-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211109_092433_772300_291A499B X-CRM114-Status: GOOD ( 14.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch enables support for PREEMPT_DYNAMIC on arm64, using static keys to disable the out-of-line forms of the preemption functions. This side-steps a number of pain points highlighted with static calls, and I expect the overhead to be similar (and hopefully lower in some cases) than would be the case for non-inlined static calls, by virtue of effectively inlining the trampolines into the callees. Signed-off-by: Mark Rutland Cc: Ard Biesheuvel Cc: Catalin Marinas Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Juri Lelli Cc: Peter Zijlstra Cc: Will Deacon --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/preempt.h | 16 ++++++++++++++-- arch/arm64/kernel/entry-common.c | 9 +++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index c4207cf9bb17..928b710465ce 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -191,6 +191,7 @@ config ARM64 select HAVE_PERF_EVENTS select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP + select HAVE_PREEMPT_DYNAMIC_KEY select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_POSIX_CPU_TIMERS_TASK_WORK select HAVE_FUNCTION_ARG_ACCESS_API diff --git a/arch/arm64/include/asm/preempt.h b/arch/arm64/include/asm/preempt.h index e83f0982b99c..73623f719d7e 100644 --- a/arch/arm64/include/asm/preempt.h +++ b/arch/arm64/include/asm/preempt.h @@ -80,10 +80,22 @@ static inline bool should_resched(int preempt_offset) } #ifdef CONFIG_PREEMPTION +#ifdef CONFIG_PREEMPT_DYNAMIC + +DECLARE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched); +void dynamic_preempt_schedule(void); +#define __preempt_schedule() dynamic_preempt_schedule() +void dynamic_preempt_schedule_notrace(void); +#define __preempt_schedule_notrace() dynamic_preempt_schedule_notrace() + +#else + void preempt_schedule(void); -#define __preempt_schedule() preempt_schedule() +#define __preempt_schedule() preempt_schedule() void preempt_schedule_notrace(void); -#define __preempt_schedule_notrace() preempt_schedule_notrace() +#define __preempt_schedule_notrace() preempt_schedule_notrace() + +#endif #endif /* CONFIG_PREEMPTION */ #endif /* __ASM_PREEMPT_H */ diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c index f7408edf8571..f096678dd580 100644 --- a/arch/arm64/kernel/entry-common.c +++ b/arch/arm64/kernel/entry-common.c @@ -220,10 +220,19 @@ static void noinstr arm64_exit_el1_dbg(struct pt_regs *regs) lockdep_hardirqs_on(CALLER_ADDR0); } +#ifdef CONFIG_PREEMPT_DYNAMIC +DEFINE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched); +#endif + static void __sched arm64_preempt_schedule_irq(void) { lockdep_assert_irqs_disabled(); +#ifdef CONFIG_PREEMPT_DYNAMIC + if (!static_branch_unlikely(&sk_dynamic_irqentry_exit_cond_resched)) + return; +#endif + /* * DAIF.DA are cleared at the start of IRQ/FIQ handling, and when GIC * priority masking is used the GIC irqchip driver will clear DAIF.IF -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel