From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Peter Oskolkov <posk@google.com>, Peter Zijlstra <peterz@infradead.org>
Cc: paulmck <paulmck@kernel.org>, Boqun Feng <boqun.feng@gmail.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Paul Turner <pjt@google.com>,
Chris Kennelly <ckennelly@google.com>,
Peter Oskolkov <posk@posk.io>, shuah <shuah@kernel.org>,
linux-kselftest <linux-kselftest@vger.kernel.org>
Subject: Re: [PATCH v8 2/3] rseq/selftests: add rseq_offset_deref_addv
Date: Thu, 24 Sep 2020 09:54:00 -0400 (EDT) [thread overview]
Message-ID: <1466248917.67912.1600955640316.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <1143241390.67886.1600954399326.JavaMail.zimbra@efficios.com>
----- On Sep 24, 2020, at 9:33 AM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote:
> ----- On Sep 23, 2020, at 7:36 PM, Peter Oskolkov posk@google.com wrote:
>
> The patch title should state that it only adds rseq_offset_deref_addv
> to x86-64. Considering that other architecture maintainers will look
> at it as inspiration for other architectures, we should also state in
> the commit message that architectures implementing it should define
> "RSEQ_ARCH_HAS_OFFSET_DEREF_ADDV".
With those changes applied, you can also add my:
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thanks,
Mathieu
>
> Thanks,
>
> Mathieu
>
>> This patch adds rseq_offset_deref_addv function to
>> tools/testing/selftests/rseq/rseq-x86.h, to be used
>> in a selftest in the next patch in the patchset.
>>
>> v7->v8: this patch split out of the v7 selftest patch.
>>
>> Signed-off-by: Peter Oskolkov <posk@google.com>
>> ---
>> tools/testing/selftests/rseq/rseq-x86.h | 57 +++++++++++++++++++++++++
>> 1 file changed, 57 insertions(+)
>>
>> diff --git a/tools/testing/selftests/rseq/rseq-x86.h
>> b/tools/testing/selftests/rseq/rseq-x86.h
>> index b2da6004fe30..640411518e46 100644
>> --- a/tools/testing/selftests/rseq/rseq-x86.h
>> +++ b/tools/testing/selftests/rseq/rseq-x86.h
>> @@ -279,6 +279,63 @@ int rseq_addv(intptr_t *v, intptr_t count, int cpu)
>> #endif
>> }
>>
>> +#define RSEQ_ARCH_HAS_OFFSET_DEREF_ADDV
>> +
>> +/*
>> + * pval = *(ptr+off)
>> + * *pval += inc;
>> + */
>> +static inline __attribute__((always_inline))
>> +int rseq_offset_deref_addv(intptr_t *ptr, off_t off, intptr_t inc, int cpu)
>> +{
>> + RSEQ_INJECT_C(9)
>> +
>> + __asm__ __volatile__ goto (
>> + RSEQ_ASM_DEFINE_TABLE(3, 1f, 2f, 4f) /* start, commit, abort */
>> +#ifdef RSEQ_COMPARE_TWICE
>> + RSEQ_ASM_DEFINE_EXIT_POINT(1f, %l[error1])
>> +#endif
>> + /* Start rseq by storing table entry pointer into rseq_cs. */
>> + RSEQ_ASM_STORE_RSEQ_CS(1, 3b, RSEQ_CS_OFFSET(%[rseq_abi]))
>> + RSEQ_ASM_CMP_CPU_ID(cpu_id, RSEQ_CPU_ID_OFFSET(%[rseq_abi]), 4f)
>> + RSEQ_INJECT_ASM(3)
>> +#ifdef RSEQ_COMPARE_TWICE
>> + RSEQ_ASM_CMP_CPU_ID(cpu_id, RSEQ_CPU_ID_OFFSET(%[rseq_abi]), %l[error1])
>> +#endif
>> + /* get p+v */
>> + "movq %[ptr], %%rbx\n\t"
>> + "addq %[off], %%rbx\n\t"
>> + /* get pv */
>> + "movq (%%rbx), %%rcx\n\t"
>> + /* *pv += inc */
>> + "addq %[inc], (%%rcx)\n\t"
>> + "2:\n\t"
>> + RSEQ_INJECT_ASM(4)
>> + RSEQ_ASM_DEFINE_ABORT(4, "", abort)
>> + : /* gcc asm goto does not allow outputs */
>> + : [cpu_id] "r" (cpu),
>> + [rseq_abi] "r" (&__rseq_abi),
>> + /* final store input */
>> + [ptr] "m" (*ptr),
>> + [off] "er" (off),
>> + [inc] "er" (inc)
>> + : "memory", "cc", "rax", "rbx", "rcx"
>> + RSEQ_INJECT_CLOBBER
>> + : abort
>> +#ifdef RSEQ_COMPARE_TWICE
>> + , error1
>> +#endif
>> + );
>> + return 0;
>> +abort:
>> + RSEQ_INJECT_FAILED
>> + return -1;
>> +#ifdef RSEQ_COMPARE_TWICE
>> +error1:
>> + rseq_bug("cpu_id comparison failed");
>> +#endif
>> +}
>> +
>> static inline __attribute__((always_inline))
>> int rseq_cmpeqv_trystorev_storev(intptr_t *v, intptr_t expect,
>> intptr_t *v2, intptr_t newv2,
>> --
>> 2.28.0.709.gb0816b6eb0-goog
>
> --
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
next prev parent reply other threads:[~2020-09-24 13:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-23 23:36 [PATCH v8 1/3] rseq/membarrier: add MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ Peter Oskolkov
2020-09-23 23:36 ` [PATCH v8 2/3] rseq/selftests: add rseq_offset_deref_addv Peter Oskolkov
2020-09-24 13:33 ` Mathieu Desnoyers
2020-09-24 13:54 ` Mathieu Desnoyers [this message]
2020-09-29 7:56 ` [tip: sched/core] rseq/selftests,x86_64: Add rseq_offset_deref_addv() tip-bot2 for Peter Oskolkov
2020-09-23 23:36 ` [PATCH v8 3/3] rseq/selftests: test MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ Peter Oskolkov
2020-09-24 13:48 ` Mathieu Desnoyers
2020-09-29 7:56 ` [tip: sched/core] rseq/selftests: Test MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ tip-bot2 for Peter Oskolkov
2020-09-24 13:51 ` [PATCH v8 1/3] rseq/membarrier: add MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ Mathieu Desnoyers
2020-09-24 14:00 ` Peter Zijlstra
2020-09-25 11:50 ` Peter Zijlstra
2020-09-29 7:56 ` [tip: sched/core] rseq/membarrier: Add MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ tip-bot2 for Peter Oskolkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1466248917.67912.1600955640316.JavaMail.zimbra@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=boqun.feng@gmail.com \
--cc=ckennelly@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=posk@google.com \
--cc=posk@posk.io \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.