Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2709851pxb; Thu, 10 Feb 2022 03:58:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxzLHNroAveOu4mSyzmrRLdeXG//CSYCuaAcVeqimi5PLnG4yuXo8fHBPGm0KPLZK6o6R6M X-Received: by 2002:a17:902:ea11:: with SMTP id s17mr7064437plg.171.1644494303761; Thu, 10 Feb 2022 03:58:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644494303; cv=none; d=google.com; s=arc-20160816; b=AwbKjn9Mp0YI+0p+KmHmxNoi71lXljrR53JG9Ut734O53+8ea4Iwa/pqUJyrEWZhog /AeVEwxoeXQ3RDh/40LQgRqBCypNDasJAQ0YSVcOsISVoaeYNcNcWABtAiPYqFK5b+80 crqKrdhqGoPx7VYX+cnx0HPySxUzCHuVz3o3QbDIVeY1ctKaxYqpdQJ6ucf1caSBGWtJ CPfpEYjX4+ryMVu62pCEPIzMGF/L2GLkcXf6yjBu7L5zJZMkIUQ/H4n9K79JX34XznaL lrZcVMh0S2gf/mc6GeQYfVRgJOzEe+KZRuDLG1TYq3E1kIfTMXCG1CCoR6l6MhqQi8VA 5UPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=a25O5e3OqKX/01EOZtigO9vFaVCPxR8faSF9sV+z9ZA=; b=G/UtjG/hVc+ao3K3dxFdNBwt23EZ/jMzLotKhcA894EyoJNBdgoClOMKVMkW3yjSmD ESErUB0sCpxpV3BfraU77WR5d1SkkSyGNX7jdaO8bVybt6UDE4qTe+oKxmhmfTGBxpPi KNj8zesr9Uv+FPE4XuRneSGkhQMGy9M0jYCgr2naB5CDRevWSK/Ou5Pt5aiNAIqyBkkA GBqbL1V78FvlzH4V51SKqrMa6Ivf2mYpahVRTKbZUNdXi+J4z0AaMyUmcJzQShT9xOQy JykSJTi+wQQEJNHbvjq9H0Gx0cgCVUEQbDTTRTm8O8f0PPzQqYiuqlChsR4U5VlHEpAn nmNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Tbc8VMyt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id az23si1197014pjb.54.2022.02.10.03.58.11; Thu, 10 Feb 2022 03:58:23 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=Tbc8VMyt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238718AbiBJJaS (ORCPT + 99 others); Thu, 10 Feb 2022 04:30:18 -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-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" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 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 >