lkml.org 
[lkml]   [2010]   [Apr]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [GIT PULL] scheduler fix

* Andreas Schwab <schwab@redhat.com> wrote:

> Linus Torvalds <torvalds@linux-foundation.org> writes:
>
> > On Thu, 8 Apr 2010, Ingo Molnar wrote:
> >>
> >> - if (len < nr_cpu_ids)
> >> + if ((len * BITS_PER_BYTE) < nr_cpu_ids)
> >> return -EINVAL;
> >
> > Not that it really matters, but this will now fail for no good reason if
> > you pass it a half-gigabyte area due to overflow.
>
> Which can easily be avoided.
>
> if (len < DIV_ROUND_UP(nr_cpu_ids, BITS_PER_BYTE))

nr_cpu_ids is a signed integer which turns the DIV_ROUND_UP into a somewhat
suboptimal instruction sequence. (havent checked it though)

So i'd suggest changing nr_cpu_ids to unsigned int [unless there's some strong
reason to have it signed] plus doing something like:

if (len < (nr_cpu_ids >> BITS_PER_BYTE_BITS))

ought to both result in better code and should be more readable. We'd have to
add:

#define BITS_PER_BYTE_BITS 3

to linux/bitops.h.

Ingo


\
 
 \ /
  Last update: 2010-04-08 20:29    [W:0.053 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site