Re: [PATCH] nohz: Change tick_dep_mask from 'unsigned long' to 'unsigned int'

From: Ingo Molnar
Date: Tue Mar 15 2016 - 08:15:55 EST



* Ingo Molnar <mingo@xxxxxxxxxx> wrote:

>
> Linus noticed that the new tick_dep_mask types introduced in:
>
> d027d45d8a17 ("nohz: New tick dependency mask")
>
> ... are sloppily defined as 'unsigned long' - which is wasteful
> to carry just 4 bits and which may also create suboptimal data
> types on 64-bit systems with word alignment padding holes in them.
>
> Fix this by changing the type to the more natural 'unsigned int'.
>
> (The xchg_or() API will work fine with 'unsigned int' as well.)
>
> Reported-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> Cc: Chris Metcalf <cmetcalf@xxxxxxxxxx>
> Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
> Cc: Christoph Lameter <cl@xxxxxxxxx>
> Cc: Chris Metcalf <cmetcalf@xxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Luiz Capitulino <lcapitulino@xxxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Rik van Riel <riel@xxxxxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
> Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
> ---
> include/linux/sched.h | 4 ++--
> kernel/time/tick-sched.c | 11 +++++------
> 2 files changed, 7 insertions(+), 8 deletions(-)

Hm, so the problem I did not consider is the following:

triton:~/tip> git grep tick_dep_mask kernel | grep _bit
kernel/time/tick-sched.c: clear_bit(bit, &tick_dep_mask);
kernel/time/tick-sched.c: clear_bit(bit, &ts->tick_dep_mask);
kernel/time/tick-sched.c: clear_bit(bit, &tsk->tick_dep_mask);
kernel/time/tick-sched.c: clear_bit(bit, &sig->tick_dep_mask);

and the bitops natural type (and in fact the only supported bitops type) is
'unsigned long'.

So it's not that easy to change a bitmask over to unsigned int.

Suggestions?

Thanks,

Ingo