From patchwork Wed Jun 14 17:42:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 108071 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp128513vqr; Wed, 14 Jun 2023 10:56:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5AXvRIWv1v9Dh5Oy15rPmFrb3yJuVEoo77DhK7J6Ets4cbbinyPR6fIorkwtVfVf+VSntw X-Received: by 2002:aa7:d70b:0:b0:514:8d88:7b70 with SMTP id t11-20020aa7d70b000000b005148d887b70mr8921192edq.6.1686765377518; Wed, 14 Jun 2023 10:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686765377; cv=none; d=google.com; s=arc-20160816; b=qRF6UEcaE1xHlT3e7utbGWO3eDF5nllusQlZhUr5t/MWqGyf7t8L+2/tbDaLJ9c+OS U2zwJNR9AsWZGMZv9s4TFgoKWDSQ3Ekic80J30Cn7vYe/zgGclohDb2ZrkIYMtKzjqga nkhdpF0ogc3+gYm7YehBFLMgGxGP833cM3JnAc6g9zy+H0SzPpLnuSRs+9Gk6FiYYAJD WrzzJKSxKsq6HlPJH4e8ZFS1fBz/D3nNgmzMbMEO851nKM/1p7pjOEQ2sw077M4xUcgS I9eQAPCaAVt3rYjflXgebO2P2qF0ApoJfmq/2qbYO4z3y9cPnwiLwT1LATI8hPUHbclC niNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=ntZkBUJtac81cXHWHcoh+F7kGceASVAOizr14nWNrKg=; b=VJc8C9k404ExVPvmdhTFq6IEj4Khge2My4hN1pKKHh1FUq25DmDO50CeUiEHavkf6I rcx3sDfB5zznJDED7uweYrav3hN6GXq9YJmDS74QkyUp4RPP6q5fk9WJC7t4xfq+3A7M qFCforad41hPn9tzHQQN3KCDksRgPSpgDymN+tIjoXL1/MchFeT+rEXaxwJX1sOrf4Ny UEQjs3Vu/tHRLFVvenq+y8R0fA6RFZ0qNwLH+oDslqnoTjKkrZN+ya1Vw7m1velOoGD1 49kZ9pHR2/uefti/a/GsBRhVy0KsT9BN32AutlKt29r14JXFCxbUO1XazU19e7T3iYzd tVYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hAIWd8nI; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m11-20020aa7c48b000000b00514b3a2009dsi9196093edq.178.2023.06.14.10.55.53; Wed, 14 Jun 2023 10:56:17 -0700 (PDT) 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=@linutronix.de header.s=2020 header.b=hAIWd8nI; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238983AbjFNRnA (ORCPT + 99 others); Wed, 14 Jun 2023 13:43:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234236AbjFNRm6 (ORCPT ); Wed, 14 Jun 2023 13:42:58 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0417CE43; Wed, 14 Jun 2023 10:42:56 -0700 (PDT) Date: Wed, 14 Jun 2023 17:42:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686764575; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ntZkBUJtac81cXHWHcoh+F7kGceASVAOizr14nWNrKg=; b=hAIWd8nI3fYDHtyR2wUV06zMD4WZ2mAzpM9r2cCb9SnFohOfRVM9nMCpuXcqIq9gYyr2lA gfZIBKlJNPJNPu8HkUevIlJ41BJQ0u4qrJBIzcqCTMJBruRKFlCstffXbqDpjudRbQkJKy /5RmSA37zMrkyPazJ2olX015hpwKRlEOBtgqupAeXkpVTxVR88r3u1Q20pddkThm7J+XH8 hofR9cHiayMdNqGQhBtdPu3iMRTvmJDlR2wZfZOCCvBcZeo07zcUB+jiMf5sSJoHM4FB1n APsUP4AfUrMrjP/dMg6rM9ybrGKtImwZkCQAhUUVFSk3S0sRJafNffYrzEmumw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686764575; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ntZkBUJtac81cXHWHcoh+F7kGceASVAOizr14nWNrKg=; b=52YXpUoazXAkyPaXjmCF9fPFBBftkVrSN3YloOUZFt9Zs1Hxmhhyjxs4nbjr3L5l3ybNdW FOW0rT9Dyofi3RDg== From: "tip-bot2 for Steven Rostedt (Google)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/alternatives] x86/alternatives: Add cond_resched() to text_poke_bp_batch() Cc: "Steven Rostedt (Google)" , "Borislav Petkov (AMD)" , "Masami Hiramatsu (Google)" , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230531092419.4d051374@rorschach.local.home> References: <20230531092419.4d051374@rorschach.local.home> MIME-Version: 1.0 Message-ID: <168676457481.404.7166372409577741142.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767144656570846093?= X-GMAIL-MSGID: =?utf-8?q?1768701692287462918?= The following commit has been merged into the x86/alternatives branch of tip: Commit-ID: 9350a629e839ca1c2b529a83a916cf2370bd1c64 Gitweb: https://git.kernel.org/tip/9350a629e839ca1c2b529a83a916cf2370bd1c64 Author: Steven Rostedt (Google) AuthorDate: Wed, 31 May 2023 09:24:19 -04:00 Committer: Borislav Petkov (AMD) CommitterDate: Wed, 14 Jun 2023 18:50:00 +02:00 x86/alternatives: Add cond_resched() to text_poke_bp_batch() Debugging in the kernel has started slowing down the kernel by a noticeable amount. The ftrace start up tests are triggering the softlockup watchdog on some boxes. This is caused by the start up tests that enable function and function graph tracing several times. Sprinkling cond_resched() just in the start up test code was not enough to stop the softlockup from triggering. It would sometimes trigger in the text_poke_bp_batch() code. When function tracing enables all functions, it will call text_poke_queue() to queue the places that need to be patched. Every 256 entries will do a "flush" that calls text_poke_bp_batch() to do the update of the 256 locations. As this is in a scheduleable context, calling cond_resched() at the start of text_poke_bp_batch() will ensure that other tasks could get a chance to run while the patching is happening. This keeps the softlockup from triggering in the start up tests. Signed-off-by: Steven Rostedt (Google) Signed-off-by: Borislav Petkov (AMD) Acked-by: Masami Hiramatsu (Google) Acked-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20230531092419.4d051374@rorschach.local.home --- arch/x86/kernel/alternative.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 0747d29..bbfbf7a 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -2119,6 +2119,16 @@ static void text_poke_bp_batch(struct text_poke_loc *tp, unsigned int nr_entries atomic_set_release(&bp_desc.refs, 1); /* + * Function tracing can enable thousands of places that need to be + * updated. This can take quite some time, and with full kernel debugging + * enabled, this could cause the softlockup watchdog to trigger. + * This function gets called every 256 entries added to be patched. + * Call cond_resched() here to make sure that other tasks can get scheduled + * while processing all the functions being patched. + */ + cond_resched(); + + /* * Corresponding read barrier in int3 notifier for making sure the * nr_entries and handler are correctly ordered wrt. patching. */