Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3119506pxm; Mon, 28 Feb 2022 12:26:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+en5hgGAtUh3GoGmAJ5PEVpbAPGOvf9jawl6hJdS5hqmHgDwKqih+VU5MMQ8LKI3exaP5 X-Received: by 2002:a17:902:a613:b0:151:7d6d:aa69 with SMTP id u19-20020a170902a61300b001517d6daa69mr829435plq.89.1646079966622; Mon, 28 Feb 2022 12:26:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646079966; cv=none; d=google.com; s=arc-20160816; b=uztmHTWmSdu6vm8L+pNqPHtoY0ML81d7N0pEOIjuiGaebnfkEO01HgO+q822AlruvG w2IwovON3zL6Z6M5xI8Ak3gAuu6nzlneYxDNLOpnU0/89EC6HCcluXgkYQ7zDfsc7PN8 qIuC461y1qT/s/Q/oDPXMmQ3wKPn7404TlNwYtK7WfiBLvO1oryf9yQ3T7gy9jTin6lz SYw2hz2HCqpD2q03RZw9ZUCbKv5e0ZM/YaigSOWtKZvuR9n6ckwyNuvNtHYchn+kehcc 7PYN/eTRknMJGqFCNcUAwBnjTipcWKssyVs8Aq398VushLNp9YKvjcqDqlXW6IMaByRO SO0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=wCPb9MgVaOcOJoZkX4FgTb7M+7eKEToYbfOjpRK5g60=; b=zHgf98inXDoJheiMY/Tv4YgQZOi0PcS9CGUdgz8QyP3bjWbmeres9Fd53SLrujlxVu NzXq7zpmmEZPKbzMtM6WikIYiXvU9Wn+AZ+XQ7Sy4FcLrPVgmh9nl46LdRxSeFudHYkf xgl/yE2T/A0wMwmAMuhsc7p3MbbbNsR7xoNscq8yga9XP36bsZIyBOgM6R+G1rcjigUn q3dhxxJi/qxjH/dJIAT+ShGCzNUoqjkw+bFTp+k5NuMOe/WZvaqqXqPHCPVSIQI7fjWr 419uqNALEgF15ESb7csfcSGjGyaLGNak1IYb/+r0DF6GbpX3n6/XSt9Ekyu2Dkt0w9Xw oW0A== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020a170902eb8f00b00151559fadd9si6063849plg.265.2022.02.28.12.25.50; Mon, 28 Feb 2022 12:26:06 -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; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229558AbiB1UZo (ORCPT + 99 others); Mon, 28 Feb 2022 15:25:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbiB1UZn (ORCPT ); Mon, 28 Feb 2022 15:25:43 -0500 X-Greylist: delayed 1345 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 28 Feb 2022 12:25:03 PST Received: from gateway30.websitewelcome.com (gateway30.websitewelcome.com [192.185.180.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C16A256C15 for ; Mon, 28 Feb 2022 12:25:03 -0800 (PST) Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 0E9D9B239 for ; Mon, 28 Feb 2022 14:02:38 -0600 (CST) Received: from gator4132.hostgator.com ([192.185.4.144]) by cmsmtp with SMTP id OmC6nxGp022u3OmC7nw2sw; Mon, 28 Feb 2022 14:00:33 -0600 X-Authority-Reason: nr=8 Received: from host-95-232-30-176.retail.telecomitalia.it ([95.232.30.176]:40014 helo=[10.0.0.45]) by gator4132.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1nOmC5-004Kdt-G2; Mon, 28 Feb 2022 14:00:29 -0600 Message-ID: <137d3573-051f-5374-70d6-cc99b44d00da@kernel.org> Date: Mon, 28 Feb 2022 21:00:26 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] tracing/osnoise: Force quiescent states while tracing Content-Language: en-US To: Nicolas Saenz Julienne , rostedt@goodmis.org, paulmck@kernel.org Cc: mingo@redhat.com, linux-kernel@vger.kernel.org, mtosatti@redhat.com References: <20220228141423.259691-1-nsaenzju@redhat.com> From: Daniel Bristot de Oliveira In-Reply-To: <20220228141423.259691-1-nsaenzju@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4132.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - kernel.org X-BWhitelist: no X-Source-IP: 95.232.30.176 X-Source-L: No X-Exim-ID: 1nOmC5-004Kdt-G2 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: host-95-232-30-176.retail.telecomitalia.it ([10.0.0.45]) [95.232.30.176]:40014 X-Source-Auth: kernel@bristot.me X-Email-Count: 2 X-Source-Cap: YnJpc3RvdG1lO2JyaXN0b3RtZTtnYXRvcjQxMzIuaG9zdGdhdG9yLmNvbQ== X-Local-Domain: no X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_SOFTFAIL, T_SCC_BODY_TEXT_LINE autolearn=no 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 On 2/28/22 15:14, Nicolas Saenz Julienne wrote: > At the moment running osnoise on an isolated CPU and a PREEMPT_RCU > kernel might have the side effect of extending grace periods too much. > This will eventually entice RCU to schedule a task on the isolated CPU > to end the overly extended grace period, adding unwarranted noise to the > CPU being traced in the process. > > So, check if we're the only ones running on this isolated CPU and that > we're on a PREEMPT_RCU setup. If so, let's force quiescent states in > between measurements. > > Non-PREEMPT_RCU setups don't need to worry about this as osnoise main > loop's cond_resched() will go though a quiescent state for them. > > Note that this same exact problem is what extended quiescent states were > created for. But adapting them to this specific use-case isn't trivial > as it'll imply reworking entry/exit and dynticks/context tracking code. > > Signed-off-by: Nicolas Saenz Julienne > --- > kernel/trace/trace_osnoise.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c > index 870a08da5b48..4928358f6e88 100644 > --- a/kernel/trace/trace_osnoise.c > +++ b/kernel/trace/trace_osnoise.c > @@ -21,7 +21,9 @@ > #include > #include > #include > +#include > #include > +#include > #include > #include > #include "trace.h" > @@ -1295,6 +1297,7 @@ static int run_osnoise(void) > struct osnoise_sample s; > unsigned int threshold; > u64 runtime, stop_in; > + unsigned long flags; > u64 sum_noise = 0; > int hw_count = 0; > int ret = -1; > @@ -1386,6 +1389,22 @@ static int run_osnoise(void) > osnoise_stop_tracing(); > } > > + /* > + * Check if we're the only ones running on this nohz_full CPU > + * and that we're on a PREEMPT_RCU setup. If so, let's fake a > + * QS since there is no way for RCU to know we're not making > + * use of it. > + * > + * Otherwise it'll be done through cond_resched(). > + */ > + if (IS_ENABLED(CONFIG_PREEMPT_RCU) && > + !housekeeping_cpu(raw_smp_processor_id(), HK_FLAG_MISC) && Does this restrict to only isolcpus cpus? what if this CPU was isolated via other methods? > + tick_nohz_tick_stopped()) { > + local_irq_save(flags); This code is always with interrupts enabled, so local_irq_disable()/enable() should be enough (and faster). > + rcu_momentary_dyntick_idle(); > + local_irq_restore(flags); > + } Question, if we set this once, we could avoid setting it on every loop unless we have a preemption from another thread, right? > /* > * For the non-preemptive kernel config: let threads runs, if > * they so wish. /me keeps playing with this patch. -- Daniel