Arun Babu
2007-Feb-27 18:22 UTC
[Xen-users] Why are shared libraries loaded multiple times in a guest VM?
Hi, I have xen 3.0.2-3 installed with linux 2.6.16.13 guests running on them. I have a simple test program to print the address of a function in a shared library (say printf) using dlopen and dlsym. I ran this test on DomO and running another instance of the same program (to make sure the library is still loaded). Both instances print the same address (as expected). But when I do this experiment on a DomU, I get different addresses for the same function. Further investigation of /proc/<pid>/maps shows that the same shared library is loaded in different places on those two machines. Why isn''t the different instances of the test program refer the same shared library/ why is the library loaded multiple times? Can somebody help me reason out why this is happening in guest vm? Is this because of some boot option or anything specific to xen? Thank you Arun -- http://www4.ncsu.edu/~abnagara _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Petersson, Mats
2007-Feb-27 18:43 UTC
RE: [Xen-users] Why are shared libraries loaded multiple times in a guest VM?
> -----Original Message----- > From: xen-users-bounces@lists.xensource.com > [mailto:xen-users-bounces@lists.xensource.com] On Behalf Of Arun Babu > Sent: 27 February 2007 18:23 > To: xen-users@lists.xensource.com > Subject: [Xen-users] Why are shared libraries loaded multiple > times in a guest VM? > > Hi, > > I have xen 3.0.2-3 installed with linux 2.6.16.13 guests > running on them. > I have a simple test program to print the address of a > function in a shared library (say printf) using dlopen and > dlsym. I ran this test on DomO and running another instance > of the same program (to make sure the library is still > loaded). Both instances print the same address (as expected). > But when I do this experiment on a DomU, I get different > addresses for the same function. Further investigation of > /proc/<pid>/maps shows that the same shared library is loaded > in different places on those two machines. Why isn''t the > different instances of the test program refer the same shared > library/ why is the library loaded multiple times?Do I get it right that your "complaint" is that the same shared library is loaded at different places in Dom0 and DomU? Since DomU is a different (albeit virtual) machine, I don''t see what there is to complain about. In a real system with two different machines, you would not complain that the shared library is in the memory of both machines, right? Just because DomU is in the same physical machine as Dom0, it doesn''t have ANY way to actually even know that Dom0 is in the same machine (aside from some timing aspects of running a virtual machine) [para-virtual kernels have been modified to do things slightly differently]. Obviously, if that''s not what you''re complaining about, sorry for misunderstanding the "complaint"... The fact that the same shared library is loaded at a different address within the virtual address range is probably something to do with what virtual addresses are available and it may also depend on what other shared libraries have already been loaded prior to this shared library - shared libraries are located at "random" addresses in memory to avoid collisions, but sometimes you get collisions anyways, and the OS will then pick a different (free) random address. You''d probably find the same thing if you have two different machines with slightly different configurations and perhaps different daemons running (xend for example will drag in a whole heap of shared libraries, both those belonging to the python language and those built by xen). -- Mats> > Can somebody help me reason out why this is happening in > guest vm? Is this because of some boot option or anything > specific to xen? > > Thank you > Arun > > -- > http://www4.ncsu.edu/~abnagara <http://www4.ncsu.edu/~abnagara> >_______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Arun Babu
2007-Feb-27 22:03 UTC
Re: [Xen-users] Why are shared libraries loaded multiple times in a guest VM?
On 2/27/07, Petersson, Mats <Mats.Petersson@amd.com> wrote:> > > > > -----Original Message----- > > From: xen-users-bounces@lists.xensource.com > > [mailto:xen-users-bounces@lists.xensource.com] On Behalf Of Arun Babu > > Sent: 27 February 2007 18:23 > > To: xen-users@lists.xensource.com > > Subject: [Xen-users] Why are shared libraries loaded multiple > > times in a guest VM? > > > > Hi, > > > > I have xen 3.0.2-3 installed with linux 2.6.16.13 guests > > running on them. > > I have a simple test program to print the address of a > > function in a shared library (say printf) using dlopen and > > dlsym. I ran this test on DomO and running another instance > > of the same program (to make sure the library is still > > loaded). Both instances print the same address (as expected). > > But when I do this experiment on a DomU, I get different > > addresses for the same function. Further investigation of > > /proc/<pid>/maps shows that the same shared library is loaded > > in different places on those two machines. Why isn''t the > > different instances of the test program refer the same shared > > library/ why is the library loaded multiple times? > > Do I get it right that your "complaint" is that the same shared library > is loaded at different places in Dom0 and DomU? Since DomU is a > different (albeit virtual) machine, I don''t see what there is to > complain about. In a real system with two different machines, you would > not complain that the shared library is in the memory of both machines, > right? Just because DomU is in the same physical machine as Dom0, it > doesn''t have ANY way to actually even know that Dom0 is in the same > machine (aside from some timing aspects of running a virtual machine) > [para-virtual kernels have been modified to do things slightly > differently].Thanks for your suggestions. But I think you got the issue wrongly. What I am concerned is that how a library, which is already loaded in the memory is reloaded at a different place once again when another instance of the program is started. (Please note that the 1st instance is still running on a busy loop while the second instance is started.) Should''nt the second instance use the shared library which is available in the memory? This is all happening within a guest VM. I am not comparing anything with Dom0. (I do understand that we treat virtual machines as different physical ones and they are not sharing pages!) Obviously, if that''s not what you''re complaining about, sorry for> misunderstanding the "complaint"... > > The fact that the same shared library is loaded at a different address > within the virtual address range is probably something to do with what > virtual addresses are available and it may also depend on what other > shared libraries have already been loaded prior to this shared library - > shared libraries are located at "random" addresses in memory to avoid > collisions, but sometimes you get collisions anyways, and the OS will > then pick a different (free) random address. You''d probably find the > same thing if you have two different machines with slightly different > configurations and perhaps different daemons running (xend for example > will drag in a whole heap of shared libraries, both those belonging to > the python language and those built by xen). > > -- > Mats > > > > Can somebody help me reason out why this is happening in > > guest vm? Is this because of some boot option or anything > > specific to xen? > > > > Thank you > > Arun > > > > -- > > http://www4.ncsu.edu/~abnagara <http://www4.ncsu.edu/~abnagara> > > > > >-- "You just have to keep breathing. Because the sun will rise. And you never know what the tide will bring in" -- Chuck Noland :) visit: http://www4.ncsu.edu/~abnagara _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users