lkml.org 
[lkml]   [2019]   [Apr]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 12/16] locking/rwsem: Enable time-based spinning on reader-owned rwsem
On Thu, Apr 18, 2019 at 11:15:33AM -0400, Waiman Long wrote:
> On 04/18/2019 09:06 AM, Peter Zijlstra wrote:

> >> + /*
> >> + * Check time threshold every 16 iterations to
> >> + * avoid calling sched_clock() too frequently.
> >> + * This will make the actual spinning time a
> >> + * bit more than that specified in the threshold.
> >> + */
> >> + else if (!(++loop & 0xf) &&
> >> + (sched_clock() > rspin_threshold)) {
> > Why is calling sched_clock() lots a problem?
>
> Actually I am more concern about the latency introduced by the
> sched_clock() call. BTW, I haven't done any measurement myself. Do you
> know how much cost the sched_clock() call is?
>
> If the cost is relatively high, the average latency period after the
> lock is free and the spinner is ready to do a trylock will increase.

Totally depends on the arch or course :/ For 'sane' x86 it is: RDTSC,
MUL; SHRD; SHR; ADD, which is plenty fast.

I know we have poll loops with sched_clock/local_clock in them, I just
can't seem to find any atm.

\
 
 \ /
  Last update: 2019-04-19 21:32    [W:0.131 / U:0.708 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site