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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4C0BFC433EF for ; Fri, 4 Feb 2022 18:49:35 +0000 (UTC) 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZGEj0Q5yIcrXw4jruOQWlfFmQvZ6OSzed6nKR4UhIY8=; b=jzoWhmFxhoqcPl 68+UAuwWStXtXTEl+BJtYkdDHxRxch8C1Iewq5lRgeQ7LIgUCUFWQ9QOqmJRY0+Ye0VaCcvu/SVyY kWmRYPiLDnG4l/htCBCnN+kENmTG7mm/tyiuxfgjlbtCupOcDMVPNH/tIZpqNGBHALX2yp+k7EhyS QU3awvU881AwUgSOl67aoGMLUexa8fvJB6++ODaRbRBwU5g7sIt4ko+5Bw0+0NPxAx13sUKl73j3Z fTE9COijyhQVxFKTaA2B9hTAdlBsBGwb0TWj3pHEot3izuQsb9gqrA9udAcbuE/yD+5QoFwxAvsES ECU2x+4VuUBoYy2I2HYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG3d9-005DCI-VW; Fri, 04 Feb 2022 18:48:24 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG3d6-005DAf-Kk for linux-arm-kernel@lists.infradead.org; Fri, 04 Feb 2022 18:48:22 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 327AA61C3F; Fri, 4 Feb 2022 18:48:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 182B2C004E1; Fri, 4 Feb 2022 18:48:16 +0000 (UTC) Date: Fri, 4 Feb 2022 18:48:13 +0000 From: Catalin Marinas To: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, ardb@kernel.org, bp@alien8.de, dave.hansen@linux.intel.com, frederic@kernel.org, james.morse@arm.com, joey.gouly@arm.com, juri.lelli@redhat.com, linux-kernel@vger.kernel.org, luto@kernel.org, mingo@redhat.com, peterz@infradead.org, tglx@linutronix.de, valentin.schneider@arm.com, will@kernel.org Subject: Re: [PATCH v2 7/7] arm64: support PREEMPT_DYNAMIC Message-ID: References: <20220204150557.434610-1-mark.rutland@arm.com> <20220204150557.434610-8-mark.rutland@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220204150557.434610-8-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220204_104820_764528_1C4BDA75 X-CRM114-Status: GOOD ( 21.49 ) 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: , 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 On Fri, Feb 04, 2022 at 03:05:57PM +0000, Mark Rutland wrote: > This patch enables support for PREEMPT_DYNAMIC on arm64, allowing the > preemption model to be chosen at boot time. > > Specifically, this patch selects HAVE_PREEMPT_DYNAMIC_KEY, so that each > preemption function is an out-of-line call with an early return > depending upon a static key. This leaves almost all the codegen up to > the compiler, and side-steps a number of pain points with static calls > (e.g. interaction with CFI schemes). This should have no worse overhead > than using non-inline static calls, as those use out-of-line trampolines > with early returns. > > For example, the dynamic_cond_resched() wrapper looks as follows (with > the first `B` being replaced with a `NOP` when the function is > disabled): > > | : > | bti c > | b > | mov w0, #0x0 // #0 > | ret > | mrs x0, sp_el0 > | ldr x0, [x0, #8] > | cbnz x0, > | paciasp > | stp x29, x30, [sp, #-16]! > | mov x29, sp > | bl > | mov w0, #0x1 // #1 > | ldp x29, x30, [sp], #16 > | autiasp > | ret > > ... compared to the regular form of the function: > > | <__cond_resched>: > | bti c > | mrs x0, sp_el0 > | ldr x1, [x0, #8] > | cbz x1, <__cond_resched+0x18> > | mov w0, #0x0 // #0 > | ret > | paciasp > | stp x29, x30, [sp, #-16]! > | mov x29, sp > | bl > | mov w0, #0x1 // #1 > | ldp x29, x30, [sp], #16 > | autiasp > | ret > > Since arm64 does not yet use the generic entry code, we must define our > own `sk_dynamic_irqentry_exit_cond_resched`, which will be > enabled/disabled by the common code in kernel/sched/core.c. All other > preemption functions and associated static keys are defined there. > > Note that PREEMPT_DYNAMIC is `def bool y`, so this will default to > enabled. > > Signed-off-by: Mark Rutland > Cc: Ard Biesheuvel > Cc: Catalin Marinas > Cc: Frederic Weisbecker > Cc: Ingo Molnar > Cc: Joey Gouly > Cc: Juri Lelli > Cc: Peter Zijlstra > Cc: Valentin Schneider > Cc: Will Deacon Acked-by: Catalin Marinas _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel