public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Pereira Habkost <ehabkost@mandriva.com>
To: Arjan van de Ven <arjan@infradead.org>
Cc: Alan Stern <stern@rowland.harvard.edu>,
	Oliver Neukum <oliver@neukum.org>,
	linux-usb-devel@lists.sourceforge.net, Greg KH <gregkh@suse.de>,
	Luiz Fernando Capitulino <lcapitulino@mandriva.com.br>,
	linux-kernel@vger.kernel.org
Subject: Re: [linux-usb-devel] Re: [PATCH 00/10] usb-serial: Switches from spin lock to atomic_t.
Date: Wed, 7 Dec 2005 14:00:47 -0200	[thread overview]
Message-ID: <20051207160047.GG20451@duckman.conectiva> (raw)
In-Reply-To: <1133968943.2869.26.camel@laptopd505.fenrus.org>

[-- Attachment #1: Type: text/plain, Size: 2458 bytes --]

On Wed, Dec 07, 2005 at 04:22:23PM +0100, Arjan van de Ven wrote:
> 
> > On the other hand, Oliver needs to be careful about claiming too much.  In 
> > general atomic_t operations _are_ superior to the spinlock approach.
> 
> No they're not. Both are just about equally expensive cpu wise,
> sometimes the atomic_t ones are a bit more expensive (like on parisc
> architecture). But on x86 in either case it's a locked cycle, which is
> just expensive no matter which side you flip the coin... 

But if a lock is used exclusively to protect a int variable, an atomic_t
seems to be more appropriate to me. Isn't it?

> 
> >   If 
> > they weren't, atomic_t wouldn't belong in the kernel at all.
> 
> there's different usage patterns where either makes sense. 
> In this case it looks just disgusting on very first sight; the atomic
> are used to implement a lock, and that lock itself is then implemented
> with a spinlock again. For me, again on first sight, the real solution
> appears to be to use a linux primitive for the higher level lock in the
> first place, instead of reimplementing <your own thing> with <another
> own thing>.

The patches don't implement any new lock scheme neither change the
current behaviour. They just replace a spin_lock + integer variable
(the spinlock is used just to protect an integer variable) by an atomic_t.

The patches aren't adding any "own lock scheme", but just replacing
a spinlock that is used exclusively to protect an integer variable
(write_urb_busy) by an atomic_t.

The whole point of the changes is that using a spin_lock to protect only
a int variable doesn't look like a Right Thing.

Please, if you could, review the patches with this in mind: we aren't
changing any behaviour neither creating any weird lock scheme, we are
only doing two things:

1. Putting all the duplicated code that handles write_urb_busy (that
   already exists) in only one place
2. Replacing a spin_lock that is being used to protect only a single
   integer field by an atomic_t

People got scared when they looked at the patch that does (1), thinking
that we were creating new, weird, locking scheme (because we are doing (2)
at the same time). But we are just isolating the existing 'write_urb_busy'
scheme that is duplicated all around the usb-serial drivers.

I guess (1) is a Good Thing, so the only question is: do you really
disagree about doing (2)?

-- 
Eduardo

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2005-12-07 15:56 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-06 11:56 [PATCH 00/10] usb-serial: Switches from spin lock to atomic_t Luiz Fernando Capitulino
2005-12-06 19:40 ` Greg KH
2005-12-06 20:13   ` Eduardo Pereira Habkost
2005-12-06 22:48     ` [linux-usb-devel] " Oliver Neukum
2005-12-07 12:24       ` Luiz Fernando Capitulino
2005-12-07 12:27         ` Arjan van de Ven
2005-12-07 12:30           ` Luiz Fernando Capitulino
2005-12-07 12:34             ` Arjan van de Ven
2005-12-07 12:41               ` Luiz Fernando Capitulino
2005-12-07 12:54                 ` Luiz Fernando Capitulino
2005-12-07 15:07       ` Alan Stern
2005-12-07 15:22         ` Arjan van de Ven
2005-12-07 15:37           ` Oliver Neukum
2005-12-07 15:40             ` Arjan van de Ven
2005-12-07 15:50               ` Oliver Neukum
2005-12-07 16:02                 ` Alan Cox
2005-12-07 16:00           ` Eduardo Pereira Habkost [this message]
2005-12-07 16:02             ` Arjan van de Ven
2005-12-07 16:23               ` Eduardo Pereira Habkost
2005-12-07 16:01           ` Alan Stern
2005-12-07 16:04             ` Arjan van de Ven
2005-12-07 15:32         ` linux-os (Dick Johnson)
2005-12-07 16:08           ` Alan Stern
2005-12-06 20:14   ` Luiz Fernando Capitulino
2005-12-06 21:02     ` Pete Zaitcev
2005-12-06 21:18       ` Luiz Fernando Capitulino
2005-12-06 22:36         ` [linux-usb-devel] " Oliver Neukum
2005-12-07 12:25           ` Luiz Fernando Capitulino
2005-12-07 13:01             ` Oliver Neukum
2005-12-07 13:17               ` Luiz Fernando Capitulino
2005-12-07 16:41 ` Greg KH
2005-12-07 16:51   ` Luiz Fernando Capitulino
2005-12-07 17:13     ` Eduardo Pereira Habkost
2005-12-07 17:56       ` Greg KH
2005-12-07 19:10         ` Eduardo Pereira Habkost
2005-12-07 16:55   ` Otavio Salvador
2005-12-07 16:59     ` Greg KH

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=20051207160047.GG20451@duckman.conectiva \
    --to=ehabkost@mandriva.com \
    --cc=arjan@infradead.org \
    --cc=gregkh@suse.de \
    --cc=lcapitulino@mandriva.com.br \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=oliver@neukum.org \
    --cc=stern@rowland.harvard.edu \
    /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