Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1383385

Re: [PATCH v5 1/6] perf tools: Derive trigger class from auxtrace_snapshot

From Namhyung Kim <namhyung@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v5 1/6] perf tools: Derive trigger class from auxtrace_snapshot
Date 2016-04-20 15:30 +0200
Message-ID <rq0mC-5D-3@gated-at.bofh.it> (permalink)
References <rpiOB-7ii-3@gated-at.bofh.it> <rpiOC-7ii-37@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hello,

On Mon, Apr 18, 2016 at 02:55:27PM +0000, Wang Nan wrote:
> Use 'trigger' to model operations which need to be executed when
> an event (a signal, for example) is observed.
> 
> States and transits:
> 
>  OFF--(on)--> READY --(toggle)--> TOGGLED
>                 ^                    |
>                 |                 (ready)
>                 |                    |
>                  \__________________/
> 
> is_toggled and is_ready are two key functions to query the state of
> a trigger. is_toggled means the event already happen; is_ready means the
> trigger is waiting for the event.

Not sure 'toggle' is the right word in this case.  Maybe 'set/reset'
or 'ready/hit' can be used, if each operation is one-way.  But this is
not a big deal anyway.

Btw why not split this patch into two parts - introducing trigger
logic and replacing snapshot code with the trigger?


> 
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: He Kuang <hekuang@huawei.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Zefan Li <lizefan@huawei.com>
> Cc: pi3orama@163.com
> ---

[SNIP]
> +#define __TRIGGER_VAR(n) n##_state
> +#define __DEF_TRIGGER_VOID_FUNC(n, op)	\
> +static inline void n##_##op(void) {trigger_##op(&__TRIGGER_VAR(n)); }
> +#define __DEF_TRIGGER_BOOL_FUNC(n, op)	\
> +static inline bool n##_##op(void) {return trigger_##op(&__TRIGGER_VAR(n)); }
> +
> +#define DEFINE_TRIGGER(n)					\
> +struct trigger n##_state = {.state = TRIGGER_OFF, .name = #n};	\
> +__DEF_TRIGGER_VOID_FUNC(n, on)					\
> +__DEF_TRIGGER_VOID_FUNC(n, ready)				\
> +__DEF_TRIGGER_VOID_FUNC(n, toggle)				\
> +__DEF_TRIGGER_VOID_FUNC(n, off)					\
> +__DEF_TRIGGER_VOID_FUNC(n, error)				\
> +__DEF_TRIGGER_BOOL_FUNC(n, is_ready)				\
> +__DEF_TRIGGER_BOOL_FUNC(n, is_toggled)				\
> +__DEF_TRIGGER_BOOL_FUNC(n, is_error)

Why did you define all functions for each trigger variable?  Wouldn't
it be better using generic trigger code and passing the trigger instead?

Thanks,
Namhyung

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v5 1/6] perf tools: Derive trigger class from auxtrace_snapshot Wang Nan <wangnan0@huawei.com> - 2016-04-18 17:00 +0200
  Re: [PATCH v5 1/6] perf tools: Derive trigger class from  auxtrace_snapshot Jiri Olsa <jolsa@redhat.com> - 2016-04-20 09:50 +0200
  Re: [PATCH v5 1/6] perf tools: Derive trigger class from  auxtrace_snapshot Namhyung Kim <namhyung@kernel.org> - 2016-04-20 15:30 +0200

csiph-web