From patchwork Mon Apr 5 14:21: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: 12182955 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.7 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 D2108C433B4 for ; Mon, 5 Apr 2021 14:21:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8720613B6 for ; Mon, 5 Apr 2021 14:21:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241285AbhDEOVa (ORCPT ); Mon, 5 Apr 2021 10:21:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241301AbhDEOVa (ORCPT ); Mon, 5 Apr 2021 10:21:30 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8C2BC061756 for ; Mon, 5 Apr 2021 07:21:23 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id h10so12707008edt.13 for ; Mon, 05 Apr 2021 07:21:23 -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=bx0IwbYTflDi7XjK37L93nsygl+2jWgYd7hRljVpQOk=; b=obAXnLWI+48QbPyNbM22AaiwXu2zaGz+tmwXwXTT5s6zdAypv4omhEkWAEk/k65WnD fWtK/fsSXGwxwXXpUh6yb67DBgfAQMz+6i25ty935LYPe1JvXHpBdWEr9RjxlD20xtU+ JBqFVilMKC7/elsUWNVn7LmIlhAl7tL2uostKEiNFCVloT7FD/Ff/tMD/F5/p3QASro7 Fv75pBu+FwsrLovNCLVfYoizuCf7VWsQXXuo2pCWO5U2E64DrGg0NDEwlSnVXy4AiPwd tGDGMMTL9weIhIa94gup95xkARL6gnbEgAOSDB4N4AHCHFKdpYCM8qxH/GvOFw2TSYWq d8EA== 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=bx0IwbYTflDi7XjK37L93nsygl+2jWgYd7hRljVpQOk=; b=b3QKoxLy64Bi9q+F+yn9lrgWP0zIaFOu03sCWAGsTbiJaU/P2vRzNcODzlDutNBQH5 ZfOhtDCkKgrWdVb0IO1bNwvx07fcuOEkmT5iQd6up3aeZMpyuS3hKpGdMbjw2YvdWnb3 C3hVSqtUNIxC/UB7PisqSY5UXOd+abB1sE0nPP9t8VvNV7oPKxaK72JYWOt61188wW4K T4BGjWSVeozDr2jr0iz83hm/qMqmhKLR0TEeJQ2rmH0fREIzYapgRezgiirriAafpa4E y4kqVpS/urNP8Z/6wrJkyQNJ/ePIbigUO6TVTj0KO1mrq4eiYyIe49iNMWdlSoMjWFdU adoQ== X-Gm-Message-State: AOAM530sAuJioJcCjf6M3mYjrainxQfzhwbL81s+T718Hjq1oDRQ6TbE spA81TU8gK/UgaAdIcNjjZ4= X-Google-Smtp-Source: ABdhPJxHxjcUam15m7TlYvGNPJopxZcYmQNs44eqaWEVnUIwVFxOZyLnh2/kSXk2DV50IqNi0LR9zg== X-Received: by 2002:aa7:d6ce:: with SMTP id x14mr11971965edr.66.1617632482707; Mon, 05 Apr 2021 07:21:22 -0700 (PDT) Received: from localhost.localdomain ([95.87.199.133]) by smtp.gmail.com with ESMTPSA id e5sm3156972edr.64.2021.04.05.07.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Apr 2021 07:21:22 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, tz.stoyanov@gmail.com, "Yordan Karadzhov (VMware)" Subject: [PATCH v2 1/5] libtracefs: Fix issues with tracefs_option_id() Date: Mon, 5 Apr 2021 17:21:03 +0300 Message-Id: <20210405142107.507711-2-y.karadz@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210405142107.507711-1-y.karadz@gmail.com> References: <20210405142107.507711-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Few mistakes have been made when introducing this API function. First of all, its declaration is missing from the header file. In addition to this the argument type is missing "const". Signed-off-by: Yordan Karadzhov (VMware) --- include/tracefs.h | 1 + src/tracefs-tools.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/tracefs.h b/include/tracefs.h index 05bd0ef..fbd7db5 100644 --- a/include/tracefs.h +++ b/include/tracefs.h @@ -145,5 +145,6 @@ bool tracefs_option_is_enabled(struct tracefs_instance *instance, enum tracefs_o 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); const char *tracefs_option_name(enum tracefs_option_id id); +enum tracefs_option_id tracefs_option_id(const char *name); #endif /* _TRACE_FS_H */ diff --git a/src/tracefs-tools.c b/src/tracefs-tools.c index e2dfc7b..51a7971 100644 --- a/src/tracefs-tools.c +++ b/src/tracefs-tools.c @@ -181,7 +181,7 @@ const char *tracefs_option_name(enum tracefs_option_id id) * Returns trace option ID or TRACEFS_OPTION_INVALID in case of an error or * unknown option name. */ -enum tracefs_option_id tracefs_option_id(char *name) +enum tracefs_option_id tracefs_option_id(const char *name) { int i; From patchwork Mon Apr 5 14:21:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12182957 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.7 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 939A8C43461 for ; Mon, 5 Apr 2021 14:21:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CD06613B2 for ; Mon, 5 Apr 2021 14:21:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241299AbhDEOVb (ORCPT ); Mon, 5 Apr 2021 10:21:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241296AbhDEOVa (ORCPT ); Mon, 5 Apr 2021 10:21:30 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7E4AC061756 for ; Mon, 5 Apr 2021 07:21:24 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id b7so17085534ejv.1 for ; Mon, 05 Apr 2021 07:21:24 -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=i2bpfUmF+YwnlreGA7yi828PWj2M/BNGHaLXVcBvWW4=; b=baxmwyx3S8N7veoaUuMl2rk6i+WTpAfCX+jbLbpGgGGG4jqWynWQErvQjFlkhy6gF5 3b278h4oOTLbQ3x2ty4xVnA2Sjk4W3uEm5sjCGK+ydv4tmO75hNtNa9o+E7mcCKfP2ep 8bx8nPcxa7vORZvqUZ42nxdNAIohTxHWryNql0RmRVjmY56wbQLC+JsQf/YNJprUWYo+ /2zkTwsk9H4KmW7utalN0JD7A1JTnBBW59GjZMvtbAuemRCEFENe1e5SFHBkw2I5hqSr Ji/NIFzbHb3WM8WLZElq4vlWTZCBSWj3NWfQr0Cx/UUMmiwnekX5xMtpRxxBgbruT8fs 85vw== 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=i2bpfUmF+YwnlreGA7yi828PWj2M/BNGHaLXVcBvWW4=; b=PiZ6AMKh5RCacodlY0QfZV1j7+fmeMPmIV4XteFanLJE3l8tLuqQ7CAMvfFBXxk2Y2 bStygwoK6nu/TEfrH1pocSR+Ih1fqoP13ZodK4oHbQfx411i3TYui0ysByAHGUx+wBSR MQe+pKcZh26/ki0utXYuzDXLiFUHEtv3BV8U2pSjTkLuXzs4/cv8BJlQwfYuKeeeQx3U njurt2zbDwyFxggV76CeaaKOAQHu5Q6hj83u51h0UOtXClA2X9LMxbE4M5Kdziij0/Ru 5h8/lcT6Rr6zmqfXmV9A1gFncy1JaX3NujMZYHmh52UW2DFS33ouhj+Bxl3mt8YIB9dJ HM3g== X-Gm-Message-State: AOAM5313T3G2rg3oTUI3XSPlbGA3aozsBaVQ+a7XbX3Uns2X/lGxDqmm 0c39PQLliOZ33/AUpFF65jA= X-Google-Smtp-Source: ABdhPJw7nRVnK+efkG0kzL2c/bdviZobkJBDMe+mLgzWJhf0MDYLcReNU0bHdEehwSTluaWl4/s6MA== X-Received: by 2002:a17:906:86c1:: with SMTP id j1mr29514863ejy.373.1617632483415; Mon, 05 Apr 2021 07:21:23 -0700 (PDT) Received: from localhost.localdomain ([95.87.199.133]) by smtp.gmail.com with ESMTPSA id e5sm3156972edr.64.2021.04.05.07.21.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Apr 2021 07:21:23 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, tz.stoyanov@gmail.com, "Yordan Karadzhov (VMware)" Subject: [PATCH v2 2/5] libtracefs: Modify the arguments of tracefs_option_is_set() Date: Mon, 5 Apr 2021 17:21:04 +0300 Message-Id: <20210405142107.507711-3-y.karadz@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210405142107.507711-1-y.karadz@gmail.com> References: <20210405142107.507711-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org This function is supposed to take as argument a mask returned by "tracefs_options_get_supported()" or "tracefs_options_get_enabled()", hence this argument must be a pointer. Signed-off-by: Yordan Karadzhov (VMware) --- include/tracefs.h | 4 ++-- src/tracefs-tools.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/tracefs.h b/include/tracefs.h index fbd7db5..5c4e50d 100644 --- a/include/tracefs.h +++ b/include/tracefs.h @@ -136,8 +136,8 @@ struct tracefs_options_mask { }; void tracefs_option_set(struct tracefs_options_mask *options, enum tracefs_option_id id); void tracefs_option_clear(struct tracefs_options_mask *options, enum tracefs_option_id id); -bool tracefs_option_is_set(struct tracefs_options_mask options, enum tracefs_option_id id); - +bool tracefs_option_is_set(struct tracefs_options_mask *options, + enum tracefs_option_id id); struct tracefs_options_mask *tracefs_options_get_supported(struct tracefs_instance *instance); bool tracefs_option_is_supported(struct tracefs_instance *instance, enum tracefs_option_id id); struct tracefs_options_mask *tracefs_options_get_enabled(struct tracefs_instance *instance); diff --git a/src/tracefs-tools.c b/src/tracefs-tools.c index 51a7971..3b5f773 100644 --- a/src/tracefs-tools.c +++ b/src/tracefs-tools.c @@ -359,10 +359,11 @@ bool tracefs_option_is_enabled(struct tracefs_instance *instance, enum tracefs_o * Returns true if an option with given id is set in the bitmask, * false if it is not set. */ -bool tracefs_option_is_set(struct tracefs_options_mask options, enum tracefs_option_id id) +bool tracefs_option_is_set(struct tracefs_options_mask *options, + enum tracefs_option_id id) { if (id > TRACEFS_OPTION_INVALID) - return options.mask & (1ULL << (id - 1)); + return options->mask & (1ULL << (id - 1)); return false; } From patchwork Mon Apr 5 14:21:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12182959 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.7 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 86F31C43460 for ; Mon, 5 Apr 2021 14:21:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 64B74613B5 for ; Mon, 5 Apr 2021 14:21:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241301AbhDEOVc (ORCPT ); Mon, 5 Apr 2021 10:21:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241296AbhDEOVb (ORCPT ); Mon, 5 Apr 2021 10:21:31 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98C6CC061756 for ; Mon, 5 Apr 2021 07:21:25 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id k8so5316345edn.6 for ; Mon, 05 Apr 2021 07:21:25 -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=uSnuq4D62Yc0ec11b4yKBS0jyRnEZHthUr23YIc0H1c=; b=ZmWIijB22JoGEcg/Jz2hKxDZw5FZro1coWSxdoysuBRT8xTmeOMekgkZFuqeUgki3Q 9eUMjN4a0RP81wuPax9F2ReKL9dWyyRCKlf+P4Rk2yUlvunSDYmYC1jorcBhpz3WgRuR 8alGC4nLH1Z2CfMHfvs9i4QPjz7vnphhFlPt64V2vwIAbR7M1Yoe2qtP4DaCc1qfZcT5 a9uwQOsJyTLjfmLH+g/U2RPm4x6tldRC/BFCksVKLsW/fkF3GG6g44YLoa9yvoECIB0B FE1NPE4PM6Fwl153/69Vlj0kmJQpOjfWH/o7roG50o5KSDYJeJwsEQh2lpr79i9O4DGe 4UTQ== 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=uSnuq4D62Yc0ec11b4yKBS0jyRnEZHthUr23YIc0H1c=; b=AG2utnJcP/N4AvkZKO2lLX1XxmJGb/nGK8E3JQMO8HIJFgwG/v7plBlVPuwCrSSYbf 5oyOzk32YL0PClEWXeiTIMycpSiGbLqWdYtDTJnyQBBX0y7LOn0S3lAl60ZZF8e5gT/6 w41K9HxCMDeEtvcIsv2rVuRIBqURZCkF3aSQstcDHvXcP/CK8zHy7rKvN4TJlxfyK1C2 BWX6HsFT5lF2SaihdrgfVcfM/GXsFIuelSaJQDkrJ8CisDqG5VQyNoz8oy5vnkCmcAB5 +6PqrE/hKM+7CaKjwweu4Nkm7PwugTuYM1pb3uXEyQLqYX5ZxqDizWit3dp0kSaLsYJn kvFw== X-Gm-Message-State: AOAM532myKGaI+okoafUlg8qAt1ppbx3tyE6LcFjtZpW3Mppk0Vut0nk TuWH1nlYLJpDCKWavhBNgLs= X-Google-Smtp-Source: ABdhPJzJddzVuxUmtsoI1Fy3pWJ8Qyhm3mbrg+Swj0dTGjPPi0d2h0GglGLOXPjKJMz8OZgH6+h3vw== X-Received: by 2002:aa7:da97:: with SMTP id q23mr31068855eds.180.1617632484381; Mon, 05 Apr 2021 07:21:24 -0700 (PDT) Received: from localhost.localdomain ([95.87.199.133]) by smtp.gmail.com with ESMTPSA id e5sm3156972edr.64.2021.04.05.07.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Apr 2021 07:21:24 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, tz.stoyanov@gmail.com, "Yordan Karadzhov (VMware)" Subject: [PATCH v2 3/5] libtracefs: Encapsulate "struct tracefs_options_mask" Date: Mon, 5 Apr 2021 17:21:05 +0300 Message-Id: <20210405142107.507711-4-y.karadz@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210405142107.507711-1-y.karadz@gmail.com> References: <20210405142107.507711-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org The definition of the mask gets hidden from the user. This way we will be able to modify this definition in the future, without breaking the API. Such a modification will be compulsory, if too many new tracing options are added in the future. Note that encapsulating the mask definition, requires two API methods to be eliminated, however those methods have no particular use-cases for the moment. Signed-off-by: Yordan Karadzhov (VMware) --- include/tracefs-local.h | 4 ++++ include/tracefs.h | 6 +----- src/tracefs-tools.c | 31 ++++++++----------------------- 3 files changed, 13 insertions(+), 28 deletions(-) diff --git a/include/tracefs-local.h b/include/tracefs-local.h index 187870e..0a746f2 100644 --- a/include/tracefs-local.h +++ b/include/tracefs-local.h @@ -33,4 +33,8 @@ char *trace_find_tracing_dir(void); #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) /* 0666*/ #endif +struct tracefs_options_mask { + unsigned long long mask; +}; + #endif /* _TRACE_FS_LOCAL_H */ diff --git a/include/tracefs.h b/include/tracefs.h index 5c4e50d..0665e8d 100644 --- a/include/tracefs.h +++ b/include/tracefs.h @@ -131,11 +131,7 @@ enum tracefs_option_id { }; #define TRACEFS_OPTION_MAX (TRACEFS_OPTION_VERBOSE + 1) -struct tracefs_options_mask { - unsigned long long mask; -}; -void tracefs_option_set(struct tracefs_options_mask *options, enum tracefs_option_id id); -void tracefs_option_clear(struct tracefs_options_mask *options, enum tracefs_option_id id); +struct tracefs_options_mask; bool tracefs_option_is_set(struct tracefs_options_mask *options, enum tracefs_option_id id); struct tracefs_options_mask *tracefs_options_get_supported(struct tracefs_instance *instance); diff --git a/src/tracefs-tools.c b/src/tracefs-tools.c index 3b5f773..a932216 100644 --- a/src/tracefs-tools.c +++ b/src/tracefs-tools.c @@ -197,6 +197,13 @@ enum tracefs_option_id tracefs_option_id(const char *name) return TRACEFS_OPTION_INVALID; } +static void trace_option_set(struct tracefs_options_mask *options, + enum tracefs_option_id id) +{ + if (options && id > TRACEFS_OPTION_INVALID) + options->mask |= (1ULL << (id - 1)); +} + static struct tracefs_options_mask *trace_get_options(struct tracefs_instance *instance, bool enabled) { @@ -229,7 +236,7 @@ static struct tracefs_options_mask *trace_get_options(struct tracefs_instance *i } id = tracefs_option_id(dent->d_name); if (id != TRACEFS_OPTION_INVALID) - tracefs_option_set(bitmask, id); + trace_option_set(bitmask, id); } closedir(dir); tracefs_put_tracing_file(dname); @@ -366,25 +373,3 @@ bool tracefs_option_is_set(struct tracefs_options_mask *options, return options->mask & (1ULL << (id - 1)); return false; } - -/** - * tracefs_option_set - Set option in options bitmask - * @options: Pointer to a bitmask with options - * @id: trace option id - */ -void tracefs_option_set(struct tracefs_options_mask *options, enum tracefs_option_id id) -{ - if (options && id > TRACEFS_OPTION_INVALID) - options->mask |= (1ULL << (id - 1)); -} - -/** - * tracefs_option_clear - Clear option from options bitmask - * @options: Pointer to a bitmask with options - * @id: trace option id - */ -void tracefs_option_clear(struct tracefs_options_mask *options, enum tracefs_option_id id) -{ - if (options && id > TRACEFS_OPTION_INVALID) - options->mask &= ~(1ULL << (id - 1)); -} From patchwork Mon Apr 5 14:21:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12182961 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.7 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 846A0C433B4 for ; Mon, 5 Apr 2021 14:21:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61831613B5 for ; Mon, 5 Apr 2021 14:21:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241302AbhDEOVd (ORCPT ); Mon, 5 Apr 2021 10:21:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241296AbhDEOVc (ORCPT ); Mon, 5 Apr 2021 10:21:32 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0756C061756 for ; Mon, 5 Apr 2021 07:21:26 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id b7so17085679ejv.1 for ; Mon, 05 Apr 2021 07:21:26 -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=UbjbDWjwzWugMAjtBnvBRAXg2Dp3jMe0PfbrEbxyyxU=; b=mlKMhI2OoEDi5DEM0U9G3WBhOxMBQtQcZ86BhpIRun/tE5cm7EG5wnT/XuI8+CxUQ2 y6w+wrAqdtE12psR4jL72WzEwFNWNm36f/Ach4dAMHBQhkY5Zln/yMCJAIyopHJC4i4c 46+MbGjqCnZ4DMMeSa622i/TOdcTwCshuzMO8NKzrLV6R88HSf0EiKDYhDjZLmTuX8Ep 4naN+TvIe5PaBJko1Xq1YfsAhHIlm0U/xGp/dyqEyTWqjUUOONCzq4eS7qNg2RAG/uQD mp+b2TRdK4vBvRRtbwEEyYklSlulwBCcqHTE+mdSFKZRCmXZu/5L/Li0sBV8/tEGJuWs UTyg== 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=UbjbDWjwzWugMAjtBnvBRAXg2Dp3jMe0PfbrEbxyyxU=; b=hQYxvLj8rsU231ylHlsDwyFj0TA/VTNiGDIn2bTaPQ4PwuhkV4qHsXzawCriD0B7d1 axGXMvsIvtJd7Ec2t986cKfxt3iRcMw7AMELL7ipPgH3sECDPhrwtTxCjw/owsfzpSZm PLbWeSTVILdDnDETEiRGm0iGWXryPzLR91WFc93gS+hHWahIrlWZQni7S/l0DBRcRAKT vmkcGjpg0RAkq6PLGG9opO2n5F8hOnJlU2XZHwPM6S6k7EzwGjlF5TDTw2MHYxierzWf P5oNW9y7DzHJar6jOaAG7yWJJA56/h99RK9xZ2PH5oqf0udIeTyh6ONwiI3CNtfJtYrs 8dTw== X-Gm-Message-State: AOAM532qYPkulGahmqg2IzN4sB5hCCT9jp4ETJXSrjw2yPWV1p4bDxKM xPS7rOQ2rIzq1uu/1psVpao= X-Google-Smtp-Source: ABdhPJz4HMaOIpCKQJXYIs6bWPpmc4dWkoBxIOFqSCzaKaKx8Y80SRfv2hTvo3LVr5YIseDj4tHtkg== X-Received: by 2002:a17:906:3886:: with SMTP id q6mr1467539ejd.118.1617632485421; Mon, 05 Apr 2021 07:21:25 -0700 (PDT) Received: from localhost.localdomain ([95.87.199.133]) by smtp.gmail.com with ESMTPSA id e5sm3156972edr.64.2021.04.05.07.21.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Apr 2021 07:21:25 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, tz.stoyanov@gmail.com, "Yordan Karadzhov (VMware)" Subject: [PATCH v2 4/5] libtracefs: Option's bit masks to be owned by the instance Date: Mon, 5 Apr 2021 17:21:06 +0300 Message-Id: <20210405142107.507711-5-y.karadz@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210405142107.507711-1-y.karadz@gmail.com> References: <20210405142107.507711-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org If the instance owns two mask objects, we no longer need to dynamically allocate memory in tracefs_options_get_supported() and tracefs_options_get_enabled(). This will simplify the code on the caller side, since the user is no longer responsible for freeing those masks. Signed-off-by: Yordan Karadzhov (VMware) --- Documentation/libtracefs-option-get.txt | 4 +--- include/tracefs-local.h | 6 ++++++ include/tracefs.h | 2 +- src/tracefs-instance.c | 14 ++++++++++++++ src/tracefs-tools.c | 18 ++++++++---------- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/Documentation/libtracefs-option-get.txt b/Documentation/libtracefs-option-get.txt index 9b3cb56..3290f24 100644 --- a/Documentation/libtracefs-option-get.txt +++ b/Documentation/libtracefs-option-get.txt @@ -52,14 +52,13 @@ EXAMPLE -- #include ... -struct tracefs_options_mask *options; +const struct tracefs_options_mask *options; ... options = tracefs_options_get_supported(NULL); if (!options) { /* Failed to get supported options */ } else { ... - free(options); } ... options = tracefs_options_get_enabled(NULL); @@ -67,7 +66,6 @@ if (!options) { /* Failed to get options, enabled in the top instance */ } else { ... - free(options); } ... diff --git a/include/tracefs-local.h b/include/tracefs-local.h index 0a746f2..0a083f9 100644 --- a/include/tracefs-local.h +++ b/include/tracefs-local.h @@ -37,4 +37,10 @@ struct tracefs_options_mask { unsigned long long mask; }; +struct tracefs_options_mask * +supported_opts_mask(struct tracefs_instance *instance); + +struct tracefs_options_mask * +enabled_opts_mask(struct tracefs_instance *instance); + #endif /* _TRACE_FS_LOCAL_H */ diff --git a/include/tracefs.h b/include/tracefs.h index 0665e8d..6e9cf55 100644 --- a/include/tracefs.h +++ b/include/tracefs.h @@ -132,7 +132,7 @@ enum tracefs_option_id { #define TRACEFS_OPTION_MAX (TRACEFS_OPTION_VERBOSE + 1) struct tracefs_options_mask; -bool tracefs_option_is_set(struct tracefs_options_mask *options, +bool tracefs_option_is_set(const struct tracefs_options_mask *options, enum tracefs_option_id id); struct tracefs_options_mask *tracefs_options_get_supported(struct tracefs_instance *instance); bool tracefs_option_is_supported(struct tracefs_instance *instance, enum tracefs_option_id id); diff --git a/src/tracefs-instance.c b/src/tracefs-instance.c index 0df313c..4d78be6 100644 --- a/src/tracefs-instance.c +++ b/src/tracefs-instance.c @@ -23,8 +23,22 @@ struct tracefs_instance { char *trace_dir; char *name; int flags; + struct tracefs_options_mask supported_opts; + struct tracefs_options_mask enabled_opts; }; +__hidden inline struct tracefs_options_mask * +supported_opts_mask(struct tracefs_instance *instance) +{ + return &instance->supported_opts; +} + +__hidden inline struct tracefs_options_mask * +enabled_opts_mask(struct tracefs_instance *instance) +{ + return &instance->enabled_opts; +} + /** * instance_alloc - allocate a new ftrace instance * @trace_dir - Full path to the tracing directory, where the instance is diff --git a/src/tracefs-tools.c b/src/tracefs-tools.c index a932216..980ad47 100644 --- a/src/tracefs-tools.c +++ b/src/tracefs-tools.c @@ -215,9 +215,8 @@ static struct tracefs_options_mask *trace_get_options(struct tracefs_instance *i DIR *dir = NULL; long long val; - bitmask = calloc(1, sizeof(struct tracefs_options_mask)); - if (!bitmask) - return NULL; + bitmask = enabled? enabled_opts_mask(instance) : + supported_opts_mask(instance); dname = tracefs_instance_get_file(instance, "options"); if (!dname) goto error; @@ -247,7 +246,6 @@ error: if (dir) closedir(dir); tracefs_put_tracing_file(dname); - free(bitmask); return NULL; } @@ -255,8 +253,8 @@ error: * tracefs_options_get_supported - Get all supported trace options in given instance * @instance: ftrace instance, can be NULL for the top instance * - * Returns allocated bitmask structure with all trace options, supported in given - * instance, or NULL in case of an error. The returned structure must be freed with free() + * Returns bitmask structure with all trace options, supported in given instance, + * or NULL in case of an error. */ struct tracefs_options_mask *tracefs_options_get_supported(struct tracefs_instance *instance) { @@ -267,8 +265,8 @@ struct tracefs_options_mask *tracefs_options_get_supported(struct tracefs_instan * tracefs_options_get_enabled - Get all currently enabled trace options in given instance * @instance: ftrace instance, can be NULL for the top instance * - * Returns allocated bitmask structure with all trace options, enabled in given - * instance, or NULL in case of an error. The returned structure must be freed with free() + * Returns bitmask structure with all trace options, enabled in given instance, + * or NULL in case of an error. */ struct tracefs_options_mask *tracefs_options_get_enabled(struct tracefs_instance *instance) { @@ -278,7 +276,7 @@ struct tracefs_options_mask *tracefs_options_get_enabled(struct tracefs_instance static int trace_config_option(struct tracefs_instance *instance, enum tracefs_option_id id, bool set) { - char *set_str = set ? "1" : "0"; + const char *set_str = set ? "1" : "0"; char file[PATH_MAX]; const char *name; @@ -366,7 +364,7 @@ bool tracefs_option_is_enabled(struct tracefs_instance *instance, enum tracefs_o * Returns true if an option with given id is set in the bitmask, * false if it is not set. */ -bool tracefs_option_is_set(struct tracefs_options_mask *options, +bool tracefs_option_is_set(const struct tracefs_options_mask *options, enum tracefs_option_id id) { if (id > TRACEFS_OPTION_INVALID) From patchwork Mon Apr 5 14:21:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12182963 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.7 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 8B4EBC43460 for ; Mon, 5 Apr 2021 14:21:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 60010613B5 for ; Mon, 5 Apr 2021 14:21:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241303AbhDEOVe (ORCPT ); Mon, 5 Apr 2021 10:21:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241296AbhDEOVd (ORCPT ); Mon, 5 Apr 2021 10:21:33 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B974C061756 for ; Mon, 5 Apr 2021 07:21:27 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id p4so2475876edr.2 for ; Mon, 05 Apr 2021 07:21:27 -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=gP2DpfxDfv80POi+Qp5LcuyBFIT37XBV5K0BjuhcS68=; b=M5bMQQrKSLEDQwfncSJsxwZnv8tdbpe+mjPGKZay6aUBNlpvgvr7n+na/xdvWfY4h8 Iojq7t6Ab5cDiGgYsEDqpq16X6MqfZsXSz8PfGlTgnGqu7IclFSX9aOlIyKH7YBrQhGW 85u1npehGEzDTYHkj0mo4NsxT+GeAYpvF6p4NZkvSsXTV2G5tSKHmOImRLFd7yFEz98X re24zrpKBhozHEdF8Zex4OlxuhgnBJ/68QLS32OUzWNSQS9xaCOBPmPISJivH/4Cjral 64DLvAM6/PZcseDxZC9zfF5bxJvHy0AVuE3krwGDlfSCIW1Twv9gSUU3Na5NbABq0dA/ Cl2Q== 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=gP2DpfxDfv80POi+Qp5LcuyBFIT37XBV5K0BjuhcS68=; b=VH6ZuhMuSwxZisLrXVXoIe3GrHxhikv85XGX11rK3inI0PWrznRQKtd0xfeBX6SzNy +dYEzh+T5IIbUQpJiDg/Zgd2HxB/oUFQ4ffDM5w6Cpoma26iTcU6sgrxLyh70Q2xomWY qr2HQbufLhdI8ZNnlvdpkaj9qD9WAsHft5XGnvkDtCc5nKZOHuk5S3lofATwEbcWTuwb b54SE4OydSnuhR94nIlo1TJeoY3/ZlgwFGNHyIn05Tv5R/cQxfsMby5PZKHkxgc1L+Ow v1TgRqKLXMyaNp1mJCiYba4qArNwj7BYhbHNYm3PXn4dS7rYEVqjBjwOOrWERxDonLiG fjtw== X-Gm-Message-State: AOAM532qXEYl1I2YaNs9nHIXxAH0bNXJ7wNOMS9qc0jrmJ0x/ugXrotT xD3ThFNPx3xsG/JZrMJ4rcg= X-Google-Smtp-Source: ABdhPJxgWuMiZjS/PSBCVECfgxutqiVNXTSZOxZcYpurQgLJs/cVMr6TZyo4jWqOvnI5WqCkZIHRAQ== X-Received: by 2002:a05:6402:3da:: with SMTP id t26mr6235344edw.84.1617632486214; Mon, 05 Apr 2021 07:21:26 -0700 (PDT) Received: from localhost.localdomain ([95.87.199.133]) by smtp.gmail.com with ESMTPSA id e5sm3156972edr.64.2021.04.05.07.21.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Apr 2021 07:21:25 -0700 (PDT) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, tz.stoyanov@gmail.com, "Yordan Karadzhov (VMware)" Subject: [PATCH v2 5/5] libtracefs: Rename tracefs_option_is_set() Date: Mon, 5 Apr 2021 17:21:07 +0300 Message-Id: <20210405142107.507711-6-y.karadz@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210405142107.507711-1-y.karadz@gmail.com> References: <20210405142107.507711-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org The old name of the function is potentially confusing. Indeed the function do not check anything about the option itself (is it supported or is it enabled). The function only check if inside the mask the bit that corresponds to a given option is set. Signed-off-by: Yordan Karadzhov (VMware) --- include/tracefs.h | 4 ++-- src/tracefs-tools.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/tracefs.h b/include/tracefs.h index 6e9cf55..dd46eca 100644 --- a/include/tracefs.h +++ b/include/tracefs.h @@ -132,8 +132,8 @@ enum tracefs_option_id { #define TRACEFS_OPTION_MAX (TRACEFS_OPTION_VERBOSE + 1) struct tracefs_options_mask; -bool tracefs_option_is_set(const struct tracefs_options_mask *options, - enum tracefs_option_id id); +bool tracefs_option_mask_is_set(const struct tracefs_options_mask *options, + enum tracefs_option_id id); struct tracefs_options_mask *tracefs_options_get_supported(struct tracefs_instance *instance); bool tracefs_option_is_supported(struct tracefs_instance *instance, enum tracefs_option_id id); struct tracefs_options_mask *tracefs_options_get_enabled(struct tracefs_instance *instance); diff --git a/src/tracefs-tools.c b/src/tracefs-tools.c index 980ad47..496053f 100644 --- a/src/tracefs-tools.c +++ b/src/tracefs-tools.c @@ -357,14 +357,14 @@ bool tracefs_option_is_enabled(struct tracefs_instance *instance, enum tracefs_o } /** - * tracefs_option_is_set - Check if given option is set in the bitmask + * tracefs_option_mask_is_set - Check if given option is set in the bitmask * @options: Options bitmask * @id: trace option id * * Returns true if an option with given id is set in the bitmask, * false if it is not set. */ -bool tracefs_option_is_set(const struct tracefs_options_mask *options, +bool tracefs_option_mask_is_set(const struct tracefs_options_mask *options, enum tracefs_option_id id) { if (id > TRACEFS_OPTION_INVALID)