Re: Stop using PUSER in tsleep(9)

2019-07-09 Thread Martin Pieuchot
On 09/07/19(Tue) 14:29, Alexandre Ratchov wrote:
> [...] 
> Why do you want to differenciate sleeping priorities from running
> priorities?

To be able to simplify the scheduler logic.  Sleeping priorities are
something we could question.  But by doing this separation it makes
it simpler to get rid of/refactor the multiple places that do:

if (p->p_priority >= PUSER)
...

You can look at my big scheduler change if you want to see the details.

I'm currently splitting it in reviewable pieces x)



Re: Stop using PUSER in tsleep(9)

2019-07-09 Thread Alexandre Ratchov
On Mon, Jul 08, 2019 at 06:43:34PM -0300, Martin Pieuchot wrote:
> PUSER has been used since the import of ___thrsleep(2) / librthread.
> This value has been then copied to futex(2).  No other tsleep(9) call
> use this value.  I'd like to stop using it to be able to differentiate
> sleeping priorities that will be always < PUSER, to running priorities.
> The only running priorities that could be < PUSER are the one of niced
> programs like sndiod(9).
> 
> Ok?

Seems correct. Use of PWAIT shouldn't hurt interactive programs which
use PSOCK (or better).

Why do you want to differenciate sleeping priorities from running
priorities?



Stop using PUSER in tsleep(9)

2019-07-08 Thread Martin Pieuchot
PUSER has been used since the import of ___thrsleep(2) / librthread.
This value has been then copied to futex(2).  No other tsleep(9) call
use this value.  I'd like to stop using it to be able to differentiate
sleeping priorities that will be always < PUSER, to running priorities.
The only running priorities that could be < PUSER are the one of niced
programs like sndiod(9).

Ok?

Index: kern/kern_sig.c
===
RCS file: /cvs/src/sys/kern/kern_sig.c,v
retrieving revision 1.231
diff -u -p -r1.231 kern_sig.c
--- kern/kern_sig.c 21 Jun 2019 09:39:48 -  1.231
+++ kern/kern_sig.c 21 Jun 2019 20:15:12 -
@@ -2049,7 +2049,7 @@ single_thread_wait(struct process *pr)
 {
/* wait until they're all suspended */
while (pr->ps_singlecount > 0)
-   tsleep(>ps_singlecount, PUSER, "suspend", 0);
+   tsleep(>ps_singlecount, PWAIT, "suspend", 0);
 }
 
 void
Index: kern/kern_synch.c
===
RCS file: /cvs/src/sys/kern/kern_synch.c,v
retrieving revision 1.150
diff -u -p -r1.150 kern_synch.c
--- kern/kern_synch.c   3 Jul 2019 22:39:33 -   1.150
+++ kern/kern_synch.c   8 Jul 2019 16:36:40 -
@@ -644,7 +644,7 @@ thrsleep(struct proc *p, struct sys___th
void *sleepaddr = >p_thrslpid;
if (ident == -1)
sleepaddr = 
-   error = tsleep(sleepaddr, PUSER | PCATCH, "thrsleep",
+   error = tsleep(sleepaddr, PWAIT|PCATCH, "thrsleep",
(int)to_ticks);
}
 
Index: kern/sys_futex.c
===
RCS file: /cvs/src/sys/kern/sys_futex.c,v
retrieving revision 1.12
diff -u -p -r1.12 sys_futex.c
--- kern/sys_futex.c6 Feb 2019 15:11:20 -   1.12
+++ kern/sys_futex.c21 Jun 2019 20:15:57 -
@@ -254,7 +254,7 @@ futex_wait(uint32_t *uaddr, uint32_t val
TAILQ_INSERT_TAIL(>ft_threads, p, p_fut_link);
p->p_futex = f;
 
-   error = rwsleep(p, , PUSER|PCATCH, "fsleep", (int)to_ticks);
+   error = rwsleep(p, , PWAIT|PCATCH, "fsleep", (int)to_ticks);
if (error == ERESTART)
error = ECANCELED;
else if (error == EWOULDBLOCK) {