From: Oleg Nesterov <oleg@redhat.com>
To: Roland McGrath <roland@redhat.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>,
caiqian@redhat.com, Heiko Carstens <heiko.carstens@de.ibm.com>,
Jan Kratochvil <jkratoch@redhat.com>,
linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
utrace-devel@redhat.com
Subject: Re: s390 && user_enable_single_step() (Was: odd utrace testing results on s390x)
Date: Thu, 21 Jan 2010 21:51:13 +0100 [thread overview]
Message-ID: <20100121205113.GB20050@redhat.com> (raw)
In-Reply-To: <20100107214821.94FF97300@magilla.sf.frob.com>
On 01/07, Roland McGrath wrote:
>
> > I am confused as well. Yes, I thought about regs->psw.mask change too,
> > but I don't understand why it helps..
> [...]
> > But. Acoording to the testing I did (unless I did something wrong
> > again) this patch doesn't make any difference in this particular
> > case. 6580807da14c423f0d0a708108e6df6ebc8bc83d does.
>
> Those results are quite mysterious to me.
> I think we'll have to get Martin to sort it out definitively.
I did the testing again with 2.6.32-5.el6 + Martin's
c3311c13adc1021e986fef12609ceb395ffc5014
f8d5faf718c9ff2c04eb8484585d4963c4111cd7
patches.
the same test-case:
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
#include <assert.h>
int main(void)
{
int pid, status;
if (!(pid = fork())) {
assert(ptrace(PTRACE_TRACEME) == 0);
kill(getpid(), SIGSTOP);
if (!fork())
return 43;
wait(&status);
return WEXITSTATUS(status);
}
for (;;) {
assert(pid == wait(&status));
if (WIFEXITED(status))
break;
assert(ptrace(PTRACE_SINGLESTEP, pid, 0,0) == 0);
}
assert(WEXITSTATUS(status) == 43);
return 0;
}
with the simple debugging patch below I did
# perl -e 'syscall 172, 666, 0,0'; ./xxx
# perl -e 'syscall 172, 666, 0,1'; ./xxx
# perl -e 'syscall 172, 666, 1,0'; ./xxx
# perl -e 'syscall 172, 666, 1,1'; ./xxx
and dmesg reports:
XXX disable_step=0, clear_flag=0
XXX: xxx/1868 0
[... 799 times ...]
XXX disable_step=0, clear_flag=1
XXX: xxx/1905 0
[... 799 times ...]
XXX disable_step=1, clear_flag=0
XXX disable_step=1, clear_flag=1
Just in case, I did the testing with and without CONFIG_UTRACE,
result is the same.
IOW, copy_thread()->clear_tsk_thread_flag(TIF_SINGLE_STEP) doesn't
make any difference, copy_process()->user_disable_single_step() does.
Although I need to re-read Martin's explanations about psw magic,
perhaps this was already explained...
Oleg.
--- K/kernel/sys.c~ 2010-01-21 14:16:15.366639654 -0500
+++ K/kernel/sys.c 2010-01-21 14:30:35.131591879 -0500
@@ -1453,6 +1453,8 @@ SYSCALL_DEFINE1(umask, int, mask)
return mask;
}
+int xxx_disable_step, xxx_clear_flag;
+
SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
unsigned long, arg4, unsigned long, arg5)
{
@@ -1466,6 +1468,13 @@ SYSCALL_DEFINE5(prctl, int, option, unsi
error = 0;
switch (option) {
+ case 666:
+ xxx_disable_step = arg2;
+ xxx_clear_flag = arg3;
+ printk(KERN_INFO "XXX disable_step=%d, clear_flag=%d\n",
+ xxx_disable_step, xxx_clear_flag);
+ break;
+
case PR_SET_PDEATHSIG:
if (!valid_signal(arg2)) {
error = -EINVAL;
--- K/kernel/fork.c~ 2010-01-18 09:35:16.823811008 -0500
+++ K/kernel/fork.c 2010-01-21 14:29:39.131624971 -0500
@@ -964,6 +964,8 @@ static void posix_cpu_timers_init(struct
INIT_LIST_HEAD(&tsk->cpu_timers[2]);
}
+extern int xxx_disable_step;
+
/*
* This creates a new process as a copy of the old one,
* but does not actually start it yet.
@@ -1207,7 +1209,8 @@ static struct task_struct *copy_process(
* Syscall tracing and stepping should be turned off in the
* child regardless of CLONE_PTRACE.
*/
- user_disable_single_step(p);
+ if (xxx_disable_step)
+ user_disable_single_step(p);
clear_tsk_thread_flag(p, TIF_SYSCALL_TRACE);
#ifdef TIF_SYSCALL_EMU
clear_tsk_thread_flag(p, TIF_SYSCALL_EMU);
--- K/arch/s390/kernel/process.c~ 2010-01-21 14:32:38.541609793 -0500
+++ K/arch/s390/kernel/process.c 2010-01-21 14:34:10.461584130 -0500
@@ -161,6 +161,8 @@ void release_thread(struct task_struct *
{
}
+extern int xxx_clear_flag;
+
int copy_thread(unsigned long clone_flags, unsigned long new_stackp,
unsigned long unused,
struct task_struct *p, struct pt_regs *regs)
@@ -217,7 +219,8 @@ int copy_thread(unsigned long clone_flag
p->thread.mm_segment = get_fs();
/* Don't copy debug registers */
memset(&p->thread.per_info, 0, sizeof(p->thread.per_info));
- clear_tsk_thread_flag(p, TIF_SINGLE_STEP);
+ if (xxx_clear_flag)
+ clear_tsk_thread_flag(p, TIF_SINGLE_STEP);
/* Initialize per thread user and system timer values */
ti = task_thread_info(p);
ti->user_timer = 0;
next prev parent reply other threads:[~2010-01-21 20:51 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1503844142.2061111261478093776.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
[not found] ` <1257887498.2061171261478252049.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
2010-01-04 15:52 ` s390 && user_enable_single_step() (Was: odd utrace testing results on s390x) Oleg Nesterov
2010-01-04 16:16 ` Martin Schwidefsky
2010-01-04 18:14 ` Oleg Nesterov
2010-01-04 19:30 ` Oleg Nesterov
2010-01-04 21:11 ` Roland McGrath
2010-01-05 9:50 ` Martin Schwidefsky
2010-01-05 15:36 ` Oleg Nesterov
2010-01-05 15:46 ` Martin Schwidefsky
2010-01-05 15:59 ` Oleg Nesterov
2010-01-05 17:03 ` Oleg Nesterov
2010-01-05 19:58 ` Oleg Nesterov
2010-01-06 14:59 ` Heiko Carstens
2010-01-06 20:17 ` Oleg Nesterov
2010-01-06 21:13 ` Roland McGrath
2010-01-07 9:18 ` Martin Schwidefsky
2010-01-07 17:54 ` Oleg Nesterov
2010-01-07 21:48 ` Roland McGrath
2010-01-21 20:51 ` Oleg Nesterov [this message]
2010-01-26 13:13 ` Martin Schwidefsky
2010-01-07 21:46 ` Roland McGrath
2010-01-08 8:30 ` Martin Schwidefsky
2010-01-08 10:25 ` Roland McGrath
2010-01-05 15:47 ` Oleg Nesterov
2010-01-05 15:50 ` Martin Schwidefsky
2010-01-06 21:08 ` Roland McGrath
2010-01-07 9:16 ` Martin Schwidefsky
2010-01-07 18:16 ` Oleg Nesterov
2010-01-07 21:44 ` Roland McGrath
2010-01-08 8:34 ` Martin Schwidefsky
2010-01-07 21:41 ` Roland McGrath
2010-01-07 18:11 ` Oleg Nesterov
2010-01-06 20:23 ` Oleg Nesterov
2010-01-06 20:56 ` Roland McGrath
2010-01-07 9:00 ` Martin Schwidefsky
2010-01-07 21:32 ` Roland McGrath
2010-01-21 20:32 ` Oleg Nesterov
2010-01-05 9:26 ` Martin Schwidefsky
2010-01-06 21:15 ` Roland McGrath
2010-01-04 20:46 ` Roland McGrath
[not found] <1158952983.251101262791902387.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
2010-01-06 15:33 ` caiqian
2010-01-06 20:09 ` Oleg Nesterov
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=20100121205113.GB20050@redhat.com \
--to=oleg@redhat.com \
--cc=caiqian@redhat.com \
--cc=heiko.carstens@de.ibm.com \
--cc=jkratoch@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=roland@redhat.com \
--cc=schwidefsky@de.ibm.com \
--cc=utrace-devel@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox