linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	 Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	 Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	 Adrian Hunter <adrian.hunter@intel.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	 Yang Jihong <yangjihong1@huawei.com>,
	linux-kernel@vger.kernel.org,  linux-perf-users@vger.kernel.org,
	bpf@vger.kernel.org
Subject: Re: [PATCH v1 4/6] perf threads: Move threads to its own files
Date: Wed, 28 Feb 2024 15:43:59 -0800	[thread overview]
Message-ID: <CAM9d7cj-kxaQc18QG_cd6EzsDbk7vmhYqg-XzCV+g5oi9Giwww@mail.gmail.com> (raw)
In-Reply-To: <CAP-5=fWKdp7rf+v7t_T_0tU0OxQO9R2g+ZH7Ag7HgyBbGT3-nQ@mail.gmail.com>

On Tue, Feb 27, 2024 at 11:24 PM Ian Rogers <irogers@google.com> wrote:
>
> On Tue, Feb 27, 2024 at 10:40 PM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > On Tue, Feb 27, 2024 at 1:42 PM Ian Rogers <irogers@google.com> wrote:
> > >
> > > On Tue, Feb 27, 2024 at 11:17 AM Arnaldo Carvalho de Melo
> > > <acme@kernel.org> wrote:
> > > >
> > > > On Tue, Feb 27, 2024 at 09:31:33AM -0800, Namhyung Kim wrote:
> > > > > I can see some other differences like machine__findnew_thread()
> > > > > which I think is due to the locking change.  Maybe we can fix the
> > > > > problem before moving the code and let the code move simple.
> > > >
> > > > I was going to suggest that, agreed.
> > > >
> > > > We may start doing a refactoring, then find a bug, at that point we
> > > > first fix the problem them go back to refactoring.
> > >
> > > Sure I do this all the time. Your typical complaint on the v+1 patch
> > > set is to move the bug fixes to the front of the changes. On the v+2
> > > patch set the bug fixes get applied but not the rest of the patch
> > > series, etc.
> > >
> > > Here we are refactoring code for an rb-tree implementation of threads
> > > and worrying about its correctness. There's no indication it's not
> > > correct, it is largely copy and paste, there is also good evidence in
> > > the locking disciple it is more correct. The next patch deletes that
> > > implementation, replacing it with a hash table. Were I not trying to
> > > break things apart I could squash those 2 patches together, but I've
> > > tried to do the right thing. Now we're trying to micro correct, break
> > > apart, etc. a state that gets deleted. A reviewer could equally
> > > criticise this being 2 changes rather than 1, and the cognitive load
> > > of having to look at code that gets deleted. At some point it is a
> > > judgement call, and I think this patch is actually the right size. I
> > > think what is missing here is some motivation in the commit message to
> > > the findnew refactoring and so I'll add that.
> >
> > I'm not against your approach and actually appreciate your effort
> > to split rb-tree refactoring and hash table introduction.  What I'm
> > asking is just to separate out the code moving.  I think you can do
> > whatever you want in the current file.  Once you have the final code
> > you can move it to its own file exactly the same.  When I look at this
> > commit, say a few years later, I won't expect a commit that says
> > moving something to a new file has other changes.
>
> The problem is that the code in machine treats the threads lock as if
> it is a lock in machine. So there is __machine__findnew_thread which
> implies the thread lock is held. This change is making threads its own
> separate concept/collection and the lock belongs with that collection.
> Most of the implementation of threads__findnew matches
> __machine__findnew_thread, so we may be able to engineer a smaller
> line diff by moving "__machine__findnew_thread" code into threads.c,
> then renaming it to build the collection, etc. We could also build the
> threads collection inside of machine and then in a separate change
> move it to threads.[ch].  In the commit history this seems muddier
> than just splitting out threads as a collection. Also, some of the API
> design choices are motivated more by the hash table implementation of
> the next patch than trying to have a good rbtree abstracted collection
> of threads. Essentially it'd be engineering a collection of threads
> but only with a view to delete it in the next patch. I don't think it
> would be for the best and the commit history for deleted code is
> unlikely to be looked upon.

I think the conversation is repeating. :)  Why not do this?

1. refactor threads code in machine.c and fix the locking
2. move threads code to its own file
3. use hash table in threads

Thanks,
Namhyung

  reply	other threads:[~2024-02-28 23:44 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14  6:37 [PATCH v1 0/6] Thread memory improvements and fixes Ian Rogers
2024-02-14  6:37 ` [PATCH v1 1/6] perf report: Sort child tasks by tid Ian Rogers
2024-02-14 17:24   ` Arnaldo Carvalho de Melo
2024-02-14 17:42     ` Ian Rogers
2024-02-16 20:25       ` Namhyung Kim
2024-02-27  6:39   ` Namhyung Kim
2024-02-27  7:12     ` Ian Rogers
2024-02-28  6:11       ` Namhyung Kim
2024-02-28  7:05         ` Ian Rogers
2024-02-28 22:45           ` Namhyung Kim
2024-02-14  6:37 ` [PATCH v1 2/6] perf trace: Ignore thread hashing in summary Ian Rogers
2024-02-14 17:25   ` Arnaldo Carvalho de Melo
2024-02-14 18:27     ` Ian Rogers
2024-02-14 21:15       ` Ian Rogers
2024-02-14 21:36         ` Ian Rogers
2024-02-14 21:42           ` Ian Rogers
2024-02-16 14:57           ` Arnaldo Carvalho de Melo
2024-02-27  6:55   ` Namhyung Kim
2024-02-14  6:37 ` [PATCH v1 3/6] perf machine: Move fprintf to for_each loop and a callback Ian Rogers
2024-02-14  6:37 ` [PATCH v1 4/6] perf threads: Move threads to its own files Ian Rogers
2024-02-27  7:07   ` Namhyung Kim
2024-02-27  7:24     ` Ian Rogers
2024-02-27 17:31       ` Namhyung Kim
2024-02-27 19:02         ` Ian Rogers
2024-02-27 19:17         ` Arnaldo Carvalho de Melo
2024-02-27 21:42           ` Ian Rogers
2024-02-28  6:39             ` Namhyung Kim
2024-02-28  7:24               ` Ian Rogers
2024-02-28 23:43                 ` Namhyung Kim [this message]
2024-02-29  0:31                   ` Ian Rogers
2024-02-29 21:59       ` David Laight
2024-03-01  0:19         ` Ian Rogers
2024-02-14  6:37 ` [PATCH v1 5/6] perf threads: Switch from rbtree to hashmap Ian Rogers
2024-02-14  6:37 ` [PATCH v1 6/6] perf threads: Reduce table size from 256 to 8 Ian Rogers
2024-02-25 18:50 ` [PATCH v1 0/6] Thread memory improvements and fixes Ian Rogers

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=CAM9d7cj-kxaQc18QG_cd6EzsDbk7vmhYqg-XzCV+g5oi9Giwww@mail.gmail.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=oliver.upton@linux.dev \
    --cc=peterz@infradead.org \
    --cc=yangjihong1@huawei.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;
as well as URLs for NNTP newsgroup(s).