[opensuse-programming] VDSO support
I am curious about this article: http://www.linuxjournal.com/content/creating-vdso-colonels-other-chicken and openSUSE's supplied kernel. I see that VDSO's are enabled in openSUSE distros: $ cat /proc/self/maps | grep vdso ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso] If I look in /usr/src/linux/arch/x86/vdso/vdso.lds.S, I see: /* * This controls what userland symbols we export from the vDSO. */ VERSION { LINUX_2.6 { global: clock_gettime; __vdso_clock_gettime; gettimeofday; __vdso_gettimeofday; getcpu; __vdso_getcpu; local: *; }; } As it turns out, gettimeofday is a function our app uses extensively. It is a data collection program that time tags everything. Is it the case that applications should just magically get the VDSO version of the three system calls listed above? If that is the case, I should not see calls to gettimeofday in straces of my app. But I do. I suspect there is is an additional step needed. I have not recognized it in my googling on the topic. Perhaps a compile/linker option? Yours sincerely, Roger Oberholtzer OPQ Systems / Ramböll RST Office: Int +46 10-615 60 20 Mobile: Int +46 70-815 1696 roger.oberholtzer@ramboll.se ________________________________________ Ramböll Sverige AB Krukmakargatan 21 P.O. Box 17009 SE-104 62 Stockholm, Sweden www.rambollrst.se -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-programming+owner@opensuse.org
Roger Oberholtzer wrote:
Is it the case that applications should just magically get the VDSO version of the three system calls listed above? If that is the case, I should not see calls to gettimeofday in straces of my app. But I do.
I suspect there is is an additional step needed. I have not recognized it in my googling on the topic. Perhaps a compile/linker option?
I think you need to link in the vdso module when you build your application. /Per Jessen, Zürich -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-programming+owner@opensuse.org
On Thu, 2012-02-09 at 15:00 +0100, Per Jessen wrote:
Roger Oberholtzer wrote:
Is it the case that applications should just magically get the VDSO version of the three system calls listed above? If that is the case, I should not see calls to gettimeofday in straces of my app. But I do.
I suspect there is is an additional step needed. I have not recognized it in my googling on the topic. Perhaps a compile/linker option?
I think you need to link in the vdso module when you build your application.
OK. Where is that? I looked for something called *vdso* in /usr/lib, but came up empty. I thought it sounded like glibc was managing this. If vdso was available, it did that instead of a syscall(SYS_xxx) call. Yours sincerely, Roger Oberholtzer OPQ Systems / Ramböll RST Office: Int +46 10-615 60 20 Mobile: Int +46 70-815 1696 roger.oberholtzer@ramboll.se ________________________________________ Ramböll Sverige AB Krukmakargatan 21 P.O. Box 17009 SE-104 62 Stockholm, Sweden www.rambollrst.se -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-programming+owner@opensuse.org
On Thu, Feb 09, 2012 at 03:37:30PM +0100, Roger Oberholtzer wrote:
On Thu, 2012-02-09 at 15:00 +0100, Per Jessen wrote:
Roger Oberholtzer wrote:
Is it the case that applications should just magically get the VDSO version of the three system calls listed above? If that is the case, I should not see calls to gettimeofday in straces of my app. But I do.
I suspect there is is an additional step needed. I have not recognized it in my googling on the topic. Perhaps a compile/linker option?
I think you need to link in the vdso module when you build your application.
OK. Where is that? I looked for something called *vdso* in /usr/lib, but came up empty.
I thought it sounded like glibc was managing this. If vdso was available, it did that instead of a syscall(SYS_xxx) call.
You dont need to do anything to link it, it should just work out of the box. Which processor architecture do you build this for, which kernel version? Can you check this simple sample with strace? #include <stdio.h> #include <sys/time.h> int main(int argc, char **argv) { struct timeval tv; gettimeofday (&tv,NULL); printf("%d\n", tv.tv_sec); } -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-programming+owner@opensuse.org
On Thu, 2012-02-09 at 15:49 +0100, Marcus Meissner wrote:
On Thu, Feb 09, 2012 at 03:37:30PM +0100, Roger Oberholtzer wrote:
On Thu, 2012-02-09 at 15:00 +0100, Per Jessen wrote:
Roger Oberholtzer wrote:
Is it the case that applications should just magically get the VDSO version of the three system calls listed above? If that is the case, I should not see calls to gettimeofday in straces of my app. But I do.
I suspect there is is an additional step needed. I have not recognized it in my googling on the topic. Perhaps a compile/linker option?
I think you need to link in the vdso module when you build your application.
OK. Where is that? I looked for something called *vdso* in /usr/lib, but came up empty.
I thought it sounded like glibc was managing this. If vdso was available, it did that instead of a syscall(SYS_xxx) call.
You dont need to do anything to link it, it should just work out of the box.
Which processor architecture do you build this for, which kernel version?
Can you check this simple sample with strace?
#include <stdio.h> #include <sys/time.h> int main(int argc, char **argv) { struct timeval tv;
gettimeofday (&tv,NULL); printf("%d\n", tv.tv_sec); }
openSUSE 11.2, 2.6.31.14-51-desktop, vdso listed in /proc/self/maps: gettimeofday({1328857222, 418127}, NULL) = 0 openSUSE 12.1, 3.1.9-1.4-desktop, vdso listed in /proc/self/maps: gettimeofday({1328857436, 119151}, NULL) = 0 Yours sincerely, Roger Oberholtzer OPQ Systems / Ramböll RST Office: Int +46 10-615 60 20 Mobile: Int +46 70-815 1696 roger.oberholtzer@ramboll.se ________________________________________ Ramböll Sverige AB Krukmakargatan 21 P.O. Box 17009 SE-104 62 Stockholm, Sweden www.rambollrst.se -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-programming+owner@opensuse.org
On Thu, 2012-02-09 at 15:49 +0100, Marcus Meissner wrote:
On Thu, Feb 09, 2012 at 03:37:30PM +0100, Roger Oberholtzer wrote:
On Thu, 2012-02-09 at 15:00 +0100, Per Jessen wrote:
Roger Oberholtzer wrote:
Is it the case that applications should just magically get the VDSO version of the three system calls listed above? If that is the case, I should not see calls to gettimeofday in straces of my app. But I do.
I suspect there is is an additional step needed. I have not recognized it in my googling on the topic. Perhaps a compile/linker option?
I think you need to link in the vdso module when you build your application.
OK. Where is that? I looked for something called *vdso* in /usr/lib, but came up empty.
I thought it sounded like glibc was managing this. If vdso was available, it did that instead of a syscall(SYS_xxx) call.
You dont need to do anything to link it, it should just work out of the box.
Which processor architecture do you build this for, which kernel version?
Oh, it is x86 (32.bit) Yours sincerely, Roger Oberholtzer OPQ Systems / Ramböll RST Office: Int +46 10-615 60 20 Mobile: Int +46 70-815 1696 roger.oberholtzer@ramboll.se ________________________________________ Ramböll Sverige AB Krukmakargatan 21 P.O. Box 17009 SE-104 62 Stockholm, Sweden www.rambollrst.se -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-programming+owner@opensuse.org
Roger Oberholtzer wrote:
On Thu, 2012-02-09 at 15:00 +0100, Per Jessen wrote:
Roger Oberholtzer wrote:
Is it the case that applications should just magically get the VDSO version of the three system calls listed above? If that is the case, I should not see calls to gettimeofday in straces of my app. But I do.
I suspect there is is an additional step needed. I have not recognized it in my googling on the topic. Perhaps a compile/linker option?
I think you need to link in the vdso module when you build your application.
OK. Where is that? I looked for something called *vdso* in /usr/lib, but came up empty.
I only read the article, sometimes another pair of eyes will help. This is the section:
Let's compile a test case to exercise the vDSO call:
/* notb.c */ #include <stdio.h>
int main(void) { int notb = number_of_the_beast();
printf("His number is %d\n", notb);
return 0; }
Then, compile the code above as:
gcc notb.c -o notb vdso.so
The file you link against is vdso.so, which provides the symbol resolution needed to make the kernel call. The kernel version of number_of_the_beast() is called, even if the code for that function is completely different in vdso.so. Where is vdso.so located? It's located in the kernel build directory after building the kernel:linux-2.6.37/arch/x86/vdso/vdso.so.
Let us know how it goes, it's an interesting topic. /Per Jessen, Zürich -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-programming+owner@opensuse.org
On Fri, 2012-02-10 at 07:34 +0100, Per Jessen wrote:
Roger Oberholtzer wrote:
On Thu, 2012-02-09 at 15:00 +0100, Per Jessen wrote:
Roger Oberholtzer wrote:
Is it the case that applications should just magically get the VDSO version of the three system calls listed above? If that is the case, I should not see calls to gettimeofday in straces of my app. But I do.
I suspect there is is an additional step needed. I have not recognized it in my googling on the topic. Perhaps a compile/linker option?
I think you need to link in the vdso module when you build your application.
OK. Where is that? I looked for something called *vdso* in /usr/lib, but came up empty.
I only read the article, sometimes another pair of eyes will help. This is the section:
The article was rather sloppy keeping kernel mods separate from user applications. Other articles I have read claim that glibc knows about vdso. /usr/src/linux/Documentation/ABI/stable/vdso (in newer kernel source trees) says: "On some architectures, when the kernel loads any userspace program it maps an ELF DSO into that program's address space. This DSO is called the vDSO and it often contains useful and highly-optimized alternatives to real syscalls." It goes on to say: "Programs that dynamically link to glibc will use the vDSO automatically." Maybe the problem is the x86 architecture, as the same doc worryingly states: "As of this writing, this ABI documentation as been confirmed for x86_64. The maintainers of the other vDSO-using architectures should confirm that it is correct for their architecture." I am trying this in x86.
Let's compile a test case to exercise the vDSO call:
/* notb.c */ #include <stdio.h>
int main(void) { int notb = number_of_the_beast();
printf("His number is %d\n", notb);
return 0; }
Then, compile the code above as:
gcc notb.c -o notb vdso.so
The file you link against is vdso.so, which provides the symbol resolution needed to make the kernel call. The kernel version of number_of_the_beast() is called, even if the code for that function is completely different in vdso.so. Where is vdso.so located? It's located in the kernel build directory after building the kernel:linux-2.6.37/arch/x86/vdso/vdso.so.
Let us know how it goes, it's an interesting topic.
/Per Jessen, Zürich
Yours sincerely, Roger Oberholtzer OPQ Systems / Ramböll RST Office: Int +46 10-615 60 20 Mobile: Int +46 70-815 1696 roger.oberholtzer@ramboll.se ________________________________________ Ramböll Sverige AB Krukmakargatan 21 P.O. Box 17009 SE-104 62 Stockholm, Sweden www.rambollrst.se -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-programming+owner@opensuse.org
participants (3)
-
Marcus Meissner
-
Per Jessen
-
Roger Oberholtzer