From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
To: Tejun Heo <tj@kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Sasha Levin <sasha.levin@oracle.com>
Subject: Re: workqueue: race in mod_delayed_work_on?
Date: Fri, 13 May 2016 16:49:48 +0300 [thread overview]
Message-ID: <5735DB7C.2040201@yandex-team.ru> (raw)
In-Reply-To: <57347FE9.4070709@yandex-team.ru>
On 12.05.2016 16:06, Konstantin Khlebnikov wrote:
> On 10.05.2016 20:20, Konstantin Khlebnikov wrote:
>> On 10.05.2016 19:36, Tejun Heo wrote:
>>> Hello,
>>>
>>> On Tue, May 10, 2016 at 07:28:08PM +0300, Konstantin Khlebnikov wrote:
>>>> On 10.05.2016 11:21, Konstantin Khlebnikov wrote:
>>>>> I've got plenty warnings, bugs and oops around trivial use of mod_delayed_work in drivers/infiniband/core/addr.c
>>>>
>>>> Looks like problem in mod_delayed_work_on was hidden because add_timer is equal to mod_timer
>>>
>>> The timer usages are gated behind PENDING bit, so whether add_timer()
>>> is equal to mod_timer() shouldn't matter.
>>
>> Hmm... this looks little bit more complicated than one bit.
>
> Yep, problem was here - both timer and work can be active at the same time.
Nope, this is impossible. This will be a bug itself.
>
> So try_to_grab_pending can return success for two coRecentncurrent callers:
> first get del_timer, second removes work from workqueue. After that
> both call add timer and one of them either catch BUG_ON or corrupt timer list.
>
> I see two possible fixes: always remove timer and work in try_to_grab_pending
> but this must be carefully synchronized. This will make it slower for sure.
> Or always use mod_timer in __queue_delayed_work() - both callers will modify timer,
> but here is no mod_timer_on().
>
>>
>>>
>>>> but Sasha accidentally backported 874bbfe600a660cba9c776b3957b1ce393151b76
>>>> (workqueue: make sure delayed work run in local cpu) into 3.18.25
>>>>
>>>> I don't see reason why that commit could break delayed work,
>>>> most likely it highlighted some other problem.
>>>
>>> What are you running? Can you reproduce the issue on upstream kernel?
>>>
>>
>> This is slight patched 3.18.y. Looks like this started when we upgraded kernel to 3.18.25 and
>> somebody have loaded module ib_addr (ip in infiniband or something) which actually unused
>> because these machines have no infiniband at all. But this code is poked from ethernet arp
>> sometimes. So, it crashes somewhere from time to time. I'll try to stresstest this piece.
>>
>
>
>
>
--
Konstantin
next prev parent reply other threads:[~2016-05-13 13:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-10 8:21 workqueue: race in mod_delayed_work_on? Konstantin Khlebnikov
2016-05-10 16:28 ` Konstantin Khlebnikov
2016-05-10 16:36 ` Tejun Heo
2016-05-10 17:20 ` Konstantin Khlebnikov
2016-05-12 13:06 ` Konstantin Khlebnikov
2016-05-13 13:49 ` Konstantin Khlebnikov [this message]
2016-05-15 16:08 ` Konstantin Khlebnikov
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=5735DB7C.2040201@yandex-team.ru \
--to=khlebnikov@yandex-team.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=sasha.levin@oracle.com \
--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