All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: "Charlton, John" <john.charlton@domain.hid>
Cc: "xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai-help] mlockall error after calling mlockall()
Date: Thu, 25 Feb 2010 23:42:03 +0100	[thread overview]
Message-ID: <4B86FCBB.10203@domain.hid> (raw)
In-Reply-To: <4B86EDC2.7010905@domain.hid>

[-- Attachment #1: Type: text/plain, Size: 4948 bytes --]

Jan Kiszka wrote:
> Charlton, John wrote:
>> I have a xenomai application that runs without problems with xenomai-2.4.6.1/linux-2.6.27.7. When run under xenomai-2.5.1/linux-2.6.32.7 it fails with the warning: Xenomai: process memory not locked (missing mlockall?).  I verified that mlockall() is being called before any xenomai calls are made as follows with out error:
>>
> 
> I'm afraid that warning is misleading.

And this should fix the error reporting (without any signal handler
installed, your application will still terminate, though):

------>

From: Jan Kiszka <jan.kiszka@domain.hid>

Avoid false error reports of xeno_handle_mlock_alert

We already propagate the SIGDEBUG reason to user space. Use it to tell
SIGDEBUG_NOMLOCK apart from other triggers of this signal, e.g. the
watchdog. This also allows to drop xeno_sigxcpu_no_mlock.

Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
---
 include/asm-generic/bits/bind.h        |    6 +++---
 include/asm-generic/bits/mlock_alert.h |    7 ++-----
 src/skins/native/task.c                |   15 ---------------
 src/skins/posix/thread.c               |    9 ---------
 4 files changed, 5 insertions(+), 32 deletions(-)

diff --git a/include/asm-generic/bits/bind.h b/include/asm-generic/bits/bind.h
index 7267e0d..1aeffb5 100644
--- a/include/asm-generic/bits/bind.h
+++ b/include/asm-generic/bits/bind.h
@@ -9,7 +9,7 @@ union xnsiginfo;
 
 typedef void xnsighandler(union xnsiginfo *si);
 
-void xeno_handle_mlock_alert(int sig);
+void xeno_handle_mlock_alert(int sig, siginfo_t *si, void *context);
 
 int 
 xeno_bind_skin_opt(unsigned skin_magic, const char *skin, 
@@ -29,9 +29,9 @@ xeno_bind_skin(unsigned skin_magic, const char *skin,
 		exit(EXIT_FAILURE);
 	}
 
-	sa.sa_handler = &xeno_handle_mlock_alert;
+	sa.sa_sigaction = xeno_handle_mlock_alert;
 	sigemptyset(&sa.sa_mask);
-	sa.sa_flags = 0;
+	sa.sa_flags = SA_SIGINFO;
 	sigaction(SIGXCPU, &sa, NULL);
 
 	return muxid;
diff --git a/include/asm-generic/bits/mlock_alert.h b/include/asm-generic/bits/mlock_alert.h
index 6c7217d..eded3c1 100644
--- a/include/asm-generic/bits/mlock_alert.h
+++ b/include/asm-generic/bits/mlock_alert.h
@@ -6,15 +6,12 @@
 #include <signal.h>
 #include <pthread.h>
 
-__attribute__ ((weak))
-int xeno_sigxcpu_no_mlock = 1;
-
 __attribute__ ((weak, visibility ("internal")))
-void xeno_handle_mlock_alert(int sig)
+void xeno_handle_mlock_alert(int sig, siginfo_t *si, void *context)
 {
 	struct sigaction sa;
 
-	if (xeno_sigxcpu_no_mlock) {
+	if (si->si_value.sival_int == SIGDEBUG_NOMLOCK) {
 		fprintf(stderr, "Xenomai: process memory not locked "
 			"(missing mlockall?)\n");
 		fflush(stderr);
diff --git a/src/skins/native/task.c b/src/skins/native/task.c
index ba04a27..6312f2f 100644
--- a/src/skins/native/task.c
+++ b/src/skins/native/task.c
@@ -41,7 +41,6 @@ extern pthread_key_t __native_tskey;
 #endif /* !HAVE___THREAD */
 
 extern int __native_muxid;
-extern int xeno_sigxcpu_no_mlock;
 
 /* Public Xenomai interface. */
 
@@ -97,9 +96,6 @@ static void *rt_task_trampoline(void *cookie)
 
 	xeno_set_current();
 
-	if (iargs->mode & T_WARNSW)
-		xeno_sigxcpu_no_mlock = 0;
-
 	/* Wait on the barrier for the task to be started. The barrier
 	   could be released in order to process Linux signals while the
 	   Xenomai shadow is still dormant; in such a case, resume wait. */
@@ -231,9 +227,6 @@ int rt_task_shadow(RT_TASK *task, const char *name, int prio, int mode)
 
 	xeno_set_current();
 
-	if (mode & T_WARNSW)
-		xeno_sigxcpu_no_mlock = 0;
-
 	return 0;
 
   fail:
@@ -347,14 +340,6 @@ int rt_task_set_mode(int clrmask, int setmask, int *oldmode)
 				__native_task_set_mode, clrmask, setmask,
 				oldmode);
 
-	/* Silently deactivate our internal handler for SIGXCPU. At that
-	   point, we know that the process memory has been properly
-	   locked, otherwise we would have caught the latter signal upon
-	   thread creation. */
-
-	if (!err && xeno_sigxcpu_no_mlock)
-		xeno_sigxcpu_no_mlock = !(setmask & T_WARNSW);
-
 	return err;
 }
 
diff --git a/src/skins/posix/thread.c b/src/skins/posix/thread.c
index d565d52..8084a20 100644
--- a/src/skins/posix/thread.c
+++ b/src/skins/posix/thread.c
@@ -330,20 +330,11 @@ int pthread_wait_np(unsigned long *overruns_r)
 
 int pthread_set_mode_np(int clrmask, int setmask)
 {
-	extern int xeno_sigxcpu_no_mlock;
 	int err;
 
 	err = -XENOMAI_SKINCALL2(__pse51_muxid,
 				 __pse51_thread_set_mode, clrmask, setmask);
 
-	/* Silently deactivate our internal handler for SIGXCPU. At that
-	   point, we know that the process memory has been properly
-	   locked, otherwise we would have caught the latter signal upon
-	   thread creation. */
-
-	if (!err && xeno_sigxcpu_no_mlock)
-		xeno_sigxcpu_no_mlock = !(setmask & PTHREAD_WARNSW);
-
 	return err;
 }
 
-- 
1.6.0.2


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]

  reply	other threads:[~2010-02-25 22:42 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-25 21:12 [Xenomai-help] mlockall error after calling mlockall() Charlton, John
2010-02-25 21:25 ` Gilles Chanteperdrix
2010-02-25 21:38 ` Jan Kiszka
2010-02-25 22:42   ` Jan Kiszka [this message]
2010-02-25 22:54     ` Gilles Chanteperdrix
2010-02-25 23:01       ` Jan Kiszka
2010-02-26 16:47         ` Charlton, John
2010-02-26 16:53           ` Gilles Chanteperdrix
2010-02-26 17:15             ` Charlton, John
2010-03-01 15:52             ` Charlton, John
2010-03-01 20:30               ` Charlton, John
2010-03-01 20:33                 ` Jan Kiszka
2010-03-01 20:38                   ` Gilles Chanteperdrix
2010-03-01 20:43                     ` Jan Kiszka
2010-03-01 20:46                       ` Jan Kiszka
2010-03-01 20:56                         ` Gilles Chanteperdrix
2010-03-01 21:00                           ` Gilles Chanteperdrix
2010-03-01 21:02                             ` Jan Kiszka
2010-03-01 21:06                               ` Jan Kiszka
2010-03-01 21:01                           ` Jan Kiszka
2010-03-01 21:05                             ` Gilles Chanteperdrix
2010-03-01 21:21                               ` Jan Kiszka
2010-03-01 21:25                                 ` Jan Kiszka
2010-03-01 21:39                                   ` Jan Kiszka
2010-03-01 21:45                                     ` Gilles Chanteperdrix
2010-03-02  8:29                                       ` Jan Kiszka
2010-03-02  8:36                                         ` Jan Kiszka
2010-03-01 21:53                                   ` Charlton, John
2010-03-02 13:26                                     ` Charlton, John
2010-03-02 14:05                                       ` Jan Kiszka
2010-03-01 20:30               ` Jan Kiszka

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=4B86FCBB.10203@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=john.charlton@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.