Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2172240pxb; Wed, 9 Feb 2022 12:24:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJywqdOfcubcPeigtrXeM+KRZh290OrgPWcVhv+prVkn8D+01HgEfZaBjFKNhek4+/JF9v0M X-Received: by 2002:a17:902:ea11:: with SMTP id s17mr3886389plg.171.1644438272571; Wed, 09 Feb 2022 12:24:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644438272; cv=none; d=google.com; s=arc-20160816; b=JXd0FFCoGbN6WgNO5u0Fc3i0xheC6N8KUCuOsNZGZOKORp6sdagJmhHriV4hc9PJav 4DNZyl1tYznYmWL+lEiDcHAjB6BEHEN4uTsm1lqT7/X4ofSjr6udTqr4VaThuwpYE8J0 nUqd5En8wKxIJTCLMJlE68Prl0sUqjq+BqoC/7TdTbDFrEC1oQtAb2hBhZNjCrrQzacY RrkALfTwYl0nIG5kGXfPXkcDUFKog4P+hWZHM3jN8ztfo4UAF8E7O35V50MlBW3hVZBS Tb/dDVGlE0JsTrDxhlVrP/4Toq87FP81aEyff3ikOwGr0IMwkN++pDe7mHWZTq2nnCEk 6sng== 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 :message-id:date:subject:cc:to:from; bh=PBUZsPd1BlLcfXkamBp+F8TSnwWlIpchOPlp67zimxM=; b=av8KNK1bV0yARWMfbT4nyp7G0RjCgvfgjTY1gMBFcjTlBHw9xk9nFvMsYrihpFZlGL ixPv3ohu9hbdKHRPTYUDdXEEkA9h+NIK4VqBsBOUhNpu2R0J25CwA28G6/m5J4k8394o Gd7iSYZTt4ULU7SGA5S+M+Y8Osin0Ef2I0N1hEA8yNuWnwCR6bBSGcy6dHYytnbA4+J4 cOwfL3ZaY9NcgIy/Tx8lLWX+lQ4dajb0t562IQcXRXobypKWlb0WS88g0RKgCTXlaP0p y+DAsdmAffROfLMoQBM8CLNEXpjTDlsrwoSDftvLhOqTN45pq8h/++sn0vuWlqsalSem gJQA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l7si17898586pfu.149.2022.02.09.12.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 12:24:32 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E0A60E04AACC; Wed, 9 Feb 2022 12:01:32 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236024AbiBIPgH (ORCPT + 99 others); Wed, 9 Feb 2022 10:36:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235964AbiBIPfl (ORCPT ); Wed, 9 Feb 2022 10:35:41 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 001BDC05CB9F for ; Wed, 9 Feb 2022 07:35:43 -0800 (PST) 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 38F1E1FB; Wed, 9 Feb 2022 07:35:43 -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 A71F43F73B; Wed, 9 Feb 2022 07:35:40 -0800 (PST) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: ardb@kernel.org, bp@alien8.de, catalin.marinas@arm.com, 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, mark.rutland@arm.com, mingo@redhat.com, peterz@infradead.org, tglx@linutronix.de, valentin.schneider@arm.com, will@kernel.org Subject: [PATCH v3 0/7] arm64 / sched/preempt: support PREEMPT_DYNAMIC with static keys Date: Wed, 9 Feb 2022 15:35:28 +0000 Message-Id: <20220209153535.818830-1-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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 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