From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: ronny meeus <ronny.meeus@domain.hid>
Cc: Xenomai-help@domain.hid
Subject: Re: [Xenomai-help] Possible memory leak in psos skin message queue handling
Date: Tue, 26 Oct 2010 13:34:19 +0200 [thread overview]
Message-ID: <4CC6BCBB.8020902@domain.hid> (raw)
In-Reply-To: <AANLkTi=y8ix9REzUeCU+adyKTE=C-M=P_gFTtjVDO+rw@domain.hid>
ronny meeus wrote:
> Hello
>
> I did some further debugging on the problem described below and I made
> some progress.
> At creation time of the message queue using:
> q_create("TEST",0,Q_NOLIMIT|Q_PRIOR,&qid);
> a chunk of message buffers (64) is allocated and added to the free
> message list of the queue (queue->freeq).
> Once the message queue is deleted, the messages are added into the
> global psosmbufq.
> During the q_create/q_delete loop, the memory pool get depleted since
> the number of messages in the psosmbufq keeps on increasing all the time.
>
> In my opinion if the Q_PRIBUF is not set during queue creation, the
> "psosmbufq" has to be used to allocate/release from/to.
> This also implies that the local freeq in the queue object is not used
> in this mode anymore.
> Each time a message needs to be send, in function get_mbuf it is simply
> taken from the psosmbufq. In case this would be empty, a feed_pool
> operation is called on it.
>
> static psosmbuf_t *get_mbuf(psosqueue_t *queue, u_long msglen)
> {
> psosmbuf_t *mbuf = NULL;
>
> if (testbits(queue->synchbase.status, Q_NOCACHE)) {
> mbuf =
> (psosmbuf_t *) xnmalloc(sizeof(*mbuf) + msglen -
> sizeof(mbuf->data));
>
> if (mbuf)
> inith(&mbuf->link);
> } else {
> xnholder_t *holder = NULL;
> if (testbits(queue->synchbase.status, Q_SHAREDINIT)) {
> holder = getq(&psosmbufq);
> if (!holder) {
> feed_pool(&psoschunkq,
> &psosmbufq,PSOS_QUEUE_MIN_ALLOC,queue->maxlen);
> holder = getq(&psosmbufq);
> }
> } else {
> holder = getq(&queue->freeq);
> if (!holder && testbits(queue->synchbase.status, Q_INFINITE)) {
> feed_pool(&queue->chunkq,&queue->freeq,
> PSOS_QUEUE_MIN_ALLOC,queue->maxlen);
> holder = getq(&queue->freeq);
> }
> }
> if (holder)
> mbuf = link2psosmbuf(holder);
> }
> return mbuf;
> }
>
> I have adapted the code accordingly and rerun my tests. Now it runs forever.
> (Of course I also did changes in the code to create and delete a queue.)
>
> Now the question is: Is my understanding correct? If it is, the flag
> Q_SHAREDINIT would be better renamed to Q_SHAREDMSGS.
>
> Please share your thoughts.
A patch would be better than some fancy HTML colouring, if you intend
your fix to be reviewed/integrated.
--
Gilles.
next prev parent reply other threads:[~2010-10-26 11:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-19 9:28 [Xenomai-help] Possible memory leak in psos skin message queue handling ronny meeus
2010-10-26 9:58 ` ronny meeus
2010-10-26 11:34 ` Gilles Chanteperdrix [this message]
2010-10-26 13:13 ` ronny meeus
2010-11-02 20:05 ` ronny meeus
2010-11-03 20:49 ` Gilles Chanteperdrix
2010-11-03 21:15 ` ronny meeus
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=4CC6BCBB.8020902@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=Xenomai-help@domain.hid \
--cc=ronny.meeus@domain.hid \
/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.