On Thu, Feb 17, 2022 at 5:19 AM Jiri Olsa <[email protected]> wrote:
>
> Both bpf_program__set_priv/bpf_program__priv are deprecated
> and will be eventually removed.
>
> Using hashmap to replace that functionality.
>
> Suggested-by: Andrii Nakryiko <[email protected]>
> Signed-off-by: Jiri Olsa <[email protected]>
> ---
> tools/perf/util/bpf-loader.c | 91 +++++++++++++++++++++++++++++-------
> 1 file changed, 75 insertions(+), 16 deletions(-)
>
[...]
> +
> +static int program_set_priv(struct bpf_program *prog, void *priv)
> +{
> + void *old_priv;
> +
> + if (!bpf_program_hash) {
> + bpf_program_hash = hashmap__new(ptr_hash, ptr_equal, NULL);
> + if (!bpf_program_hash)
should use IS_ERR here
> + return -ENOMEM;
> + }
> +
> + old_priv = program_priv(prog);
> + if (old_priv) {
> + clear_prog_priv(prog, old_priv);
> + return hashmap__set(bpf_program_hash, prog, priv, NULL, NULL);
> + }
> + return hashmap__add(bpf_program_hash, prog, priv);
> }
[...]
On Thu, Feb 17, 2022 at 01:47:16PM -0800, Andrii Nakryiko wrote:
> On Thu, Feb 17, 2022 at 5:19 AM Jiri Olsa <[email protected]> wrote:
> >
> > Both bpf_program__set_priv/bpf_program__priv are deprecated
> > and will be eventually removed.
> >
> > Using hashmap to replace that functionality.
> >
> > Suggested-by: Andrii Nakryiko <[email protected]>
> > Signed-off-by: Jiri Olsa <[email protected]>
> > ---
> > tools/perf/util/bpf-loader.c | 91 +++++++++++++++++++++++++++++-------
> > 1 file changed, 75 insertions(+), 16 deletions(-)
> >
>
> [...]
>
> > +
> > +static int program_set_priv(struct bpf_program *prog, void *priv)
> > +{
> > + void *old_priv;
> > +
> > + if (!bpf_program_hash) {
> > + bpf_program_hash = hashmap__new(ptr_hash, ptr_equal, NULL);
> > + if (!bpf_program_hash)
>
> should use IS_ERR here
ah right, thanks
jirka
>
> > + return -ENOMEM;
> > + }
> > +
> > + old_priv = program_priv(prog);
> > + if (old_priv) {
> > + clear_prog_priv(prog, old_priv);
> > + return hashmap__set(bpf_program_hash, prog, priv, NULL, NULL);
> > + }
> > + return hashmap__add(bpf_program_hash, prog, priv);
> > }
>
> [...]