All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: "Steve M. Robbins" <steve@sumost.ca>
Cc: Xenomai@xenomai.org
Subject: Re: [Xenomai] Message Pipe services behaviour
Date: Mon, 03 Nov 2014 17:29:53 +0100	[thread overview]
Message-ID: <5457AD81.7090200@xenomai.org> (raw)
In-Reply-To: <20141103155947.GA15262@sumost.ca>

On 11/03/2014 04:59 PM, Steve M. Robbins wrote:
> On Mon, Nov 03, 2014 at 09:18:53AM +0100, Philippe Gerum wrote:
>> On 11/02/2014 01:53 AM, Steve M. Robbins wrote:
>>> On November 1, 2014 10:54:39 AM Philippe Gerum wrote:
>>
>>>> Perhaps the rt side sends a large burst of data once in a while causing
>>>> the overflow? In this case, you could not detect the issue looming from
>>>> the nrt side until it happens, since the rt side has higher priority
>>>> (i.e. rt would cause ENOMEM even before nrt had a chance to resume
>>>> execution).
>>>
>>> OK, I understand the theory.  However, I don't believe that is my case.  The 
>>> message queue is transporting fault information and through user actions I can 
>>> set it up to send 2 messages per cycle and using the FIFO code, the nrt side 
>>> is indeed reading 2 messages.  Using message queues, I can see that there are 
>>> multiple messages outstanding but it reads only one.
>>>
>>
>> Ok, so if no message gets lost, if you can see FIONREAD increase until
>> ENOMEM is raised, and if throttling the rt side only delays the issue
>> without solving it, the only explanation would be that a notification of
>> input availability is lost by the poll handler backing select() in the
>> rt-pipe driver. That would cause the messages to pile up on the rt side,
>> with too few deliveries to nrt.
> 
> I want to emphasize that FIONREAD is being done on the nrt side, after
> the select() and just prior to the actual read() call.  Thus the nrt
> side is seeing N > 1 messages available on the file descriptor, but
> read() only reads 1, even though the fd is nonblocking and the read
> buffer is sized for 100 messages.

Just to make sure we are on the same page, as Dietmar mentioned in an
earlier mail, read() as implemented by the rt-pipe driver only returns
_one_ message at a time, although > 1 could be pending. One has to
iterate over a read() loop using a non-blocking fd on the /dev/rtp
device to get them all. I'm likely beating a dead horse here this said.

  So it seems to me there is somehow
> a disconnect between the "available bytes" as seen by read() versus
> FIONREAD.  I admit to being naive about the kernel but that seems
> like something that should not be possible.
> 
> 
> Given that, I don't understand what you're saying about notification
> of input availability being lost.  It may be true that the select()
> doesn't fire as often as it should, but the nrt side does wake up
> prior to the queue being completely full and still will only read 1
> message.  Are you saying that missing a notification would affect the
> "available bytes" seen by read() on the nrt side?  But still the
> FIONREAD would tell us the truth?

FIONREAD value and select() events are not synchronized, FIONREAD is
maintained in the rt-send and nrt-read handlers. FIONREAD always tells
the truth. On the other hand, if for some reason a wake up event is
missed, select() would be wrong. I don't have any evidence that such bug
happens looking at the code, but would something go wrong there, then it
might explain the behaviour you observed.

-- 
Philippe.


  reply	other threads:[~2014-11-03 16:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-29 16:11 [Xenomai] Message Pipe services behaviour Steve M. Robbins
2014-10-29 17:30 ` Philippe Gerum
2014-10-31 20:00   ` Steve M. Robbins
2014-11-01  9:54     ` Philippe Gerum
2014-11-02  0:53       ` Steve M. Robbins
2014-11-03  8:18         ` Philippe Gerum
2014-11-03 15:59           ` Steve M. Robbins
2014-11-03 16:29             ` Philippe Gerum [this message]
2014-11-03 18:37               ` Steve M. Robbins
2014-11-03 20:01                 ` Philippe Gerum
2014-11-03 20:03                   ` Gilles Chanteperdrix
2014-11-03 20:18                     ` Philippe Gerum
2014-11-03 22:22                   ` Steve M. Robbins
2014-11-03  8:54 ` dietmar.schindler
2014-11-03  9:08   ` 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=5457AD81.7090200@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=Xenomai@xenomai.org \
    --cc=steve@sumost.ca \
    /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.