LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Multiple instances of program sharing same text segment ?
@ 2007-03-20 17:47 Ravinandan Arakali (rarakali)
  2007-03-20 18:12 ` Jeremy Fitzhardinge
  0 siblings, 1 reply; 4+ messages in thread
From: Ravinandan Arakali (rarakali) @ 2007-03-20 17:47 UTC (permalink / raw)
  To: Linux Kernel

Hi,
We have multiple instances of the same executable running on our system.
Do these instances share the text segment or are there multiple copies
of the text segment(one for each process) ? Note that I am not talking
about the shared libraries.
I note that do_exec calls do_mmap to map the executable file to memory.
But not sure what happens(w.r.t text sharing) when another instance of 
the program is invoked. BTW, this is 2.6.10.

Thanks,
Ravi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple instances of program sharing same text segment ?
  2007-03-20 17:47 Multiple instances of program sharing same text segment ? Ravinandan Arakali (rarakali)
@ 2007-03-20 18:12 ` Jeremy Fitzhardinge
  2007-03-20 18:22   ` Ravinandan Arakali (rarakali)
  2007-03-20 19:40   ` Jeffrey Hundstad
  0 siblings, 2 replies; 4+ messages in thread
From: Jeremy Fitzhardinge @ 2007-03-20 18:12 UTC (permalink / raw)
  To: Ravinandan Arakali (rarakali); +Cc: Linux Kernel

Ravinandan Arakali (rarakali) wrote:
> I note that do_exec calls do_mmap to map the executable file to memory.
> But not sure what happens(w.r.t text sharing) when another instance of 
> the program is invoked. BTW, this is 2.6.10.

Yes, they will be shared.  As far as the rest of the kernel is
concerned, an mmap is an mmap is an mmap, and the pages will be shared.

    J

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Multiple instances of program sharing same text segment ?
  2007-03-20 18:12 ` Jeremy Fitzhardinge
@ 2007-03-20 18:22   ` Ravinandan Arakali (rarakali)
  2007-03-20 19:40   ` Jeffrey Hundstad
  1 sibling, 0 replies; 4+ messages in thread
From: Ravinandan Arakali (rarakali) @ 2007-03-20 18:22 UTC (permalink / raw)
  To: Jeremy Fitzhardinge; +Cc: Linux Kernel

Thanks Jeremy.

Ravi 

-----Original Message-----
From: Jeremy Fitzhardinge [mailto:jeremy@goop.org] 
Sent: Tuesday, March 20, 2007 11:12 AM
To: Ravinandan Arakali (rarakali)
Cc: Linux Kernel
Subject: Re: Multiple instances of program sharing same text segment ?

Ravinandan Arakali (rarakali) wrote:
> I note that do_exec calls do_mmap to map the executable file to
memory.
> But not sure what happens(w.r.t text sharing) when another instance of

> the program is invoked. BTW, this is 2.6.10.

Yes, they will be shared.  As far as the rest of the kernel is
concerned, an mmap is an mmap is an mmap, and the pages will be shared.

    J

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple instances of program sharing same text segment ?
  2007-03-20 18:12 ` Jeremy Fitzhardinge
  2007-03-20 18:22   ` Ravinandan Arakali (rarakali)
@ 2007-03-20 19:40   ` Jeffrey Hundstad
  1 sibling, 0 replies; 4+ messages in thread
From: Jeffrey Hundstad @ 2007-03-20 19:40 UTC (permalink / raw)
  To: Jeremy Fitzhardinge; +Cc: Ravinandan Arakali (rarakali), Linux Kernel

Keep in mind that while the text of the program IS SHARED any 
configuration file that is then loaded into ram after the execution IS 
NOT SHARED.

BTW you can find out what is shared and not by taking a look at the proc 
files:

# ps auxwww | grep emacs | grep -v grep # -- find the pids
user       21529  0.2  0.3  16784  7560 pts/11   S+   14:27   0:00 
xemacs -nw
user       21549  0.2  0.3  16784  7548 pts/12   S+   14:27   0:00 
xemacs -nw

# cat /proc/21529/maps |grep xemacs | grep "r-xp" # -- find the mapped 
text executable
08048000-081f5000 r-xp 00000000 08:02 201672393  
/usr/bin/xemacs-21.4.19-nomule

# cat /proc/21549/maps |grep xemacs | grep "r-xp" # -- find the mapped 
text executable
08048000-081f5000 r-xp 00000000 08:02 201672393  
/usr/bin/xemacs-21.4.19-nomule

#ls -li /usr/bin/xemacs-21.4.19-nomule # -- confirm that 201672393 is 
the inode we're looking at.
201672393 -rwxr-xr-x 1 root root 1800764 2006-11-03 11:11 
/usr/bin/xemacs-21.4.19-nomule


Jeremy Fitzhardinge wrote:
> Ravinandan Arakali (rarakali) wrote:
>   
>> I note that do_exec calls do_mmap to map the executable file to memory.
>> But not sure what happens(w.r.t text sharing) when another instance of 
>> the program is invoked. BTW, this is 2.6.10.
>>     
>
> Yes, they will be shared.  As far as the rest of the kernel is
> concerned, an mmap is an mmap is an mmap, and the pages will be shared.
>
>     J
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>   

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-03-20 19:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-20 17:47 Multiple instances of program sharing same text segment ? Ravinandan Arakali (rarakali)
2007-03-20 18:12 ` Jeremy Fitzhardinge
2007-03-20 18:22   ` Ravinandan Arakali (rarakali)
2007-03-20 19:40   ` Jeffrey Hundstad

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).