Re: [PATCH 1/2] tools/lib/traceevent: make libtraceevent thread safe

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

 



On Wed, 5 Dec 2018 09:22:12 +0000
Tzvetomir Stoyanov <tstoyanov@xxxxxxxxxx> wrote:

> @@ -3499,19 +3500,19 @@ struct tep_event *tep_find_event(struct tep_handle *pevent, int id)
>   * @sys. If @sys is NULL the first event with @name is returned.
>   */
>  struct tep_event *
> -tep_find_event_by_name(struct tep_handle *pevent,
> +tep_find_event_by_name(struct tep_handle *tep,
>  		       const char *sys, const char *name)
>  {
> -	struct tep_event *event;
>  	int i;
> +	struct tep_event *event = NULL;
> +	struct tep_event *event_cache = get_thread_local_event_by_name(tep, name, sys);

BTW, I modified this to keep with the "upside down christmas tree"
method. That is, instead of:

	int i;
	struct tep_event *event = NULL;
	struct tep_event *event_cache = get_thread_local_event_by_name(tep, name, sys);

I made it:

	struct tep_event *event_cache = get_thread_local_event_by_name(tep, name, sys);
	struct tep_event *event = NULL;
	int i;

to make it look better, and some kernel developers (as well as the perf
developers) require that for declarations.

-- Steve

>  
> -	if (pevent->last_event &&
> -	    strcmp(pevent->last_event->name, name) == 0 &&
> -	    (!sys || strcmp(pevent->last_event->system, sys) == 0))
> -		return pevent->last_event;
> +	/* Check cache first */
> +	if (event_cache)
> +		return event_cache;
>  
> -	for (i = 0; i < pevent->nr_events; i++) {
> -		event = pevent->events[i];
> +	for (i = 0; i < tep->nr_events; i++) {
> +		event = tep->events[i];
>  		if (strcmp(event->name, name) == 0) {
>  			if (!sys)
>  				break;



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

  Powered by Linux