Skip to content

Commit 5e0ccd4

Browse files
edumazetPeter Zijlstra
authored andcommitted
rseq: Optimise rseq_get_rseq_cs() and clear_rseq_cs()
Commit ec9c82e ("rseq: uapi: Declare rseq_cs field as union, update includes") added regressions for our servers. Using copy_from_user() and clear_user() for 64bit values is suboptimal. We can use faster put_user() and get_user() on 64bit arches. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Mathieu Desnoyers <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 0ed9605 commit 5e0ccd4

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

kernel/rseq.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,13 @@ static int rseq_get_rseq_cs(struct task_struct *t, struct rseq_cs *rseq_cs)
127127
u32 sig;
128128
int ret;
129129

130+
#ifdef CONFIG_64BIT
131+
if (get_user(ptr, &t->rseq->rseq_cs.ptr64))
132+
return -EFAULT;
133+
#else
130134
if (copy_from_user(&ptr, &t->rseq->rseq_cs.ptr64, sizeof(ptr)))
131135
return -EFAULT;
136+
#endif
132137
if (!ptr) {
133138
memset(rseq_cs, 0, sizeof(*rseq_cs));
134139
return 0;
@@ -211,9 +216,13 @@ static int clear_rseq_cs(struct task_struct *t)
211216
*
212217
* Set rseq_cs to NULL.
213218
*/
219+
#ifdef CONFIG_64BIT
220+
return put_user(0UL, &t->rseq->rseq_cs.ptr64);
221+
#else
214222
if (clear_user(&t->rseq->rseq_cs.ptr64, sizeof(t->rseq->rseq_cs.ptr64)))
215223
return -EFAULT;
216224
return 0;
225+
#endif
217226
}
218227

219228
/*

0 commit comments

Comments
 (0)