Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 May 2012 17:37:54 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Xin LI <delphij@gmail.com>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Xin LI <delphij@freebsd.org>
Subject:   Re: svn commit: r235301 - head/sys/kern
Message-ID:  <20120512172928.U926@besplex.bde.org>
In-Reply-To: <CAGMYy3twRfACSF9rMCwjJOwUBuT_j9N1VLtTeJ5xNO6xhnd2PA@mail.gmail.com>
References:  <201205112343.q4BNhWh7005829@svn.freebsd.org> <CAGMYy3twRfACSF9rMCwjJOwUBuT_j9N1VLtTeJ5xNO6xhnd2PA@mail.gmail.com>

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

On Fri, 11 May 2012, Xin LI wrote:

>> Log:
>>  Revert previous revision, misunderstood the code :(
>>
>> Modified:
>>  head/sys/kern/kern_kthread.c
>>
>> Modified: head/sys/kern/kern_kthread.c
>> ==============================================================================
>> --- head/sys/kern/kern_kthread.c        Fri May 11 23:41:52 2012        (r235300)
>> +++ head/sys/kern/kern_kthread.c        Fri May 11 23:43:32 2012        (r235301)
>> @@ -182,7 +182,6 @@ kproc_suspend(struct proc *p, int timo)
>>                return (EINVAL);
>>        }
>>        SIGADDSET(p->p_siglist, SIGSTOP);
>> -       PROC_UNLOCK(p);
>>        wakeup(p);
>>        return msleep(&p->p_siglist, &p->p_mtx, PPAUSE | PDROP, "suspkp", timo);

Please don't use mailer clients that corrupt whitespace to binary characters.
The above is unreadable in vi (but i remember it from the original).

> For the record, p->p_mtx is the mutex used by PROC_[UN]LOCK(), which
> has to be held while calling msleep().

Even if it weren't, dropping the lock before sleeping would give a classic
race.

Otherwise, PROC_UNLOCK() is a good obfuscation.  p_mtx in the sleep call
isn't similarly obfuscated.  Some subsystems have a macro that obfuscates
the name of their lock(s) too, but proc.h doesn't.  kern/*.c has 23
hard-coded references of the form &somep->p_mtx.

Bruce

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