lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 22 Feb 2024 12:36:29 +0800
From: Lai Jiangshan <jiangshanlai@...il.com>
To: Tejun Heo <tj@...nel.org>
Cc: torvalds@...ux-foundation.org, linux-kernel@...r.kernel.org, 
	allen.lkml@...il.com, kernel-team@...a.com
Subject: Re: [PATCH 6/7] workqueue: Allow cancel_work_sync() and
 disable_work() from atomic contexts on BH work items

Hello

On Thu, Feb 22, 2024 at 1:43 AM Tejun Heo <tj@...nel.org> wrote:

> @@ -4077,11 +4076,37 @@ static bool __flush_work(struct work_struct *work, bool from_cancel)
>
>         rcu_read_lock();
>         pool = start_flush_work(work, &barr, from_cancel);
> +       is_bh = pool && (pool->flags & POOL_BH);
>         rcu_read_unlock();
>         if (!pool)
>                 return false;
>
> -       wait_for_completion(&barr.done);
> +       if (is_bh && from_cancel) {

Can "*work_data_bits(work) & WORK_OFFQ_BH" be used here?
If so, the previous patch will not be needed.

Thanks.
Lai

> +               /*
> +                * We're flushing a BH work item which is being canceled. It
> +                * must have been executing during start_flush_work() and can't
> +                * currently be queued. If @work is still executing, we know it
> +                * is running in the BH context and thus can be busy-waited.
> +                *
> +                * On RT, prevent a live lock when %current preempted soft
> +                * interrupt processing or prevents ksoftirqd from running by
> +                * keeping flipping BH. If the BH work item runs on a different
> +                * CPU then this has no effect other than doing the BH
> +                * disable/enable dance for nothing. This is copied from
> +                * kernel/softirq.c::tasklet_unlock_spin_wait().
> +                */
> +               while (!try_wait_for_completion(&barr.done)) {
> +                       if (IS_ENABLED(CONFIG_PREEMPT_RT)) {
> +                               local_bh_disable();
> +                               local_bh_enable();
> +                       } else {
> +                               cpu_relax();
> +                       }
> +               }
> +       } else {
> +               wait_for_completion(&barr.done);
> +       }
> +
>         destroy_work_on_stack(&barr.work);
>         return true;
>  }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