[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <777590253.2016.1522245960189.JavaMail.zimbra@efficios.com>
Date: Wed, 28 Mar 2018 10:06:00 -0400 (EDT)
From: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To: Boqun Feng <boqun.feng@...il.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Andy Lutomirski <luto@...capital.net>,
Dave Watson <davejwatson@...com>,
linux-kernel <linux-kernel@...r.kernel.org>,
linux-api <linux-api@...r.kernel.org>,
Paul Turner <pjt@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Russell King <linux@....linux.org.uk>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, Andrew Hunter <ahh@...gle.com>,
Andi Kleen <andi@...stfloor.org>, Chris Lameter <cl@...ux.com>,
Ben Maurer <bmaurer@...com>, rostedt <rostedt@...dmis.org>,
Josh Triplett <josh@...htriplett.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will.deacon@....com>,
Michael Kerrisk <mtk.manpages@...il.com>,
Alexander Viro <viro@...iv.linux.org.uk>
Subject: Re: [RFC PATCH for 4.17 02/21] rseq: Introduce restartable
sequences system call (v12)
----- On Mar 28, 2018, at 2:47 AM, Boqun Feng boqun.feng@...il.com wrote:
> On Tue, Mar 27, 2018 at 12:05:23PM -0400, Mathieu Desnoyers wrote:
> [...]
>> Changes since v11:
>>
>> - Replace task struct rseq_preempt, rseq_signal, and rseq_migrate
>> bool by u32 rseq_event_mask.
> [...]
>> @@ -979,6 +980,17 @@ struct task_struct {
>> unsigned long numa_pages_migrated;
>> #endif /* CONFIG_NUMA_BALANCING */
>>
>> +#ifdef CONFIG_RSEQ
>> + struct rseq __user *rseq;
>> + u32 rseq_len;
>> + u32 rseq_sig;
>> + /*
>> + * RmW on rseq_event_mask must be performed atomically
>> + * with respect to preemption.
>> + */
>> + unsigned long rseq_event_mask;
>
> s/unsigned long/u32
good point, fixed.
>
>> +#endif
>> +
>> struct tlbflush_unmap_batch tlb_ubc;
>>
>> struct rcu_head rcu;
>> @@ -1688,4 +1700,110 @@ extern long sched_getaffinity(pid_t pid, struct cpumask
>> *mask);
>> #define TASK_SIZE_OF(tsk) TASK_SIZE
>> #endif
>>
>
> [...]
>
>> +
>> +static int rseq_ip_fixup(struct pt_regs *regs)
>> +{
>> + unsigned long ip = instruction_pointer(regs), start_ip = 0,
>> + post_commit_offset = 0, abort_ip = 0;
>> + struct task_struct *t = current;
>> + uint32_t cs_flags = 0;
>> + bool in_rseq_cs = false;
>
> This seems unnecessary? Because..
>
>> + int ret;
>> +
>> + ret = rseq_get_rseq_cs(t, &start_ip, &post_commit_offset, &abort_ip,
>> + &cs_flags);
>> + if (ret)
>> + return ret;
>> +
>> + /*
>> + * Handle potentially not being within a critical section.
>> + * Unsigned comparison will be true when
>> + * ip >= start_ip, and when ip < start_ip + post_commit_offset.
>> + */
>> + if (ip - start_ip < post_commit_offset)
>> + in_rseq_cs = true;
>> +
>> + /*
>> + * If not nested over a rseq critical section, restart is
>> + * useless. Clear the rseq_cs pointer and return.
>> + */
>> + if (!in_rseq_cs)
>> + return clear_rseq_cs(t);
>
> we can write
>
> if (ip - start_ip >= post_commit_offset)
> return clear_rseq_cs(t);
Good point. In a previous version, rseq_get_rseq_cs() had to conditionally
update in_rseq_cs, but it's not the case anymore, so your approach
indeed cleans up the code.
Thanks!
Mathieu
>
> Regards,
> Boqun
>
>> + ret = rseq_need_restart(t, cs_flags);
>> + if (ret <= 0)
>> + return ret;
>> + ret = clear_rseq_cs(t);
>> + if (ret)
>> + return ret;
>> + trace_rseq_ip_fixup(ip, start_ip, post_commit_offset, abort_ip);
>> + instruction_pointer_set(regs, (unsigned long)abort_ip);
>> + return 0;
>> +}
>> +
> [...]
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
Powered by blists - more mailing lists