Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 May 2012 00:28:34 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Attilio Rao <attilio@freebsd.org>
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
Message-ID:  <20120503212834.GP2358@deviant.kiev.zoral.com.ua>
In-Reply-To: <CAJ-FndAhRPyMsFwCEh0w6=VmRy4faL4L0rC4kG4de8rNkX-DQw@mail.gmail.com>
References:  <201205031038.q43Ac2eZ032779@svn.freebsd.org> <CAJ-FndBF7%2BfLwivrMdH=rMHsEVQ5jojk3noceN8wxmaj2ZaTvg@mail.gmail.com> <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> <CAJ-FndCa8xBmKJNnm6kfVpAyCtWtJmoti75XvCBiOR7ppREqng@mail.gmail.com> <20120503132715.GN2358@deviant.kiev.zoral.com.ua> <CAJ-FndAhRPyMsFwCEh0w6=VmRy4faL4L0rC4kG4de8rNkX-DQw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On Thu, May 03, 2012 at 10:06:53PM +0100, Attilio Rao wrote:
> 2012/5/3 Konstantin Belousov <kostikbel@gmail.com>:
> > On Thu, May 03, 2012 at 02:14:20PM +0100, Attilio Rao wrote:
> >> 2012/5/3, Konstantin Belousov <kostikbel@gmail.com>:
> >> > On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote:
> >> >> 2012/5/3, Konstantin Belousov <kib@freebsd.org>:
> >> >> > Author: kib
> >> >> > Date: Thu May š3 10:38:02 2012
> >> >> > New Revision: 234952
> >> >> > URL: http://svn.freebsd.org/changeset/base/234952
> >> >> >
> >> >> > Log:
> >> >> > š When callout_reset_on() cannot immediately migrate a callout since it
> >> >> > š is running on other cpu, the CALLOUT_PENDING flag is temporarily
> >> >> > š cleared. Then, callout_stop() on this, in fact active, callout fails
> >> >> > š because CALLOUT_PENDING is not set, and callout_stop() returns 0.
> >> >> >
> >> >> > š Now, in sleepq_check_timeout(), the failed callout_stop() causes the
> >> >> > š sleepq code to execute mi_switch() without even setting the wmesg,
> >> >> > š since the switch-out is supposed to be transient. In fact, the thread
> >> >> > š is put off the CPU for full timeout interval, instead of being put on
> >> >> > š runq immediately. šUntil timeout fires, the process is unkillable for
> >> >> > š obvious reasons.
> >> >> >
> >> >> > š Fix this by marking the migrating callouts with CALLOUT_DFRMIGRATION
> >> >> > š flag. The flag is cleared by callout_stop_safe() when the function
> >> >> > š detects a migration, besides returning the success. The softclock()
> >> >> > š rechecks the flag for migrating callout and cancels its execution if
> >> >> > š 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 != c) is not the case which caused the issue. It might be
> > needed to treatened this way, but the reported case is opposite.
> 
> Yes, of course, because the migration handover happens in the same
> critical context of cc->cc_curr == c, but now I wonder if this fix is
> really right.
> 
> 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 == 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.

> 
> Probabilly the bug is in the sleepq use of this mechanism?
And, what the bug is, then ?

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (FreeBSD)

iEYEARECAAYFAk+i+IIACgkQC3+MBN1Mb4g8gACdFRb4hFMRIYccDzPtofqjJk2F
oFIAoKunxB+SHTkWgKRHleB37GPxYgE0
=iAP5
-----END PGP SIGNATURE-----

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120503212834.GP2358>