All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Steve B <sbattazzo@gmail.com>
Cc: xenomai <xenomai@xenomai.org>
Subject: Re: [Xenomai] XDDP socket, any memory allocation when sendto() is called?
Date: Fri, 13 May 2016 20:08:54 +0200	[thread overview]
Message-ID: <57361836.4090906@xenomai.org> (raw)
In-Reply-To: <CAEMXjGws9VOasRJh2aV+bTXDvqFHTP4yuWD_T7hPp7BJCnM+bA@mail.gmail.com>

On 05/13/2016 07:53 PM, Steve B wrote:
> On Fri, May 13, 2016 at 6:50 AM, Philippe Gerum <rpm@xenomai.org> wrote:
> 
>> On 05/13/2016 01:42 AM, Steve B wrote:
>>> Hi guys,
>>> Does sendto() going into an XDDP socket involve any memory allocation
>>> that's not automatically getting de-allocated each time it's called?
>>>
>>> I have an application running where I am writing a few different types of
>>> data packets to an XDDP socket on a fixed periodic basis, and in a
>> separate
>>> console using "free" I see the memory usage increasing steadily until I
>>> only have about 5MB left, at which point it doesn't grow/shrink anymore.
>> I
>>> don't seem to be losing any data after this happens, though.
>>>
>>> I tried temporarily disabling my largest packet type, and saw that the
>> rate
>>> of memory consumption decreases very significantly, which is why I think
>> it
>>> has something to do with this.
>>>
>>> I may be able to live with this if it's not causing any real problems but
>>> it is a little unsettling...
>>
>> The memory is freed upon read() on the other side. Do the datagrams
>> linger somehow on the (non-rt) read-side?
>>
>> --
>> Philippe.
>>
> 
> The non-rt side just reads the messages and writes them to binary files. I
> have a slightly over 1k byte message coming across 100x per second, and log
> files are saved off and new files are created every 60 seconds. The files
> are pretty consistently coming out at 6.5 MB give or take a few percent (I
> think the slop is mostly in the time keeping in the non-RT side). So I
> think all of my data is there, though I wonder if whatever buffering there
> is between the RT and non-RT side may be overflowing. I would think that I
> should be seeing failures in my writes if the buffer is full?
> 

Correct. If you don't get any error on the write side, then it's fine.

Giving your XDDP connection a private memory pool would allow you to cap
the maximum consumption, and check how much is actually consumed by
looking at /proc/xenomai/heaps/xddp-pool@<port-number>. An XDDP
connection consumes memory from the pool it has been given exclusively.

XDDP_POOLSZ is the setsockopt() option you need to set for that.

> That actually does bring me to the question, do I even need to be buffering
> my on board log files to the non-RT side via XDDP at all? Could I just
> write the files straight from my RT side?
> 

This would entail a switch to Linux mode, which is like demoting a
thread priority-wise, so you would lose RT guarantees doing so from the
RT side. XDDP is there to prevent this, keeping the RT side in primary
mode while sending out the data to the other end.

-- 
Philippe.


  reply	other threads:[~2016-05-13 18:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-12 23:42 [Xenomai] XDDP socket, any memory allocation when sendto() is called? Steve B
2016-05-13 13:50 ` Philippe Gerum
2016-05-13 17:53   ` Steve B
2016-05-13 18:08     ` Philippe Gerum [this message]
2016-05-13 18:19       ` Steve B
2016-05-13 18:27         ` Steve B
2016-05-13 18:45           ` Philippe Gerum
2016-05-13 19:42             ` Steve B
2016-05-14 12:28               ` Gilles Chanteperdrix
2016-05-14 13:00               ` Philippe Gerum
2016-05-17  0:17                 ` Steve B

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=57361836.4090906@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=sbattazzo@gmail.com \
    --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.