From patchwork Tue Nov 15 20:48:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guilherme G. Piccoli" X-Patchwork-Id: 20556 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2934955wru; Tue, 15 Nov 2022 12:51:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf5gRkWAVWqCvkVEXnU4uQL7O8jI43W1wPYZqwH0QAofXFvdKjjg0vRXQriB1HtFPS5HurmD X-Received: by 2002:a17:906:2509:b0:772:e95f:cdce with SMTP id i9-20020a170906250900b00772e95fcdcemr15530080ejb.78.1668545491934; Tue, 15 Nov 2022 12:51:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668545491; cv=none; d=google.com; s=arc-20160816; b=FBowCeB3csUjDjJ0DzMfxwTLVfDq1FfZ5rmc/muN8W9YZookJ3X9v1gefYNUX8Ptxr KnFpZ7tbW4Q6+mYhKrKAUC+hQzOT7WOT94ZpEjWmpflUESDuHHqCcADA+zhejRKFAB5n d5VOYg+KdF3Q2/s/AQlhCdwQ/kJrDUH42X61cxj4vdAXo8+mXkoJVP6Agv7ybZhED0D/ WG6p0pWUCbAcQJJ2Npp7R2zOrAZeHkgv4iHrzAT4dl7dPwjpBxqhSh2GhmGi/Oirl2FC AXmTmLOJZbxBZtB5WGW4ZxGKoubniEc4o9zw7YZx9kcqUILRejiVyCyV9JsxVkwIcRGp AMZA== 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:dkim-signature; bh=USwSRFESZzf+4Lm757bVfbPV8dteEKJuMeMsGiYUTng=; b=BTpjYmgAZzgkYOLMKuE0H2EjM1x9sNbSDEg+PDHPf5426MDupAwmBK4+F5oWvhYZXX fWRL9MK8gyVsbNVRus6W0OoLAcH9Pxltxt9dkzQVUN/xELFKkXv/+5wXjNnhovS5YbT8 ipfEL/Q20sfUFBnCaDzyAKq5C+SP7nJuvHZMjlqTPI+NBhWjE4KTMnZQXrcRT/OeAk3R w7pMQnr2np9Pcng1dlI1hEWf/9Egam4foBU/zeXjRJMWG+uWI/+ciUE6oKu2SNsanyTL knYftO5ybnwk6pmhUjFY8DU56rl4CBt2oyKhnpKgKTHK4oX3Y1pKaA6d1yQEiKmr/fp+ v1JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=Az8gETdC; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020a17090685c300b007894b9de062si10902632ejy.631.2022.11.15.12.51.07; Tue, 15 Nov 2022 12:51:31 -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=fail header.i=@igalia.com header.s=20170329 header.b=Az8gETdC; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238005AbiKOUtQ (ORCPT + 99 others); Tue, 15 Nov 2022 15:49:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238362AbiKOUtI (ORCPT ); Tue, 15 Nov 2022 15:49:08 -0500 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF41AF7D; Tue, 15 Nov 2022 12:49:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=USwSRFESZzf+4Lm757bVfbPV8dteEKJuMeMsGiYUTng=; b=Az8gETdCuJDCVCYZTqc0emOvy5 S8JcspxVFRr7xQZ+6S2yvPP9FxvyAYrqrOW76JIv9Dr8EplAnCrJYmfTRhS9moibRlpwHeW09M+Cz X3RVi3ljuMOLn7+etzlIX0ijUJAqsW1qntk8UZwH3WzygkgCC/IsbWWOLEznLviLJCGao/tW7fFAp mMHdsPSeq7RoLUI6VpIuMKzc6RV7KZ0JujWfdlpLJecg2ymvEAOVMNoUin2refCPnq51OKv2eCE6y KLfIP8ZxBDg1N5ipZr4s6sJqIvFIpiOUSSWybS6XqJa+6fpbEFiRHi61YcAifW5/3ZtSmoyLIyhLG DY4AXV7g==; Received: from [179.232.147.2] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1ov2rc-001Qk7-2d; Tue, 15 Nov 2022 21:49:00 +0100 From: "Guilherme G. Piccoli" To: linux-kernel@vger.kernel.org, rostedt@goodmis.org Cc: rcu@vger.kernel.org, kernel-dev@igalia.com, kernel@gpiccoli.net, "Guilherme G. Piccoli" , "Paul E . McKenney" , Masami Hiramatsu , Mark Rutland Subject: [PATCH] ftrace: Prevent RCU stall on PREEMPT_VOLUNTARY kernels Date: Tue, 15 Nov 2022 17:48:47 -0300 Message-Id: <20221115204847.593616-1-gpiccoli@igalia.com> X-Mailer: git-send-email 2.38.0 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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?1749596757358696368?= X-GMAIL-MSGID: =?utf-8?q?1749596757358696368?= The function match_records() may take a while due to a large number of string comparisons, so when in PREEMPT_VOLUNTARY kernels we could face RCU stalls due to that. Add a cond_resched() to prevent that. Suggested-by: Steven Rostedt Acked-by: Paul E. McKenney # from RCU CPU stall warning perspective Cc: Masami Hiramatsu Cc: Mark Rutland Signed-off-by: Guilherme G. Piccoli Acked-by: Masami Hiramatsu (Google) --- Hi Steve / Paul, thanks for the discussions on the first thread [0], much appreciated! Here is the "official" version. Steve: lemme know if it's good for you, and in case you prefer to send it yourself (since you proposed it on IRC), fine by me! Paul: kept your ACK (thanks for that BTW) even though I changed the place of cond_resched() to align with Steve's preference. Lemme know in case you want to drop this ACK. Cheers, Guilherme [0] https://lore.kernel.org/lkml/1ef5fe19-a82f-835e-fda5-455e9c2b94b4@igalia.com/ kernel/trace/ftrace.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 7dc023641bf1..80639bdb85f6 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -4192,6 +4192,7 @@ match_records(struct ftrace_hash *hash, char *func, int len, char *mod) } found = 1; } + cond_resched(); } while_for_each_ftrace_rec(); out_unlock: mutex_unlock(&ftrace_lock);