From owner-freebsd-current@FreeBSD.ORG Wed Jan 19 12:24:26 2011 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A9B751065673 for ; Wed, 19 Jan 2011 12:24:26 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id ECAA08FC1E for ; Wed, 19 Jan 2011 12:24:25 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p0JCOIQj084054 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 19 Jan 2011 14:24:18 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p0JCOI4F017496; Wed, 19 Jan 2011 14:24:18 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p0JCOIpE017495; Wed, 19 Jan 2011 14:24:18 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 19 Jan 2011 14:24:18 +0200 From: Kostik Belousov To: Beat G?tzi Message-ID: <20110119122417.GW2518@deviant.kiev.zoral.com.ua> References: <4D35A0BB.3010601@chruetertee.ch> <20110118144611.GP2518@deviant.kiev.zoral.com.ua> <4D35B2F2.1000804@chruetertee.ch> <20110118161355.GR2518@deviant.kiev.zoral.com.ua> <4D35C26E.4070108@chruetertee.ch> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="FcqbpLOAFGOf/VCz" Content-Disposition: inline In-Reply-To: <4D35C26E.4070108@chruetertee.ch> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: current@freebsd.org Subject: Re: Running linux ldconfig on tmpfs results in unkillable process X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Jan 2011 12:24:26 -0000 --FcqbpLOAFGOf/VCz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jan 18, 2011 at 05:40:14PM +0100, Beat G?tzi wrote: > On 18.01.2011 17:13, Kostik Belousov wrote: > > On Tue, Jan 18, 2011 at 04:34:10PM +0100, Beat G?tzi wrote: > >> On 18.01.2011 15:46, Kostik Belousov wrote: > >>> On Tue, Jan 18, 2011 at 03:16:27PM +0100, Beat G?tzi wrote: > >>>> Hi, > >>>> > >>>> I've a tinderbox which uses tmpfs to build ports. Every time I build= a > >>>> port which executes linux ldconfig it results in an unkillable proce= ss > >>>> which uses 100% CPU. The problem is reproduceable without tinderbox: > >>>> > >>>> # uname -a > >>>> FreeBSD daedalus.network.local 9.0-CURRENT FreeBSD 9.0-CURRENT #3 > >>>> r216761: Tue Dec 28 15:32:26 CET 2010 > >>>> root@daedalus.network.local:/usr/obj/usr/src/sys/GENERIC i386 > >>>> # mkdir /compat/test > >>>> # mount -t tmpfs tmpfs /compat/test > >>>> # cp -Rp /compat/linux/* /compat/test/ > >>>> # mount -t linprocfs linprocfs /compat/test/proc > >>>> # /compat/linux/sbin/ldconfig -r /compat/test/ > >>>> # pgrep ldconfig > >>>> 3449 > >>>> # procstat -i 3449 | grep KILL > >>>> 3449 ldconfig KILL --- > >>>> # kill -9 3449 > >>>> # procstat -i 3449 | grep KILL > >>>> 3449 ldconfig KILL P-- > >>>> > >>>> >From top(1): > >>>> PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND > >>>> 3449 root 1 44 0 992K 712K CPU1 1 10:06 100.00% ldco= nfig > >>>> > >>>> When I reboot the machine it hangs after "All buffers synced.". > >>>> > >>>> I've uploaded some additional output of procstat and ktrace here: > >>>> http://people.freebsd.org/~beat/logs/linux-ldconfig-tmpfs.txt > >>>> > >>>> Anyone knows how to fix this? > >>> kdump for the trace of the linux binary is a garbage. You need to > >>> use linux_kdump (from ports). > >>> > >>> I think that your process is looping in the kernel, you can confirm t= his > >>> by dropping in the ddb and doing "bt ". > >> > >> I've uploaded a screenshot from the output of bt in ddb: > >> http://people.freebsd.org/~beat/logs/linux-ldconfig-tmpfs-bt.jpg > >=20 > > Please try this. > >=20 > > diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_fil= e.c > > index 9ff1cf0..44ad193 100644 > > --- a/sys/compat/linux/linux_file.c > > +++ b/sys/compat/linux/linux_file.c > > @@ -369,7 +369,6 @@ getdents_common(struct thread *td, struct linux_get= dents64_args *args, > > lbuf =3D malloc(LINUX_MAXRECLEN, M_TEMP, M_WAITOK | M_ZERO); > > vn_lock(vp, LK_SHARED | LK_RETRY); > > =20 > > -again: > > aiov.iov_base =3D buf; > > aiov.iov_len =3D buflen; > > auio.uio_iov =3D &aiov; > > @@ -506,8 +505,10 @@ again: > > break; > > } > > =20 > > - if (outp =3D=3D (caddr_t)args->dirent) > > - goto again; > > + if (outp =3D=3D (caddr_t)args->dirent) { > > + nbytes =3D resid; > > + goto eof; > > + } > > =20 > > fp->f_offset =3D off; > > if (justone) > > diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c > > index 84a2038..62dd0bf 100644 > > --- a/sys/fs/tmpfs/tmpfs_subr.c > > +++ b/sys/fs/tmpfs/tmpfs_subr.c > > @@ -827,9 +827,10 @@ tmpfs_dir_getdents(struct tmpfs_node *node, struct= uio *uio, off_t *cntp) > > /* Copy the new dirent structure into the output buffer and > > * advance pointers. */ > > error =3D uiomove(&d, d.d_reclen, uio); > > - > > - (*cntp)++; > > - de =3D TAILQ_NEXT(de, td_entries); > > + if (error =3D=3D 0) { > > + (*cntp)++; > > + de =3D TAILQ_NEXT(de, td_entries); > > + } > > } while (error =3D=3D 0 && uio->uio_resid > 0 && de !=3D NULL); > > =20 > > /* Update the offset and cache. */ >=20 > This patch solves the problem. >=20 Thank you, but apparently this is not the end of story. I committed the linuxolator part of change, but I think that tmpfs change is uncomplete yet. Strictly following getdirentries(2), tmpfs must return EINVAL in the case when no single record can be returned. Currently, it indicates EOF instead. I think this could be a complete solution, but it might break e.g. Linux ldconfig(8) since it exposed the linuxolator situation. Can you apply the patch below over the latest HEAD with r217578 included and retest ? Thanks. diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index 84a2038..62dd0bf 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -827,9 +827,10 @@ tmpfs_dir_getdents(struct tmpfs_node *node, struct uio= *uio, off_t *cntp) /* Copy the new dirent structure into the output buffer and * advance pointers. */ error =3D uiomove(&d, d.d_reclen, uio); - - (*cntp)++; - de =3D TAILQ_NEXT(de, td_entries); + if (error =3D=3D 0) { + (*cntp)++; + de =3D TAILQ_NEXT(de, td_entries); + } } while (error =3D=3D 0 && uio->uio_resid > 0 && de !=3D NULL); =20 /* Update the offset and cache. */ diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 059a790..a57c1f2 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -1349,7 +1349,7 @@ outok: MPASS(error >=3D -1); =20 if (error =3D=3D -1) - error =3D 0; + error =3D (cnt !=3D 0) ? 0 : EINVAL; =20 if (eofflag !=3D NULL) *eofflag =3D --FcqbpLOAFGOf/VCz Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk021/EACgkQC3+MBN1Mb4juAwCg3x9K2x2aJk5J4QAApFG/fob8 J9YAoIaBmqUSyjfFbOwhnU1O9jifsets =6Xhf -----END PGP SIGNATURE----- --FcqbpLOAFGOf/VCz--