From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Tejun Heo <tj@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V2] workqueue: fix possible race condition when rescuer VS pwq-release
Date: Thu, 17 Apr 2014 00:21:21 +0800 [thread overview]
Message-ID: <CACvQF532wtmegbNixch2zTGDmYoGoB4TFTHikw3dTNQPo7Gg2w@mail.gmail.com> (raw)
In-Reply-To: <20140416152326.GG1257@htj.dyndns.org>
On Wed, Apr 16, 2014 at 11:23 PM, Tejun Heo <tj@kernel.org> wrote:
> Hello, Lai.
>
> On Wed, Apr 16, 2014 at 09:25:16AM +0800, Lai Jiangshan wrote:
>> 1) Our aim is to protect unbound pwq, not percpu pwq which can't be be protected by get_pwq().
>> 2) get_pwq() will make reviewers confused/surprised, destroy_workqueue() may destroy percpu pwqs
>> with ref > 1. At least we need to add more comments explain this behavior. Origin comments:
>> /*
>> * The base ref is never dropped on per-cpu pwqs. Directly
>> * free the pwqs and wq.
>> */
Hi, Tejun
OK. It is better to use get_pwq(). I will also change the above comments to:
The base ref and the possible ref from rerscuer(stopped) are never
dropped on per-cpu pwqs.
Directly free the pwqs and wq.
The reason I quickly dropped V1 and wrote the V2 is that I saw this comment.
"The base ref" is precise after I used get_pwq() in V1.
Or to avoid to change to this comments.
I can also move the following code down to the bottom of the rescuer_thread().
if (kthread_should_stop()) {
__set_current_state(TASK_RUNNING);
rescuer->task->flags &= ~PF_WQ_WORKER;
return 0;
}
(I reply this email on browser, never mind the syntax).
Maybe the second choice are better.
Any think?
Thanks,
Lai.
>
> You can just comment "pwqs might go away at any time, pin it until
> rescuer is done with it" and that's actually the better way to do it.
> percpu wq's not supporting attribute changes may change in the future.
> What the code path wants is pinning down the pwq no matter where it
> came from. There's no point in distinguishing unbound and per-cpu
> here.
>
>> 3) get_unbound_pwq() self document.
>
> Not really. If the name is get_pwq_if_unbound(), maybe. Functions
> which take args and become noop depending on the argument aren't
> generally good ideas. There are specific cases that they are suitable
> but this is just gratuituous.
>
> Thanks.
>
> --
> tejun
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2014-04-16 16:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-27 16:20 [PATCH] workqueue: fix possible race condition when rescuer VS pwq-release Lai Jiangshan
2014-03-28 12:07 ` [PATCH V2] " Lai Jiangshan
2014-03-31 14:40 ` Lai Jiangshan
2014-03-31 20:06 ` Tejun Heo
2014-04-14 7:02 ` Lai Jiangshan
2014-04-15 16:47 ` Tejun Heo
2014-04-16 1:25 ` Lai Jiangshan
2014-04-16 15:23 ` Tejun Heo
2014-04-16 16:21 ` Lai Jiangshan [this message]
2014-04-16 16:50 ` Tejun Heo
2014-04-16 22:35 ` Lai Jiangshan
2014-04-16 23:34 ` [PATCH 1/2] workqueue: rescuer_thread() processes all pwqs before exit Lai Jiangshan
2014-04-16 23:34 ` [PATCH 2/2] workqueue: fix possible race condition when rescuer VS pwq-release Lai Jiangshan
2014-04-17 15:27 ` [PATCH 1/2] workqueue: rescuer_thread() processes all pwqs before exit Tejun Heo
2014-04-17 16:04 ` Lai Jiangshan
2014-04-17 16:08 ` Tejun Heo
2014-04-17 16:21 ` Lai Jiangshan
2014-04-17 16:27 ` Tejun Heo
2014-04-18 13:25 ` [PATCH 1/2 V4] " Lai Jiangshan
2014-04-18 13:25 ` [PATCH 2/2 V4] workqueue: fix possible race condition when rescuer VS pwq-release Lai Jiangshan
2014-04-18 15:06 ` [PATCH 2/2] workqueue: fix a possible race condition between rescuer and pwq-release Tejun Heo
2014-04-18 16:24 ` Lai Jiangshan
2014-04-18 16:35 ` Tejun Heo
2014-04-18 15:06 ` [PATCH 1/2] workqueue: make rescuer_thread() empty wq->maydays list before exiting Tejun Heo
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=CACvQF532wtmegbNixch2zTGDmYoGoB4TFTHikw3dTNQPo7Gg2w@mail.gmail.com \
--to=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).