Message ID | 20221115204847.593616-1-gpiccoli@igalia.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> 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 <rfc822;maxim.cournoyer@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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" <gpiccoli@igalia.com> To: linux-kernel@vger.kernel.org, rostedt@goodmis.org Cc: rcu@vger.kernel.org, kernel-dev@igalia.com, kernel@gpiccoli.net, "Guilherme G. Piccoli" <gpiccoli@igalia.com>, "Paul E . McKenney" <paulmck@kernel.org>, Masami Hiramatsu <mhiramat@kernel.org>, Mark Rutland <mark.rutland@arm.com> 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: <linux-kernel.vger.kernel.org> 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?= |
Series |
ftrace: Prevent RCU stall on PREEMPT_VOLUNTARY kernels
|
|
Commit Message
Guilherme G. Piccoli
Nov. 15, 2022, 8:48 p.m. UTC
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 <rostedt@goodmis.org> Acked-by: Paul E. McKenney <paulmck@kernel.org> # from RCU CPU stall warning perspective Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com> --- 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(+)
Comments
On Tue, 15 Nov 2022 17:48:47 -0300 "Guilherme G. Piccoli" <gpiccoli@igalia.com> wrote: > 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 <rostedt@goodmis.org> > Acked-by: Paul E. McKenney <paulmck@kernel.org> # from RCU CPU stall warning perspective > Cc: Masami Hiramatsu <mhiramat@kernel.org> > Cc: Mark Rutland <mark.rutland@arm.com> > Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com> This looks good to me. Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Thanks! > --- > > 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 >
On 16/11/2022 03:36, Masami Hiramatsu (Google) wrote: > [...] > This looks good to me. > > Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> > > Thanks! Thanks for your review/Ack Masami, much appreciated. Cheers, Guilherme
On 16/11/2022 03:36, Masami Hiramatsu (Google) wrote: > On Tue, 15 Nov 2022 17:48:47 -0300 > "Guilherme G. Piccoli" <gpiccoli@igalia.com> wrote: > >> 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 <rostedt@goodmis.org> >> Acked-by: Paul E. McKenney <paulmck@kernel.org> # from RCU CPU stall warning perspective >> Cc: Masami Hiramatsu <mhiramat@kernel.org> >> Cc: Mark Rutland <mark.rutland@arm.com> >> Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com> > > This looks good to me. > > Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> > > Thanks! > Hi Steve, apologies for the ping, just want to ask you if you plan to take this one or should I change something? Thanks in advance, Guilherme
On Tue, 22 Nov 2022 10:16:41 -0300 "Guilherme G. Piccoli" <gpiccoli@igalia.com> wrote: > Hi Steve, apologies for the ping, just want to ask you if you plan to > take this one or should I change something? Thanks in advance, I was traveling for work from Oct 31-Nov 14 and when I got back, I had over 300 patches to review in my queue. I'm now down under 100, so hopefully I can get to it soon. Just may take a bit. Thanks, -- Steve
On 22/11/2022 12:49, Steven Rostedt wrote: > [...] > I was traveling for work from Oct 31-Nov 14 and when I got back, I had over > 300 patches to review in my queue. I'm now down under 100, so hopefully I > can get to it soon. > > Just may take a bit. > > Thanks, > > -- Steve No hurries, thanks for your heads-up! Cheers, Guilherme
On 16/11/2022 03:36, Masami Hiramatsu (Google) wrote: > On Tue, 15 Nov 2022 17:48:47 -0300 > "Guilherme G. Piccoli" <gpiccoli@igalia.com> wrote: > >> 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 <rostedt@goodmis.org> >> Acked-by: Paul E. McKenney <paulmck@kernel.org> # from RCU CPU stall warning perspective >> Cc: Masami Hiramatsu <mhiramat@kernel.org> >> Cc: Mark Rutland <mark.rutland@arm.com> >> Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com> > > This looks good to me. > > Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> > > Thanks! > Hi Steve, sorry to annoy, just a regular ping to see if we can get this into 6.2 (if too late, not a huge deal). Thanks, Guilherme
On Tue, 13 Dec 2022 19:04:41 -0300 "Guilherme G. Piccoli" <gpiccoli@igalia.com> wrote: > Hi Steve, sorry to annoy, just a regular ping to see if we can get this > into 6.2 (if too late, not a huge deal). Thanks for the ping. For some reason this patch didn't make it into my internal Patchwork, so I missed it (even though I did reply to you, I just assumed it was in my patchwork). It's not too late. I have some last minute patches I'm still testing. I'll queue this one up. BTW, we now have a kernel ftrace mailing list that you can Cc (but still Cc LKML). linux-trace-kernel@vger.kernel.org -- Steve
On 13/12/2022 19:34, Steven Rostedt wrote: > On Tue, 13 Dec 2022 19:04:41 -0300 > "Guilherme G. Piccoli" <gpiccoli@igalia.com> wrote: > >> Hi Steve, sorry to annoy, just a regular ping to see if we can get this >> into 6.2 (if too late, not a huge deal). > > Thanks for the ping. For some reason this patch didn't make it into my > internal Patchwork, so I missed it (even though I did reply to you, I just > assumed it was in my patchwork). > > It's not too late. I have some last minute patches I'm still testing. I'll > queue this one up. > > BTW, we now have a kernel ftrace mailing list that you can Cc (but still Cc > LKML). > > linux-trace-kernel@vger.kernel.org > > -- Steve Tnx a lot Steve! I'll start to CC this list as well. Cheers, Guilherme
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);