Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7498563rwb; Tue, 15 Nov 2022 13:17:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf4L3TpE0OFyejEQaf2B77RJ3DRdiYJLwey36Ge1nXmZIjsWTRBCJJOoFa4NrLibzznN3xNT X-Received: by 2002:a17:903:1091:b0:187:3c62:5851 with SMTP id u17-20020a170903109100b001873c625851mr5929139pld.127.1668547038247; Tue, 15 Nov 2022 13:17:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668547038; cv=none; d=google.com; s=arc-20160816; b=CRQT3wz8IFgBJRXLhs5x/7UQymsKuMrofOF9pMoIRCLWvV7Lr3Dsk+ZvLedfk9HsZO vHeUtOJkisRr8ZX4DTvZ09lrCrqlaKgFYpWjruiwLqNGdh7IlC6Yn1dTfoWMLRNxKWPW ESj0TFe1VscaOHaO0x//YJEbI6OA/Bj8auoa6rgZFAfb2a30CEIP7JP1oBlTmxFJE4ly xPeimId1NziD+jipv+MU0aTWalB6VBaGtL38dUQjCod+DLz+09e+DhH/c7Dv4WKV5Hvf t9LVIZoYpaiqEfrAe5bMMykZmVusJ9USyUNYMyVPwKRgbvcYiOG+EaErGVMex3Gp2s2i p8QA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b16-20020a170902d51000b001870c4d4378si16248859plg.498.2022.11.15.13.17.03; Tue, 15 Nov 2022 13:17:18 -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 + 90 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 Content-Transfer-Encoding: 8bit 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 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 --- 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); -- 2.38.0