From: Steven Rostedt <rostedt@goodmis.org>
To: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [RFC PATCH 2/4] libtracefs: Transform tracefs_hist_add_sort_key()
Date: Fri, 10 Sep 2021 16:01:01 -0400 [thread overview]
Message-ID: <20210910160101.2ef82513@gandalf.local.home> (raw)
In-Reply-To: <20210910163857.324696-3-y.karadz@gmail.com>
On Fri, 10 Sep 2021 19:38:55 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:
> The current version of the API makes it hard to add multiple sort keys
> to a histogram. The only way to do this is to use the variadic arguments,
> however in order to do this the caller have to know the number of sort
> keys at compile time, because the method overwrite all previously added
> keys. The problem is addressed by splitting tracefs_hist_add_sort_key()
> into two methods - one that overwrite and one that does not.
>
> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
> ---
> include/tracefs.h | 4 +++-
> src/tracefs-hist.c | 21 +++++++++++++++++++--
> 2 files changed, 22 insertions(+), 3 deletions(-)
>
> diff --git a/include/tracefs.h b/include/tracefs.h
> index 64fbb3f..c3fa1d6 100644
> --- a/include/tracefs.h
> +++ b/include/tracefs.h
> @@ -303,7 +303,9 @@ int tracefs_hist_add_key(struct tracefs_hist *hist, const char *key,
> enum tracefs_hist_key_type type);
> int tracefs_hist_add_value(struct tracefs_hist *hist, const char *value);
> int tracefs_hist_add_sort_key(struct tracefs_hist *hist,
> - const char *sort_key, ...);
> + char *sort_key);
Why did you remove the const? The add_sort_key() takes a const and makes a
copy of it.
> +int tracefs_hist_sort_key(struct tracefs_hist *hist,
> + const char *sort_key, ...);
> int tracefs_hist_sort_key_direction(struct tracefs_hist *hist,
> const char *sort_key,
> enum tracefs_hist_sort_direction dir);
> diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c
> index 8501d64..2ea90d9 100644
> --- a/src/tracefs-hist.c
> +++ b/src/tracefs-hist.c
> @@ -453,6 +453,23 @@ add_sort_key(struct tracefs_hist *hist, const char *sort_key, char **list)
> return tracefs_list_add(list, sort_key);
> }
>
Needs a kerneldoc documentation header.
> +int tracefs_hist_add_sort_key(struct tracefs_hist *hist,
> + char *sort_key)
> +{
> + char **list = hist->sort;
> +
> + if (!hist || !sort_key)
> + return -1;
> +
> + list = add_sort_key(hist, sort_key, hist->sort);
> + if (!list)
> + return -1;
> +
> + hist->sort = list;
> +
> + return 0;
> +}
> +
> /**
> * tracefs_hist_add_sort_key - add a key for sorting the histogram
The above name needs to be updated.
> * @hist: The histogram to add the sort key to
> @@ -464,8 +481,8 @@ add_sort_key(struct tracefs_hist *hist, const char *sort_key, char **list)
> *
> * Returns 0 on success, -1 on error.
> */
> -int tracefs_hist_add_sort_key(struct tracefs_hist *hist,
> - const char *sort_key, ...)
> +int tracefs_hist_sort_key(struct tracefs_hist *hist,
How about if we call this:
tracefs_hist_replace_sort_keys()
I think that would be a more intuitive name.
-- Steve
> + const char *sort_key, ...)
> {
> char **list = NULL;
> char **tmp;
next prev parent reply other threads:[~2021-09-10 20:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-10 16:38 [RFC PATCH 0/4] Modifications of some 'hist' APIs Yordan Karadzhov (VMware)
2021-09-10 16:38 ` [RFC PATCH 1/4] libtracefs: Add new constructors for histograms Yordan Karadzhov (VMware)
2021-09-10 16:38 ` [RFC PATCH 2/4] libtracefs: Transform tracefs_hist_add_sort_key() Yordan Karadzhov (VMware)
2021-09-10 20:01 ` Steven Rostedt [this message]
2021-09-13 12:26 ` Yordan Karadzhov
2021-09-13 17:56 ` Steven Rostedt
2021-09-10 20:04 ` Steven Rostedt
2021-09-13 12:28 ` Yordan Karadzhov
2021-09-10 16:38 ` [RFC PATCH 3/4] libtracefs: Add new 'hist' APIs Yordan Karadzhov (VMware)
2021-09-10 16:38 ` [RFC PATCH 4/4] libtracefs: Remove tracefs_hist_add_key() Yordan Karadzhov (VMware)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210910160101.2ef82513@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=y.karadz@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).