All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: Wolfgang Grandegger <wg@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-core] Re: [Xenomai-help] [ANNOUNCE] RTDM driver for CAN	devices
Date: Sun, 06 Aug 2006 20:32:13 +0200	[thread overview]
Message-ID: <44D635AD.3050605@domain.hid> (raw)
In-Reply-To: <44D4FF53.8000904@domain.hid>

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

Jan Kiszka wrote:
> ...
> PS: Another point for the long-term to-do list :-> : The nested locking
> and the global scope of certain locks. It's safe, it's harmless for
> current primary target platforms (UP), but it's not really beautiful
> when considering SMP setups. A bit tricky, for sure.
> 

I put Sebastian in the CC. Maybe he sees issues I may ignore in the
following.

Here is some first idea on a new locking scheme. It reduces the number
of locks by one and turns them either into per-device or per-socket in
the end:


rtcan_socket.lock
----------------------
Protects:
 - concurrent read access to socket FIFO
 - /maybe/ also timeouts (but I think the user should better take care
   to not set a timeout and make use of it at the same time - not that
   hard to achieve in practice...)

This means that we need lock-less FIFOs wrt/ reader/writer
synchronisation. Some pattern like RTnet's rtskb_fifo e.g.


rtcan_device.lock
------------------------
Protects:
 - hardware access of related CAN port
 - device reception list

So we only take a single lock in the IRQ handler (+eventually the nklock
when waking someone up). But it requires that a socket, or more
precisely its FIFO is exclusively assigned to a single device.

And this raises the question how to deal with ifindex=0, i.e. attaching
a socket to all devices. Given that in this case the socket may run into
troubles anyway due to the fixed FIFO size, I would say that we better
create multiple FIFOs here (or additional rtcan_socket structures), one
per device of interest. The wakeup would then need some indirection in
order to use a common rtdm_event for all FIFOs of a socket.

Ok, this may complicate things, so we could do this in several steps:

1. Decouple FIFO reader from writer protection. A *global* device lock
   protects the writers + the reception lists, a socket recv_lock the
   read access. Make FIFOs lock-less wrt/ reader/writer concurrency.
2. Make the ifindex=0 support optional, fall back to global locking if
   it's on. If it's off (should be default), use per-device locking
   (again) as we then have exclusive assignments of sockets to a single
   device.
3. Create multiple FIFOs if ifindex is 0, always use per-device locks.
   As we already have the all-devices-support configurable at that time,
   we could let the user decide if the additional code for this mode
   should get compiled in or not.

Once this is implemented, the whole pattern could nicely be reused for
RTnet. I have in mind to shorten the reception path in the future and
make it more SMP friendly. So I'm with you here to gain experience! :)

Jan


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

  reply	other threads:[~2006-08-06 18:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-01 15:09 [Xenomai-core] [ANNOUNCE] RTDM driver for CAN devices Wolfgang Grandegger
2006-08-01 17:13 ` [Xenomai-core] " Bernhard Walle
2006-08-01 17:39   ` Wolfgang Grandegger
2006-08-04 15:11 ` [Xenomai-core] Re: [Xenomai-help] " Jan Kiszka
2006-08-05 13:45   ` Wolfgang Grandegger
2006-08-05 15:45     ` Philippe Gerum
2006-08-05 16:44     ` Jan Kiszka
2006-08-05 17:25       ` Philippe Gerum
2006-08-05 18:29       ` Wolfgang Grandegger
2006-08-05 20:28         ` Jan Kiszka
2006-08-06 18:32           ` Jan Kiszka [this message]
2006-08-07 13:23           ` Wolfgang Grandegger
2006-08-07 14:17           ` Wolfgang Grandegger
2006-08-07 14:31             ` Jan Kiszka
2006-08-07 15:43               ` Philippe Gerum
2006-08-11  6:59               ` Wolfgang Grandegger
2006-08-11  7:08                 ` Jan Kiszka
2006-08-11  7:21                   ` Wolfgang Grandegger
2006-08-07 14:32             ` Philippe Gerum

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=44D635AD.3050605@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=wg@domain.hid \
    --cc=xenomai@xenomai.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 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.