From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
"H. Peter Anvin" <hpa@zytor.com>,
Jeremy Fitzhardinge <jeremy@goop.org>,
Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>, Joe Perches <joe@perches.com>,
linux-kernel@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [RFC PATCH] Fair low-latency rwlock v5
Date: Tue, 19 Aug 2008 03:33:45 -0400 [thread overview]
Message-ID: <20080819073345.GA30285@Krystal> (raw)
In-Reply-To: <20080819060417.GB24085@Krystal>
* Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca) wrote:
[...]
> The problem of this approach wrt RT kernels is that we cannot provide
> enough "priority groups" (current irq, softirq and threads in mainline
> kernel) for all the subtile priority levels of RT kernels. The more
> groups we add, the less threads we allow on the system.
>
> So basically, the relationship between the max number of threads (T) and
> the number of reader priorities goes as follow on a 64 bits machine :
>
> T writers subscribed count bits
> 1 bit for writer mutex
>
> for first priority group :
> T reader count bits
> (no need of reader exclusion bit because the writer subscribed count
> bits and the writer mutex act as exclusion)
>
> for each other priority group :
> T reader count bits
> 1 reader exclusion bit (set by the writer)
>
> We have the inequality :
>
> 64 >= (T + 1) + T + (NR_PRIORITIES - 1) * (T + 1)
>
> 64 >= (2T + 1) + (NR_PRIORITIES - 1) * (T + 1)
> 63 - 2T >= (NR_PRIORITIES - 1) * (T + 1)
> ((63 - 2T) / (T + 1)) + 1 >= NR_PRIORITIES
>
> Therefore :
>
> Thread bits | Max number of threads | Number of priorities
> 31 | 2147483648 | 1
> 20 | 1048576 | 2
> 15 | 32768 | 3
> 12 | 4096 | 4
> 9 | 512 | 5
> 8 | 256 | 6
> 7 | 128 | 7
> 6 | 64 | 8
> 5 | 32 | 9
> 4 | 16 | 10
> 3 | 8 | 15
>
> Starting from here, we have more priority groups than threads in the
> system, which becomes somewhat pointless... :)
>
> So currently, for the mainline kernel, I chose 3 priority levels thread,
> softirq, irq), which gives me 32768 max CPU in the system because I
> choose to disable preemption. However, we can think of ways to tune that
> in the direction we prefer. We could also hybrid those : having more
> bits for some groups which have preemptable threads (for which we need
> a max. of nr. threads) and less bits for other groups where preemption
> is disabled (where we only need enough bits to cound NR_CPUS)
>
> Ideas are welcome...
>
>
It strikes me that Intel has a nice (probably slow?) cmpxchg16b
instruction on x86_64. Therefore, we could atomically update 128 bits,
which gives the following table :
((127 - 2T) / (T + 1)) + 1 >= NR_PRIORITIES
Thread bits | Max number of threads | Number of priorities
63 | 2^63 | 1
42 | 2^42 | 2
31 | 2^31 | 3
24 | 2^24 | 4
20 | 2^20 | 5
17 | 131072 | 6
15 | 32768 | 7
13 | 8192 | 8
11 | 2048 | 9
10 | 1024 | 10
9 | 512 | 11
8 | 256 | 13
7 | 128 | 15
6 | 64 | 17
5 | 32 | 20
4 | 16 | 24
.. where we have more priorities than threads.
So I wonder if having in the surrounding of 10 priorities, which could
dynamically adapt the number of threads to the number of priorities
available, could be interesting for the RT kernel ?
That would however depend on the very architecture-specific cmpxchg16b.
Mathieu
--
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
next prev parent reply other threads:[~2008-08-19 7:33 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-16 7:39 [PATCH] x86_64 : support atomic ops with 64 bits integer values Mathieu Desnoyers
2008-08-16 15:04 ` H. Peter Anvin
2008-08-16 15:43 ` Mathieu Desnoyers
2008-08-16 17:30 ` Linus Torvalds
2008-08-16 21:19 ` [RFC PATCH] Fair rwlock Mathieu Desnoyers
2008-08-16 21:33 ` Linus Torvalds
2008-08-17 7:53 ` [RFC PATCH] Fair low-latency rwlock v3 Mathieu Desnoyers
2008-08-17 16:17 ` Linus Torvalds
2008-08-17 19:10 ` [RFC PATCH] Fair low-latency rwlock v5 Mathieu Desnoyers
2008-08-17 21:30 ` [RFC PATCH] Fair low-latency rwlock v5 (updated benchmarks) Mathieu Desnoyers
2008-08-18 18:59 ` [RFC PATCH] Fair low-latency rwlock v5 Linus Torvalds
2008-08-18 23:25 ` Paul E. McKenney
2008-08-19 6:04 ` Mathieu Desnoyers
2008-08-19 7:33 ` Mathieu Desnoyers [this message]
2008-08-19 9:06 ` Mathieu Desnoyers
2008-08-19 16:48 ` Linus Torvalds
2008-08-21 20:50 ` [RFC PATCH] Writer-biased low-latency rwlock v8 Mathieu Desnoyers
2008-08-21 21:00 ` Linus Torvalds
2008-08-21 21:15 ` Linus Torvalds
2008-08-21 22:22 ` Linus Torvalds
2008-08-23 5:09 ` Mathieu Desnoyers
2008-08-23 18:02 ` Linus Torvalds
2008-08-23 20:30 ` Mathieu Desnoyers
2008-08-23 21:40 ` Linus Torvalds
2008-08-21 21:26 ` H. Peter Anvin
2008-08-21 21:41 ` Linus Torvalds
2008-08-25 19:20 ` [RFC PATCH] Fair low-latency rwlock v5 Peter Zijlstra
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=20080819073345.GA30285@Krystal \
--to=mathieu.desnoyers@polymtl.ca \
--cc=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=jeremy@goop.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rostedt@goodmis.org \
--cc=torvalds@linux-foundation.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