lkml.org 
[lkml]   [2011]   [Aug]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 04/16] freezer: implement and use kthread_freezable_should_stop()
    On 08/19, Tejun Heo wrote:
    >
    > +bool kthread_freezable_should_stop(bool *was_frozen)
    > +{
    > + bool frozen = false;
    > +
    > + might_sleep();
    > +
    > + if (unlikely(freezing(current)))
    > + frozen = __refrigerator(true);
    > +
    > + if (was_frozen)
    > + *was_frozen = frozen;
    > +
    > + return kthread_should_stop();
    > +}

    Imho, nice interface...

    So, the caller can not miss the kthread_stop() request and freeze.
    And the change in __refrigerator() means that kthread_should_stop()
    acts as thaw_process() (in some sense).

    But. can't __refrigerator() race with thaw_process() in this case?

    > +bool __refrigerator(bool check_kthr_stop)
    > {
    > /* Hmm, should we be allowed to suspend when there are realtime
    > processes around? */
    > @@ -50,7 +51,8 @@ bool __refrigerator(void)
    >
    > for (;;) {
    > set_current_state(TASK_UNINTERRUPTIBLE);
    > - if (!frozen(current))
    > + if (!frozen(current) ||
    > + (check_kthr_stop && kthread_should_stop()))
    > break;

    OK, but then we do

    current->flags &= ~PF_FREEZING;

    since PF_FROZEN wasn't cleared this can race with

    p->flags &= ~PF_FROZEN;

    No?

    Oleg.



    \
     
     \ /
      Last update: 2011-08-21 21:19    [W:0.020 / U:30.228 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site