Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1229746pxb; Fri, 18 Feb 2022 03:31:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgZGpappgBFdPztiel4YhobgPKPEIpaKo5O+FJ9rwKDkIM5y/9vTfDyxTtf7UFuhKZzfIN X-Received: by 2002:a17:903:2341:b0:14c:c151:2b0a with SMTP id c1-20020a170903234100b0014cc1512b0amr7175119plh.61.1645183893111; Fri, 18 Feb 2022 03:31:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645183893; cv=none; d=google.com; s=arc-20160816; b=GyjysrdllsUWzXOe2auadsvdz0dJUmC7CTI+Fcafp5Ewq6WjMsjGAv9jQ27EH11CnE U/yjtxCPVqMZfjyw44m4l/953YszSw/IBcxbQQb9AuWh472mCmRnCMmzc1M6cwiWyaHB q+77V6Vj5kTdGNWGbFQb3h3PSuWmf+JaARMmmNaF0wOuHxBMUiGIOZGi72p3utrZOosB TrSF0PjcADfXwvwM2yJIzvDssNzwuL/eXs2BFOSnfRjzfL9Z7tJ8ixm3Y7c9Q1h5DVQd 63UGKEFwaqum2HsQdVjD1aZvX8BkuF6yuVQcDWqJGS6OeHwPJcHPohkvCaRQOrej8Hkj oCAg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=29yMi5UDDn1VkW2oOjnLHVrnLBe0j2ARnrac3Dtnrcw=; b=vXWZwmuinwLdt1eeaFjuAvuoyCBt2QUgakov/cWd6La/UWgv42Zp39N6XY0mGSJnEH aWW1dmNKRF/GitacoWYAl/cmhRN3DV+WN0D55cIDBJsa94a/wPc8B2lE6oTTz8L9+8nB hqSO6jkmtXpKZuWd/FC84bJzOcMC1Vx7FdiXNo5L/1Uo0ZhGf2Pe9YUjlWYGDO+0a87z 3UBfa1dhBiLLX3jlKeM4yrueg4LlUPysJUkNQt+oU+Iafl4Uv6Hi7Dkv9jIDoKq9a67e iRqVotUVV5uC5WSvGuH1UT10g9wHA3hLaWbon8UbiLGw7wT4s+PPwe/Wb7dPAHfFwSux AEyA== 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 u5si24994995plf.139.2022.02.18.03.31.18; Fri, 18 Feb 2022 03:31:33 -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 S234393AbiBRLJx convert rfc822-to-8bit (ORCPT + 99 others); Fri, 18 Feb 2022 06:09:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232636AbiBRLJw (ORCPT ); Fri, 18 Feb 2022 06:09:52 -0500 Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [205.139.111.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 01AB22AEDA2 for ; Fri, 18 Feb 2022 03:09:35 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-592-Pz5iJAAPPi-0QAazgGQkUQ-1; Fri, 18 Feb 2022 06:09:31 -0500 X-MC-Unique: Pz5iJAAPPi-0QAazgGQkUQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 91D9918009C6; Fri, 18 Feb 2022 11:09:30 +0000 (UTC) Received: from x1.com (unknown [10.22.32.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2DAC2B4B9; Fri, 18 Feb 2022 11:09:28 +0000 (UTC) From: Daniel Bristot de Oliveira To: Steven Rostedt Cc: Daniel Bristot de Oliveira , Jonathan Corbet , linux-trace-devel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] rtla/osnoise: Add support to adjust the tracing_thresh Date: Fri, 18 Feb 2022 12:09:13 +0100 Message-Id: <6047c475fedd8f523fff516c313d54fb6a6b402e.1645182327.git.bristot@kernel.org> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset=WINDOWS-1252 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,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 osnoise uses the tracing_thresh parameter to define the delta between two reads of the time to be considered a noise. Add support to get and set the tracing_thresh from osnoise tools. Cc: Daniel Bristot de Oliveira Cc: Steven Rostedt Cc: Jonathan Corbet Cc: linux-trace-devel@vger.kernel.org Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Daniel Bristot de Oliveira --- tools/tracing/rtla/src/osnoise.c | 83 ++++++++++++++++++++++++++++++++ tools/tracing/rtla/src/osnoise.h | 8 +++ 2 files changed, 91 insertions(+) diff --git a/tools/tracing/rtla/src/osnoise.c b/tools/tracing/rtla/src/osnoise.c index 5648f9252e58..0dfce437edf4 100644 --- a/tools/tracing/rtla/src/osnoise.c +++ b/tools/tracing/rtla/src/osnoise.c @@ -655,6 +655,85 @@ void osnoise_put_print_stack(struct osnoise_context *context) context->orig_print_stack = OSNOISE_OPTION_INIT_VAL; } +/* + * osnoise_get_tracing_thresh - read and save the original "tracing_thresh" + */ +static long long +osnoise_get_tracing_thresh(struct osnoise_context *context) +{ + long long tracing_thresh; + + if (context->tracing_thresh != OSNOISE_OPTION_INIT_VAL) + return context->tracing_thresh; + + if (context->orig_tracing_thresh != OSNOISE_OPTION_INIT_VAL) + return context->orig_tracing_thresh; + + tracing_thresh = osnoise_read_ll_config("tracing_thresh"); + if (tracing_thresh < 0) + goto out_err; + + context->orig_tracing_thresh = tracing_thresh; + return tracing_thresh; + +out_err: + return OSNOISE_OPTION_INIT_VAL; +} + +/* + * osnoise_set_tracing_thresh - set "tracing_thresh" + */ +int osnoise_set_tracing_thresh(struct osnoise_context *context, long long tracing_thresh) +{ + long long curr_tracing_thresh = osnoise_get_tracing_thresh(context); + int retval; + + if (curr_tracing_thresh == OSNOISE_OPTION_INIT_VAL) + return -1; + + retval = osnoise_write_ll_config("tracing_thresh", tracing_thresh); + if (retval < 0) + return -1; + + context->tracing_thresh = tracing_thresh; + + return 0; +} + +/* + * osnoise_restore_tracing_thresh - restore the original "tracing_thresh" + */ +void osnoise_restore_tracing_thresh(struct osnoise_context *context) +{ + int retval; + + if (context->orig_tracing_thresh == OSNOISE_OPTION_INIT_VAL) + return; + + if (context->orig_tracing_thresh == context->tracing_thresh) + goto out_done; + + retval = osnoise_write_ll_config("tracing_thresh", context->orig_tracing_thresh); + if (retval < 0) + err_msg("Could not restore original tracing_thresh\n"); + +out_done: + context->tracing_thresh = OSNOISE_OPTION_INIT_VAL; +} + +/* + * osnoise_put_tracing_thresh - restore original values and cleanup data + */ +void osnoise_put_tracing_thresh(struct osnoise_context *context) +{ + osnoise_restore_tracing_thresh(context); + + if (context->orig_tracing_thresh == OSNOISE_OPTION_INIT_VAL) + return; + + context->orig_tracing_thresh = OSNOISE_OPTION_INIT_VAL; +} + /* * enable_osnoise - enable osnoise tracer in the trace_instance */ @@ -716,6 +795,9 @@ struct osnoise_context *osnoise_context_alloc(void) context->orig_print_stack = OSNOISE_OPTION_INIT_VAL; context->print_stack = OSNOISE_OPTION_INIT_VAL; + context->orig_tracing_thresh = OSNOISE_OPTION_INIT_VAL; + context->tracing_thresh = OSNOISE_OPTION_INIT_VAL; + osnoise_get_context(context); return context; @@ -741,6 +823,7 @@ void osnoise_put_context(struct osnoise_context *context) osnoise_put_stop_total_us(context); osnoise_put_timerlat_period_us(context); osnoise_put_print_stack(context); + osnoise_put_tracing_thresh(context); free(context); } diff --git a/tools/tracing/rtla/src/osnoise.h b/tools/tracing/rtla/src/osnoise.h index 9e4b2e2a4559..04a4384cc544 100644 --- a/tools/tracing/rtla/src/osnoise.h +++ b/tools/tracing/rtla/src/osnoise.h @@ -23,6 +23,10 @@ struct osnoise_context { long long orig_timerlat_period_us; long long timerlat_period_us; + /* 0 as init value */ + long long orig_tracing_thresh; + long long tracing_thresh; + /* -1 as init value because 0 is disabled */ long long orig_stop_us; long long stop_us; @@ -67,6 +71,10 @@ int osnoise_set_timerlat_period_us(struct osnoise_context *context, long long timerlat_period_us); void osnoise_restore_timerlat_period_us(struct osnoise_context *context); +int osnoise_set_tracing_thresh(struct osnoise_context *context, + long long tracing_thresh); +void osnoise_restore_tracing_thresh(struct osnoise_context *context); + void osnoise_restore_print_stack(struct osnoise_context *context); int osnoise_set_print_stack(struct osnoise_context *context, long long print_stack); -- 2.34.1