public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jiri Olsa <olsajiri@gmail.com>
Cc: Alan Maguire <alan.maguire@oracle.com>,
	yhs@fb.com, ast@kernel.org, eddyz87@gmail.com,
	sinquersw@gmail.com, timo@incline.eu, daniel@iogearbox.net,
	andrii@kernel.org, songliubraving@fb.com,
	john.fastabend@gmail.com, kpsingh@chromium.org, sdf@google.com,
	haoluo@google.com, martin.lau@kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH v2 dwarves 3/5] btf_encoder: rework btf_encoders__*() API to allow traversal of encoders
Date: Mon, 30 Jan 2023 21:24:06 -0300	[thread overview]
Message-ID: <Y9hfpqES52+um9mR@kernel.org> (raw)
In-Reply-To: <Y9g+5LlDrOjqS5ES@krava>

Em Mon, Jan 30, 2023 at 11:04:20PM +0100, Jiri Olsa escreveu:
> On Mon, Jan 30, 2023 at 02:29:43PM +0000, Alan Maguire wrote:
> > To coordinate across multiple encoders at collection time, there
> > will be a need to access the set of encoders.  Rework the unused
> > btf_encoders__*() API to facilitate this.
> > 
> > Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> > ---
> >  btf_encoder.c | 30 ++++++++++++++++++++++--------
> >  btf_encoder.h |  6 ------
> >  2 files changed, 22 insertions(+), 14 deletions(-)
> > 
> > diff --git a/btf_encoder.c b/btf_encoder.c
> > index 44f1905..e20b628 100644
> > --- a/btf_encoder.c
> > +++ b/btf_encoder.c
> > @@ -30,6 +30,7 @@
> >  
> >  #include <errno.h>
> >  #include <stdint.h>
> > +#include <pthread.h>
> >  
> >  struct elf_function {
> >  	const char	*name;
> > @@ -79,21 +80,32 @@ struct btf_encoder {
> >  	} functions;
> >  };
> >  
> > -void btf_encoders__add(struct list_head *encoders, struct btf_encoder *encoder)
> > -{
> > -	list_add_tail(&encoder->node, encoders);
> > -}
> > +static LIST_HEAD(encoders);
> > +static pthread_mutex_t encoders__lock = PTHREAD_MUTEX_INITIALIZER;
> >  
> > -struct btf_encoder *btf_encoders__first(struct list_head *encoders)
> > +/* mutex only needed for add/delete, as this can happen in multiple encoding
> > + * threads.  Traversal of the list is currently confined to thread collection.
> > + */
> > +static void btf_encoders__add(struct btf_encoder *encoder)
> >  {
> > -	return list_first_entry(encoders, struct btf_encoder, node);
> > +	pthread_mutex_lock(&encoders__lock);
> > +	list_add_tail(&encoder->node, &encoders);
> > +	pthread_mutex_unlock(&encoders__lock);
> >  }
> >  
> > -struct btf_encoder *btf_encoders__next(struct btf_encoder *encoder)
> > +#define btf_encoders__for_each_encoder(encoder)		\
> > +	list_for_each_entry(encoder, &encoders, node)
> > +
> > +static void btf_encoders__delete(struct btf_encoder *encoder)
> >  {
> > -	return list_next_entry(encoder, node);
> > +	pthread_mutex_lock(&encoders__lock);
> > +	list_del(&encoder->node);
> > +	pthread_mutex_unlock(&encoders__lock);
> >  }
> >  
> > +#define btf_encoders__for_each_encoder(encoder)			\
> > +	list_for_each_entry(encoder, &encoders, node)
> > +
> 
> there's extra btf_encoders__for_each_encoder define
> 
> hum I'm scratching my head how this compile, probably because it's identical

I removed it, thanks!

- Arnaldo
 
