From: Eduardo Pereira Habkost <ehabkost@mandriva.com>
To: Greg KH <gregkh@suse.de>
Cc: Luiz Fernando Capitulino <lcapitulino@mandriva.com.br>,
linux-kernel@vger.kernel.org,
linux-usb-devel@lists.sourceforge.net
Subject: Re: [PATCH 00/10] usb-serial: Switches from spin lock to atomic_t.
Date: Wed, 7 Dec 2005 17:10:58 -0200 [thread overview]
Message-ID: <20051207191058.GK20451@duckman.conectiva> (raw)
In-Reply-To: <20051207175614.GA29117@suse.de>
[-- Attachment #1: Type: text/plain, Size: 1860 bytes --]
Hi, Greg,
On Wed, Dec 07, 2005 at 09:56:14AM -0800, Greg KH wrote:
> On Wed, Dec 07, 2005 at 03:13:32PM -0200, Eduardo Pereira Habkost wrote:
> > I have a small question: in my view, this patch series is a small
> > step towards implementing the usb-serial drivers The Right Way, as it
> > removes a a bit of duplicated code.
>
> It doesn't remove any "duplicated code", it only changes a spinlock to
> an atomic_t for one single value (which I personally do not think is the
> best thing to do, and based on the number of comments on this thread, I
> think others also feel this way.)
Every usb-serial driver currently has:
spin_lock(port->lock);
if (port->write_urb_busy)
return;
port->write_urb_busy = 1;
spin_unlock(port->lock);
Having the same 5 lines on many usb-serial drivers looks like duplicated
code to me. Maybe I am being too exigent. Anyway, this is unrelated to
the atomic_t change, and we could do it without dropping ths spinlock.
But I would like to know: would you would accept such change (that
encapsulate this write_urb_busy logic without necessarily dropping the
spinlock)?
And, about the atomic_t: I've felt most people didn't liked the atomic_t
approach for one of two reasons:
1. The existence of write_urb_busy looks like a hack, and we've
make it explicit when we isolated the code that uses write_urb_busy
in a set of functions (the point of Arjan in his "square wheel"
comment)
2. The whole discussion about atomic_t vs. spinlock efficiency
I agree with (1), but I still don't see why using a spinlock to protect
a single field is better than using atomic_t. Both in code readability
and efficiency. Specially as the difference between each one (even which
one is more efficient) is very arch-specific.
Thank you very much for your advice,
--
Eduardo
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2005-12-07 19:07 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-06 11:56 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
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 [this message]
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=20051207191058.GK20451@duckman.conectiva \
--to=ehabkost@mandriva.com \
--cc=gregkh@suse.de \
--cc=lcapitulino@mandriva.com.br \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb-devel@lists.sourceforge.net \
/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
Powered by JetHome