Unix Technical Forum

rfork() strangeness in v3.6

This is a discussion on rfork() strangeness in v3.6 within the mailing.openbsd.tech forums, part of the OpenBSD category; --> Hi, I've been poking around the kernel sources, and got stuck trying to write some test programs for sharing ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-18-2008, 07:44 AM
Jason W. Kim
 
Posts: n/a
Default rfork() strangeness in v3.6

Hi, I've been poking around the kernel sources, and got stuck trying to
write some test programs for sharing data across processes (beyond SYSV
SHM which works great) via rfork() and minherit().

I've also looked at Charles Cranor's dissertation regarding UVM, and he
doesn't mention any specifics about how rfork() should be implemented,
but the following code snippets look a little wierd to me.

near uvm_glue.c:262
--

if (shared == TRUE) {
p2->p_vmspace = NULL;
uvmspace_share(p1, p2); /* share vmspace */
} else
....

near uvm_map.c:3175
---
/*
* uvmspace_share: share a vmspace between two proceses
*
* - XXX: no locking on vmspace
* - used for vfork, threads(?)
*/

void
uvmspace_share(p1, p2)
struct proc *p1, *p2;
{
p2->p_vmspace = p1->p_vmspace;
p1->p_vmspace->vm_refcnt++;
}

From what I can gather via rfork() man pages, the code snippet for
uvmspace_share() seems a bit spare to me -

Furthermore, the regression code that use rfork() with the RFMEM flag
all seem to crash (dmesg attached)

For example:

--
[root@base:i386-OpenBSD3:/usr/src/regress/sys/kern/rfork/rfmem-stack]#
../rfmem-stack
rfmem-stack: child error: Undefined error: 0
rfmem-stack: : Undefined error: 0
zsh: segmentation fault (core dumped) ./rfmem-stack
--


So my question regarding rfork()/RFMEM what is the preferred use of the
calls? From what I can gather from previous posts here, (for example,
take a look at this snippet of strangeness -)

---
> Subject: Re: We need a clone() or rfork().
> To: Todd Vierling <tv@pobox.com>
> From: Jason Thorpe <thorpej@nas.nasa.gov>
> List: tech-kern
> Date: 04/15/1999 11:59:14


> On Thu, 15 Apr 1999 13:07:22 -0400 (EDT)
> Todd Vierling <tv@pobox.com> wrote:


> > I remember Jason Thorpe speaking a while back about having the VM

