All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tilman Schmidt <tilman@imap.cc>
To: Arjan van de Ven <arjan@infradead.org>
Cc: Hansjoerg Lipp <hjlipp@web.de>, Karsten Keil <kkeil@suse.de>,
	i4ldeveloper@listserv.isdn4linux.de,
	linux-usb-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, Greg Kroah-Hartman <gregkh@suse.de>
Subject: Re: [PATCH 0/7] isdn4linux: add drivers for Siemens Gigaset ISDN DECT PABX
Date: Fri, 03 Mar 2006 15:54:19 +0100	[thread overview]
Message-ID: <4408589B.2040305@imap.cc> (raw)
In-Reply-To: <1141368808.2883.16.camel@laptopd505.fenrus.org>

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

On Fri, 03 Mar 2006 07:53:28 +0100, Arjan van de Ven wrote:

> On Fri, 2006-03-03 at 00:03 +0100, Tilman Schmidt wrote:

>> So you are saying that, for example
>>
>> 	spin_lock_irqsave(&cs->ev_lock, flags);
>> 	head = cs->ev_head;
>> 	tail = cs->ev_tail;
>> 	spin_unlock_irqrestore(&cs->ev_lock, flags);
>>
>> is (mutatis mutandis) actually cheaper than
>>
>> 	head = atomic_read(&cs->ev_head);
>> 	tail = atomic_read(&cs->ev_tail);
>
> atomic_read is special since it's not actually an atomic operation ;)
> but.. think about it: you do 2 atomic reads, however there is ZERO
> guarantee that the reads are atomic with respect to eachother; eg your
> head and tail are not an atomic "snapshot" of these 2 variables!

That's not a problem. It's a ringbuffer. It doesn't need an atomic
snapshot of the reading and writing pointers together. Nothing breaks
if a reader advances the read pointer while a writer is holding a
local copy of it, or vice versa. The only thing we have to guard
against is the result of an individual read operation being corrupted
by a parallel write.

So what's better in that case? Should we change these from atomic to
spinlocked or not?

[#define IFNULL*]
>> Ok, these were mainly debugging aids. We'll just drop them and let the
>> oops mechanism catch the (hopefully non-existent) remaining cases of
>> pointers being unexpectedly NULL.
>
> you can also use WARN_ON() and BUG_ON() for that, you then get a more
> readable oops message (with filename and line information)

Actually, we won't. The IFNULL* macros were not only printing a message,
but also taking evasive action in order to avoid dereferencing the NULL
pointer. To achieve the same with WARN_ON() would require four lines of
code for each occurrence, which IMHO is too much code clutter for a class
of bugs which should be largely eradicated by now anyway.

>> >> +void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
>> >> +			size_t len, const unsigned char *buf, int from_user)
>> >
>> > such "from_user" parameter is highly evil, and also breaks sparse and
>> > friends.. (btw please run sparse on the code and fix all warnings)
>>
>> Are you referring to anything in particular? We do run sparse regularly,
>> and it did not emit any warnings for the submitted version, not even for
>> this function. (But heaps of them for other parts of the kernel, if you
>> pardon the remark.)
>
> msg should have the __user atribute here since it can be in userspace...
> sometimes. It is the "sometimes" that is the bad idea!

That's understood and will be fixed. I was just wondering whether your
remark in parentheses was prompted by any particular sparse warnings you
wanted us to fix and which for some reason we hadn't seen?

> (GFP_ATOMIC is like borrowing from the VM, the VM will be in slight
> imbalance afterwards. With GFP_KERNEL you allow the kernel to fix this
> imbalance. A slight imbalance is fine and not a problem. Especially if
> you give it the memory back soon. But if the imbalance can accumulate,
> for example because you keep allocating and free the memory much later,
> it can become a problem)

Thanks muchly for that very lucid explanation. I see much clearer now
in that area! :-)

Regards
Tilman

--
Tilman Schmidt                    E-Mail: tilman@imap.cc
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeoeffnet mindestens haltbar bis: (siehe Rueckseite)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

      parent reply	other threads:[~2006-03-03 14:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-27  6:23 [PATCH 0/7] isdn4linux: add drivers for Siemens Gigaset ISDN DECT PABX Hansjoerg Lipp
2006-02-27  6:23 ` [PATCH 1/7] isdn4linux: Siemens Gigaset drivers - common module Hansjoerg Lipp
2006-02-27  6:23   ` [PATCH 2/7] isdn4linux: Siemens Gigaset drivers - event layer Hansjoerg Lipp
2006-02-27  6:23     ` [PATCH 3/7] isdn4linux: Siemens Gigaset drivers - subsystem interfaces Hansjoerg Lipp
2006-02-27  6:23       ` [PATCH 4/7] isdn4linux: Siemens Gigaset drivers - direct USB connection Hansjoerg Lipp
2006-02-27  6:23         ` [PATCH 5/7] isdn4linux: Siemens Gigaset drivers - isochronous data handler Hansjoerg Lipp
2006-02-27  6:23           ` [PATCH 6/7] isdn4linux: Siemens Gigaset drivers - M105 USB DECT adapter Hansjoerg Lipp
2006-02-27  6:23             ` [PATCH 7/7] isdn4linux: Siemens Gigaset drivers - Kconfigs and Makefiles Hansjoerg Lipp
2006-02-27  8:01     ` [PATCH 2/7] isdn4linux: Siemens Gigaset drivers - event layer Arjan van de Ven
2006-02-27  8:02     ` Arjan van de Ven
2006-02-27  7:52   ` [PATCH 1/7] isdn4linux: Siemens Gigaset drivers - common module Arjan van de Ven
2006-02-27  8:00   ` Arjan van de Ven
2006-02-27  9:29 ` [PATCH 0/7] isdn4linux: add drivers for Siemens Gigaset ISDN DECT PABX Arjan van de Ven
2006-03-02 23:03   ` Tilman Schmidt
2006-03-03  0:58     ` Roland Dreier
2006-03-03  6:53     ` Arjan van de Ven
2006-03-03  9:44       ` Karsten Keil
2006-03-03 14:54       ` Tilman Schmidt [this message]

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=4408589B.2040305@imap.cc \
    --to=tilman@imap.cc \
    --cc=arjan@infradead.org \
    --cc=gregkh@suse.de \
    --cc=hjlipp@web.de \
    --cc=i4ldeveloper@listserv.isdn4linux.de \
    --cc=kkeil@suse.de \
    --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 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.