All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Daniel Merrill <daniel.merrill@psware.com>,
	'Gilles Chanteperdrix' <gilles.chanteperdrix@xenomai.org>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai] t_suspend and XNBREAK
Date: Thu, 24 Oct 2013 12:03:20 +0200	[thread overview]
Message-ID: <5268F068.7000201@xenomai.org> (raw)
In-Reply-To: <d73ca437.00001700.00000035@dmerrill_win764.PERF.PERFORMANCESOFTWARE>

On 10/24/2013 01:11 AM, Daniel Merrill wrote:
>>
>> Ok, I can't reproduce with this code yet. Let's proceed differently.
>> Could you apply the patch below, then send back the kernel output
>> you should get when the issue happens? The traces are emitted only when
>> a task self-suspends using a null tid, which should restrict the scope
>> enough to avoid extraneous messages. I'd be interested in the gdb output
>> you get as well when running over gdb into this issue (i.e. which
>> t_suspend()
>> call fails with -EINTR in this case - lineno?).
>>
>> In the meantime, you may also try switching temporarily to 2.6.3,
>> just for testing. It is 100% ABI and API compatible with 2.6.2.1,
>> you would only need to recompile your app, nothing more. You don't
>> have to switch i-pipe support for doing this. We fixed a
>> couple of issues in the 2.6.3 time frame wrt GDB support. Although
>> I don't see a direct relationship between your issue and what we fixed,
>> it makes sense to do a quick check anyway.
>>
>> TIA,
>> --
>> Philippe.
> 
> Ok, here is the log output, plus the gdb output run on 2.6.3
> 
> Oct 23 16:05:55 JETSdev kernel: [ 7013.901317] t_suspend: self-suspend
> SUB1[1387], sigpending=0, state=0x300180, info=0x0
> Oct 23 16:05:55 JETSdev kernel: [ 7013.901324] t_suspend: self-suspend
> SUB2[1388], sigpending=0, state=0x300180, info=0x0
> Oct 23 16:05:55 JETSdev kernel: [ 7013.901344] t_suspend: self-suspend
> SUB3[1389], sigpending=0, state=0x300180, info=0x0
> Oct 23 16:05:55 JETSdev kernel: [ 7013.906328] t_suspend: unblocked
> SUB3[1389], sigpending=1, state=0x302180, info=0xc
> Oct 23 16:05:55 JETSdev kernel: [ 7013.906330]    => SIG19 pending
> Oct 23 16:05:55 JETSdev kernel: [ 7013.906339] t_suspend: unblocked
> SUB2[1388], sigpending=1, state=0x302180, info=0xc
> Oct 23 16:05:55 JETSdev kernel: [ 7013.906340]    => SIG19 pending
> Oct 23 16:05:55 JETSdev kernel: [ 7013.907202] t_suspend: self-suspend
> SUB3[1389], sigpending=0, state=0x300180, info=0x0
> Oct 23 16:05:55 JETSdev kernel: [ 7013.907210] t_suspend: self-suspend
> SUB2[1388], sigpending=0, state=0x300180, info=0x0
> Oct 23 16:05:55 JETSdev kernel: [ 7013.907223] t_suspend: self-suspend
> SUB1[1387], sigpending=0, state=0x300180, info=0x0
> Oct 23 16:05:55 JETSdev kernel: [ 7013.912273] t_suspend: unblocked
> SUB3[1389], sigpending=1, state=0x302180, info=0xc
> Oct 23 16:05:55 JETSdev kernel: [ 7013.912274]    => SIG19 pending
> Oct 23 16:05:55 JETSdev kernel: [ 7013.912282] t_suspend: unblocked
> SUB2[1388], sigpending=1, state=0x302180, info=0xc
> Oct 23 16:05:55 JETSdev kernel: [ 7013.912283]    => SIG19 pending
> Oct 23 16:05:55 JETSdev kernel: [ 7013.912290] t_suspend: unblocked
> SUB1[1387], sigpending=1, state=0x302180, info=0xc
> Oct 23 16:05:55 JETSdev kernel: [ 7013.912291]    => SIG19 pending
> Oct 23 16:05:55 JETSdev kernel: [ 7013.912694] t_suspend: self-suspend
> SUB3[1389], sigpending=0, state=0x300180, info=0x0
> Oct 23 16:05:55 JETSdev kernel: [ 7013.912701] t_suspend: self-suspend
> SUB2[1388], sigpending=0, state=0x300180, info=0x0
> Oct 23 16:05:55 JETSdev kernel: [ 7013.912707] t_suspend: self-suspend
> SUB1[1387], sigpending=0, state=0x300180, info=0x0
> Oct 23 16:05:55 JETSdev kernel: [ 7013.912783] t_suspend: unblocked
> SUB3[1389], sigpending=1, state=0x302180, info=0xc
> Oct 23 16:05:55 JETSdev kernel: [ 7013.912784]    => SIG19 pending
> Oct 23 16:05:55 JETSdev kernel: [ 7013.912792] t_suspend: unblocked
> SUB2[1388], sigpending=1, state=0x302180, info=0xc
> Oct 23 16:05:55 JETSdev kernel: [ 7013.912792]    => SIG19 pending
> Oct 23 16:05:55 JETSdev kernel: [ 7013.912799] t_suspend: unblocked
> SUB1[1387], sigpending=1, state=0x302180, info=0xc
> Oct 23 16:05:55 JETSdev kernel: [ 7013.912800]    => SIG19 pending
> Oct 23 16:05:55 JETSdev kernel: [ 7013.914466] t_suspend: self-suspend
> SUB3[1389], sigpending=0, state=0x300180, info=0x0
> Oct 23 16:05:55 JETSdev kernel: [ 7013.914474] t_suspend: self-suspend
> SUB2[1388], sigpending=0, state=0x300180, info=0x0
> Oct 23 16:05:55 JETSdev kernel: [ 7013.914480] t_suspend: self-suspend
> SUB1[1387], sigpending=0, state=0x300180, info=0x0
> Oct 23 16:05:55 JETSdev kernel: [ 7013.914515] t_suspend: unblocked
> SUB1[1387], sigpending=1, state=0x300180, info=0xc
> Oct 23 16:05:55 JETSdev kernel: [ 7013.914516]    => SIG32 pending
> Oct 23 16:05:55 JETSdev kernel: [ 7013.914751] t_suspend: unblocked
> SUB3[1389], sigpending=1, state=0x302180, info=0xc
> Oct 23 16:05:55 JETSdev kernel: [ 7013.914752]    => SIG19 pending
> Oct 23 16:05:55 JETSdev kernel: [ 7013.915840] t_suspend: self-suspend
> SUB3[1389], sigpending=0, state=0x300180, info=0x0
> Oct 23 16:05:55 JETSdev kernel: [ 7013.915858] t_suspend: self-suspend
> SUB2[1388], sigpending=0, state=0x300180, info=0x0
> Oct 23 16:05:55 JETSdev kernel: [ 7013.920201] t_suspend: unblocked
> SUB2[1388], sigpending=1, state=0x300180, info=0xc
> Oct 23 16:05:55 JETSdev kernel: [ 7013.920203]    => SIG32 pending
> Oct 23 16:05:55 JETSdev kernel: [ 7013.922922] t_suspend: unblocked
> SUB3[1389], sigpending=1, state=0x302180, info=0xc
> Oct 23 16:05:55 JETSdev kernel: [ 7013.922924]    => SIG19 pending
> Oct 23 16:05:55 JETSdev kernel: [ 7013.923319] t_suspend: self-suspend
> SUB3[1389], sigpending=0, state=0x300180, info=0x0
> 
> jets@JETSdev:~/projects/tdelete_fail_test$ gdb test
> GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
> Copyright (C) 2012 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "i686-linux-gnu".
> For bug reporting instructions, please see:
> <http://bugs.launchpad.net/gdb-linaro/>...
> Reading symbols from /home/jets/projects/tdelete_fail_test/test...done.
> Breakpoint 1 at 0x80486fa: file test.c, line 20.
> Breakpoint 2 at 0x8048765: file test.c, line 35.
> Breakpoint 3 at 0x80487d0: file test.c, line 50.
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
> [New Thread 0xb7fd3b40 (LWP 1386)]
> [New Thread 0xb7fceb40 (LWP 1387)]
> [New Thread 0xb7deab40 (LWP 1388)]
> [New Thread 0xb7de5b40 (LWP 1389)]
> SUB1 TID:124
> subTask1, suspend returned 0
> [Switching to Thread 0xb7fceb40 (LWP 1387)]
> 
> Breakpoint 3, subTask1 () at test.c:50
> 50		retValue = t_suspend(0);
> SUB2 TID:125
> subTask2, suspend returned 0
> [Switching to Thread 0xb7deab40 (LWP 1388)]
> 
> Breakpoint 2, subTask2 () at test.c:35
> 35		retValue = t_suspend(0);
> subTask1, suspend returned -4
> [Thread 0xb7deab40 (LWP 1388) exited]
> 
> It hangs after subTask1 fails to suspend because subTask1 starts misbehaving
> at that point and never gives up time.
> 
> Anyway hopefully this starts to lead us down the right path. Thanks
> 

