All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-core] [PATCH v2 1/4] POSIX: Fix SCHED_RR thread creation
Date: Tue, 17 Feb 2009 18:28:41 +0100	[thread overview]
Message-ID: <499AF3C9.2040502@domain.hid> (raw)
In-Reply-To: <499AF09F.8040402@domain.hid>

Gilles Chanteperdrix wrote:
> Jan Kiszka wrote:
>> @@ -192,6 +192,9 @@ static void *__pthread_trampoline(void *arg)
>>  
>>  	param.sched_priority = iargs->prio;
>>  	policy = iargs->policy;
>> +	if (policy == SCHED_RR)
>> +		/* Restrict round-robin scheduling to the Xenomai domain. */
>> +		policy = SCHED_FIFO;
> 
> Should not there be the same thing in __wrap_pthread_setschedparam ?

Yes, and setschedparam_ex, here we go:

--------->

SCHED_RR threads created via pthread_create do not receive the
round-robin property at kernel side. Fix this by pushing the policy as
an additional argument to __pse51_thread_create down to the kernel.
Moreover, enforce SCHED_FIFO for the Linux part of those threads.

Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
---

 0 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/ksrc/skins/posix/syscall.c b/ksrc/skins/posix/syscall.c
index 99c2a16..3480142 100644
--- a/ksrc/skins/posix/syscall.c
+++ b/ksrc/skins/posix/syscall.c
@@ -167,7 +167,7 @@ static int __pthread_create(struct pt_regs *regs)
 	   calling context. */
 
 	pthread_attr_init(&attr);
-	attr.policy = p->policy;
+	attr.policy = __xn_reg_arg2(regs);
 	attr.detachstate = PTHREAD_CREATE_DETACHED;
 	attr.schedparam_ex.sched_priority = p->rt_priority;
 	attr.fp = 1;
@@ -179,7 +179,7 @@ static int __pthread_create(struct pt_regs *regs)
 		return -err;	/* Conventionally, our error codes are negative. */
 
 	err = xnshadow_map(&k_tid->threadbase, NULL,
-			   (unsigned long __user *)__xn_reg_arg2(regs));
+			   (unsigned long __user *)__xn_reg_arg3(regs));
 
 	if (!err && !__pthread_hash(&hkey, k_tid))
 		err = -ENOMEM;
diff --git a/src/skins/posix/thread.c b/src/skins/posix/thread.c
index f32c7e1..1593eea 100644
--- a/src/skins/posix/thread.c
+++ b/src/skins/posix/thread.c
@@ -61,8 +61,13 @@ int __wrap_pthread_setschedparam(pthread_t thread,
 				 __pse51_thread_setschedparam,
 				 thread, policy, param, mode_buf, &promoted);
 
-	if (err == EPERM)
+	if (err == EPERM) {
+		if (policy == SCHED_RR)
+			/* Restrict round-robin scheduling to the Xenomai
+			   domain. */
+			policy = SCHED_FIFO;
 		return __real_pthread_setschedparam(thread, policy, param);
+	}
 
 	if (!err && promoted) {
 		sigshadow_install_once();
@@ -104,6 +109,10 @@ int pthread_setschedparam_ex(pthread_t thread,
 
 	if (err == EPERM) {
 		short_param.sched_priority = param->sched_priority;
+		if (policy == SCHED_RR)
+			/* Restrict round-robin scheduling to the Xenomai
+			   domain. */
+			policy = SCHED_FIFO;
 		return __real_pthread_setschedparam(thread, policy, &short_param);
 	}
 
@@ -192,6 +201,9 @@ static void *__pthread_trampoline(void *arg)
 
 	param.sched_priority = iargs->prio;
 	policy = iargs->policy;
+	if (policy == SCHED_RR)
+		/* Restrict round-robin scheduling to the Xenomai domain. */
+		policy = SCHED_FIFO;
 	parent_prio = iargs->parent_prio;
 	mode_buf = xeno_init_current_mode();
 
@@ -203,8 +215,8 @@ static void *__pthread_trampoline(void *arg)
 
 	/* Do _not_ inline the call to pthread_self() in the syscall
 	   macro: this trashes the syscall regs on some archs. */
-	err = XENOMAI_SKINCALL2(__pse51_muxid, __pse51_thread_create, tid,
-				mode_buf);
+	err = XENOMAI_SKINCALL3(__pse51_muxid, __pse51_thread_create, tid,
+				iargs->policy, mode_buf);
 	iargs->ret = -err;
 
 	/* We must save anything we'll need to use from *iargs on our own
@@ -221,9 +233,7 @@ static void *__pthread_trampoline(void *arg)
 	__real_sem_post(&iargs->sync);
 
 	if (!err) {
-		/* Broken pthread libs ignore some of the thread attribute specs
-		   passed to pthread_create(3), so we force the scheduling policy
-		   once again here. */
+		/* Adjust to final Linux policy and priority. */
 		__real_pthread_setschedparam(tid, policy, &param);
 
 		/* If the thread running pthread_create runs with the same


  reply	other threads:[~2009-02-17 17:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-17 17:04 [Xenomai-core] [PATCH v2 0/4] Various fixes and cleanups Jan Kiszka
2009-02-17 17:04 ` [Xenomai-core] [PATCH v2 2/4] Mark libs nodlopen on initial-exec TLS Jan Kiszka
2009-02-17 17:04 ` [Xenomai-core] [PATCH v2 1/4] POSIX: Fix SCHED_RR thread creation Jan Kiszka
2009-02-17 17:15   ` Gilles Chanteperdrix
2009-02-17 17:28     ` Jan Kiszka [this message]
2009-02-17 17:37       ` Gilles Chanteperdrix
2009-02-17 17:47         ` Jan Kiszka
2009-02-17 17:50           ` Gilles Chanteperdrix
2009-02-17 17:57             ` Jan Kiszka
2009-02-17 18:17               ` Gilles Chanteperdrix
2009-02-17 18:19                 ` Jan Kiszka
2009-02-17 18:21                   ` Gilles Chanteperdrix
2009-02-17 18:41                     ` Jan Kiszka
2009-02-17 23:48                       ` Jan Kiszka
2009-02-18  7:51                         ` Jan Kiszka
2009-02-17 17:04 ` [Xenomai-core] [PATCH v2 4/4] POSIX: Do not auto-shadow main with dlopen enabled Jan Kiszka
2009-02-17 17:04 ` [Xenomai-core] [PATCH v2 3/4] Add --enable-dlopen-skins configure switch Jan Kiszka
2009-02-25 10:04 ` [Xenomai-core] [PATCH v2 0/4] Various fixes and cleanups Jan Kiszka
2009-02-25 11:19   ` 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=499AF3C9.2040502@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=gilles.chanteperdrix@xenomai.org \
    --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.