From patchwork Wed Jun 21 16:29:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 111186 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4501373vqr; Wed, 21 Jun 2023 09:47:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4v6LdAXdTZMs8/z8m86nAUuwnidRTEEdQg2pvP9Y17MGIPn3HFBit5opWKlJNANIoL4vm3 X-Received: by 2002:a05:6a00:2288:b0:668:79d6:34dc with SMTP id f8-20020a056a00228800b0066879d634dcmr6594765pfe.10.1687366032512; Wed, 21 Jun 2023 09:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687366032; cv=none; d=google.com; s=arc-20160816; b=tV1x6T7wIrfiXEkSeIOB1Ar6R+NZ0O8O2sFH0E4vBx58OSEJh2gJY7w5CKk/kh1AX8 Z2dFR5kZtnBYlwgoR1WxUtcvZBLuGqghxrxrcXctapxqAIssN9YrcPfqanf8i1ZSm7kf EOJJL+olbTgTTL7RYlQmmG2KlFKiI23OUz1C6vIAjcNaUCTSnv2IgDnvYMfQ6Upws72t ARG0GZfiW9jjP4rSyD200S1wEGtDyjxoFbjT04A9qLRZdBfa9wjN4aQ+qitIlZKNJbMa /wz5gowIQVSLS9lP8aqsgR4hqC+7Nyx4qXql4j2PEMWTow/a/i2lQEkGZnosLODdonHS aVeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id; bh=xC/A/3xMhqneI9tBtyI8nmKB4KYE+WCp3kpKvLkrHQU=; b=02rdM1z9duBw7RSSNlBoHYCjtqjhfMnE/mshDAo90Rl82aXL7yumJUR3wOTg+SnKFQ JjAKD9aIoaY1hlJU4pKB5Y71x4bZVoaVKrhZpDC4CR+mmrrZoaPtpZ1zglF21kwvLmZO 3wJyUJzK6ki1iQg0pBA453W1FLFtS6Yqz6etkdvxwUgmTv+WcAqD2lLL+O9AFanU4dJl f9djHWdGuuAy/fFuNcxrc2agVxhV4hNdKPLerHSO2NV2agNuseAWS85d3Q4FAoBvHaIX Ypg5+MtQ3rbhDcP1Ui1ZVLAXlmEDxngY8RrSfWFmjEQAMdWtpalkBcc/Rf+IYtV8QKyx KcWA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a29-20020aa794bd000000b00660d2553147si4217244pfl.212.2023.06.21.09.46.59; Wed, 21 Jun 2023 09:47:12 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232520AbjFUQad (ORCPT + 99 others); Wed, 21 Jun 2023 12:30:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232406AbjFUQ35 (ORCPT ); Wed, 21 Jun 2023 12:29:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7AB9171C for ; Wed, 21 Jun 2023 09:29:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8C77961627 for ; Wed, 21 Jun 2023 16:29:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67D0DC433C0; Wed, 21 Jun 2023 16:29:47 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from ) id 1qC0iI-001ynt-1c; Wed, 21 Jun 2023 12:29:46 -0400 Message-ID: <20230621162946.318422585@goodmis.org> User-Agent: quilt/0.66 Date: Wed, 21 Jun 2023 12:29:33 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Andrew Morton , Juri Lelli , William White , Daniel Bristot de Oliveira , Jonathan Corbet Subject: [for-next][PATCH 10/13] tracing/osnoise: Skip running osnoise if all instances are off References: <20230621162923.953123395@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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?1769331525019880726?= X-GMAIL-MSGID: =?utf-8?q?1769331525019880726?= From: Daniel Bristot de Oliveira In the case of all tracing instances being off, sleep for the entire period. Q: Why not kill all threads so? A: It is valid and useful to start the threads with tracing off. For example, rtla disables tracing, starts the tracer, applies the scheduling setup to the threads, e.g., sched priority and cgroup, and then begin tracing with all set. Skipping the period helps to speed up rtla setup and save the trace after a stop tracing. Link: https://lkml.kernel.org/r/aa4dd9b7e76fcb63901fe5407e15ec002b318599.1686063934.git.bristot@kernel.org Cc: Juri Lelli Cc: William White Cc: Daniel Bristot de Oliveira Cc: Masami Hiramatsu Cc: Jonathan Corbet Signed-off-by: Daniel Bristot de Oliveira Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_osnoise.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c index c265ec5f1726..220172cb874d 100644 --- a/kernel/trace/trace_osnoise.c +++ b/kernel/trace/trace_osnoise.c @@ -1285,6 +1285,22 @@ static __always_inline void osnoise_stop_tracing(void) rcu_read_unlock(); } +/* + * osnoise_has_tracing_on - Check if there is at least one instance on + */ +static __always_inline int osnoise_has_tracing_on(void) +{ + struct osnoise_instance *inst; + int trace_is_on = 0; + + rcu_read_lock(); + list_for_each_entry_rcu(inst, &osnoise_instances, list) + trace_is_on += tracer_tracing_is_on(inst->tr); + rcu_read_unlock(); + + return trace_is_on; +} + /* * notify_new_max_latency - Notify a new max latency via fsnotify interface. */ @@ -1517,13 +1533,16 @@ static struct cpumask save_cpumask; /* * osnoise_sleep - sleep until the next period */ -static void osnoise_sleep(void) +static void osnoise_sleep(bool skip_period) { u64 interval; ktime_t wake_time; mutex_lock(&interface_lock); - interval = osnoise_data.sample_period - osnoise_data.sample_runtime; + if (skip_period) + interval = osnoise_data.sample_period; + else + interval = osnoise_data.sample_period - osnoise_data.sample_runtime; mutex_unlock(&interface_lock); /* @@ -1604,8 +1623,14 @@ static int osnoise_main(void *data) if (osnoise_migration_pending()) break; + /* skip a period if tracing is off on all instances */ + if (!osnoise_has_tracing_on()) { + osnoise_sleep(true); + continue; + } + run_osnoise(); - osnoise_sleep(); + osnoise_sleep(false); } migrate_enable();