- Do you handle SIG32 specifically in GDB, so that the
latter does not intercept the signal? If not, could you check whether
this makes any difference? (i.e. "handle SIG32 nostop noprint pass")

- Could you apply the patch below, keeping the previous one in?
We should be sending back -ERESTARTSYS to the kernel when the
issue happens, and this behaves as if the Xenomai core did
not.

diff --git a/ksrc/nucleus/shadow.c b/ksrc/nucleus/shadow.c
index c91a6f3..9b96029 100644
--- a/ksrc/nucleus/shadow.c
+++ b/ksrc/nucleus/shadow.c
@@ -699,11 +699,21 @@ void __init xnheap_init_vdso(void)
 
 static inline void request_syscall_restart(xnthread_t *thread,
 					   struct pt_regs *regs,
-					   int sysflags)
+					   int sysflags,
+					   int head)
 {
 	int notify = 0;
 
 	if (xnthread_test_info(thread, XNKICKED)) {
+		printk(KERN_WARNING
+		       "%s[%s]: %s, state=0x%lx, info=0x%lx, rval=%ld, sysflags=0x%x\n",
+		       __func__,
+		       head ? "hi" : "lo",
+		       thread->name,
+		       thread->state, thread->info,
+		       __xn_reg_rval(regs),
+		       sysflags);
+
 		if (__xn_interrupted_p(regs)) {
 			__xn_error_return(regs,
 					  (sysflags & __xn_exec_norestart) ?
@@ -2364,7 +2374,7 @@ int do_hisyscall_event(unsigned event, rthal_pipeline_stage_t *stage,
 		if (signal_pending(p) || xnthread_amok_p(thread)) {
 			sigs = 1;
 			xnthread_clear_amok(thread);
-			request_syscall_restart(thread, regs, sysflags);
+			request_syscall_restart(thread, regs, sysflags, 1);
 		} else if (xnthread_test_state(thread, XNOTHER) &&
 			   xnthread_get_rescnt(thread) == 0) {
 			if (switched)
@@ -2537,7 +2547,7 @@ int do_losyscall_event(unsigned event, rthal_pipeline_stage_t *stage,
 		thread = xnshadow_thread(current);
 		if (signal_pending(current)) {
 			sigs = 1;
-			request_syscall_restart(thread, regs, sysflags);
+			request_syscall_restart(thread, regs, sysflags, 0);
 		} else if (xnthread_test_state(thread, XNOTHER) &&
 			   xnthread_get_rescnt(thread) == 0)
 			sysflags |= __xn_exec_switchback;

-- 
Philippe.


  reply	other threads:[~2013-10-24 10:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-09 16:29 [Xenomai] t_suspend and XNBREAK Daniel Merrill
2013-10-09 16:33 ` Philippe Gerum
2013-10-09 16:37   ` Daniel Merrill
2013-10-09 16:43     ` Philippe Gerum
2013-10-09 17:01       ` Daniel Merrill
2013-10-16 18:30         ` Daniel Merrill
2013-10-21 18:21           ` Daniel Merrill
2013-10-22 13:46             ` Philippe Gerum
2013-10-22 14:49               ` Gilles Chanteperdrix
2013-10-22 16:53                 ` Philippe Gerum
2013-10-22 22:10                   ` Daniel Merrill
2013-10-23 17:31                     ` Philippe Gerum
2013-10-23 23:11                       ` Daniel Merrill
2013-10-24 10:03                         ` Philippe Gerum [this message]
2013-10-24 15:52                           ` Daniel Merrill
2013-10-24 18:24                           ` Daniel Merrill
2013-10-22 16:50               ` Daniel Merrill
2014-05-20 12:52           ` 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=5268F068.7000201@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=daniel.merrill@psware.com \
    --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.