[Differential] [Commented On] D1711: Changes to the callout code to restore active semantics and also add a test-framework and test to validate thecallout code (and potentially for use by other tests).

hselasky (Hans Petter Selasky) phabric-noreply at FreeBSD.org
Tue Feb 17 20:05:36 UTC 2015


hselasky added a comment.

randall: Let me try to explain a bit slower:

Assume that a callout has been cancelled and is now migrating to another CPU. c->c_cpu = CPUBLOCK.

Upon calling _callout_stop_safe() we will enter the callout_lock() function which will wait for the condition "c->c_cpu == CPUBLOCK" to disappear.

Thread 1:
mtx_lock(xxx);
  _callout_stop_safe(struct callout *c, int safe)
     callout_lock();
       while(c->c_cpu == CPUBLOCK)
            ;
mtx_unlock(xxx);

Thread 2:
   softclock_call_cc()
       if (c_lock != NULL)
           class->lc_lock(xxx);   /* stuck forever */


  In softclock_call_cc() c->c_cpu is only updated _after_ that class->lc_lock() has been locked / unlocked. Especially this is critical if the callback function locks and unlocks the "xxx" lock multiple times.

Do you get it? Or do you want me to explain more. Sorry I am not so good communicating with you.

--HPS

REVISION DETAIL
  https://reviews.freebsd.org/D1711

To: rrs, gnn, rwatson, lstewart, jhb, kostikbel, sbruno, imp, adrian, hselasky
Cc: julian, hiren, jhb, kostikbel, emaste, delphij, neel, erj, freebsd-net


More information about the freebsd-net mailing list