All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Jan Kiszka <jan.kiszka@domain.hid>
Cc: Xenomai core <Xenomai-core@domain.hid>
Subject: Re: [Xenomai-core] RFC: use a pool of pre-allocated buffers in rt_printf
Date: Thu, 23 Jun 2011 13:29:43 +0200	[thread overview]
Message-ID: <4E0323A7.2040107@domain.hid> (raw)
In-Reply-To: <4E0302B3.3090201@domain.hid>

On 06/23/2011 11:09 AM, Jan Kiszka wrote:
> On 2011-06-23 11:05, Gilles Chanteperdrix wrote:
>> On 06/23/2011 09:38 AM, Jan Kiszka wrote:
>>>> +#ifdef CONFIG_XENO_FASTSYNCH
>>>> +	if (xeno_get_current() != XN_NO_HANDLE &&
>>>> +	    !(xeno_get_current_mode() & XNRELAX) && buf_pool_get()) {
>>>> +		struct print_buffer *old;
>>>> +
>>>> +		old = buf_pool_get();
>>>> +		while (old != buffer) {
>>>> +			buffer = old;
>>>> +			old = buf_pool_cmpxchg(buffer, buffer->pool_next);
>>>
>>> Though unlikely, it's still possible: The buffer obtained in the last
>>> round may have been dequeued meanwhile and then freed (in case a third
>>> buffer was released to the pool, filling it up to pool_capacity).
>>
>> I do not get it: it seems to me that if the current head (that is
>> buf_pool_get()) is freed, then the cmpxchg will fail, so we will loop
>> and try again.
> 
> Problematic is the dereferencing of the stale buffer pointer obtained
> during the last cmpxchg or via buf_pool_get. This happens before the new
> cmpxchg.

Ok. Got it, that would be a problem only if the stale pointer pointed to
an unmapped area, but ok, better avoid freeing the buffers. I guess it
would not be a problem as applications tend to have a fixed number of
threads anyway.

-- 
                                                                Gilles.


  reply	other threads:[~2011-06-23 11:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-22 21:55 [Xenomai-core] RFC: use a pool of pre-allocated buffers in rt_printf Gilles Chanteperdrix
2011-06-23  7:38 ` Jan Kiszka
2011-06-23  9:05   ` Gilles Chanteperdrix
2011-06-23  9:09     ` Jan Kiszka
2011-06-23 11:29       ` Gilles Chanteperdrix [this message]
2011-06-23 11:36         ` Jan Kiszka
2011-06-23 11:40           ` Gilles Chanteperdrix
2011-06-24 19:58           ` Gilles Chanteperdrix
2011-06-27  6:32             ` Jan Kiszka
2011-06-27 10:57               ` Gilles Chanteperdrix

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=4E0323A7.2040107@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=Xenomai-core@domain.hid \
    --cc=jan.kiszka@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.