lkml.org 
[lkml]   [2020]   [Nov]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] kcsan: Avoid scheduler recursion by using non-instrumented preempt_{disable,enable}()
On Mon, Nov 23, 2020 at 04:57:46PM +0100, Marco Elver wrote:
> Let me know what you prefer.
>

> @@ -288,27 +288,19 @@ static u32 kcsan_prandom_u32_max(u32 ep_ro)
> u32 res;
>
> /*
> + * Avoid recursion with scheduler by disabling KCSAN because
> + * preempt_enable_notrace() will still call into scheduler code.
> */
> + kcsan_disable_current();
> preempt_disable_notrace();
> state = raw_cpu_ptr(&kcsan_rand_state);
> res = prandom_u32_state(state);
> + preempt_enable_notrace();
> + kcsan_enable_current_nowarn();
>
> return (u32)(((u64) res * ep_ro) >> 32);
> }

This is much preferred over the other. The thing with _no_resched is that
you can miss a preemption for an unbounded amount of time, which is bad.

The _only_ valid use of _no_resched is when there's a call to schedule()
right after it.

\
 
 \ /
  Last update: 2020-11-23 17:39    [W:0.070 / U:1.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site