lkml.org 
[lkml]   [2016]   [Aug]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH v7 1/7] Restartable sequences system call
----- On Aug 10, 2016, at 3:50 AM, Peter Zijlstra peterz@infradead.org wrote:

> On Tue, Aug 09, 2016 at 10:41:47PM +0000, Mathieu Desnoyers wrote:
>> #ifdef __LP64__
>>
>> static bool rseq_update_cpu_id_event_counter(struct task_struct *t)
>> {
>> union rseq_cpu_event u;
>>
>> u.e.cpu_id = raw_smp_processor_id();
>> u.e.event_counter = ++t->rseq_event_counter;
>> if (__put_user(u.v, &t->rseq->u.v))
>> return false;
>> trace_rseq_inc(t->rseq_event_counter);
>> return true;
>> }
>>
>> #else /* #ifdef __LP64__ */
>>
>> static bool rseq_update_cpu_id_event_counter(struct task_struct *t)
>> {
>> if (__put_user(raw_smp_processor_id(), &t->rseq->u.e.cpu_id))
>> return false;
>> if (__put_user(++t->rseq_event_counter, &t->rseq->u.e.event_counter))
>> return false;
>> trace_rseq_inc(t->rseq_event_counter);
>> return true;
>> }
>>
>> #endif /* #else #ifdef __LP64__ */
>
> I don't think you need to guard it (and CONFIG_64BIT is the 'right'
> kernel symbol for that), 32bit should have u64 __put_user() only
> implemented as 2 u32 stores.

OK, I can then simplify the implementation to:

[...]
* On 64-bit architectures, both cpu_id and event_counter can be updated
* with a single 64-bit store. On 32-bit architectures, __put_user() is
* expected to perform two 32-bit single-copy stores to guarantee
* single-copy atomicity semantics for other threads.
*/
static bool rseq_update_cpu_id_event_counter(struct task_struct *t)
{
union rseq_cpu_event u;

u.e.cpu_id = raw_smp_processor_id();
u.e.event_counter = ++t->rseq_event_counter;
if (__put_user(u.v, &t->rseq->u.v))
return false;
trace_rseq_inc(t->rseq_event_counter);
return true;
}

Thanks!

Mathieu

--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

\
 
 \ /
  Last update: 2016-08-10 21:41    [W:0.159 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site