From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Andi Kleen <andi@firstfloor.org>,
tglx@linutronix.de, hpa@zytor.com, linux-kernel@vger.kernel.org,
heukelum@fastmail.fm
Subject: Re: [PATCH 2/5] x86: ret_from_fork - get rid of jump back
Date: Thu, 27 Nov 2008 22:12:35 +0300 [thread overview]
Message-ID: <20081127191234.GD23593@localhost> (raw)
In-Reply-To: <20081127134121.GA22736@elte.hu>
[Ingo Molnar - Thu, Nov 27, 2008 at 02:41:21PM +0100]
|
| * Cyrill Gorcunov <gorcunov@gmail.com> wrote:
|
...
|
| Could you test something like the patch attached below, which cleans
| up this code and applies the code reduction and speedup? Warning:
| completely untested! Please check that things like strace -f and gdb
| attaching to forked tasks still works fine. (it should by all means)
|
| Thanks,
|
| Ingo
Ingo, I found 2.6.26 test machine where I've patched the entry_64.S
in a manner you pointed. So here is a test program and strace output.
Seems all works fine. Didn't check "audit" code which I simply don't
know how to be done.
- Cyrill -
---
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int pid;
pid = fork();
if (pid < 0) {
fprintf(stderr, "Fork failed!\n");
exit(-1);
}
else if (pid == 0) {
printf("I am the child, return from fork=%d\n", pid);
} else {
printf("I am the parent, return from fork, child pid=%d\n", pid);
printf("Parent exiting!\n");
exit(0);
}
}
---
5897 execve("./main", ["./main"], [/* 18 vars */]) = 0
5897 brk(0) = 0x2514000
5897 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa0e517f000
5897 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
5897 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa0e517d000
5897 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
5897 open("/etc/ld.so.cache", O_RDONLY) = 3
5897 fstat(3, {st_mode=S_IFREG|0644, st_size=48530, ...}) = 0
5897 mmap(NULL, 48530, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fa0e5171000
5897 close(3) = 0
5897 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
5897 open("/lib/libc.so.6", O_RDONLY) = 3
5897 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220\345"..., 832) = 832
5897 fstat(3, {st_mode=S_IFREG|0755, st_size=1502520, ...}) = 0
5897 mmap(NULL, 3609304, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fa0e4bf0000
5897 mprotect(0x7fa0e4d59000, 2093056, PROT_NONE) = 0
5897 mmap(0x7fa0e4f58000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x168000) = 0x7fa0e4f58000
5897 mmap(0x7fa0e4f5d000, 17112, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fa0e4f5d000
5897 close(3) = 0
5897 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa0e5170000
5897 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa0e516f000
5897 arch_prctl(ARCH_SET_FS, 0x7fa0e516f6e0) = 0
5897 mprotect(0x7fa0e4f58000, 16384, PROT_READ) = 0
5897 mprotect(0x7fa0e5180000, 4096, PROT_READ) = 0
5897 munmap(0x7fa0e5171000, 48530) = 0
5897 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fa0e516f770) = 5898
5897 fstat(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(5, 1), ...}) = 0
5898 fstat(1, <unfinished ...>
5897 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS <unfinished ...>
5898 <... fstat resumed> {st_mode=S_IFCHR|0600, st_rdev=makedev(5, 1), ...}) = 0
5897 <... ioctl resumed> , {B38400 opost isig icanon echo ...}) = 0
5897 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 <unfinished ...>
5898 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS <unfinished ...>
5897 <... mmap resumed> ) = 0x7fa0e517c000
5898 <... ioctl resumed> , {B38400 opost isig icanon echo ...}) = 0
5897 write(1, "I am the parent, return from for"..., 50 <unfinished ...>
5898 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 <unfinished ...>
5897 <... write resumed> ) = 50
5898 <... mmap resumed> ) = 0x7fa0e517c000
5897 write(1, "Parent exiting!\n", 16 <unfinished ...>
5898 write(1, "I am the child, return from fork"..., 35 <unfinished ...>
5897 <... write resumed> ) = 16
5898 <... write resumed> ) = 35
5897 exit_group(0) = ?
5898 exit_group(0) = ?
---
next prev parent reply other threads:[~2008-11-27 19:12 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-26 19:16 x86 -tip: entry_64.S cleanup series gorcunov
2008-11-26 19:17 ` [PATCH 1/5] x86: entry_64.S - use ENTRY to define child_rip gorcunov
2008-11-26 19:17 ` [PATCH 2/5] x86: ret_from_fork - get rid of jump back gorcunov
2008-11-26 19:33 ` Cyrill Gorcunov
2008-11-26 20:04 ` Andi Kleen
2008-11-26 20:10 ` Cyrill Gorcunov
2008-11-26 20:15 ` Cyrill Gorcunov
2008-11-27 13:41 ` Ingo Molnar
2008-11-27 14:16 ` Andi Kleen
2008-11-28 13:47 ` Ingo Molnar
2008-11-28 18:55 ` Andi Kleen
2008-11-27 16:20 ` Cyrill Gorcunov
2008-11-27 19:12 ` Cyrill Gorcunov [this message]
2008-11-26 19:17 ` [PATCH 3/5] x86: entry_64.S - use X86_EFLAGS_IF instead of hardcoded number gorcunov
2008-11-27 10:37 ` Alexander van Heukelum
2008-11-27 12:00 ` Ingo Molnar
2008-11-26 19:17 ` [PATCH 4/5] x86: ret_from_fork - add CFI proc annotation gorcunov
2008-11-27 10:15 ` Alexander van Heukelum
2008-11-27 11:27 ` Cyrill Gorcunov
2008-11-26 19:17 ` [PATCH 5/5] x86: entry_64.S - trivial: space, comments fixup gorcunov
2008-11-27 10:39 ` Alexander van Heukelum
2008-11-27 12:02 ` Ingo Molnar
2008-11-27 12:25 ` Cyrill Gorcunov
2008-11-27 18:10 ` Cyrill Gorcunov
2008-11-28 13:54 ` Ingo Molnar
2008-11-27 10:37 ` [PATCH 1/5] x86: entry_64.S - use ENTRY to define child_rip Alexander van Heukelum
2008-11-27 12:04 ` Ingo Molnar
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=20081127191234.GD23593@localhost \
--to=gorcunov@gmail.com \
--cc=andi@firstfloor.org \
--cc=heukelum@fastmail.fm \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/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