Print this page
OS-7753 THREAD_KPRI_RELEASE does nothing of the sort
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>


 186         time_t  t_start;                /* start time, seconds since epoch */
 187         clock_t t_lbolt;                /* lbolt at last clock_tick() */
 188         hrtime_t t_stoptime;            /* timestamp at stop() */
 189         uint_t  t_pctcpu;               /* %cpu at last clock_tick(), binary */
 190                                         /* point at right of high-order bit */
 191         short   t_sysnum;               /* system call number */
 192         kcondvar_t      t_delay_cv;
 193         kmutex_t        t_delay_lock;
 194 
 195         /*
 196          * Pointer to the dispatcher lock protecting t_state and state-related
 197          * flags.  This pointer can change during waits on the lock, so
 198          * it should be grabbed only by thread_lock().
 199          */
 200         disp_lock_t     *t_lockp;       /* pointer to the dispatcher lock */
 201         ushort_t        t_oldspl;       /* spl level before dispatcher locked */
 202         volatile char   t_pre_sys;      /* pre-syscall work needed */
 203         lock_t          t_lock_flush;   /* for lock_mutex_flush() impl */
 204         struct _disp    *t_disp_queue;  /* run queue for chosen CPU */
 205         clock_t         t_disp_time;    /* last time this thread was running */
 206         uint_t          t_kpri_req;     /* kernel priority required */
 207 
 208         /*
 209          * Post-syscall / post-trap flags.
 210          *      No lock is required to set these.
 211          *      These must be cleared only by the thread itself.
 212          *
 213          *      t_astflag indicates that some post-trap processing is required,
 214          *              possibly a signal or a preemption.  The thread will not
 215          *              return to user with this set.
 216          *      t_post_sys indicates that some unusualy post-system call
 217          *              handling is required, such as an error or tracing.
 218          *      t_sig_check indicates that some condition in ISSIG() must be
 219          *              checked, but doesn't prevent returning to user.
 220          *      t_post_sys_ast is a way of checking whether any of these three
 221          *              flags are set.
 222          */
 223         union __tu {
 224                 struct __ts {
 225                         volatile char   _t_astflag;     /* AST requested */
 226                         volatile char   _t_sig_check;   /* ISSIG required */


 591 #define thread_unlock_high(t)           disp_lock_exit_high((t)->t_lockp)
 592 #define thread_unlock_nopreempt(t)      disp_lock_exit_nopreempt((t)->t_lockp)
 593 
 594 #define THREAD_LOCK_HELD(t)     (DISP_LOCK_HELD((t)->t_lockp))
 595 
 596 extern disp_lock_t transition_lock;     /* lock protecting transiting threads */
 597 extern disp_lock_t stop_lock;           /* lock protecting stopped threads */
 598 
 599 caddr_t thread_stk_init(caddr_t);       /* init thread stack */
 600 
 601 int thread_setname(kthread_t *, const char *);
 602 int thread_vsetname(kthread_t *, const char *, ...);
 603 
 604 extern int default_binding_mode;
 605 
 606 #endif  /* _KERNEL */
 607 
 608 #define THREAD_NAME_MAX 32      /* includes terminating NUL */
 609 
 610 /*
 611  * Macros to indicate that the thread holds resources that could be critical
 612  * to other kernel threads, so this thread needs to have kernel priority
 613  * if it blocks or is preempted.  Note that this is not necessary if the
 614  * resource is a mutex or a writer lock because of priority inheritance.
 615  *
 616  * The only way one thread may legally manipulate another thread's t_kpri_req
 617  * is to hold the target thread's thread lock while that thread is asleep.
 618  * (The rwlock code does this to implement direct handoff to waiting readers.)
 619  */
 620 #define THREAD_KPRI_REQUEST()   (curthread->t_kpri_req++)
 621 #define THREAD_KPRI_RELEASE()   (curthread->t_kpri_req--)
 622 #define THREAD_KPRI_RELEASE_N(n) (curthread->t_kpri_req -= (n))
 623 
 624 /*
 625  * Macro to change a thread's priority.
 626  */
 627 #define THREAD_CHANGE_PRI(t, pri) {                                     \
 628         pri_t __new_pri = (pri);                                        \
 629         DTRACE_SCHED2(change__pri, kthread_t *, (t), pri_t, __new_pri); \
 630         (t)->t_pri = __new_pri;                                              \
 631         schedctl_set_cidpri(t);                                         \
 632 }
 633 
 634 /*
 635  * Macro to indicate that a thread's priority is about to be changed.
 636  */
 637 #define THREAD_WILLCHANGE_PRI(t, pri) {                                 \
 638         DTRACE_SCHED2(change__pri, kthread_t *, (t), pri_t, (pri));     \
 639 }
 640 
 641 /*
 642  * Macros to change thread state and the associated lock.
 643  */
 644 #define THREAD_SET_STATE(tp, state, lp) \




 186         time_t  t_start;                /* start time, seconds since epoch */
 187         clock_t t_lbolt;                /* lbolt at last clock_tick() */
 188         hrtime_t t_stoptime;            /* timestamp at stop() */
 189         uint_t  t_pctcpu;               /* %cpu at last clock_tick(), binary */
 190                                         /* point at right of high-order bit */
 191         short   t_sysnum;               /* system call number */
 192         kcondvar_t      t_delay_cv;
 193         kmutex_t        t_delay_lock;
 194 
 195         /*
 196          * Pointer to the dispatcher lock protecting t_state and state-related
 197          * flags.  This pointer can change during waits on the lock, so
 198          * it should be grabbed only by thread_lock().
 199          */
 200         disp_lock_t     *t_lockp;       /* pointer to the dispatcher lock */
 201         ushort_t        t_oldspl;       /* spl level before dispatcher locked */
 202         volatile char   t_pre_sys;      /* pre-syscall work needed */
 203         lock_t          t_lock_flush;   /* for lock_mutex_flush() impl */
 204         struct _disp    *t_disp_queue;  /* run queue for chosen CPU */
 205         clock_t         t_disp_time;    /* last time this thread was running */

 206 
 207         /*
 208          * Post-syscall / post-trap flags.
 209          *      No lock is required to set these.
 210          *      These must be cleared only by the thread itself.
 211          *
 212          *      t_astflag indicates that some post-trap processing is required,
 213          *              possibly a signal or a preemption.  The thread will not
 214          *              return to user with this set.
 215          *      t_post_sys indicates that some unusualy post-system call
 216          *              handling is required, such as an error or tracing.
 217          *      t_sig_check indicates that some condition in ISSIG() must be
 218          *              checked, but doesn't prevent returning to user.
 219          *      t_post_sys_ast is a way of checking whether any of these three
 220          *              flags are set.
 221          */
 222         union __tu {
 223                 struct __ts {
 224                         volatile char   _t_astflag;     /* AST requested */
 225                         volatile char   _t_sig_check;   /* ISSIG required */


 590 #define thread_unlock_high(t)           disp_lock_exit_high((t)->t_lockp)
 591 #define thread_unlock_nopreempt(t)      disp_lock_exit_nopreempt((t)->t_lockp)
 592 
 593 #define THREAD_LOCK_HELD(t)     (DISP_LOCK_HELD((t)->t_lockp))
 594 
 595 extern disp_lock_t transition_lock;     /* lock protecting transiting threads */
 596 extern disp_lock_t stop_lock;           /* lock protecting stopped threads */
 597 
 598 caddr_t thread_stk_init(caddr_t);       /* init thread stack */
 599 
 600 int thread_setname(kthread_t *, const char *);
 601 int thread_vsetname(kthread_t *, const char *, ...);
 602 
 603 extern int default_binding_mode;
 604 
 605 #endif  /* _KERNEL */
 606 
 607 #define THREAD_NAME_MAX 32      /* includes terminating NUL */
 608 
 609 /*














 610  * Macro to change a thread's priority.
 611  */
 612 #define THREAD_CHANGE_PRI(t, pri) {                                     \
 613         pri_t __new_pri = (pri);                                        \
 614         DTRACE_SCHED2(change__pri, kthread_t *, (t), pri_t, __new_pri); \
 615         (t)->t_pri = __new_pri;                                              \
 616         schedctl_set_cidpri(t);                                         \
 617 }
 618 
 619 /*
 620  * Macro to indicate that a thread's priority is about to be changed.
 621  */
 622 #define THREAD_WILLCHANGE_PRI(t, pri) {                                 \
 623         DTRACE_SCHED2(change__pri, kthread_t *, (t), pri_t, (pri));     \
 624 }
 625 
 626 /*
 627  * Macros to change thread state and the associated lock.
 628  */
 629 #define THREAD_SET_STATE(tp, state, lp) \