Skip to contentSkip to conversation

init segfaults when CONFIG_PROFILE_LIKELY=y

BUG 2.6.20-rc2-mm1 Daniel Walker 4 participants 6 messages Dec 31, 2006 – Jan 2, 2007 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 4 lines · Fengguang Wu

Hi,

The following messages keeps popping up when CONFIG_PROFILE_LIKELY=y:

Quoted 9 lines

init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15

Does this seem like an appropriate solution? This just reconstitutes Ingo's patch by removing the unlikely calls that got added recently.

Maybe a comment into vsyscall.c that says to stay away from all macro's and possible debug code that could be added might be helpful ?

---
 arch/x86_64/kernel/vsyscall.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86_64/kernel/vsyscall.c +2 -2
Index: linux-2.6.19/arch/x86_64/kernel/vsyscall.c
===================================================================
@@ -111,7 +111,7 @@ static __always_inline void do_vgettimeo
 		seq = read_seqbegin(&__vsyscall_gtod_data.lock);
 
 		vread = __vsyscall_gtod_data.clock.vread;
-		if (unlikely(!__vsyscall_gtod_data.sysctl_enabled || !vread)) {
+		if (!__vsyscall_gtod_data.sysctl_enabled || !vread) {
 			gettimeofday(tv,0);
 			return;
 		}
@@ -151,7 +151,7 @@ int __vsyscall(0) vgettimeofday(struct t
  * unlikely */
 time_t __vsyscall(1) vtime(time_t *t)
 {
-	if (unlikely(!__vsyscall_gtod_data.sysctl_enabled))
+	if (!__vsyscall_gtod_data.sysctl_enabled)
 		return time_syscall(t);
 	else if (t)
 		*t = __vsyscall_gtod_data.wall_time_tv.tv_sec;
#2 lore raw
Quoted 16 lines · On Sun, 31 Dec 2006 11:45:09 -0800 Daniel Walker wrote:
Quoted 4 lines · Fengguang Wu

Hi,

The following messages keeps popping up when CONFIG_PROFILE_LIKELY=y:

Quoted 9 lines

init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15

Quoted 2 lines

Does this seem like an appropriate solution? This just reconstitutes Ingo's patch by removing the unlikely calls that got added recently.

How does this fix the problem? (if it does)
What is the real cause of the problem?

Quoted 2 lines

Maybe a comment into vsyscall.c that says to stay away from all macro's and possible debug code that could be added might be helpful ?

Why?

Quoted 20 lines
---
 arch/x86_64/kernel/vsyscall.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Index: linux-2.6.19/arch/x86_64/kernel/vsyscall.c
===================================================================

arch/x86_64/kernel/vsyscall.c +1 -1
@@ -111,7 +111,7 @@ static __always_inline void do_vgettimeo
 		seq = read_seqbegin(&__vsyscall_gtod_data.lock);
 
 		vread = __vsyscall_gtod_data.clock.vread;
-		if (unlikely(!__vsyscall_gtod_data.sysctl_enabled || !vread)) {
+		if (!__vsyscall_gtod_data.sysctl_enabled || !vread) {
 			gettimeofday(tv,0);
 			return;
 		}

arch/x86_64/kernel/vsyscall.c int __vsyscall(0) vgettimeofday(struct t · line 157

Quoted 8 lines
arch/x86_64/kernel/vsyscall.c +1 -1
@@ -151,7 +151,7 @@ int __vsyscall(0) vgettimeofday(struct t
  * unlikely */
 time_t __vsyscall(1) vtime(time_t *t)
 {
-	if (unlikely(!__vsyscall_gtod_data.sysctl_enabled))
+	if (!__vsyscall_gtod_data.sysctl_enabled)
 		return time_syscall(t);
 	else if (t)
 		*t = __vsyscall_gtod_data.wall_time_tv.tv_sec;

---
~Randy

#3 lore raw
Quoted 18 lines · Randy Dunlap
Quoted 16 lines · On Sun, 31 Dec 2006 11:45:09 -0800 Daniel Walker wrote:
Quoted 13 lines · Fengguang Wu

Hi,

The following messages keeps popping up when CONFIG_PROFILE_LIKELY=y:

init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15

Quoted 5 lines
Quoted 2 lines

Does this seem like an appropriate solution? This just reconstitutes Ingo's patch by removing the unlikely calls that got added recently.

How does this fix the problem? (if it does)
What is the real cause of the problem?

Well I tested it so I sure hope it fixes it (unless I've gone mad). I guess we can wait for Fengguang to test it tho.

Quoted 4 lines
Quoted 2 lines

Maybe a comment into vsyscall.c that says to stay away from all macro's and possible debug code that could be added might be helpful ?

Why?

I don't know very much about vsyscalls, but from what I've read they actually reside in userspace. So with and "unlikely" added into that code, and profiling on, you will end up calling do_check_likely() which is in kernel space that's how the segfault happens.

I imagine this goes for all debugging in kernel space, you can't add it into a vsyscall. That's my reasoning behind adding a comment.

Daniel

#4 lore raw
Quoted 19 lines · On Sun, 31 Dec 2006 13:11:26 -0800 Daniel Walker wrote:
Quoted 18 lines · Randy Dunlap
Quoted 16 lines · On Sun, 31 Dec 2006 11:45:09 -0800 Daniel Walker wrote:
Quoted 13 lines · Fengguang Wu

Hi,

The following messages keeps popping up when CONFIG_PROFILE_LIKELY=y:

init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Does this seem like an appropriate solution? This just reconstitutes Ingo's patch by removing the unlikely calls that got added recently.

How does this fix the problem? (if it does)
What is the real cause of the problem?

Well I tested it so I sure hope it fixes it (unless I've gone mad). I guess we can wait for Fengguang to test it tho.

Yes, it fixed it in my testing also.

Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

Maybe a comment into vsyscall.c that says to stay away from all macro's and possible debug code that could be added might be helpful ?

Why?

Quoted 7 lines

I don't know very much about vsyscalls, but from what I've read they actually reside in userspace. So with and "unlikely" added into that code, and profiling on, you will end up calling do_check_likely() which is in kernel space that's how the segfault happens.

I imagine this goes for all debugging in kernel space, you can't add it into a vsyscall. That's my reasoning behind adding a comment.

OK, thanks. The first explanation was a bit lacking IMO, but this one begins to help.

---
~Randy

#5 lore raw
In reply to Daniel Walker
Quoted 16 lines · Daniel Walker
Quoted 4 lines · Fengguang Wu

Hi,

The following messages keeps popping up when CONFIG_PROFILE_LIKELY=y:

Quoted 9 lines

init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15

Quoted 7 lines

Does this seem like an appropriate solution? This just reconstitutes Ingo's patch by removing the unlikely calls that got added recently.

Maybe a comment into vsyscall.c that says to stay away from all macro's and possible debug code that could be added might be helpful ?

Thanks, it worked!

Acked-by
#6 lore raw
In reply to Daniel Walker
Quoted 16 lines · Daniel Walker
Quoted 4 lines · Fengguang Wu

Hi,

The following messages keeps popping up when CONFIG_PROFILE_LIKELY=y:

Quoted 9 lines

init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15 init[1]: segfault at ffffffff8118c110 rip ffffffff8118c110 rsp 00007fff9a9d14d8 error 15

Quoted 7 lines

Does this seem like an appropriate solution? This just reconstitutes Ingo's patch by removing the unlikely calls that got added recently.

Maybe a comment into vsyscall.c that says to stay away from all macro's and possible debug code that could be added might be helpful ?

Yep, good catch Daniel!

Quoted 28 lines
---
 arch/x86_64/kernel/vsyscall.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Index: linux-2.6.19/arch/x86_64/kernel/vsyscall.c
===================================================================

arch/x86_64/kernel/vsyscall.c +2 -2
@@ -111,7 +111,7 @@ static __always_inline void do_vgettimeo
 		seq = read_seqbegin(&__vsyscall_gtod_data.lock);
 
 		vread = __vsyscall_gtod_data.clock.vread;
-		if (unlikely(!__vsyscall_gtod_data.sysctl_enabled || !vread)) {
+		if (!__vsyscall_gtod_data.sysctl_enabled || !vread) {
 			gettimeofday(tv,0);
 			return;
 		}
@@ -151,7 +151,7 @@ int __vsyscall(0) vgettimeofday(struct t
  * unlikely */
 time_t __vsyscall(1) vtime(time_t *t)
 {
-	if (unlikely(!__vsyscall_gtod_data.sysctl_enabled))
+	if (!__vsyscall_gtod_data.sysctl_enabled)
 		return time_syscall(t);
 	else if (t)
 		*t = __vsyscall_gtod_data.wall_time_tv.tv_sec;