From: Pavel Machek <pavel@ucw.cz>
To: Manfred Spraul <manfred@colorfullife.com>
Cc: Paul Mackerras <paulus@samba.org>, linux-kernel@vger.kernel.org
Subject: Re: Fix locking in input
Date: Mon, 24 Nov 2003 10:34:48 +0100 [thread overview]
Message-ID: <20031124093448.GA306@elf.ucw.cz> (raw)
In-Reply-To: <3FC13382.3060701@colorfullife.com>
Hi!
> >>input uses "volatile signed char" as a shared variable between normal
> >>and interrupt threads (look at _sendbyte()). Thats bad idea, this
> >>switches it to atomic_t.
> >
> >This change looks unnecessary to me - we aren't trying to increment or
> >decrement the variable, just set it and read it. Reading and writing
> >individual bytes is atomic on any platform we care about.
> >
> >
> I think one platform (early ARM?) cannot access bytes directly, and
> implement the access with read 16-bit, change 8-bit, write back 16 bit.
> Reading/writing pointers or longs is atomic.
>
> Pavel: Do you know that atomic_set and atomic_read aren't memory barriers?
> I.e.
>
> - psmouse->ack = 0;
> + atomic_set(&psmouse->ack, 0);
> psmouse->acking = 1;
>
> It's not guaranteed that all cpus will see psmouse->ack=0 before
> psmouse->acking=1. And adding the required memory barriers usually makes
> the code completely unreadable, thus I usually give up and switch to a
> spinlock.
Would simply adding mb() there fix it? It is not performance-critical
in any way...
Pavel
--
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
next prev parent reply other threads:[~2003-11-24 9:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-23 22:24 Fix locking in input Manfred Spraul
2003-11-23 22:34 ` Russell King
2003-11-23 22:54 ` Manfred Spraul
2003-12-03 23:44 ` Timothy Miller
2003-12-04 1:29 ` Linus Torvalds
2003-11-24 9:34 ` Pavel Machek [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-11-22 15:52 Pavel Machek
2003-11-23 21:51 ` Paul Mackerras
[not found] ` <20031123134140.GE22591@vana.vc.cvut.cz>
2003-11-24 11:05 ` Pavel Machek
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=20031124093448.GA306@elf.ucw.cz \
--to=pavel@ucw.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
--cc=paulus@samba.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