From: Yordan Karadzhov <y.karadz@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [RFC] Modifications of some 'hist' APIs
Date: Mon, 11 Oct 2021 16:55:29 +0300 [thread overview]
Message-ID: <5439fe13-8d78-2fe6-3749-5e60cf10151c@gmail.com> (raw)
In-Reply-To: <20210924095702.151826-1-y.karadz@gmail.com>
Hi Steven et al.
I would like to suggest some further modifications of the current APIs of libtracefs. The problem that I am trying to
solve with this modifications is the unnecessary and potentially confusing variety of patterns used when implementing
the APIs for dealing with 'instances', 'kprobes', 'histigrams' and 'synthetic events'. I believe that
unifying/templating the structure of those APIs will be beneficial and will make the usage fare more intuitive. I am
posting below a pseudo code for one possible implementation of such template APIs that can be used as a starting point
for a discussion.
/**
* tracefs_XXX_alloc - allocate a new tracefs_XXX descriptor. This only
* initializes the descriptor, it does not introduce any changes on the
* system.
*
* @arguments: Some arguments specific for the type of the object ...
*
* Returns a newly allocated tracefs_XXX descriptor objext, or NULL in case
* of an error. The returned instance must be freed by tracefs_XXX_free().
*/
struct tracefs_XXX *tracefs_XXX_alloc(arguments);
/**
* tracefs_XXX_create - creates new tracefs_XXX object on the system.
* This method calls tracefs_XXX_alloc() internally.
*
* @arguments: Some arguments specific for the type of the object ...
* This function should not take an instance as argument. Otherwise the
* same instance will have to be passed to tracefs_XXX_destroy(), which
* can be a problem in some more sophisticated use-cases.
*
* Returns 0 on succes and -1 on error. On error, errno is set to:
* EBUSY - the object already exists on the system.
* ENOMEM - memory allocation failure.
* ENIVAL - a parameter is passed as NULL or value that should not be or
* a problem writing into the system.
*/
struct tracefs_XXX *tracefs_XXX_create(arguments);
/**
* tracefs_XXX_find - find a tracefs_XXX object that already exists on the
* system. This method calls tracefs_XXX_alloc() internally.
*
* @arguments: Some arguments specific for the type of the object ...
* This function should not take an instance as argument. Otherwise the same
* instance will have to be passed to tracefs_XXX_destroy(), which can be a
* problem in some more sophisticated use-cases.
*
* Returns tracefs_XXX descriptor on succes and NULL if the object do not
* exist on the system or in the case of an error. On error, errno is set to:
* ENOMEM - memory allocation failure.
* ENIVAL - a parameter is passed as NULL or value that should not be or
* a problem writing into the system.
*/
struct tracefs_XXX *tracefs_XXX_find(arguments);
/**
* tracefs_instance_destroy - Remove/clears a tracefs_XXX objext from the
* system. tracefs_XXX_free() must be called in order to free the memory used
* by the descriptor itself.
*
* @obj: Pointer to the tracefs_XXX descriptor of the objext to be destroyed.
* @force: If false the object is not guaranteed to be destroyed. If @force
* is true, all tangled objects that prevent the destruction of the object
* will be destroyed as well.
*
* This function should not take any other arguments.
*
* Returns -1 in case of an error or if the object failed to destroy.
* 0 otherwise.
*/
int tracefs_XXX_destroy(struct tracefs_XXX *obj, bool force);
/**
* tracefs_XXX_free - Free a tracefs_XXX descriptor, previously allocated
* by tracefs_XXX_alloc, tracefs_XXX_create() or tracefs_XXX_find().
*
* @obj: Pointer to the tracefs_XXX descriptor objext to be freed.
*
* This function should not take any other arguments.
*/
void tracefs_XXX_free(struct tracefs_XXX *obj);
/**
* tracefs_XXX_YYY - Method implementing the user action 'YYY' (can be
* enable/disable, start/stop/clear, ... etc.)
*
* @obj: Pointer to the tracefs_XXX objext for witch the user action will
* apply.
* @instance: Ftrace instance, can be NULL for top tracing instance.
* @more_arguments: Some additional arguments specific for the type XXX and
* the action YYY.
*/
void/int tracefs_XXX_YYY(struct tracefs_XXX *obj,
struct tracefs_instance *inst,
more_arguments);
Thanks a lot!
Yordan
next prev parent reply other threads:[~2021-10-11 14:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-24 9:56 [PATCH v2 0/4] Modifications of some 'hist' APIs Yordan Karadzhov (VMware)
2021-09-24 9:56 ` [PATCH v2 1/4] libtracefs: Add new constructors for histograms Yordan Karadzhov (VMware)
2021-09-24 15:51 ` Tzvetomir Stoyanov
2021-09-24 15:54 ` Steven Rostedt
2021-09-24 16:53 ` Yordan Karadzhov
2021-09-24 9:57 ` [PATCH v2 2/4] libtracefs: Transform tracefs_hist_add_sort_key() Yordan Karadzhov (VMware)
2021-09-24 15:51 ` Tzvetomir Stoyanov
2021-09-24 16:56 ` Yordan Karadzhov
2021-11-10 22:43 ` Steven Rostedt
2021-09-24 9:57 ` [PATCH v2 3/4] libtracefs: Add new 'hist' APIs Yordan Karadzhov (VMware)
2021-09-24 9:57 ` [PATCH v2 4/4] libtracefs: Update 'hist' documentation Yordan Karadzhov (VMware)
2021-10-11 13:55 ` Yordan Karadzhov [this message]
2021-10-13 2:14 ` [RFC] Modifications of some 'hist' APIs Steven Rostedt
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=5439fe13-8d78-2fe6-3749-5e60cf10151c@gmail.com \
--to=y.karadz@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/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).