Re: [PATCH v1 1/3] libtracefs: Add user_events to libtracefs sources

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 22, 2022 at 09:00:21AM -0500, Steven Rostedt wrote:
> On Tue, 22 Feb 2022 08:27:31 +0200
> Yordan Karadzhov <y.karadz@xxxxxxxxx> wrote:
> 
> > I have one last question. Do you consider as a valid use case that
> > the library must support, someone to do a just 'test" without writing
> > after this, or to "write" without testing first?
> 
> Actually, that's a very good point.
> 
> I was thinking that I didn't like the "test" name, and was thinking of
> having it be:
> 
> 	if (tracefs_user_event_enabled(event)) {
> 		tracefs_user_event_record(event, ...);
> 	}

I do like the renaming of test to enabled and write to record.

> 
> But I think you have a good point. Perhaps we should just have:
> 
> 	tracefs_user_event_trace(event, ...);
> 
> and it do all the work. But it would need to be a macro, that does:
> 
> #define tracefs_user_event_trace(event, ...)			\
> 	do {							\
> 		if (tracefs_user_event_enabled(event)) {	\
> 			tracefs_user_event_record(event, ##__VA_ARGS); \
> 		}						\
> 	} while (0)
> 
> Because we do not want to have the compiler process the arguments when
> the event is not enabled. That would be too much overhead.
> 
> But as a macro, it would work.
> 
> Thoughts?

Many times we have found that we have to do work that should only be
performed if the event is enabled. As long as there is a still clear
ways to check without the macro, this would be fine with me.

IE: strlen(message)

We should not walk strings unless the event is enabled.

Thanks,
-Beau



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux