Re: [PATCH v2 2/3] kfence: maximize allocation wait timeout duration
From: Marco Elver
Date: Thu Sep 16 2021 - 11:48:31 EST
On Thu, 16 Sept 2021 at 17:45, David Laight <David.Laight@xxxxxxxxxx> wrote:
>
> From: Kefeng Wang
> > Sent: 16 September 2021 02:21
> >
> > We found kfence_test will fails on ARM64 with this patch with/without
> > CONFIG_DETECT_HUNG_TASK,
> >
> > Any thought ?
> >
> ...
> > >> /* Enable static key, and await allocation to happen. */
> > >> static_branch_enable(&kfence_allocation_key);
> > >> - wait_event_timeout(allocation_wait, atomic_read(&kfence_allocation_gate), HZ);
> > >> + if (sysctl_hung_task_timeout_secs) {
> > >> + /*
> > >> + * During low activity with no allocations we might wait a
> > >> + * while; let's avoid the hung task warning.
> > >> + */
> > >> + wait_event_timeout(allocation_wait, atomic_read(&kfence_allocation_gate),
> > >> + sysctl_hung_task_timeout_secs * HZ / 2);
> > >> + } else {
> > >> + wait_event(allocation_wait, atomic_read(&kfence_allocation_gate));
> > >> + }
> > >> /* Disable static key and reset timer. */
> > >> static_branch_disable(&kfence_allocation_key);
>
> It has replaced a wait_event_timeout() with a wait_event().
>
> That probably isn't intended.
> Although I'd expect their to be some test for the wait being
> signalled or timing out.
It is intended -- there's a wake_up() for this. See the whole patch
series for explanation.
The whole reason we had the timeout was to avoid the hung task
warnings, but we can do better if there is no hung task warning
enabled.