Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp961980pxp; Wed, 16 Mar 2022 22:45:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxizfCtdVM7aBJgtr1AzXQemkTplb71Tqw1ef7HNMnEE0QSkzLg7VL4Uf5LArXlPRb1MbHq X-Received: by 2002:a05:6a00:15cc:b0:4f7:bcb1:cda4 with SMTP id o12-20020a056a0015cc00b004f7bcb1cda4mr3024649pfu.74.1647495916507; Wed, 16 Mar 2022 22:45:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647495916; cv=none; d=google.com; s=arc-20160816; b=L4fFNdylMMRjlts/C0SGCDbWBa0d8qEPa4u0UVpG6v9Fp2lTfe6rUfMFludlvdFBK+ +1KLPyY22EmSgUFflr358loqpEhi1xbrAirSTb7kyhlf8R4jGp5jYf8GMSN6nbJDsyh3 9+TCUWD6G14JLIF15rZ0hQnLO+CZa2LIlw9BqflxGM8110hwTcvUETpL7oNTxhrpuO1B /Xf3NizJTMF749Pgdg13k0MREWFyXbl7SCuaO6VYkIdrppK5utwCkxKPmLBL/K6oT9Tc Hssvs6oK9lG9SWwlVvGW+gd2MUpQjIJXU09FhMNrHuV9Wk0H5xmIXd4hvceR/MPsaFFh 4iRQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rvLEscsRSjT8btHkQkiJHEHfTOzKxheoENM8t3GichA=; b=s4JHYP+ShGqNF9gM4Rw33LTkAMnroHZBqv/AaO/PATG7zy9s4ytXY+aorBZvelpzHi 4GvjQlpfxNBDTMSYAtXemybDDvKbRAeb3m2dM53mpPzvCOUCc5AFFjITICeJ3KJN1u/U J4PRrm2mHCuNnqzdvJYKTJdml1QIAubu3hEeYm8Z4kTD1SJZqdFsO/WyiioxjxjdHlw6 CS9XBbYXG1k0EkzpKfxO2cvo7mXehPIDOpFiq56LcnnfcIKBiEtk5FmfRph6qg411cyI Q+oGSZ62eCCRkZT4fv/XSymuvzG98R7HhU9ks8eqfN9NuPC96yB0WdsGCHvEHi21zPOV a34g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kp0aN0M6; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e16-20020a170902ef5000b00153a066a538si3612056plx.520.2022.03.16.22.45.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 22:45:16 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kp0aN0M6; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C32CA11D7BC; Wed, 16 Mar 2022 21:39:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242249AbiCNM3Y (ORCPT + 99 others); Mon, 14 Mar 2022 08:29:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243865AbiCNMVU (ORCPT ); Mon, 14 Mar 2022 08:21:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6A28FC2; Mon, 14 Mar 2022 05:17:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 545D8B80DC0; Mon, 14 Mar 2022 12:17:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F0E7C340E9; Mon, 14 Mar 2022 12:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647260246; bh=yzg5IR4VRVT8Va/TUPQgbSNe9TTJ0bz1xg2lEhxVHlc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kp0aN0M6Kt9/WjCegyiqmdh9xNlYmKlCuGALB/jrlIpy08fofOesOcn0y9Ge3vl6P jrMmAIk+wCvYSuumqggm+3v9Px026qL7hmyzF940pUd0QyZ+HFvB9J2qZbJkGFfjUs 834skQU2BxBNv79AT5WgYW/Sex/kKczV0ki0JNJI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Saenz Julienne , "Paul E. McKenney" , Daniel Bristot de Oliveira , "Steven Rostedt (Google)" Subject: [PATCH 5.16 095/121] tracing/osnoise: Force quiescent states while tracing Date: Mon, 14 Mar 2022 12:54:38 +0100 Message-Id: <20220314112746.765514018@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112744.120491875@linuxfoundation.org> References: <20220314112744.120491875@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Nicolas Saenz Julienne commit caf4c86bf136845982c5103b2661751b40c474c0 upstream. At the moment running osnoise on a nohz_full CPU or uncontested FIFO priority and a PREEMPT_RCU kernel might have the side effect of extending grace periods too much. This will entice RCU to force a context switch on the wayward CPU to end the grace period, all while introducing unwarranted noise into the tracer. This behaviour is unavoidable as overly extending grace periods might exhaust the system's memory. This same exact problem is what extended quiescent states (EQS) were created for, conversely, rcu_momentary_dyntick_idle() emulates them by performing a zero duration EQS. So let's make use of it. In the common case rcu_momentary_dyntick_idle() is fairly inexpensive: atomically incrementing a local per-CPU counter and doing a store. So it shouldn't affect osnoise's measurements (which has a 1us granularity), so we'll call it unanimously. The uncommon case involve calling rcu_momentary_dyntick_idle() after having the osnoise process: - Receive an expedited quiescent state IPI with preemption disabled or during an RCU critical section. (activates rdp->cpu_no_qs.b.exp code-path). - Being preempted within in an RCU critical section and having the subsequent outermost rcu_read_unlock() called with interrupts disabled. (t->rcu_read_unlock_special.b.blocked code-path). Neither of those are possible at the moment, and are unlikely to be in the future given the osnoise's loop design. On top of this, the noise generated by the situations described above is unavoidable, and if not exposed by rcu_momentary_dyntick_idle() will be eventually seen in subsequent rcu_read_unlock() calls or schedule operations. Link: https://lkml.kernel.org/r/20220307180740.577607-1-nsaenzju@redhat.com Cc: stable@vger.kernel.org Fixes: bce29ac9ce0b ("trace: Add osnoise tracer") Signed-off-by: Nicolas Saenz Julienne Acked-by: Paul E. McKenney Acked-by: Daniel Bristot de Oliveira Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_osnoise.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) --- a/kernel/trace/trace_osnoise.c +++ b/kernel/trace/trace_osnoise.c @@ -1388,6 +1388,26 @@ static int run_osnoise(void) } /* + * In some cases, notably when running on a nohz_full CPU with + * a stopped tick PREEMPT_RCU has no way to account for QSs. + * This will eventually cause unwarranted noise as PREEMPT_RCU + * will force preemption as the means of ending the current + * grace period. We avoid this problem by calling + * rcu_momentary_dyntick_idle(), which performs a zero duration + * EQS allowing PREEMPT_RCU to end the current grace period. + * This call shouldn't be wrapped inside an RCU critical + * section. + * + * Note that in non PREEMPT_RCU kernels QSs are handled through + * cond_resched() + */ + if (IS_ENABLED(CONFIG_PREEMPT_RCU)) { + local_irq_disable(); + rcu_momentary_dyntick_idle(); + local_irq_enable(); + } + + /* * For the non-preemptive kernel config: let threads runs, if * they so wish. */