From: Philippe Gerum <rpm@xenomai.org>
To: "Steve M. Robbins" <steve@sumost.ca>, Xenomai@xenomai.org
Subject: Re: [Xenomai] Message Pipe services behaviour
Date: Wed, 29 Oct 2014 18:30:40 +0100 [thread overview]
Message-ID: <54512440.3000806@xenomai.org> (raw)
In-Reply-To: <94331816.zv1NYeHro4@riemann>
On 10/29/2014 05:11 PM, Steve M. Robbins wrote:
> In the old FIFO-based code, we had a suspicion of the similar problem. Since
> the linux process is not real time, we expect multiple messages to be waiting.
> To avoid running through the select/read loop once for each message, our old
> FIFO-based code opened the file in nonblocking mode and did a read into a buffer
> that could hold up to 100 messages. We generally would read 5-7 at a time,
> not 100, so this proved that the reader could keep up when reading in batches.
>
> Using this same technique with the /dev/rtpN end of a Message Pipe never reads
> more than 1 message. I tried both blocking and non-blocking modes but got the
> same result. So this is my main question: knowing that there are likely many
> messages in the pipe, how do I read them in a batch?
>
Reading with O_NONBLOCK set on /dev/rtp should do the trick. If it does
not, this could mean that your rt side is filling up the pool too fast
compared to the scheduling opportunities for the nrt side. The latter
won't run until the rt activity becomes quiescent long enough.
You can track how many bytes are readable on the nrt side by using
ioctl(.., FIONREAD, &some_int), to make sure this value does increase
over time until ENOMEM is received. Otherwise there must be a leak of
consumed message buffers.
[snip]
> When I created the pipes with poolsize=0, all three queues would eventually
> begin to return -ENOMEM. After switching to poolsize=1000*sizeof(message), it
> seems to be only the middle-sized message that fails to allocate. That's not
> a conclusive observation, but if the other two are failing to allocate it is
> much less often than the middle one which eventally gets stuffed up and always
> fails. This is quite surprising to me.
poolsize=0 means to pull the buffer memory from the main Xenomai heap,
the size of which is given by CONFIG_XENO_OPT_SYS_HEAPSZ in your
Kconfig. Otherwise, some kernel memory is pulled from the regular linux
allocator for this purpose.
So if ENOMEM is received with poolsize=0, this means that a memory
shortage happens due to the pressure on the Xenomai main/system heap,
which is always bad news. I would recommend to use a local pool (i.e.
poolsz > 0) to prevent a consumption peak on the pipe from affecting the
whole Xenomai system.
You can read /proc/xenomai/heap while your test runs, to observe how
heaps behave.
Also, a memory leak was fixed in the 2.6 time frame, but it would bite
only when closing the file descriptor to the pipe. This said, you may
want to patch it in, to save some hair pulling sessions in the future:
http://git.xenomai.org/xenomai-2.6.git/commit/?id=ef8be4e4e58489479c2245a87b1dbd04d331dca9
--
Philippe.
next prev parent reply other threads:[~2014-10-29 17:30 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 [this message]
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
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=54512440.3000806@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.