public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Manfred Spraul <manfred@colorfullife.com>
To: Paul Mackerras <paulus@samba.org>
Cc: Pavel Machek <pavel@suse.cz>, linux-kernel@vger.kernel.org
Subject: Re: Fix locking in input
Date: Sun, 23 Nov 2003 23:24:02 +0100	[thread overview]
Message-ID: <3FC13382.3060701@colorfullife.com> (raw)

Paul wrote:

>Pavel Machek writes:
>
>> 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.

--
	Manfred





             reply	other threads:[~2003-11-23 22:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-23 22:24 Manfred Spraul [this message]
2003-11-23 22:34 ` Fix locking in input 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
  -- 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=3FC13382.3060701@colorfullife.com \
    --to=manfred@colorfullife.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulus@samba.org \
    --cc=pavel@suse.cz \
    /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