> mechanisms
> > available to do an implementation of clone() or rfork() (not

> necessarily
> > threading, but `splitting a process').

>
> Can you tell me precisely what Wine needs? I.e. what clone()/rfork()
> flags does it use?
>
> Note, the OpenBSD rfork() doesn't actually share the address space,
> but
> rather uses sharing maps ... sharing maps don't exist in UVM. Also,

^^^^^^^^^^ ^^^^^

I don't know what to make of this (!)

> the original rfork() API specifies that RFMEM _does not actually share
> the address space_, but only shares text/data (i.e. stack, heap, etc.
> are apparently NOT shared). So, calling the new call rfork() seems
> rather lame, to me.



So was rfork() and uvmspace_share() just not completed? or is there some
secret magic sauce that I am missing? According to the docs for
minherit() and rfork(), minherit() followed by an rfork(RFMEM|..) SHOULD
result in a child process sharing data pages with the parent - but as
yet, I can't see how this is to be accomplished, given the existing
kernel/uvm code in v3.6.

Plus, the rfork(RFMEM) regression tests seem to crash on a vanilla
kernel running under VMWARE (dmesg attached).

Thanks all,
-Jason Kim
OpenBSD 3.6 (sys) #0: Wed Nov 17 06:43:45 EST 2004
jkim@base.cs.drexel.edu:/home/jkim/sys
cpu0: Intel(R) Pentium(R) 4 CPU 2.80GHz ("GenuineIntel" 686-class) 2.80 GHz
cpu0: FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MC A,CMOV,PAT,PSE36,CFLUSH,ACPI,MMX,FXSR,SSE,SSE2,SS, HTT,TM,SBF,CNXT-ID
real mem = 268017664 (261736K)
avail mem = 237678592 (232108K)
using 3297 buffers containing 13504512 bytes (13188K) of memory
mainbus0 (root)
bios0 at mainbus0: AT/286+(aa) BIOS, date 02/15/02, BIOS32 rev. 0 @ 0xfd860
apm0 at bios0: Power Management spec V1.2
apm0: AC on, battery charge unknown
pcibios0 at bios0: rev 2.1 @ 0xfd860/0x7a0
pcibios0: PCI IRQ Routing Table rev 1.0 @ 0xfdf30/176 (9 entries)
pcibios0: PCI Interrupt Router at 000:07:0 ("Intel 82371FB ISA" rev 0x00)
pcibios0: PCI bus #0 is the last bus
bios0: ROM list: 0xc0000/0x6000! 0xdc000/0x4000!
cpu0 at mainbus0
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 "Intel 82443BX" rev 0x01
pcib0 at pci0 dev 7 function 0 "Intel 82371AB PIIX4 ISA" rev 0x08
pciide0 at pci0 dev 7 function 1 "Intel 82371AB IDE" rev 0x01: DMA, channel 0 configured to compatibility, channel 1 configured to compatibility
wd0 at pciide0 channel 0 drive 0: <VMware Virtual IDE Hard Drive>
wd0: 64-sector PIO, LBA, 4000MB, 8192205 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
atapiscsi0 at pciide0 channel 1 drive 0
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0: <NECVMWar, VMware IDE CDR10, 1.00> SCSI0 5/cdrom removable
cd0(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 2
uhci0 at pci0 dev 7 function 2 "Intel 82371AB USB" rev 0x00: irq 9
usb0 at uhci0: USB revision 1.0
uhub0 at usb0
uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
"Intel 82371AB Power Mgmt" rev 0x08 at pci0 dev 7 function 3 not configured
vga1 at pci0 dev 15 function 0 "VMware Virtual SVGA II" rev 0x00
wsdisplay0 at vga1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
le1 at pci0 dev 16 function 0 "AMD 79c970 PCnet-PCI" rev 0x10: irq 9
le1: address 00:50:56:41:03:58
le1: 8 receive buffers, 2 transmit buffers
isa0 at pcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pmsi0 at pckbc0 (aux slot)
pckbc0: using irq 12 for aux slot
wsmouse0 at pmsi0 mux 0
pcppi0 at isa0 port 0x61
midi0 at pcppi0: <PC speaker>
sysbeep0 at pcppi0
npx0 at isa0 port 0xf0/16: using exception 16
pccom0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
pccom1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
pccom2 at isa0 port 0x3e8/8 irq 5: ns16550a, 16 byte fifo
fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
fd0 at fdc0 drive 0: 1.44MB 80 cyl, 2 head, 18 sec
biomask efc5 netmask efc5 ttymask ffc7
pctr: user-level cycle counter enabled
dkcsum: wd0 matched BIOS disk 80
root on wd0a
rootdev=0x0 rrootdev=0x300 rawdev=0x302
WARNING: / was not properly unmounted
syncing disks... done
rebooting...
OpenBSD 3.6 (GENERIC) #59: Fri Sep 17 12:32:57 MDT 2004
deraadt@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: Intel(R) Pentium(R) 4 CPU 2.80GHz ("GenuineIntel" 686-class) 2.80 GHz
cpu0: FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MC A,CMOV,PAT,PSE36,CFLUSH,ACPI,MMX,FXSR,SSE,SSE2,SS, HTT,TM,SBF,CNXT-ID
real mem = 268017664 (261736K)
avail mem = 237674496 (232104K)
using 3297 buffers containing 13504512 bytes (13188K) of memory
mainbus0 (root)
bios0 at mainbus0: AT/286+(aa) BIOS, date 02/15/02, BIOS32 rev. 0 @ 0xfd860
apm0 at bios0: Power Management spec V1.2
apm0: AC on, battery charge unknown
pcibios0 at bios0: rev 2.1 @ 0xfd860/0x7a0
pcibios0: PCI IRQ Routing Table rev 1.0 @ 0xfdf30/176 (9 entries)
pcibios0: PCI Interrupt Router at 000:07:0 ("Intel 82371FB ISA" rev 0x00)
pcibios0: PCI bus #0 is the last bus
bios0: ROM list: 0xc0000/0x6000! 0xdc000/0x4000!
cpu0 at mainbus0
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 "Intel 82443BX" rev 0x01
pcib0 at pci0 dev 7 function 0 "Intel 82371AB PIIX4 ISA" rev 0x08
pciide0 at pci0 dev 7 function 1 "Intel 82371AB IDE" rev 0x01: DMA, channel 0 configured to compatibility, channel 1 configured to compatibility
wd0 at pciide0 channel 0 drive 0: <VMware Virtual IDE Hard Drive>
wd0: 64-sector PIO, LBA, 4000MB, 8192205 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
atapiscsi0 at pciide0 channel 1 drive 0
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0: <NECVMWar, VMware IDE CDR10, 1.00> SCSI0 5/cdrom removable
cd0(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 2
uhci0 at pci0 dev 7 function 2 "Intel 82371AB USB" rev 0x00: irq 9
usb0 at uhci0: USB revision 1.0
uhub0 at usb0
uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
"Intel 82371AB Power Mgmt" rev 0x08 at pci0 dev 7 function 3 not configured
vga1 at pci0 dev 15 function 0 "VMware Virtual SVGA II" rev 0x00
wsdisplay0 at vga1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
le1 at pci0 dev 16 function 0 "AMD 79c970 PCnet-PCI" rev 0x10: irq 9
le1: address 00:50:56:41:03:58
le1: 8 receive buffers, 2 transmit buffers
isa0 at pcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pmsi0 at pckbc0 (aux slot)
pckbc0: using irq 12 for aux slot
wsmouse0 at pmsi0 mux 0
pcppi0 at isa0 port 0x61
midi0 at pcppi0: <PC speaker>
sysbeep0 at pcppi0
npx0 at isa0 port 0xf0/16: using exception 16
pccom0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
pccom1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
pccom2 at isa0 port 0x3e8/8 irq 5: ns16550a, 16 byte fifo
fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
fd0 at fdc0 drive 0: 1.44MB 80 cyl, 2 head, 18 sec
biomask efc5 netmask efc5 ttymask ffc7
pctr: user-level cycle counter enabled
dkcsum: wd0 matched BIOS disk 80
root on wd0a
rootdev=0x0 rrootdev=0x300 rawdev=0x302

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:16 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com