Bug 131506 - [linux] pipes in forked procs sometimes hang under Linux emulation 2.6.16
Summary: [linux] pipes in forked procs sometimes hang under Linux emulation 2.6.16
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-emulation (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-08 16:00 UTC by Arno J. Klaassen
Modified: 2009-02-22 18:20 UTC (History)
0 users

See Also:


Attachments
pwaitfix.diff (1.41 KB, patch)
2009-02-18 12:44 UTC, takahiro.kurosawa
no flags Details | Diff
pwaitfix.diff (1.41 KB, patch)
2009-02-17 15:19 UTC, takahiro.kurosawa
no flags Details | Diff
file.dat (212 bytes, text/plain; charset="us-ascii")
2009-02-17 15:19 UTC, takahiro.kurosawa
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arno J. Klaassen 2009-02-08 16:00:08 UTC

portinstall gentoo-stage3
chroot /usr/local/gentoo-stage3
emerge libIDL

it will hang on the following output :

  libIDL 0.8.11 configuration complete

  C Preprocessor: "i486-pc-linux-gnu-gcc -E"
  Standard input supported.

  bison -y -d -v 2>/dev/null ./parser.y

in a freebsd-shell all implied procs ar in ppwiat or piperd state :

# ps axlww | fgrep 410
    0  4104  1659   0  76  0  2576  1748 ppwait D+     0    0:00.03 make (gmake)
    0  4105  4104   0  76  0  3316  2548 wait   I+     0    0:00.01 /bin/sh -c bison -y -d -v 2>/dev/null ./parser.y (bash)
    0  4106  4105   0  76  0  3044  2008 ppwait D+     0    0:00.03 bison -y -d -v ./parser.y
    0  4107  4106   0  76  0  2432  1532 piperd I+     0    0:00.01 /usr/bin/m4 /usr/share/bison/m4sugar/m4sugar.m4 - /usr/share/bison/yacc.c
    0  4118  1392   0  44  0  6000  2416 -      R+     1    0:00.00 fgrep 410 (bash)


NB, for some specific input-files 'i486-linux-gcc -pipe ' exhibits
the same behaviour but most often works OK

How-To-Repeat: 
portinstall gentoo-stage3
chroot /usr/local/gentoo-stage3
emerge libIDL
Comment 1 Arno J. Klaassen 2009-02-08 16:23:11 UTC
follow-up to myself for completeness :

[root@m37 ~]# fgrep osrele /etc/sysctl.conf 
compat.linux.osrelease=2.6.16
[root@m37 ~]# 

[root@m37 ~]# df                  
Filesystem  1K-blocks     Used    Avail Capacity  Mounted on
/dev/ad4s2a    507630   266394   200626    57%    /
devfs               1        1        0   100%    /dev
/dev/ad4s2e  16725510 10666544  4720926    69%    /usr
/dev/ad4s2d   2026030   161448  1702500     9%    /var
/dev/ad4s3d 131947140 30895828 90495542    25%    /files
procfs              4        4        0   100%    /proc
linprocfs           4        4        0   100%    /usr/compat/linux/proc
linsysfs            4        4        0   100%    /usr/compat/linux/sys
devfs               1        1        0   100%
/usr/local/gentoo-stage3/dev
linprocfs           4        4        0   100%
/usr/local/gentoo-stage3/proc
linsysfs            4        4        0   100%
/usr/local/gentoo-stage3/sys
/dev/md1       507630       20   507610     0%    /var/tmp
[root@m37 ~]#

[root@m37 ~]# ls -d /var/db/pkg/linux*
/var/db/pkg/linux-atk-1.9.1
/var/db/pkg/linux-cairo-1.0.2
/var/db/pkg/linux-expat-1.95.8
/var/db/pkg/linux-fontconfig-2.2.3_7
/var/db/pkg/linux-gtk2-2.6.10
/var/db/pkg/linux-jpeg-6b.34
/var/db/pkg/linux-openmotif-2.2.4_2
/var/db/pkg/linux-pango-1.10.2
/var/db/pkg/linux-png-1.2.8_2
/var/db/pkg/linux-tiff-3.7.1
/var/db/pkg/linux-xorg-libs-6.8.2_5
/var/db/pkg/linux_base-fc6-6_5
/var/db/pkg/linux_dist-gentoo-stage3-2008.0
/var/db/pkg/linux_dri-7.0
/var/db/pkg/linux_kdump-1.5_2
[root@m37 ~]# 


I tried as well with linux_base-f8, same result (though
no repeated after recent tracking of -current)
Comment 2 Gavin Atkinson freebsd_committer freebsd_triage 2009-02-10 13:47:31 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-emulation

Over to maintainer(s).
Comment 3 takahiro.kurosawa 2009-02-17 15:19:56 UTC
It seems that vfork/exec synchronization was changed recently
but the linux emulation code keeps using the obsolete mechanism.

The attached patch may fix the problem.
Comment 4 takahiro.kurosawa 2009-02-18 12:44:13 UTC
(resending to bug-followup@, sorry if duplicate)

It seems that vfork/exec synchronization was changed recently
but the linux emulation code keeps using the obsolete mechanism.

The attached patch may fix the problem.
Comment 5 takahiro.kurosawa 2009-02-18 14:08:05 UTC
2009/2/18 Kostik Belousov <kostikbel@gmail.com>:

> Please, resend the patch without base64-encoding, best as a plain/text
> attachment.

Sure.  Sending the patch inline...
The attachment of my previous mail looks broken to me too.

=== sys/amd64/linux32/linux32_machdep.c
==================================================================
--- sys/amd64/linux32/linux32_machdep.c	(revision 188741)
+++ sys/amd64/linux32/linux32_machdep.c	(local)
@@ -560,7 +560,7 @@
 	/* wait for the children to exit, ie. emulate vfork */
 	PROC_LOCK(p2);
 	while (p2->p_flag & P_PPWAIT)
-	   	msleep(td->td_proc, &p2->p_mtx, PWAIT, "ppwait", 0);
+		cv_wait(&p2->p_pwait, &p2->p_mtx);
 	PROC_UNLOCK(p2);

 	return (0);
@@ -749,7 +749,7 @@
 		/* wait for the children to exit, ie. emulate vfork */
 		PROC_LOCK(p2);
 		while (p2->p_flag & P_PPWAIT)
-			msleep(td->td_proc, &p2->p_mtx, PWAIT, "ppwait", 0);
+			cv_wait(&p2->p_pwait, &p2->p_mtx);
 		PROC_UNLOCK(p2);
 	}

