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: Tue, 02 Mar 2010 15:05:11 +0100 [thread overview]
Message-ID: <4B8D1B17.6000507@domain.hid> (raw)
In-Reply-To: <CF7FB0793253794F9F45991443E5FE2006483DE995@domain.hid>
Charlton, John wrote:
> While I was debugging this problem, it looked like I could change ksrc/skins/native/cond.c by modifying the rt_cond_wait_inner function as follows:
> --- xenomai-2.5.1_bak/ksrc/skins/native/cond.c 2010-01-15 19:09:31.000000000 -0500
> +++ xenomai-2.5.1/ksrc/skins/native/cond.c 2010-03-01 17:17:22.000000000 -0500
> @@ -468,15 +468,22 @@
> {
> unsigned lockcnt;
> int err;
> + int err_save;
>
> err = rt_cond_wait_prologue(cond, mutex, &lockcnt,
> timeout_mode, timeout);
>
> + err_save = err;
> if(!err || err == -ETIMEDOUT || err == -EINTR)
> do {
> err = rt_cond_wait_epilogue(mutex, lockcnt);
> } while (err == -EINTR);
>
> + if (err_save == -ETIMEDOUT)
> + {
> + err = err_save;
> + }
> +
> return err;
> }
> /**
That is for in-kernel cond_wait only.
>
> When I made these changes and put a printk in rt_cond_wait_inner also the printk did not get printed and the change above did not seem to make any difference. So should I revert these changes or should they be made in addition to the syscall.c kernel and cond.c user space changes as follows:
>
> --- xenomai-2.5.1_bak/ksrc/skins/native/syscall.c 2010-02-01 20:01:09.000000000 -0500
> +++ xenomai-2.5.1/ksrc/skins/native/syscall.c 2010-03-01 16:13:20.000000000 -0500
> @@ -1869,8 +1869,12 @@
>
> err = rt_cond_wait_prologue(cond, mutex, &lockcnt, timeout_mode, timeout);
>
> - if (err == 0 || err == -ETIMEDOUT)
> - err = rt_cond_wait_epilogue(mutex, lockcnt);
> + if (err == 0 || err == -ETIMEDOUT) {
> + int loc_err = rt_cond_wait_epilogue(mutex, lockcnt);
> + if (loc_err < 0)
> + err = loc_err;
> + }
> +
>
> if (err == -EINTR && __xn_reg_arg3(regs)
> && __xn_safe_copy_to_user((void __user *)__xn_reg_arg3(regs),
>
> --- xenomai-2.5.1_bak/src/skins/native/cond.c 2010-01-15 19:09:32.000000000 -0500
> +++ xenomai-2.5.1/src/skins/native/cond.c 2010-03-01 16:44:48.000000000 -0500
> @@ -41,7 +41,7 @@
>
> int rt_cond_wait(RT_COND *cond, RT_MUTEX *mutex, RTIME timeout)
> {
> - int saved_lockcnt, err;
> + int saved_lockcnt, err, saved_err;
>
> #ifdef CONFIG_XENO_FASTSYNCH
> saved_lockcnt = mutex->lockcnt;
> @@ -49,7 +49,7 @@
> err = XENOMAI_SKINCALL5(__native_muxid,
> __native_cond_wait_prologue, cond, mutex,
> NULL, XN_RELATIVE, &timeout);
> -
> + saved_err = err;
> while (err == -EINTR)
> err = XENOMAI_SKINCALL2(__native_muxid,
> __native_cond_wait_epilogue, mutex,
> @@ -62,6 +62,7 @@
> __native_cond_wait_prologue, cond, mutex,
> &saved_lockcnt, XN_RELATIVE, &timeout);
>
> + saved_err = err;
> while (err == -EINTR)
> err = XENOMAI_SKINCALL2(__native_muxid,
> __native_cond_wait_epilogue, mutex,
> @@ -69,12 +70,12 @@
>
> #endif /* !CONFIG_XENO_FASTSYNCH */
>
> - return err;
> + return saved_err;
> }
>
> int rt_cond_wait_until(RT_COND *cond, RT_MUTEX *mutex, RTIME timeout)
> {
> - int saved_lockcnt, err;
> + int saved_lockcnt, err, saved_err;
>
> #ifdef CONFIG_XENO_FASTSYNCH
> saved_lockcnt = mutex->lockcnt;
> @@ -82,7 +83,7 @@
> err = XENOMAI_SKINCALL5(__native_muxid,
> __native_cond_wait_prologue, cond, mutex,
> NULL, XN_REALTIME, &timeout);
> -
> + saved_err = err;
> while (err == -EINTR)
> err = XENOMAI_SKINCALL2(__native_muxid,
> __native_cond_wait_epilogue, mutex,
> @@ -94,14 +95,14 @@
> err = XENOMAI_SKINCALL5(__native_muxid,
> __native_cond_wait_prologue, cond, mutex,
> &saved_lockcnt, XN_REALTIME, &timeout);
> -
> + saved_err = err;
> while (err == -EINTR)
> - err = -XENOMAI_SKINCALL2(__native_muxid,
> + err = XENOMAI_SKINCALL2(__native_muxid,
> __native_cond_wait_epilogue, mutex,
> saved_lockcnt);
> #endif /* !CONFIG_XENO_FASTSYNCH */
>
> - return err;
> + return saved_err;
> }
>
> int rt_cond_signal(RT_COND *cond)
>
Yep, the easiest approach for you is to throw away the epilogue error
for now (just loop over -EINTR). That's what 2.4.x did as well. We are
still struggling with proper fixes for all corner cases.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2010-03-02 14:05 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
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 [this message]
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=4B8D1B17.6000507@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.