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 70F9CC636D6 for ; Fri, 17 Feb 2023 22:23:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229851AbjBQWXG (ORCPT ); Fri, 17 Feb 2023 17:23:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbjBQWXC (ORCPT ); Fri, 17 Feb 2023 17:23:02 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B80345D3EB; Fri, 17 Feb 2023 14:23:01 -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 ams.source.kernel.org (Postfix) with ESMTPS id 6EF30B82DD0; Fri, 17 Feb 2023 22:23:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC44DC433EF; Fri, 17 Feb 2023 22:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676672579; bh=nDYIubJTBPWH5ktJId6VhvPlAhhjbmackYfSKNUBnA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HvaqSr5PbTHNs8mAMaAmaYbTfmj4JGX1vO3kz55UvEw93l5BToEp5+PskKaCtMUeS OUMKsxV+tVXyKFXE+8+csdac7DIDBeylDt7DWhvsWVljlU4UlctSUoRrOmFMPlYBpv zgOZhnks24H2u7Ie0dgDdmYZftBRMVkj0epeKHM4sLSs17K8xg3btcsVxQ2K3C5h7u sva5ly/+lj6K1pMbn2gwTWJBSx0JCIp/u7aSiSH3zae9c7968ZiY97Coz7SedTHhNz q31EckXsm5CLqqo9HEQ7WAcVB4TnJPv7Wpy4g6/QRkUk09ZQ7s5cUGDjCVS1gHXIfJ Lmn9k+xGyVk3Q== From: Josh Poimboeuf To: live-patching@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Seth Forshee , Peter Zijlstra , Song Liu , Mark Rutland , Petr Mladek , Joe Lawrence , Miroslav Benes , Jiri Kosina , Ingo Molnar , Rik van Riel Subject: [PATCH v2 1/3] livepatch: Skip task_call_func() for current task Date: Fri, 17 Feb 2023 14:22:54 -0800 Message-Id: <4b92e793462d532a05f03767151fa29db3e68e13.1676672328.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current task doesn't need the scheduler's protection to unwind its own stack. Tested-by: Seth Forshee (DigitalOcean) Reviewed-by: Petr Mladek Signed-off-by: Josh Poimboeuf --- kernel/livepatch/transition.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/livepatch/transition.c b/kernel/livepatch/transition.c index f1b25ec581e0..4d1f443778f7 100644 --- a/kernel/livepatch/transition.c +++ b/kernel/livepatch/transition.c @@ -307,7 +307,11 @@ static bool klp_try_switch_task(struct task_struct *task) * functions. If all goes well, switch the task to the target patch * state. */ - ret = task_call_func(task, klp_check_and_switch_task, &old_name); + if (task == current) + ret = klp_check_and_switch_task(current, &old_name); + else + ret = task_call_func(task, klp_check_and_switch_task, &old_name); + switch (ret) { case 0: /* success */ break; -- 2.39.1