All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: dmitry.torokhov@gmail.com, Jiri Pirko <jpirko@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH] atkbd: cancel delayed work before freeing its structure
Date: Fri, 7 Nov 2008 16:43:25 +0100	[thread overview]
Message-ID: <20081107154325.GD9368@redhat.com> (raw)
In-Reply-To: <20081105153140.25132ca1@psychotron.englab.brq.redhat.com>

On 11/05, Jiri Pirko wrote:
>
> diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
> index 22016ca..f3bbf49 100644
> --- a/drivers/input/keyboard/atkbd.c
> +++ b/drivers/input/keyboard/atkbd.c
> @@ -824,7 +824,7 @@ static void atkbd_disconnect(struct serio *serio)
>  	atkbd_disable(atkbd);
>
>  	/* make sure we don't have a command in flight */
> -	flush_scheduled_work();
> +	cancel_delayed_work_sync(&atkbd->event_work);

Ping. Dmitry, could you take a look?


While we are here, what is the reason for atkbd_schedule_event_work()->wmb() ?
It looks absolutely bogus. Is it for atkbd_event_work() ? In that case it
is not needed, it must see all previous STOREs because both queue_work() and
run_workqueue() take cwq->lock. And in any case,
test_and_set_bit(WORK_STRUCT_PENDING) implies mb(). If schedule_delayed_work()
fails we can race with the soon-to-be-executed atkbd_event_work(), in that
case that test_and_set_bit() + test_and_clear_bit(->event_mask) save us,
but wmb() can't help again.

Another question is why do we need ->event_mutex? OK, it can serialize
multiple instances of atkbd_event_work() running on the different CPUs,
but in that case atkbd_reconnect() needs this lock too? It also calls
atkbd_set_repeat_rate/atkbd_set_leds.

I don't understand this code, don't take my words too seriously, just
curious.

Oleg.


  reply	other threads:[~2008-11-07 14:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-05 14:31 [PATCH] atkbd: cancel delayed work before freeing its structure Jiri Pirko
2008-11-07 15:43 ` Oleg Nesterov [this message]
2008-11-11 14:51   ` Dmitry Torokhov
2008-11-11 17:20     ` Oleg Nesterov
2008-11-11 16:30       ` Dmitry Torokhov
2008-11-11 18:24         ` Oleg Nesterov

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=20081107154325.GD9368@redhat.com \
    --to=oleg@redhat.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jpirko@redhat.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.