Date: Fri, 22 Oct 2010 23:03:17 +0200 From: Pawel Jakub Dawidek <pjd@FreeBSD.org> To: Jaakko Heinonen <jh@FreeBSD.org> Cc: Ivan Voras <ivoras@freebsd.org>, freebsd-geom@freebsd.org Subject: Re: Hyperactive g_event thread Message-ID: <20101022210317.GB1742@garage.freebsd.pl> In-Reply-To: <20101022184645.GA1381@a91-153-123-205.elisa-laajakaista.fi> References: <4C4ED619.7050305@FreeBSD.org> <27237.1280241532@critter.freebsd.dk> <AANLkTi=uRPV2T0=t_1s=Jc4PmBtai=__HqhCtYpiDdTQ@mail.gmail.com> <AANLkTikvV4oymBBA%2B_0zbzd_edS8dRfqqJRODE0989%2Bn@mail.gmail.com> <4C4F171C.9010106@FreeBSD.org> <20101021174301.GA1381@a91-153-123-205.elisa-laajakaista.fi> <i9rn51$ec0$1@dough.gmane.org> <20101022184645.GA1381@a91-153-123-205.elisa-laajakaista.fi>
next in thread | previous in thread | raw e-mail | index | archive | help
--2B/JsCI69OhZNC5r Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 22, 2010 at 09:46:46PM +0300, Jaakko Heinonen wrote: > On 2010-10-22, Ivan Voras wrote: > > Isn't this sequence: > >=20 > > - mtx_unlock(&g_eventlock); > > wakeup(&g_wait_event); > > + mtx_unlock(&g_eventlock); > >=20 > > too racy? It is possible, especially if something changes in scheduling > > or the wakeup() implementation, and on single-CPU machines, that the > > woken thread could run and then encounter the lock not yet released, > > leading to more lock waiting. >=20 > As far as I have understood this is the normal way to protect against > losing wakeups, no? You won't lose wakeup even if you unlock first and then call wakeup(), but unlocking first might save you a context switch. To avoid wakeup entirely you could remember if the tailq is empty before inserting new element and call wakeup() only if it was empty. --=20 Pawel Jakub Dawidek http://www.wheelsystems.com pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! --2B/JsCI69OhZNC5r Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAkzB/BUACgkQForvXbEpPzQe8ACgs+v2R/o/yXorY2oUoQqnercV MJ8AoNQLnBX3fhFDJO+8pU4fABsMmnwT =jpxl -----END PGP SIGNATURE----- --2B/JsCI69OhZNC5r--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20101022210317.GB1742>