Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Sep 2015 18:43:17 +0200
From:      Julien Charbon <jch@freebsd.org>
To:        Hans Petter Selasky <hps@selasky.org>, Davide Italiano <davide@freebsd.org>, George Neville-Neil <gnn@FreeBSD.org>
Cc:        "src-committers@freebsd.org" <src-committers@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, rss@freebsd.org, Gleb Smirnoff <glebius@freebsd.org>, "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, Warner Losh <imp@bsdimp.com>, Randall Stewart <rrs@netflix.com>
Subject:   Re: svn commit: r287780 - in head: share/man/man9 sys/kern sys/sys
Message-ID:  <56018525.8050601@freebsd.org>
In-Reply-To: <55FD22E9.2040508@selasky.org>
References:  <201509141052.t8EAqRWf008293@repo.freebsd.org> <20150916220559.GS1023@FreeBSD.org> <55FA69BD.10507@selasky.org> <CACYV=-EaGiUkjnoAH%2BJLgyqBWYx7Mw=r-ADEwfr0MQ8VsT7iJw@mail.gmail.com> <55FD22E9.2040508@selasky.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--sOHNcRUpvmhivD5NJfEUv3QNSDx20px3r
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable


 Hi guys,

On 19/09/15 10:55, Hans Petter Selasky wrote:
> On 09/18/15 22:33, Davide Italiano wrote:
>> On Thu, Sep 17, 2015 at 12:20 AM, Hans Petter Selasky=20
>> <hps@selasky.org> wrote:
>>> On 09/17/15 00:05, Gleb Smirnoff wrote:
>> [...] 2) Your commit message didn't explain what (if any) is the
>> use case
> for this.
>=20
> It currently has one critical client, and that is destruction of
> TCP connections.
>=20
> The last 6 months there has been terribly much discussion, bugs
> and panics in the callout area, and there seems no end with recent
> panics posted to -current. Even the updates which rss & more did
> slipped in new bugs.
>=20
> I'm going to let Julien finish his work first. If he doesn't need
> the KPI it will be removed. Else I want that it stays in. [...]

 It is too much pressure on my shoulders, I am a callout rookie after
all.  :)  Let me continue this discussion at a technical level:


 o Short answers:

 - Is callout_drain_async() currently required for TCP timers callout:  N=
o

 - Are we using the same logic than callout_drain_async() in current
TCP timers code:  Yes

 - Would callout_drain_async() make TCP timer code cleaner:  Yes

 - Is callout(9) with an associated mutex hard to use:  No

 - Is callout(9) without an associated mutex (mpsafe callout) hard to
use:  Yes


 o My callout (rookie) solutions:

 - Short-term:  At least, improve man callout(9) page for mpsafe
callout usage.  I am working on it.

 - Mid-term:  Improve current mpsafe callout KPI.  hps is working on it.

 - Long-term I:  Deprecate mpsafe callout usage.  On TCP stack side it
would require to remove INP_INFO lock, this is achievable as soon as
we have RCU-ish locks in kernel.  gnn is working on getting RCU-ish
lock.  (@gnn you might feel a gentle backpressure here :)

 - Long-term II:  Come with a new callout-ish KPI only for that brings
more guarantee in mpsafe callout cases and use it (Lot of work!).


 o Long answers:

 - Is callout_drain_async() KPI required for TCP timers:  No
 - Are we using the same logic than callout_drain_async() in current
TCP timers code:  Yes

 All TCP timers race conditions (so far) have been fixed in two commits:

https://svnweb.freebsd.org/base?view=3Drevision&revision=3D281599
https://svnweb.freebsd.org/base?view=3Drevision&revision=3D284245

 This logic is used currently in release/10.2.0, stable/10 and HEAD
with no issues (so far).  And it is the same logic than
callout_drain_async().

 - Would it make the TCP time code cleaner: Yes

 Below code with mpsafe callout is wrong:

  if (callout_stop(c)) {

    /* Free resources used in callout callback */
    free_res(); <- Kernel panic here
  } else {

    /* Defer free resources used in callout callback */
    defer_free_res();
  }

  Below code with mpsafe callout is right, but tricky as in general
callout_reset() and callout_stop() calls are far away (current TCP
timers code login):

  r =3D callout_reset(c);
  ...
  s =3D callout_stop(c);
  if (r && s) {

    /* Free resources used in callout callback */
    free_res();
  } else {

    /* Defer free resources used in callout callback */
    defer_free_res();
  }

 Below code with mpsafe callout is right, and less tricky:

 if (callout_stop_async(c, defer_free_res)) {

   /* Free resources used in callout callback */
   free_res();
 }

 Sorry for this too long answer.

--
Julien


--sOHNcRUpvmhivD5NJfEUv3QNSDx20px3r
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - https://gpgtools.org

iQEcBAEBCgAGBQJWAYUvAAoJEKVlQ5Je6dhxxZQIAJ3txCnzUdOBT0mjT0E9X8ft
9cSTXkNbPjmFUySl66mi6FFo98KzSpmCxJ3kp4e70dXmn1uyeyfH52VrpttHzU9z
DUeqhj3EiHuWJiOH05uwMZhS/v37CZFdlILFZViOh8gfX/U6xEUhgfpGkruPfnMi
pYXiiCe0Oha0QdpfiYPm9JclWeF5sPWrTxMs3zvUWJ3HHjQ46vk9/oInlemVCWmk
MggvmO0KZdZJGqGwAhYuVuyJSmWl8m5EFyAuuyP5eJFyh3GVKm+INl934pbITE/5
fcaaShDAO3XGrrocl5IhGlLq7v8t9JmMtVyUzlp2DmdnrulW8GgxSY/uXKD8Pr4=
=7fRS
-----END PGP SIGNATURE-----

--sOHNcRUpvmhivD5NJfEUv3QNSDx20px3r--



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