All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: Jan Kiszka <jan.kiszka@domain.hid>, xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] [PATCH] Fix gatekeeper affinity
Date: Tue, 24 Feb 2009 16:02:18 +0100	[thread overview]
Message-ID: <49A40BFA.1010701@domain.hid> (raw)
In-Reply-To: <49A3FB6E.2090509@domain.hid>

Gilles Chanteperdrix wrote:
> Jan Kiszka wrote:
>> As the xnsched structures get initialized later, during xnpod_init,
>> xnsched_cpu always returned 0 in the gatekeeper_thread prologue. That
>> caused binding of all gatekeepers to CPU 0.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
>> ---
>>
>>  ksrc/nucleus/shadow.c |    5 ++++-
>>  1 files changed, 4 insertions(+), 1 deletions(-)
>>
>> diff --git a/ksrc/nucleus/shadow.c b/ksrc/nucleus/shadow.c
>> index 1dedd85..2243c0e 100644
>> --- a/ksrc/nucleus/shadow.c
>> +++ b/ksrc/nucleus/shadow.c
>> @@ -823,11 +823,14 @@ static int gatekeeper_thread(void *data)
>>  	struct task_struct *this_task = current;
>>  	DECLARE_WAITQUEUE(wait, this_task);
>>  	struct xnsched *sched = data;
>> -	int cpu = xnsched_cpu(sched);
>>  	struct xnthread *target;
>>  	cpumask_t cpumask;
>> +	int cpu;
>>  	spl_t s;
>>  
>> +	/* sched not fully initialized, xnsched_cpu does not work yet */
>> +	cpu = sched - nkpod_struct.sched;
>> +
>>  	this_task->flags |= PF_NOFREEZE;
>>  	sigfillset(&this_task->blocked);
>>  	cpumask = cpumask_of_cpu(cpu);
> 
> This does not look good, it means that the gatekeeper accesses the sched
> structure before it is initialized.

Fortunately, no, this can't be. The gatekeeper only refers to the semaphore and
the sync barrier and only that. Since the semaphore is initialized when the gk
starts, the gk sets up the barrier on entry, and the barrier can't be signaled
until the nucleus has fully initialized in xnpod_init(), we used to be safe.

 So, IMO, the proper fix would be to
> start the gatekeepers only after the sched structure has been initialized.
> 

-- 
Philippe.


  parent reply	other threads:[~2009-02-24 15:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-24 13:35 [Xenomai-core] [PATCH] Fix gatekeeper affinity Jan Kiszka
2009-02-24 13:51 ` Gilles Chanteperdrix
2009-02-24 13:57   ` Jan Kiszka
2009-02-24 14:09     ` Gilles Chanteperdrix
2009-02-24 14:20       ` Jan Kiszka
2009-02-24 15:02   ` Philippe Gerum [this message]
2009-02-24 14:57 ` 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=49A40BFA.1010701@domain.hid \
    --to=rpm@xenomai.org \
    --cc=gilles.chanteperdrix@xenomai.org \
    --cc=jan.kiszka@domain.hid \
    --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.