lkml.org 
[lkml]   [2016]   [Dec]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3 03/12] locking/ww_mutex: Extract stamp comparison to __ww_mutex_stamp_after
From
Date
On 22.12.2016 02:58, zhoucm1 wrote:
> On 2016年12月22日 02:46, Nicolai Hähnle wrote:
>> +static inline bool __sched
>> +__ww_ctx_stamp_after(struct ww_acquire_ctx *a, struct ww_acquire_ctx *b)
>> +{
>> + return a->stamp - b->stamp <= LONG_MAX &&
>> + (a->stamp != b->stamp || a > b);
> I want to ask a stupid question, why a can compare with b? They are
> pointers of structure. Isn't stamp enough for compare?

As far as I understand, the idea is to provide a tie-breaker to ensure
that there is a strict order between contexts even if the stamp happens
to be equal. Since we get stamps from atomic increments, this really
only matters if (a) someone makes a mistake and confuses ww_classes
(which CONFIG_DEBUG_MUTEXES would flag) or (b) the ww_class stamp
counter wraps around fully during the lifetime of the acquire context.
This is extremely unlikely of course.

Nicolai

\
 
 \ /
  Last update: 2016-12-22 09:44    [W:1.200 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site