mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org, Paul Mackerras <paulus@samba.org>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH] perf lock: Implement basic sorting function of perf lock
Date: Fri, 08 Jan 2010 17:33:59 +0900	[thread overview]
Message-ID: <4B46EDF7.3040205@dcl.info.waseda.ac.jp> (raw)
In-Reply-To: <1261998064.7135.74.camel@laptop>

On 2009年12月28日 20:01, Peter Zijlstra wrote:
> On Sun, 2009-12-20 at 11:56 +0900, Hitoshi Mitake wrote:
>> +static struct lock_stat *lock_stat_findnew(void *addr, const char *name)
>> +{
>> +       struct list_head *entry = lockhashentry(addr);
>> +       struct lock_stat *ret, *new;
>
>
> Right, so you use a hash table to match lock instances, I suppose that's
> faster than an rb-tree?

Maybe. But it is hard to determine which data structure is better.
This is a histogram from perf.data produced by "perf bench sched messaging",

(left is length of list, right is number of list whose length is value 
of left)
0: 3333
1: 153
2: 91
3: 114
4: 96
5: 75
6: 61
7: 43
8: 29
9: 32
10: 23
11: 15
12: 9
13: 5
14: 7
15: 3
16: 1
17: 3
18: 0
19: 3   # 19 means "longer than 19"

Total number of lock instances is 3459,
so if perf lock use rb-tree for storing info of lock instances,
average order of accessing stored node is lg 4096 == 12.
And the histogram above describes,
there are relatively very few lists with length over 12.
So I think hash list is better thing for storing info of lock instances 
than rb-tree.
(Sorting result is another issue, of course.)

>
> Do you also remove instances after a match to keep the hash relatively
> small?
>
>

No, I don't.
At the last phase of profiling,
perf lock makes rb-tree sorted by the key user specified.

static void sort_result(void)
{
	unsigned int i;
	struct lock_stat *st;

	for (i = 0; i < LOCKHASH_SIZE; i++) {
		list_for_each_entry(st, &lockhash_table[i], hash_entry) {
			insert_to_result(st, compare); # insert to rb-tree
		}
	}
}

As this code describes,
referencing the completed hash list is done only once.
So removing instances to keep the hash list relatively small
is not required, I think.

      reply	other threads:[~2010-01-08  8:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-20  2:56 Hitoshi Mitake
2009-12-28 10:17 ` Peter Zijlstra
2010-01-08  8:02   ` Hitoshi Mitake
2009-12-28 10:58 ` Peter Zijlstra
2010-01-08  8:04   ` Hitoshi Mitake
2009-12-28 11:01 ` Peter Zijlstra
2010-01-08  8:33   ` Hitoshi Mitake [this message]

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=4B46EDF7.3040205@dcl.info.waseda.ac.jp \
    --to=mitake@dcl.info.waseda.ac.jp \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    /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

all inboxes | Powered by JetHome®