Messages in this thread | | | Date | Mon, 17 Oct 2011 09:55:44 +0200 | From | Martin Schwidefsky <> | Subject | Re: Linux 3.1-rc9 |
| |
On Sun, 16 Oct 2011 18:39:57 -0700 Linus Torvalds <torvalds@linux-foundation.org> wrote:
> That stupid definition of cputime_add() has apparently existed as-is > since it was introduced in 2005. Why do we have code like this: > > times->utime = cputime_add(times->utime, t->utime); > > instead of just > > times->utime += t->utime; > > which seems not just shorter, but more readable too? The reason is not > some type safety in the cputime_add() thing, it's just a macro. > > Added Martin and Ingo to the discussion - Martin because he added that > cputime_add in the first place, and Ingo because he gets the most hits > on kernel/sched_stats.h. Guys - you can see the history on lkml.
I introduced those macros to find all the places in the kernel operating on a cputime value. The additional debug patch defined cputime_t as a struct which contained a single u64. That way I got a compiler error for every place I missed.
The reason for the cputime_xxx primitives has been my fear that people ignore the cputime_t type and just use unsigned long (as they always have). That would break s390 which needs a u64 for its cputime value. Dunno if we still need it, seems like we got used to using cputime_t.
-- blue skies, Martin.
"Reality continues to ruin my life." - Calvin.
| |