From owner-svn-src-all@FreeBSD.ORG Thu May 3 21:28:42 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E2C3E106564A; Thu, 3 May 2012 21:28:42 +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 7C08C8FC08; Thu, 3 May 2012 21:28:42 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q43LSZLq089113; Fri, 4 May 2012 00:28:35 +0300 (EEST) (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.5/8.14.5) with ESMTP id q43LSYuf042297; Fri, 4 May 2012 00:28:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q43LSY9r042296; Fri, 4 May 2012 00:28:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 4 May 2012 00:28:34 +0300 From: Konstantin Belousov To: Attilio Rao Message-ID: <20120503212834.GP2358@deviant.kiev.zoral.com.ua> References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> <20120503132715.GN2358@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="dKRZzP6oNMY5EfTG" Content-Disposition: inline In-Reply-To: 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=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, christian.esken@trivago.com Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:28:43 -0000 --dKRZzP6oNMY5EfTG Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 03, 2012 at 10:06:53PM +0100, Attilio Rao wrote: > 2012/5/3 Konstantin Belousov : > > On Thu, May 03, 2012 at 02:14:20PM +0100, Attilio Rao wrote: > >> 2012/5/3, Konstantin Belousov : > >> > On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote: > >> >> 2012/5/3, Konstantin Belousov : > >> >> > Author: kib > >> >> > Date: Thu May =9A3 10:38:02 2012 > >> >> > New Revision: 234952 > >> >> > URL: http://svn.freebsd.org/changeset/base/234952 > >> >> > > >> >> > Log: > >> >> > =9A When callout_reset_on() cannot immediately migrate a callout = since it > >> >> > =9A is running on other cpu, the CALLOUT_PENDING flag is temporar= ily > >> >> > =9A cleared. Then, callout_stop() on this, in fact active, callou= t fails > >> >> > =9A because CALLOUT_PENDING is not set, and callout_stop() return= s 0. > >> >> > > >> >> > =9A Now, in sleepq_check_timeout(), the failed callout_stop() cau= ses the > >> >> > =9A sleepq code to execute mi_switch() without even setting the w= mesg, > >> >> > =9A since the switch-out is supposed to be transient. In fact, th= e thread > >> >> > =9A is put off the CPU for full timeout interval, instead of bein= g put on > >> >> > =9A runq immediately. =9AUntil timeout fires, the process is unki= llable for > >> >> > =9A obvious reasons. > >> >> > > >> >> > =9A Fix this by marking the migrating callouts with CALLOUT_DFRMI= GRATION > >> >> > =9A flag. The flag is cleared by callout_stop_safe() when the fun= ction > >> >> > =9A detects a migration, besides returning the success. The softc= lock() > >> >> > =9A rechecks the flag for migrating callout and cancels its execu= tion if > >> >> > =9A the flag was cleared meantime. > >> >> > >> >> Can you please clarify why you cannot simply drop the deferred > >> >> migration in the case !CALLOUT_PENDING in callout_stop_safe()? > >> > > >> > I probably can, I think I went with the route of committed patch > >> > because it is slightly less work. Also, the comment in the while() > >> > loop suggested me to rely on softclock. > >> > >> I don't think this is more work at all, the attached patch > >> (pre-r234952, untested) should address it properly in few than 10 > >> lines: > >> http://www.freebsd.org/~attilio/callout_cancel_mig_stop.patch > >> > >> without the need to add further flags and re-using existing mechanisms. > > > > (cc->cc_curr !=3D c) is not the case which caused the issue. It might be > > needed to treatened this way, but the reported case is opposite. >=20 > Yes, of course, because the migration handover happens in the same > critical context of cc->cc_curr =3D=3D c, but now I wonder if this fix is > really right. >=20 > It seems to me that in the case you describe callout_stop() must > return 0 and the migration must not be cancelled because the callout > is not stopped. It is not stopped not because of the deferred > migration but because cc->cc_curr =3D=3D c. It seems a perfectly valid > situation to me. Yes, and my patch makes the callout to be indeed stopped right after migration is finished. Did you looked at the patch itself ? What is the valid situation ? callout_stop returning 0 but not stopping a pending callout ? I have to disagree. >=20 > Probabilly the bug is in the sleepq use of this mechanism? And, what the bug is, then ? --dKRZzP6oNMY5EfTG Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk+i+IIACgkQC3+MBN1Mb4g8gACdFRb4hFMRIYccDzPtofqjJk2F oFIAoKunxB+SHTkWgKRHleB37GPxYgE0 =iAP5 -----END PGP SIGNATURE----- --dKRZzP6oNMY5EfTG--