Date: Fri, 22 May 2009 11:20:31 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: Attilio Rao <attilio@freebsd.org> Cc: Scott Long <scottl@samsco.org>, src-committers@freebsd.org, John Baldwin <jhb@freebsd.org>, svn-src-all@freebsd.org, rwatson@freebsd.org, svn-src-head@freebsd.org, "M. Warner Losh" <imp@bsdimp.com> Subject: Re: svn commit: r192535 - head/sys/kern Message-ID: <20090522082031.GY1927@deviant.kiev.zoral.com.ua> In-Reply-To: <3bbf2fe10905211511g53defb6cmac45fc2469cc64f@mail.gmail.com> References: <3bbf2fe10905210629p46c7a204v6863aaba77354462@mail.gmail.com> <20090521.094100.70797067.imp@bsdimp.com> <4A157919.7040103@samsco.org> <200905211211.00168.jhb@freebsd.org> <20090521161535.GQ1927@deviant.kiev.zoral.com.ua> <4A157FF3.8020408@samsco.org> <20090521163846.GT1927@deviant.kiev.zoral.com.ua> <3bbf2fe10905211005m350dc4d1yed6dc1b79f1603d9@mail.gmail.com> <20090521194243.GW1927@deviant.kiev.zoral.com.ua> <3bbf2fe10905211511g53defb6cmac45fc2469cc64f@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--t98UOKzcpBZ5uth4 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 22, 2009 at 12:11:02AM +0200, Attilio Rao wrote: > 2009/5/21 Kostik Belousov <kostikbel@gmail.com>: > > On Thu, May 21, 2009 at 07:05:17PM +0200, Attilio Rao wrote: > >> 2009/5/21 Kostik Belousov <kostikbel@gmail.com>: > >> > On Thu, May 21, 2009 at 09:23:15AM -0700, Scott Long wrote: > >> >> Kostik Belousov wrote: > >> >> >We do have the KPI for the callers that cannot drop the locks and = need > >> >> >to do destroy_dev, destroy_dev_sched(9). > >> >> > >> >> Good to know, I'll look at destroy_dev_sched(). =9AI'd rather not h= ave to > >> >> roll my own decoupled version. =9AAnd I understand the argument abo= ut > >> >> destroy_dev being a drain point for the API. =9AHowever, what about > >> >> create_dev()? =9AMaking that non-blocking would help a lot. > >> > > >> > create_dev() can be made non-blocking, and this is the first argumen= t pro > >> > Attilio patch. > >> > > >> > From the quick look, all that is needed is to replace M_WAITOK with > >> > M_NOWAIT inside prep_cdevsw() and devfs_alloc(). Untested patch belo= w. > >> > > >> > diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c > >> > index 4041911..f470ee8 100644 > >> > --- a/sys/fs/devfs/devfs_devs.c > >> > +++ b/sys/fs/devfs/devfs_devs.c > >> > @@ -120,7 +120,7 @@ devfs_alloc(void) > >> > =9A =9A =9A =9Astruct cdev *cdev; > >> > =9A =9A =9A =9Astruct timespec ts; > >> > > >> > - =9A =9A =9A cdp =3D malloc(sizeof *cdp, M_CDEVP, M_USE_RESERVE | M= _ZERO | M_WAITOK); > >> > + =9A =9A =9A cdp =3D malloc(sizeof *cdp, M_CDEVP, M_USE_RESERVE | M= _ZERO | M_NOWAIT); > >> > > >> > =9A =9A =9A =9Acdp->cdp_dirents =3D &cdp->cdp_dirent0; > >> > =9A =9A =9A =9Acdp->cdp_dirent0 =3D NULL; > >> > diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c > >> > index 284f482..acdd44a 100644 > >> > --- a/sys/kern/kern_conf.c > >> > +++ b/sys/kern/kern_conf.c > >> > @@ -559,7 +559,7 @@ prep_cdevsw(struct cdevsw *devsw) > >> > =9A =9A =9A =9A =9A =9A =9A =9Areturn; > >> > =9A =9A =9A =9Aif (devsw->d_flags & D_NEEDGIANT) { > >> > =9A =9A =9A =9A =9A =9A =9A =9Adev_unlock(); > >> > - =9A =9A =9A =9A =9A =9A =9A dsw2 =3D malloc(sizeof *dsw2, M_DEVT, = M_WAITOK); > >> > + =9A =9A =9A =9A =9A =9A =9A dsw2 =3D malloc(sizeof *dsw2, M_DEVT, = M_NOWAIT); > >> > =9A =9A =9A =9A =9A =9A =9A =9Adev_lock(); > >> > =9A =9A =9A =9A} else > >> > =9A =9A =9A =9A =9A =9A =9A =9Adsw2 =3D NULL; > >> > >> You need to check return values here if it returns NULL. > >> > >> IMHO, having a non-sleepable version of destroy_dev(), create_dev() > >> and such would be ideal. > >> Ideally, we should resolve all the sleeping point and do the conversio= n. > >> I'm unable to check the code right now. > > > > Sure. Something like this. > > >=20 > At this point I wonder what's the purpose of maintaining the sleeping > version for such functions? They cannot fail, thus behaving in the way that all present consumers of the function expect. --t98UOKzcpBZ5uth4 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkoWYE8ACgkQC3+MBN1Mb4ioaQCfU7KJRTPQ5cKp8BV9aRbGsiPY mi4An0q+muWTo/XGL1/jHbmCDJ4neCvX =+Ly2 -----END PGP SIGNATURE----- --t98UOKzcpBZ5uth4--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090522082031.GY1927>