> jirka
> 
> 
> >  #define PERCPU_SECTION ".data..percpu"
> >  
> >  /*
> > @@ -1505,6 +1517,7 @@ struct btf_encoder *btf_encoder__new(struct cu *cu, const char *detached_filenam
> >  
> >  		if (encoder->verbose)
> >  			printf("File %s:\n", cu->filename);
> > +		btf_encoders__add(encoder);
> >  	}
> >  out:
> >  	return encoder;
> > @@ -1519,6 +1532,7 @@ void btf_encoder__delete(struct btf_encoder *encoder)
> >  	if (encoder == NULL)
> >  		return;
> >  
> > +	btf_encoders__delete(encoder);
> >  	__gobuffer__delete(&encoder->percpu_secinfo);
> >  	zfree(&encoder->filename);
> >  	btf__free(encoder->btf);
> > diff --git a/btf_encoder.h b/btf_encoder.h
> > index a65120c..34516bb 100644
> > --- a/btf_encoder.h
> > +++ b/btf_encoder.h
> > @@ -23,12 +23,6 @@ int btf_encoder__encode(struct btf_encoder *encoder);
> >  
> >  int btf_encoder__encode_cu(struct btf_encoder *encoder, struct cu *cu, struct conf_load *conf_load);
> >  
> > -void btf_encoders__add(struct list_head *encoders, struct btf_encoder *encoder);
> > -
> > -struct btf_encoder *btf_encoders__first(struct list_head *encoders);
> > -
> > -struct btf_encoder *btf_encoders__next(struct btf_encoder *encoder);
> > -
> >  struct btf *btf_encoder__btf(struct btf_encoder *encoder);
> >  
> >  int btf_encoder__add_encoder(struct btf_encoder *encoder, struct btf_encoder *other);
> > -- 
> > 1.8.3.1
> > 

-- 

- Arnaldo

  reply	other threads:[~2023-01-31  0:24 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-30 14:29 [PATCH v2 dwarves 0/5] dwarves: support encoding of optimized-out parameters, removal of inconsistent static functions Alan Maguire
2023-01-30 14:29 ` [PATCH v2 dwarves 1/5] dwarves: help dwarf loader spot functions with optimized-out parameters Alan Maguire
2023-01-30 18:36   ` Arnaldo Carvalho de Melo
2023-01-30 20:10     ` Arnaldo Carvalho de Melo
2023-01-30 20:23       ` Arnaldo Carvalho de Melo
2023-01-30 22:37         ` Alan Maguire
2023-01-31  0:25           ` Arnaldo Carvalho de Melo
2023-01-31  1:04             ` Arnaldo Carvalho de Melo
2023-01-31 12:14               ` Alan Maguire
2023-01-31 12:33                 ` Arnaldo Carvalho de Melo
2023-01-31 13:35                   ` Jiri Olsa
2023-01-31 17:43                 ` Alexei Starovoitov
2023-01-31 18:16                   ` Alexei Starovoitov
2023-01-31 23:45                     ` Alan Maguire
2023-01-31 23:58                       ` David Vernet
2023-02-01  0:14                         ` Alexei Starovoitov
2023-02-01  3:02                           ` David Vernet
2023-02-01 13:59                             ` Alan Maguire
2023-02-01 15:02                               ` Arnaldo Carvalho de Melo
2023-02-01 15:13                                 ` Alan Maguire
2023-02-01 15:19                                 ` David Vernet
2023-02-01 16:49                                   ` Alexei Starovoitov
2023-02-01 17:01                                     ` Arnaldo Carvalho de Melo
2023-02-01 17:18                                       ` Alan Maguire
2023-02-01 18:54                                         ` Arnaldo Carvalho de Melo
2023-02-01 22:33                                         ` Alan Maguire
2023-02-01 22:32                                       ` Arnaldo Carvalho de Melo
2023-02-02  1:09                                         ` Arnaldo Carvalho de Melo
2023-02-03  1:09                             ` Yonghong Song
2023-01-30 14:29 ` [PATCH v2 dwarves 2/5] btf_encoder: refactor function addition into dedicated btf_encoder__add_func Alan Maguire
2023-02-01 17:19   ` Arnaldo Carvalho de Melo
2023-02-01 17:50     ` Alan Maguire
2023-02-01 18:59       ` Arnaldo Carvalho de Melo
2023-01-30 14:29 ` [PATCH v2 dwarves 3/5] btf_encoder: rework btf_encoders__*() API to allow traversal of encoders Alan Maguire
2023-01-30 22:04   ` Jiri Olsa
2023-01-31  0:24     ` Arnaldo Carvalho de Melo [this message]
2023-01-30 14:29 ` [PATCH v2 dwarves 4/5] btf_encoder: represent "."-suffixed functions (".isra.0") in BTF Alan Maguire
2023-01-30 14:29 ` [PATCH v2 dwarves 5/5] btf_encoder: delay function addition to check for function prototype inconsistencies Alan Maguire
2023-01-30 17:20   ` Alexei Starovoitov
2023-01-30 18:08     ` Arnaldo Carvalho de Melo

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=Y9hfpqES52+um9mR@kernel.org \
    --to=acme@kernel.org \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kpsingh@chromium.org \
    --cc=martin.lau@kernel.org \
    --cc=olsajiri@gmail.com \
    --cc=sdf@google.com \
    --cc=sinquersw@gmail.com \
    --cc=songliubraving@fb.com \
    --cc=timo@incline.eu \
    --cc=yhs@fb.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