=== sys/i386/linux/linux_machdep.c
==================================================================
--- sys/i386/linux/linux_machdep.c	(revision 188741)
+++ sys/i386/linux/linux_machdep.c	(local)
@@ -376,7 +376,7 @@
 	/* wait for the children to exit, ie. emulate vfork */
 	PROC_LOCK(p2);
 	while (p2->p_flag & P_PPWAIT)
-	   	msleep(td->td_proc, &p2->p_mtx, PWAIT, "ppwait", 0);
+		cv_wait(&p2->p_pwait, &p2->p_mtx);
 	PROC_UNLOCK(p2);

 	return (0);
@@ -581,7 +581,7 @@
    	   	/* wait for the children to exit, ie. emulate vfork */
    	   	PROC_LOCK(p2);
 		while (p2->p_flag & P_PPWAIT)
-   		   	msleep(td->td_proc, &p2->p_mtx, PWAIT, "ppwait", 0);
+			cv_wait(&p2->p_pwait, &p2->p_mtx);
 		PROC_UNLOCK(p2);
 	}
Comment 6 dfilter service freebsd_committer freebsd_triage 2009-02-18 16:11:52 UTC
Author: kib
Date: Wed Feb 18 16:11:39 2009
New Revision: 188750
URL: http://svn.freebsd.org/changeset/base/188750

Log:
  Adapt linux emulation to use cv for vfork wait.
  
  Submitted by:	Takahiro Kurosawa <takahiro.kurosawa gmail com>
  PR:	kern/131506

Modified:
  head/sys/amd64/linux32/linux32_machdep.c
  head/sys/i386/linux/linux_machdep.c

Modified: head/sys/amd64/linux32/linux32_machdep.c
==============================================================================
--- head/sys/amd64/linux32/linux32_machdep.c	Wed Feb 18 10:02:32 2009	(r188749)
+++ head/sys/amd64/linux32/linux32_machdep.c	Wed Feb 18 16:11:39 2009	(r188750)
@@ -560,7 +560,7 @@ linux_vfork(struct thread *td, struct li
 	/* wait for the children to exit, ie. emulate vfork */
 	PROC_LOCK(p2);
 	while (p2->p_flag & P_PPWAIT)
-	   	msleep(td->td_proc, &p2->p_mtx, PWAIT, "ppwait", 0);
+		cv_wait(&p2->p_pwait, &p2->p_mtx);
 	PROC_UNLOCK(p2);
 
 	return (0);
@@ -749,7 +749,7 @@ linux_clone(struct thread *td, struct li
 		/* wait for the children to exit, ie. emulate vfork */
 		PROC_LOCK(p2);
 		while (p2->p_flag & P_PPWAIT)
-			msleep(td->td_proc, &p2->p_mtx, PWAIT, "ppwait", 0);
+			cv_wait(&p2->p_pwait, &p2->p_mtx);
 		PROC_UNLOCK(p2);
 	}
 

Modified: head/sys/i386/linux/linux_machdep.c
==============================================================================
--- head/sys/i386/linux/linux_machdep.c	Wed Feb 18 10:02:32 2009	(r188749)
+++ head/sys/i386/linux/linux_machdep.c	Wed Feb 18 16:11:39 2009	(r188750)
@@ -376,7 +376,7 @@ linux_vfork(struct thread *td, struct li
 	/* wait for the children to exit, ie. emulate vfork */
 	PROC_LOCK(p2);
 	while (p2->p_flag & P_PPWAIT)
-	   	msleep(td->td_proc, &p2->p_mtx, PWAIT, "ppwait", 0);
+		cv_wait(&p2->p_pwait, &p2->p_mtx);
 	PROC_UNLOCK(p2);
 
 	return (0);
@@ -581,7 +581,7 @@ linux_clone(struct thread *td, struct li
    	   	/* wait for the children to exit, ie. emulate vfork */
    	   	PROC_LOCK(p2);
 		while (p2->p_flag & P_PPWAIT)
-   		   	msleep(td->td_proc, &p2->p_mtx, PWAIT, "ppwait", 0);
+			cv_wait(&p2->p_pwait, &p2->p_mtx);
 		PROC_UNLOCK(p2);
 	}
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 7 Konstantin Belousov freebsd_committer freebsd_triage 2009-02-18 16:12:45 UTC
State Changed
From-To: open->closed

Patch committed, thanks.