Re: [PATCH 4/7] time: Update timekeeper structure using a localshadow

From: Ingo Molnar
Date: Tue Feb 28 2012 - 03:12:37 EST



* John Stultz <john.stultz@xxxxxxxxxx> wrote:

> static void update_wall_time(void)
> {
> struct clocksource *clock;
> + struct timekeeper tk;
> cycle_t offset;
> int shift = 0, maxshift;
> unsigned long flags;
> @@ -1063,10 +1064,11 @@ static void update_wall_time(void)
> if (unlikely(timekeeping_suspended))
> goto out;
>
> - clock = timekeeper.clock;
> + tk = timekeeper;

'tk' is now an on-stack copy of a very non-trivial (read: large)
structure - including locks, amongst other things. That's a
no-no.

> + timekeeper = tk;

You just broke lockdep here.

It's also ugly code: global data structures should almost always
be updated in situ, instead of updating a local copy and then
copying it back blindly ...

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/