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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA24FC433F5 for ; Thu, 10 Feb 2022 09:30:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238562AbiBJJaT (ORCPT ); Thu, 10 Feb 2022 04:30:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238720AbiBJJ3g (ORCPT ); Thu, 10 Feb 2022 04:29:36 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA5A31112 for ; Thu, 10 Feb 2022 01:29:35 -0800 (PST) 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 69418619A5 for ; Thu, 10 Feb 2022 09:29:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD7A3C340F3 for ; Thu, 10 Feb 2022 09:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644485374; bh=HGM4Q7IrvX3TCMF1bCBJF/zPO3rFe3dmiOQn+Ok2zCM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Tbc8VMytVSPwXhPAFQ+pHW0VyXILcAVQiYcTRAHd9pZIO4SZXyZVupdvYHlpEfFUs MayK24kZfPvksWqOGd40rwRrxRceQ8hjZPiEmP1pVr5n4iLKklamS+/WhXp9dsCxXB YBENBAFVolTJop4EqJPtwL22sKGbSygW6QpHvUlYeCJX/4bYti6U8wgKltQs9Il4Hm Oar81vk9stV3J1/N2UpeA/eufrKFhbtybgz5pVV7hxvEv2O+cfPgePE5fuW/w+zGL5 BQWTAdmZ0xL8lSQ1hjWn/wJHdOJASqQgkwogbXY+ipSoHzuHxmQaURClnCHG0CgVfR mFmr+OZgFVCFg== Received: by mail-wr1-f50.google.com with SMTP id d27so4604821wrb.5 for ; Thu, 10 Feb 2022 01:29:34 -0800 (PST) X-Gm-Message-State: AOAM532hJDDeZV2n4UE6v1wRghffSnlw3aJE+3bVmmJTI09re+R1UA3X eheLHNNqiW3i4mwOMVZgw+wH5r0A7Q4/UZ8rlNA= X-Google-Smtp-Source: ABdhPJyj1SGdUBiIOfZDt8ZwdLNUao09JQ8pTbN3rxClO1zCdUAgLNfU5RFjsfxJNTGpgIBiQYMSTTpb0iJqfvEwCss= X-Received: by 2002:a05:6000:15ca:: with SMTP id y10mr5599700wry.417.1644485373021; Thu, 10 Feb 2022 01:29:33 -0800 (PST) MIME-Version: 1.0 References: <20220209153535.818830-1-mark.rutland@arm.com> In-Reply-To: <20220209153535.818830-1-mark.rutland@arm.com> From: Ard Biesheuvel Date: Thu, 10 Feb 2022 10:29:21 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 0/7] arm64 / sched/preempt: support PREEMPT_DYNAMIC with static keys To: Mark Rutland Cc: Linux ARM , Borislav Petkov , Catalin Marinas , Dave Hansen , Frederic Weisbecker , James Morse , joey.gouly@arm.com, Juri Lelli , Linux Kernel Mailing List , Andy Lutomirski , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Valentin Schneider , Will Deacon Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 9 Feb 2022 at 16:35, Mark Rutland wrote: > > This series enables PREEMPT_DYNAMIC on arm64. To do so, it adds a new > mechanism allowing the preemption functions to be enabled/disabled using > static keys rather than static calls, with architectures selecting > whether they use static calls or static keys. > > With non-inline static calls, each function call results in a call to > the (out-of-line) trampoline which either tail-calls its associated > callee or performs an early return. > > The key idea is that where we're only enabling/disabling a single > callee, we can inline this trampoline into the start of the callee, > using a static key to decide whether to return early, and leaving the > remaining codegen to the compiler. The overhead should be similar to > (and likely lower than) using a static call trampoline. Since most > codegen is up to the compiler, we sidestep a number of implementation > pain-points (e.g. things like CFI should "just work" as well as they do > for any other functions). > > The bulk of the diffstat for kernel/sched/core.c is shuffling the > PREEMPT_DYNAMIC code later in the file, and the actual additions are > fairly trivial. > > I've given this very light build+boot testing so far. > > Since v1 [1]: > * Rework Kconfig text to be clearer > * Rework arm64 entry code > * Clarify commit messages. > > Since v2 [2]: > * Add missing includes > * Always provide prototype for preempt_schedule() > * Always provide prototype for preempt_schedule_notrace() > * Fix __cond_resched() to default to disabled > * Fix might_resched() to default to disabled > * Clarify example in commit message > > [1] https://lore.kernel.org/r/20211109172408.49641-1-mark.rutland@arm.com/ > [2] https://lore.kernel.org/r/20220204150557.434610-1-mark.rutland@arm.com/ > > Mark Rutland (7): > sched/preempt: move PREEMPT_DYNAMIC logic later > sched/preempt: refactor sched_dynamic_update() > sched/preempt: simplify irqentry_exit_cond_resched() callers > sched/preempt: decouple HAVE_PREEMPT_DYNAMIC from GENERIC_ENTRY > sched/preempt: add PREEMPT_DYNAMIC using static keys > arm64: entry: centralize premeption decision > arm64: support PREEMPT_DYNAMIC > Acked-by: Ard Biesheuvel > arch/Kconfig | 37 +++- > arch/arm64/Kconfig | 1 + > arch/arm64/include/asm/preempt.h | 19 +- > arch/arm64/kernel/entry-common.c | 28 ++- > arch/x86/Kconfig | 2 +- > arch/x86/include/asm/preempt.h | 10 +- > include/linux/entry-common.h | 15 +- > include/linux/kernel.h | 7 +- > include/linux/sched.h | 10 +- > kernel/entry/common.c | 23 +- > kernel/sched/core.c | 347 ++++++++++++++++++------------- > 11 files changed, 327 insertions(+), 172 deletions(-) > > -- > 2.30.2 > 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 D4632C433EF for ; Thu, 10 Feb 2022 09:31:02 +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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2oXjTLxJ86zEp+wGdY/KubDssFpU6omo9+Dh9XUnCv8=; b=oGB1qP/EJXW6i2 qhGZKF9jkiwjt48JKNj0b+8dSDKnS4T5m2qCw7dFw4jTTKZxmMwTug39oc7NXnpqNV+lrZNS5YjRq kVgUdLZPfAsKWMKKHbh4MdIKQude+XiBqoBBMqLIBx+jDn4C7WCQg61Npw7W8anIeYplHJI4zw9eg PsJlF64Y8zBHeirKPVSANYLJmcvJ4YM777WTLtif7UPWj/CpCv93piYIjpVDQfqTYDycT4V4tbXHC 1ebknIJka3TpBrGtOrskovewCYHfaYbu2eY7XsWugTt8haOHb0yOLbi4b9/vb+ZPpMUPd2On1jpLU yl0a489XpX3eiitS0gcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nI5ln-003HNx-RZ; Thu, 10 Feb 2022 09:29:43 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nI5li-003HLs-2c for linux-arm-kernel@lists.infradead.org; Thu, 10 Feb 2022 09:29:41 +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 ams.source.kernel.org (Postfix) with ESMTPS id 030FFB82463 for ; Thu, 10 Feb 2022 09:29:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1729C340EF for ; Thu, 10 Feb 2022 09:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644485374; bh=HGM4Q7IrvX3TCMF1bCBJF/zPO3rFe3dmiOQn+Ok2zCM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Tbc8VMytVSPwXhPAFQ+pHW0VyXILcAVQiYcTRAHd9pZIO4SZXyZVupdvYHlpEfFUs MayK24kZfPvksWqOGd40rwRrxRceQ8hjZPiEmP1pVr5n4iLKklamS+/WhXp9dsCxXB YBENBAFVolTJop4EqJPtwL22sKGbSygW6QpHvUlYeCJX/4bYti6U8wgKltQs9Il4Hm Oar81vk9stV3J1/N2UpeA/eufrKFhbtybgz5pVV7hxvEv2O+cfPgePE5fuW/w+zGL5 BQWTAdmZ0xL8lSQ1hjWn/wJHdOJASqQgkwogbXY+ipSoHzuHxmQaURClnCHG0CgVfR mFmr+OZgFVCFg== Received: by mail-wr1-f46.google.com with SMTP id k1so8383742wrd.8 for ; Thu, 10 Feb 2022 01:29:34 -0800 (PST) X-Gm-Message-State: AOAM532syX7tH3CmPMy3AAdYKNEoH3Z3sqUfc6LsXFOxWw+LUN4GciJG e1I4mGmK9yIZYNymoy1IIXBLMqmQmE1K/tq6irQ= X-Google-Smtp-Source: ABdhPJyj1SGdUBiIOfZDt8ZwdLNUao09JQ8pTbN3rxClO1zCdUAgLNfU5RFjsfxJNTGpgIBiQYMSTTpb0iJqfvEwCss= X-Received: by 2002:a05:6000:15ca:: with SMTP id y10mr5599700wry.417.1644485373021; Thu, 10 Feb 2022 01:29:33 -0800 (PST) MIME-Version: 1.0 References: <20220209153535.818830-1-mark.rutland@arm.com> In-Reply-To: <20220209153535.818830-1-mark.rutland@arm.com> From: Ard Biesheuvel Date: Thu, 10 Feb 2022 10:29:21 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 0/7] arm64 / sched/preempt: support PREEMPT_DYNAMIC with static keys To: Mark Rutland Cc: Linux ARM , Borislav Petkov , Catalin Marinas , Dave Hansen , Frederic Weisbecker , James Morse , joey.gouly@arm.com, Juri Lelli , Linux Kernel Mailing List , Andy Lutomirski , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Valentin Schneider , Will Deacon X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220210_012938_485166_E622D86B X-CRM114-Status: GOOD ( 28.74 ) 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 Wed, 9 Feb 2022 at 16:35, Mark Rutland wrote: > > This series enables PREEMPT_DYNAMIC on arm64. To do so, it adds a new > mechanism allowing the preemption functions to be enabled/disabled using > static keys rather than static calls, with architectures selecting > whether they use static calls or static keys. > > With non-inline static calls, each function call results in a call to > the (out-of-line) trampoline which either tail-calls its associated > callee or performs an early return. > > The key idea is that where we're only enabling/disabling a single > callee, we can inline this trampoline into the start of the callee, > using a static key to decide whether to return early, and leaving the > remaining codegen to the compiler. The overhead should be similar to > (and likely lower than) using a static call trampoline. Since most > codegen is up to the compiler, we sidestep a number of implementation > pain-points (e.g. things like CFI should "just work" as well as they do > for any other functions). > > The bulk of the diffstat for kernel/sched/core.c is shuffling the > PREEMPT_DYNAMIC code later in the file, and the actual additions are > fairly trivial. > > I've given this very light build+boot testing so far. > > Since v1 [1]: > * Rework Kconfig text to be clearer > * Rework arm64 entry code > * Clarify commit messages. > > Since v2 [2]: > * Add missing includes > * Always provide prototype for preempt_schedule() > * Always provide prototype for preempt_schedule_notrace() > * Fix __cond_resched() to default to disabled > * Fix might_resched() to default to disabled > * Clarify example in commit message > > [1] https://lore.kernel.org/r/20211109172408.49641-1-mark.rutland@arm.com/ > [2] https://lore.kernel.org/r/20220204150557.434610-1-mark.rutland@arm.com/ > > Mark Rutland (7): > sched/preempt: move PREEMPT_DYNAMIC logic later > sched/preempt: refactor sched_dynamic_update() > sched/preempt: simplify irqentry_exit_cond_resched() callers > sched/preempt: decouple HAVE_PREEMPT_DYNAMIC from GENERIC_ENTRY > sched/preempt: add PREEMPT_DYNAMIC using static keys > arm64: entry: centralize premeption decision > arm64: support PREEMPT_DYNAMIC > Acked-by: Ard Biesheuvel > arch/Kconfig | 37 +++- > arch/arm64/Kconfig | 1 + > arch/arm64/include/asm/preempt.h | 19 +- > arch/arm64/kernel/entry-common.c | 28 ++- > arch/x86/Kconfig | 2 +- > arch/x86/include/asm/preempt.h | 10 +- > include/linux/entry-common.h | 15 +- > include/linux/kernel.h | 7 +- > include/linux/sched.h | 10 +- > kernel/entry/common.c | 23 +- > kernel/sched/core.c | 347 ++++++++++++++++++------------- > 11 files changed, 327 insertions(+), 172 deletions(-) > > -- > 2.30.2 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel