From patchwork Tue Jun 8 13:55:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12306861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF361C47082 for ; Tue, 8 Jun 2021 13:56:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C7F8D61351 for ; Tue, 8 Jun 2021 13:56:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232752AbhFHN6X (ORCPT ); Tue, 8 Jun 2021 09:58:23 -0400 Received: from mail-wm1-f49.google.com ([209.85.128.49]:42644 "EHLO mail-wm1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233017AbhFHN6W (ORCPT ); Tue, 8 Jun 2021 09:58:22 -0400 Received: by mail-wm1-f49.google.com with SMTP id l7-20020a05600c1d07b02901b0e2ebd6deso1934836wms.1 for ; Tue, 08 Jun 2021 06:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=55oWRdipxyNAdejx6zL6X9rpYX6wUCaJnDfUsVrLRsE=; b=gAE1DyfNcoBi3YsZ2dG/jN3TMkeLmcFPzNEscn7d8zNbW9g5+7CcfpPhO9FkhG92+y aVHCbkNk1+kJalW7xCD7xVM8Ra4ZPBN7awyXlFxzHIH4HhOX3QG3w7Ds0nDbkU9Pa3r5 MyMd08H7OqXgLN02Uw5078cXKiJ4rVee7g9+kZ8eHuYJaZxVo6Od7CHfNR9he8GcMJ5D 2ESD1g45lQbFI2XZmqUl1qo2jDjI1UZf9kL9w2zrQsYQMSLJC7qQ8Y1mDHiVAfICC0+Q YTWLFBLAh108kDrug4F0hIDeIUOJD2utWXcBO4CYIHad/sH2VBdzdAYKKtSqnImAhTaz 0VMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=55oWRdipxyNAdejx6zL6X9rpYX6wUCaJnDfUsVrLRsE=; b=IMBthfYSab7xagROdg3Dr5fYVx7RCjIRwOG5oqpvQC5IiqWHa8Fymwy6eXIIX1QLDV NT9x1UN0z3gDcsFVkDb4eFuSX5Tz8p34/4QKnVnCi3mAo4+1MqfNGHBwgprRgKoJOdMh H+6sJH1WJ410VNBh1uJotYSGpoc4xvwew1LyH/iutskn2CRLMTD+F11eY5TK7AquhJYH 2eJTMONyf/VH0KLuCYYWDkWk4hjTzJ8sM+I2Bu+eYjlFH/J1BqxM8wNYp//iEMM4DfFf d2x6rkhXhzKNhScBGqzLOaZdA7p4CHv5j749dIFsudQ39mBebEF2NQHIQc+zSzv1CzfF GV1A== X-Gm-Message-State: AOAM531U/62tXGFnka0OG846ZcOHlUlJqbAw5+zLyDdY9SmrsUf44Z97 AfnWKllIB7uufJPXLtCBwgQ= X-Google-Smtp-Source: ABdhPJw1gUc+9kG4DW11IvaE5qrWtT7lgCk0fa9dMU90usgQnloMrEQfcE/LVWkXQLKNv31DMSE41Q== X-Received: by 2002:a05:600c:5122:: with SMTP id o34mr14200388wms.168.1623160516070; Tue, 08 Jun 2021 06:55:16 -0700 (PDT) Received: from localhost.localdomain ([84.40.73.164]) by smtp.gmail.com with ESMTPSA id w13sm6806973wmi.48.2021.06.08.06.55.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 06:55:15 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Yordan Karadzhov (VMware)" Subject: [PATCH 1/4] libtracefs: Fix enable_disable_all() return value Date: Tue, 8 Jun 2021 16:55:00 +0300 Message-Id: <20210608135503.12135-1-y.karadz@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org enable_disable_all() is a static method used internally by the tracefs_event_enable/disable() API. In some cases its return value gets propagated as a return of the API function but this value do not obey the description given in the documentation. Fixes: fc94d1a (libtracefs: Add tracefs_event_enable/disable() API) Signed-off-by: Yordan Karadzhov (VMware) --- src/tracefs-events.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tracefs-events.c b/src/tracefs-events.c index 55316c6..8b2d9ef 100644 --- a/src/tracefs-events.c +++ b/src/tracefs-events.c @@ -822,8 +822,10 @@ static int enable_disable_all(struct tracefs_instance *instance, bool enable) { const char *str = enable ? "1" : "0"; + int ret; - return tracefs_instance_file_write(instance, "events/enable", str); + ret = tracefs_instance_file_write(instance, "events/enable", str); + return ret < 0 ? ret : 0; } static int event_enable_disable(struct tracefs_instance *instance, From patchwork Tue Jun 8 13:55:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12306855 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CFBAC47082 for ; Tue, 8 Jun 2021 13:55:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED6A16134F for ; Tue, 8 Jun 2021 13:55:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232752AbhFHN5Y (ORCPT ); Tue, 8 Jun 2021 09:57:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232341AbhFHN5X (ORCPT ); Tue, 8 Jun 2021 09:57:23 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91AC7C061787 for ; Tue, 8 Jun 2021 06:55:20 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id d184so1936533wmd.0 for ; Tue, 08 Jun 2021 06:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mZcW/VyvthwwS3Yln3hBopaQYabd9Gfkvtj8854YCm0=; b=Jf4w11w5I5Yez9ZJjGt3Z23ds5RdWkIHSdmp6Pu+PyodHNj9SBGBx2xX+I3IVcVLJw IAG+WpuPjLNuj0SnTYVbDTTOzm37R8KE4y+rx8ZITjfXNMjFTXHokXOWcarBiEDPBAtO Gu/gfKoqJunVSOB2ZENXbz7Ij7rR1xTzZL2Zk/heUjR5SKN6P3NOO9r++MP2s4LisDDP F4FjSZWabYmHNw/QnW/HSECYt1exSNWoFaLS3LeWjXPJdW75pEMw2zpEpNyxxPvLdroJ C2skOBt9TI3MQbPyMBz3rsqJ5CfU+whbu85gK0+1B4O+sHR/WaTD+QPM4bMmT+VG0DqP 7JXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mZcW/VyvthwwS3Yln3hBopaQYabd9Gfkvtj8854YCm0=; b=DB/LfF0hcLNNpZXY9IISwjdpeUTmkvThnyon05cb+Bq1+KJ4kWbXcb/MTi/W0xv3Xf wXuYObyvA/0zIqCip66AZgwvCTZcDXOkd/FA+6mguKGXMOzvkdO3Xn83OoZTHzlO5x78 GhhPLFj+FN5DfQUQOR3BG0cC0v5IfpYhCFpVa5L1eqiBKLDCSkkZ2wYsXEzezw2Ehbwk UCeir02sdDCAe3cpx8g5ymi2FSDbo1+b/G03xeuTwALpO3DbZPEYFCAgArpsHvMOfbQv x5R3qG4W/nNKc8f8WOe3OBPFz3LEOGIslP/oVge7J29YLTLQ94M5WybiU3L0ArhJzJ0B +rEw== X-Gm-Message-State: AOAM532MkAlpm9SE1UstgKOGY50AVbASBGJc3JaKL6ICInF6dxlhVb5f ejc34l0qii1jwOqAJY+QSxOerCB/b88= X-Google-Smtp-Source: ABdhPJy2qn/ruceBQy668wNatZKtVGrKs8QmfWtMfwc8f7ojyVVTFuVsVayXTo3L01grrJ2wSRCDzg== X-Received: by 2002:a05:600c:4f4a:: with SMTP id m10mr10084353wmq.51.1623160517366; Tue, 08 Jun 2021 06:55:17 -0700 (PDT) Received: from localhost.localdomain ([84.40.73.164]) by smtp.gmail.com with ESMTPSA id w13sm6806973wmi.48.2021.06.08.06.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 06:55:16 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Yordan Karadzhov (VMware)" Subject: [PATCH 2/4] libtracefs: Fix event_enable_disable() return value Date: Tue, 8 Jun 2021 16:55:01 +0300 Message-Id: <20210608135503.12135-2-y.karadz@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210608135503.12135-1-y.karadz@gmail.com> References: <20210608135503.12135-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org event_enable_disable() is a static method used internally by the tracefs_event_enable/disable() API. The returned value do not obey the description given in the documentation. Note that "ret" must be set to -1 right before the beginning of the loop. Fixes: fc94d1a (libtracefs: Add tracefs_event_enable/disable() API) Signed-off-by: Yordan Karadzhov (VMware) --- src/tracefs-events.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tracefs-events.c b/src/tracefs-events.c index 8b2d9ef..0fef64f 100644 --- a/src/tracefs-events.c +++ b/src/tracefs-events.c @@ -835,7 +835,7 @@ static int event_enable_disable(struct tracefs_instance *instance, regex_t system_re, event_re; char **systems; char **events = NULL; - int ret = -1; + int ret; int s, e; /* Handle all events first */ @@ -860,6 +860,7 @@ static int event_enable_disable(struct tracefs_instance *instance, } } + ret = -1; for (s = 0; systems[s]; s++) { if (system && !match(systems[s], &system_re)) continue; From patchwork Tue Jun 8 13:55:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12306857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4E08C47082 for ; Tue, 8 Jun 2021 13:55:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9217161351 for ; Tue, 8 Jun 2021 13:55:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232951AbhFHN51 (ORCPT ); Tue, 8 Jun 2021 09:57:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232894AbhFHN51 (ORCPT ); Tue, 8 Jun 2021 09:57:27 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 506CBC061574 for ; Tue, 8 Jun 2021 06:55:20 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id t4-20020a1c77040000b029019d22d84ebdso2016964wmi.3 for ; Tue, 08 Jun 2021 06:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uXsrh8XAqCRsJNUF8izn/jBJQ2kGPlJB7DeWfnr9SFY=; b=Kt4bWoMdPz9DfttmCrmpBWZ3ihCgrllN6TNSmqOvixFd6AEww7fojstQMZd+bVYTKl ghjkRoTAM0vlDDM1s/H6ODLXp50jl16v+DfndReQEiC6vF59zTqzCgAbPycUVSiPFssj No1mZvonb3Y8DNx0mLZuWNR31jwQdMZ+gwNIp9kZ4Avza/23JmWVfOCjkkBBuKoUtCev 2jEc1dD3nJgfH9853zrb4cFWmS3dFz+sGIy+ajtoYi2zbq3Sl3ntmxiZxXbjVNrh9DXM bcE9H1Z+M2f8iZjBwMT4GJUERAA9TErhrPjk/T4lsBHH9eicESU4bUhXhQnClQvhrRhf mVFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uXsrh8XAqCRsJNUF8izn/jBJQ2kGPlJB7DeWfnr9SFY=; b=YtEFNDIExRLtbOrPEIdKCCpyHebq9lkWhtplqa6xvb4XhYjMCQ57ag7109Emq8c/1d gx1frM7Xsq3beHB0mzb7Sow3kyjszL8mpkQe5veDTUwaq1HQWXaLiA80aH/L550U+HBL SxFJF6hmK1ecC9yD10PlKH0qAjiT4A4K7JQ12XNeHx5k1UHXOaClHl06UtbKimS7NQW4 9UTV02U2WHa84LuYN+w2YEuaXI4gpG3KdE6IATcO397He2/VFEFn6TsaYdODtgGhOocp 012vgV7f15gY4CHqFkJxLPDDdp8oqk7u0bjylQFLfYDVe8Io5mPduRURTytYWSGkbMyk hUkQ== X-Gm-Message-State: AOAM533AVuJsa69h5X8kBr6cBNn41+EeGZ8fEhMy09mjwvJ8f4ZueHO7 pyE95mJRqq4tP9nKpE9psVo= X-Google-Smtp-Source: ABdhPJyYi+nWFD8nDhnXbpdx6L+mcVo+UXg+kRSWdKRVOTNIYfir4xld3fghbLy6QaQS/pOVkbu+xw== X-Received: by 2002:a05:600c:4fd6:: with SMTP id o22mr22243092wmq.83.1623160518117; Tue, 08 Jun 2021 06:55:18 -0700 (PDT) Received: from localhost.localdomain ([84.40.73.164]) by smtp.gmail.com with ESMTPSA id w13sm6806973wmi.48.2021.06.08.06.55.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 06:55:17 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Yordan Karadzhov (VMware)" Subject: [PATCH 3/4] libtracefs: Fix typo in function name Date: Tue, 8 Jun 2021 16:55:02 +0300 Message-Id: <20210608135503.12135-3-y.karadz@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210608135503.12135-1-y.karadz@gmail.com> References: <20210608135503.12135-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Fixes: 5c013e7 (libtracefs: New APIs for trace options) Signed-off-by: Yordan Karadzhov (VMware) --- include/tracefs.h | 2 +- src/tracefs-tools.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/tracefs.h b/include/tracefs.h index 08dda13..e29b550 100644 --- a/include/tracefs.h +++ b/include/tracefs.h @@ -159,7 +159,7 @@ bool tracefs_option_is_supported(struct tracefs_instance *instance, enum tracefs const struct tracefs_options_mask *tracefs_options_get_enabled(struct tracefs_instance *instance); bool tracefs_option_is_enabled(struct tracefs_instance *instance, enum tracefs_option_id id); int tracefs_option_enable(struct tracefs_instance *instance, enum tracefs_option_id id); -int tracefs_option_diasble(struct tracefs_instance *instance, enum tracefs_option_id id); +int tracefs_option_disable(struct tracefs_instance *instance, enum tracefs_option_id id); const char *tracefs_option_name(enum tracefs_option_id id); enum tracefs_option_id tracefs_option_id(const char *name); diff --git a/src/tracefs-tools.c b/src/tracefs-tools.c index 993fb3c..ca40d4d 100644 --- a/src/tracefs-tools.c +++ b/src/tracefs-tools.c @@ -307,13 +307,13 @@ int tracefs_option_enable(struct tracefs_instance *instance, enum tracefs_option } /** - * tracefs_option_diasble - Disable trace option + * tracefs_option_disable - Disable trace option * @instance: ftrace instance, can be NULL for the top instance * @id: trace option id * * Returns -1 in case of an error or 0 otherwise */ -int tracefs_option_diasble(struct tracefs_instance *instance, enum tracefs_option_id id) +int tracefs_option_disable(struct tracefs_instance *instance, enum tracefs_option_id id) { return trace_config_option(instance, id, false); } From patchwork Tue Jun 8 13:55:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12306859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0661C47082 for ; Tue, 8 Jun 2021 13:56:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6DB460240 for ; Tue, 8 Jun 2021 13:56:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232874AbhFHN6M (ORCPT ); Tue, 8 Jun 2021 09:58:12 -0400 Received: from mail-wm1-f42.google.com ([209.85.128.42]:36750 "EHLO mail-wm1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233017AbhFHN6M (ORCPT ); Tue, 8 Jun 2021 09:58:12 -0400 Received: by mail-wm1-f42.google.com with SMTP id h11-20020a05600c350bb02901b59c28e8b4so1533953wmq.1 for ; Tue, 08 Jun 2021 06:56:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KOFWTsW32zObIKhBdqXmbhJ+NsPRPsEuIHdG7g4sxAI=; b=cneC/vVvOB4FTt6t62HGRC51tr0iITryHTpDYuQYXIQxPoiDViKILmZFYWR+r4Q1uI RK/E2P6K3ESBOjDbJOnmtZ39L612XSNrNfIrjI13LTFj9fulXLyvvCYpbAJcY2GD+kLh jetFSPo4TiACQVlFf5k+z/AN+vYRAIGmBXQajvNvrZbpGISlA/u5zWmag4duZoI0unn8 D0x/e5ET7xLygrL7d5Kg22VoIDJTHAjrATmKFvlbz/BXBLfjpPZrJA1veuBIYfj4TN9I LYk7WX59qsBt67kyzUNSTHqK0JlyDmPgtG4GJfw4GlfL6yhWvRP7ntrF7Ua4AwMkKHhe ZpsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KOFWTsW32zObIKhBdqXmbhJ+NsPRPsEuIHdG7g4sxAI=; b=Laei0u5VBp918Bjn1AW5pdYO0ubePZT8NqVhvNxEqDZVuaKJEAMCHvRQnATwuPhX+3 i80KPHsXt+ooFCwtfY/jbD5zxL2YwrgcM6ZGxqlz1hQ37slqDEkCHqY58nqngYo/kcHi DBvfFTAX2OTb+bsFGCkGaUKkNS6w9o6rjeiPCvLZkYCSYG1sqBQ5WrKuQvUwow5lGQYe r3uyjyeZVfT1RY/p/7QIO808qg9gv2Lv7+yGW5y/wIvUmIRjbYUMYBhrRyra/tLWggyB nItMy818TJiQOOLfniXXsDHghW0SDsZbev7B4H/srNpu5n+ZERsJqiljBTxBVWVlcUAe UvWA== X-Gm-Message-State: AOAM531MzS/9Afax5SjqWjraOMcCxw5ufO+Bf3akZw0ipIU84me6Idv2 +Gls1r1F/BITtg86KMUpqp8= X-Google-Smtp-Source: ABdhPJxHbQdDyZCwpQ0PWmsvE1ibqoXhmAWvimP4Z5wFjGqg14bVNOJvBMqgLKKUR1N1u3cvMe+JgA== X-Received: by 2002:a7b:cbd1:: with SMTP id n17mr22942730wmi.2.1623160518792; Tue, 08 Jun 2021 06:55:18 -0700 (PDT) Received: from localhost.localdomain ([84.40.73.164]) by smtp.gmail.com with ESMTPSA id w13sm6806973wmi.48.2021.06.08.06.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 06:55:18 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Yordan Karadzhov (VMware)" Subject: [PATCH 4/4] libtracefs: Propagate the return value of the callback function Date: Tue, 8 Jun 2021 16:55:03 +0300 Message-Id: <20210608135503.12135-4-y.karadz@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210608135503.12135-1-y.karadz@gmail.com> References: <20210608135503.12135-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Currently the return value of the callback function can be used to stop pulling data from the trace buffer, however this return value is lost and the user has no idea if tracefs_iterate_raw_events() terminated because there was no more data or because this was requested from the callback function. If we propagate the return value of the callback, this can be used in cases like the one below: int callback(struct tep_event *event, struct tep_record *record, int cpu, void *py_func) { .... return (something) ? 0 : 1 } int main() { int ret; .... while(ret == 0) ret = tracefs_iterate_raw_events(tep, instance, NULL, 0, callback, NULL); .... Here the user can effectively terminate the pulling the data from inside the callback. Signed-off-by: Yordan Karadzhov (VMware) --- src/tracefs-events.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tracefs-events.c b/src/tracefs-events.c index 0fef64f..0a87d28 100644 --- a/src/tracefs-events.c +++ b/src/tracefs-events.c @@ -131,7 +131,8 @@ static int read_cpu_pages(struct tep_handle *tep, struct cpu_iterate *cpus, int } if (j < count) { if (callback(cpus[j].event, &cpus[j].record, cpus[j].cpu, callback_context)) - break; + return -1; + cpus[j].event = NULL; read_next_record(tep, cpus + j); } else {