Re: knlist_empty locking fix
--ed2sj0fx90rgoibw
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Thu, Jan 26, 2012 at 01:03:26PM -0800, Doug Ambrisko wrote:
> Ran into problems with running kqueue/aio with WITNESS etc. Sometimes
> things are locked sometimes not. knlist_remove is called telling it
> whether it is locked or not ie:
> extern void knlist_remove(struct knlist *knl, struct knote *kn, int =
islocked);
> so I changed:
> extern int knlist_empty(struct knlist *knl);
> to:
> extern int knlist_empty(struct knlist *knl, int islocked);
>=20
> and then updated things to reflect that following what that state of the
> lock for knlist_remove. If it is not locked, it gets a lock and=20
> frees it after.
>=20
> This now fixes a panic when a process using kqueue/aio is killed on
> shutdown with WITNESS.
>=20
> It changes an API/ABI so it probably can't merged back. If there are
> no objections then I'll commit it.
>=20
Change to knlist_init() does not make sense at all, the knlist shall
not be exposed to other consumers during initialization, so no need
to exclude the parallel access.
Regarding the knlist_empty(), I propose to keep it as is. Locking
the knlist inside knlist_empty() does not make sense, because lock
is immediately dropped afterward, and relocked for remove. This way,
the entry could be removed from the list meantime (can it, really ?).
I think that you should take a lock around the whole if() {} statement,
and call knlist_remove with locked =3D=3D 1.
--ed2sj0fx90rgoibw
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)
iEYEARECAAYFAk8iZtgACgkQC3+MBN1Mb4i2CgCfWHZPTo8+ZH45enS5lsoeFrMw
1GAAn1J1OhCzi0Q7vNZwgEA9YCTz29TE
=tzJl
-----END PGP SIGNATURE-----
--ed2sj0fx90rgoibw--
討論串 (同標題文章)
完整討論串 (本文為第 2 之 10 篇):