Re: [RFC patch 4/7] timekeeping: Add NMI safe accessor to mono/boot/real clocks

From: Linus Torvalds
Date: Fri Nov 17 2017 - 18:12:48 EST


On Fri, Nov 17, 2017 at 3:00 PM, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> Could you indent this better. It looks like timekeeping_delta_to_ns()
> takes 4 arguments, when it really only takes two.

Actually, even better would be to simply not have that ugly three-line
expression from hell.

Maybe it could even be a helper inline function, somethin glike

static inline u64 tk_delta_ns(struct tk_read_base *tkr)
{
u64 cycle = tk_clock_read(tkr);
u64 delta= clocksource_delta(cycle, tkr->cycle_last, tkr->mask);
return timekeeping_delta_to_ns(tkr, cycle);
}

and that whole thing would just become

now += tk_delta_ns(tkr);

which looks a whole lot more legible. And shouldn't generate any worse code.

(I might have screwed up something, I wrote that in the email client,
maybe I got something wrong.

And my name choice is probably garbage. But you get the idea.

Linus