All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Eduard Zingerman <eddyz87@gmail.com>
Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>,
	dwarves@vger.kernel.org, bpf@vger.kernel.org, kernel-team@fb.com,
	ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	yhs@fb.com, mykolal@fb.com
Subject: Re: [PATCH dwarves] pahole: avoid adding same struct structure to two rb trees
Date: Mon, 10 Jul 2023 10:13:53 -0300	[thread overview]
Message-ID: <ZKwEEd1Ercz8kkId@kernel.org> (raw)
In-Reply-To: <ZH4vZjaQnCGOzY/w@kernel.org>

Em Mon, Jun 05, 2023 at 03:54:30PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Mon, Jun 05, 2023 at 05:39:19PM +0300, Eduard Zingerman escreveu:
> > On Mon, 2023-06-05 at 10:47 -0300, Arnaldo Carvalho de Melo wrote:
> > > Em Fri, Jun 02, 2023 at 09:08:51PM +0300, Eduard Zingerman escreveu:
> > > > On Fri, 2023-06-02 at 15:04 -0300, Arnaldo Carvalho de Melo wrote:
> > > > > Em Fri, Jun 02, 2023 at 04:52:40PM +0300, Eduard Zingerman escreveu:
> > > > > > Right, you are correct.
> > > > > > The 'structures__tree = RB_ROOT' part is still necessary, though.
> > > > > > If you are ok with overall structure of the patch I can resend it w/o bzero().
> > > 
> > > > > Humm, so basically this boils down to the following patch?
> > > 
> > > > > +++ b/pahole.c
> > > > > @@ -674,7 +674,12 @@ static void print_ordered_classes(void)
> > > > >  		__print_ordered_classes(&structures__tree);
> > > > >  	} else {
> > > > >  		struct rb_root resorted = RB_ROOT;
> > > > > -
> > > > > +#ifdef DEBUG_CHECK_LEAKS
> > > > > +		// We'll delete structures from structures__tree, since we're
> > > > > +		// adding them to ther resorted list, better not keep
> > > > > +		// references there.
> > > > > +		structures__tree = RB_ROOT;
> > > > > +#endif
> > >  
> > > > But __structures__delete iterates over structures__tree,
> > > > so it won't delete anything if code like this, right?
> > >  
> > > > >  		resort_classes(&resorted, &structures__list);
> > > > >  		__print_ordered_classes(&resorted);
> > > > >  	}
> > > 
> > > Yeah, I tried to be minimalistic, my version avoids the crash, but
> > > defeats the DEBUG_CHECK_LEAKS purpose :-\
> > > 
> > > How about:
> > > 
> > > diff --git a/pahole.c b/pahole.c
> > > index 6fc4ed6a721b97ab..e843999fde2a8a37 100644
> > > --- a/pahole.c
> > > +++ b/pahole.c
> > > @@ -673,10 +673,10 @@ static void print_ordered_classes(void)
> > >  	if (!need_resort) {
> > >  		__print_ordered_classes(&structures__tree);
> > >  	} else {
> > > -		struct rb_root resorted = RB_ROOT;
> > > +		structures__tree = RB_ROOT;
> > >  
> > > -		resort_classes(&resorted, &structures__list);
> > > -		__print_ordered_classes(&resorted);
> > > +		resort_classes(&structures__tree, &structures__list);
> > > +		__print_ordered_classes(&structures__tree);
> > >  	}
> > >  }
> > >  
> > 
> > That would work, but I still think that there is no need to replicate call

I'm going thru the pile of stuff from before my vacations, can I take
the above as an Acked-by in addition to your Reported-by?

- Arnaldo

> > to __print_ordered_classes, as long as the same list is passed as an argument,
> > e.g.:
> > 
> > @@ -670,14 +671,11 @@ static void resort_classes(struct rb_root *resorted, struct list_head *head)
> >  
> >  static void print_ordered_classes(void)
> >  {
> > -       if (!need_resort) {
> > -               __print_ordered_classes(&structures__tree);
> > -       } else {
> > -               struct rb_root resorted = RB_ROOT;
> > -
> > -               resort_classes(&resorted, &structures__list);
> > -               __print_ordered_classes(&resorted);
> > +       if (need_resort) {
> > +               structures__tree = RB_ROOT;
> > +               resort_classes(&structures__tree, &structures__list);
> >         }
> > +       __print_ordered_classes(&structures__tree);
> >  }
> 
> Right, that can be done as a follow up patch, further simplifying the
> code.
> 
> I'm just trying to have each patch as small as possible.

  reply	other threads:[~2023-07-10 13:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-25 23:59 [PATCH dwarves] pahole: avoid adding same struct structure to two rb trees Eduard Zingerman
2023-06-02 13:42 ` Arnaldo Carvalho de Melo
2023-06-02 13:52   ` Eduard Zingerman
2023-06-02 18:04     ` Arnaldo Carvalho de Melo
2023-06-02 18:08       ` Eduard Zingerman
2023-06-05 13:47         ` Arnaldo Carvalho de Melo
2023-06-05 14:39           ` Eduard Zingerman
2023-06-05 18:54             ` Arnaldo Carvalho de Melo
2023-07-10 13:13               ` Arnaldo Carvalho de Melo [this message]
2023-07-10 13:15                 ` Eduard Zingerman

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=ZKwEEd1Ercz8kkId@kernel.org \
    --to=acme@kernel.org \
    --cc=andrii@kernel.org \
    --cc=arnaldo.melo@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dwarves@vger.kernel.org \
    --cc=eddyz87@gmail.com \
    --cc=kernel-team@fb.com \
    --cc=mykolal@fb.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.