Lines Matching refs:rnp

105 static void rcu_report_exp_rnp(struct rcu_node *rnp, bool wake);
151 static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp) in rcu_preempt_ctxt_queue() argument
152 __releases(rnp->lock) /* But leaves rrupts disabled. */ in rcu_preempt_ctxt_queue()
154 int blkd_state = (rnp->gp_tasks ? RCU_GP_TASKS : 0) + in rcu_preempt_ctxt_queue()
155 (rnp->exp_tasks ? RCU_EXP_TASKS : 0) + in rcu_preempt_ctxt_queue()
156 (rnp->qsmask & rdp->grpmask ? RCU_GP_BLKD : 0) + in rcu_preempt_ctxt_queue()
157 (rnp->expmask & rdp->grpmask ? RCU_EXP_BLKD : 0); in rcu_preempt_ctxt_queue()
160 raw_lockdep_assert_held_rcu_node(rnp); in rcu_preempt_ctxt_queue()
161 WARN_ON_ONCE(rdp->mynode != rnp); in rcu_preempt_ctxt_queue()
162 WARN_ON_ONCE(!rcu_is_leaf_node(rnp)); in rcu_preempt_ctxt_queue()
164 WARN_ON_ONCE(rnp->qsmaskinitnext & ~rnp->qsmaskinit & rnp->qsmask & in rcu_preempt_ctxt_queue()
185 list_add(&t->rcu_node_entry, &rnp->blkd_tasks); in rcu_preempt_ctxt_queue()
203 list_add_tail(&t->rcu_node_entry, &rnp->blkd_tasks); in rcu_preempt_ctxt_queue()
216 list_add(&t->rcu_node_entry, rnp->exp_tasks); in rcu_preempt_ctxt_queue()
227 list_add(&t->rcu_node_entry, rnp->gp_tasks); in rcu_preempt_ctxt_queue()
243 if (!rnp->gp_tasks && (blkd_state & RCU_GP_BLKD)) { in rcu_preempt_ctxt_queue()
244 WRITE_ONCE(rnp->gp_tasks, &t->rcu_node_entry); in rcu_preempt_ctxt_queue()
245 WARN_ON_ONCE(rnp->completedqs == rnp->gp_seq); in rcu_preempt_ctxt_queue()
247 if (!rnp->exp_tasks && (blkd_state & RCU_EXP_BLKD)) in rcu_preempt_ctxt_queue()
248 WRITE_ONCE(rnp->exp_tasks, &t->rcu_node_entry); in rcu_preempt_ctxt_queue()
250 !(rnp->qsmask & rdp->grpmask)); in rcu_preempt_ctxt_queue()
252 !(rnp->expmask & rdp->grpmask)); in rcu_preempt_ctxt_queue()
253 raw_spin_unlock_rcu_node(rnp); /* interrupts remain disabled. */ in rcu_preempt_ctxt_queue()
316 struct rcu_node *rnp; in rcu_note_context_switch() local
325 rnp = rdp->mynode; in rcu_note_context_switch()
326 raw_spin_lock_rcu_node(rnp); in rcu_note_context_switch()
328 t->rcu_blocked_node = rnp; in rcu_note_context_switch()
339 (rnp->qsmask & rdp->grpmask) in rcu_note_context_switch()
340 ? rnp->gp_seq in rcu_note_context_switch()
341 : rcu_seq_snap(&rnp->gp_seq)); in rcu_note_context_switch()
342 rcu_preempt_ctxt_queue(rnp, rdp); in rcu_note_context_switch()
369 static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp) in rcu_preempt_blocked_readers_cgp() argument
371 return READ_ONCE(rnp->gp_tasks) != NULL; in rcu_preempt_blocked_readers_cgp()
441 struct rcu_node *rnp) in rcu_next_node_entry() argument
446 if (np == &rnp->blkd_tasks) in rcu_next_node_entry()
455 static bool rcu_preempt_has_tasks(struct rcu_node *rnp) in rcu_preempt_has_tasks() argument
457 return !list_empty(&rnp->blkd_tasks); in rcu_preempt_has_tasks()
474 struct rcu_node *rnp; in rcu_preempt_deferred_qs_irqrestore() local
517 rnp = t->rcu_blocked_node; in rcu_preempt_deferred_qs_irqrestore()
518 raw_spin_lock_rcu_node(rnp); /* irqs already disabled. */ in rcu_preempt_deferred_qs_irqrestore()
519 WARN_ON_ONCE(rnp != t->rcu_blocked_node); in rcu_preempt_deferred_qs_irqrestore()
520 WARN_ON_ONCE(!rcu_is_leaf_node(rnp)); in rcu_preempt_deferred_qs_irqrestore()
521 empty_norm = !rcu_preempt_blocked_readers_cgp(rnp); in rcu_preempt_deferred_qs_irqrestore()
522 WARN_ON_ONCE(rnp->completedqs == rnp->gp_seq && in rcu_preempt_deferred_qs_irqrestore()
523 (!empty_norm || rnp->qsmask)); in rcu_preempt_deferred_qs_irqrestore()
524 empty_exp = sync_rcu_exp_done(rnp); in rcu_preempt_deferred_qs_irqrestore()
526 np = rcu_next_node_entry(t, rnp); in rcu_preempt_deferred_qs_irqrestore()
530 rnp->gp_seq, t->pid); in rcu_preempt_deferred_qs_irqrestore()
531 if (&t->rcu_node_entry == rnp->gp_tasks) in rcu_preempt_deferred_qs_irqrestore()
532 WRITE_ONCE(rnp->gp_tasks, np); in rcu_preempt_deferred_qs_irqrestore()
533 if (&t->rcu_node_entry == rnp->exp_tasks) in rcu_preempt_deferred_qs_irqrestore()
534 WRITE_ONCE(rnp->exp_tasks, np); in rcu_preempt_deferred_qs_irqrestore()
537 drop_boost_mutex = rt_mutex_owner(&rnp->boost_mtx.rtmutex) == t; in rcu_preempt_deferred_qs_irqrestore()
538 if (&t->rcu_node_entry == rnp->boost_tasks) in rcu_preempt_deferred_qs_irqrestore()
539 WRITE_ONCE(rnp->boost_tasks, np); in rcu_preempt_deferred_qs_irqrestore()
548 empty_exp_now = sync_rcu_exp_done(rnp); in rcu_preempt_deferred_qs_irqrestore()
549 if (!empty_norm && !rcu_preempt_blocked_readers_cgp(rnp)) { in rcu_preempt_deferred_qs_irqrestore()
551 rnp->gp_seq, in rcu_preempt_deferred_qs_irqrestore()
552 0, rnp->qsmask, in rcu_preempt_deferred_qs_irqrestore()
553 rnp->level, in rcu_preempt_deferred_qs_irqrestore()
554 rnp->grplo, in rcu_preempt_deferred_qs_irqrestore()
555 rnp->grphi, in rcu_preempt_deferred_qs_irqrestore()
556 !!rnp->gp_tasks); in rcu_preempt_deferred_qs_irqrestore()
557 rcu_report_unblock_qs_rnp(rnp, flags); in rcu_preempt_deferred_qs_irqrestore()
559 raw_spin_unlock_irqrestore_rcu_node(rnp, flags); in rcu_preempt_deferred_qs_irqrestore()
567 rcu_report_exp_rnp(rnp, true); in rcu_preempt_deferred_qs_irqrestore()
571 rt_mutex_futex_unlock(&rnp->boost_mtx.rtmutex); in rcu_preempt_deferred_qs_irqrestore()
642 struct rcu_node *rnp = rdp->mynode; in rcu_read_unlock_special() local
645 (rdp->grpmask & READ_ONCE(rnp->expmask)) || in rcu_read_unlock_special()
647 ((rdp->grpmask & READ_ONCE(rnp->qsmask)) || t->rcu_blocked_node)) || in rcu_read_unlock_special()
693 static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp) in rcu_preempt_check_blocked_tasks() argument
698 raw_lockdep_assert_held_rcu_node(rnp); in rcu_preempt_check_blocked_tasks()
699 if (WARN_ON_ONCE(rcu_preempt_blocked_readers_cgp(rnp))) in rcu_preempt_check_blocked_tasks()
700 dump_blkd_tasks(rnp, 10); in rcu_preempt_check_blocked_tasks()
701 if (rcu_preempt_has_tasks(rnp) && in rcu_preempt_check_blocked_tasks()
702 (rnp->qsmaskinit || rnp->wait_blkd_tasks)) { in rcu_preempt_check_blocked_tasks()
703 WRITE_ONCE(rnp->gp_tasks, rnp->blkd_tasks.next); in rcu_preempt_check_blocked_tasks()
704 t = container_of(rnp->gp_tasks, struct task_struct, in rcu_preempt_check_blocked_tasks()
707 rnp->gp_seq, t->pid); in rcu_preempt_check_blocked_tasks()
709 WARN_ON_ONCE(rnp->qsmask); in rcu_preempt_check_blocked_tasks()
778 dump_blkd_tasks(struct rcu_node *rnp, int ncheck) in dump_blkd_tasks() argument
786 raw_lockdep_assert_held_rcu_node(rnp); in dump_blkd_tasks()
788 __func__, rnp->grplo, rnp->grphi, rnp->level, in dump_blkd_tasks()
789 (long)READ_ONCE(rnp->gp_seq), (long)rnp->completedqs); in dump_blkd_tasks()
790 for (rnp1 = rnp; rnp1; rnp1 = rnp1->parent) in dump_blkd_tasks()
794 __func__, READ_ONCE(rnp->gp_tasks), data_race(rnp->boost_tasks), in dump_blkd_tasks()
795 READ_ONCE(rnp->exp_tasks)); in dump_blkd_tasks()
798 list_for_each(lhp, &rnp->blkd_tasks) { in dump_blkd_tasks()
804 for (cpu = rnp->grplo; cpu <= rnp->grphi; cpu++) { in dump_blkd_tasks()
913 static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp) in rcu_preempt_blocked_readers_cgp() argument
921 static bool rcu_preempt_has_tasks(struct rcu_node *rnp) in rcu_preempt_has_tasks() argument
955 static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp) in rcu_preempt_check_blocked_tasks() argument
957 WARN_ON_ONCE(rnp->qsmask); in rcu_preempt_check_blocked_tasks()
995 dump_blkd_tasks(struct rcu_node *rnp, int ncheck) in dump_blkd_tasks() argument
997 WARN_ON_ONCE(!list_empty(&rnp->blkd_tasks)); in dump_blkd_tasks()
1047 static int rcu_boost(struct rcu_node *rnp) in rcu_boost() argument
1053 if (READ_ONCE(rnp->exp_tasks) == NULL && in rcu_boost()
1054 READ_ONCE(rnp->boost_tasks) == NULL) in rcu_boost()
1057 raw_spin_lock_irqsave_rcu_node(rnp, flags); in rcu_boost()
1063 if (rnp->exp_tasks == NULL && rnp->boost_tasks == NULL) { in rcu_boost()
1064 raw_spin_unlock_irqrestore_rcu_node(rnp, flags); in rcu_boost()
1074 if (rnp->exp_tasks != NULL) in rcu_boost()
1075 tb = rnp->exp_tasks; in rcu_boost()
1077 tb = rnp->boost_tasks; in rcu_boost()
1096 rt_mutex_init_proxy_locked(&rnp->boost_mtx.rtmutex, t); in rcu_boost()
1097 raw_spin_unlock_irqrestore_rcu_node(rnp, flags); in rcu_boost()
1099 rt_mutex_lock(&rnp->boost_mtx); in rcu_boost()
1100 rt_mutex_unlock(&rnp->boost_mtx); /* Then keep lockdep happy. */ in rcu_boost()
1101 rnp->n_boosts++; in rcu_boost()
1103 return READ_ONCE(rnp->exp_tasks) != NULL || in rcu_boost()
1104 READ_ONCE(rnp->boost_tasks) != NULL; in rcu_boost()
1112 struct rcu_node *rnp = (struct rcu_node *)arg; in rcu_boost_kthread() local
1118 WRITE_ONCE(rnp->boost_kthread_status, RCU_KTHREAD_WAITING); in rcu_boost_kthread()
1120 rcu_wait(READ_ONCE(rnp->boost_tasks) || in rcu_boost_kthread()
1121 READ_ONCE(rnp->exp_tasks)); in rcu_boost_kthread()
1123 WRITE_ONCE(rnp->boost_kthread_status, RCU_KTHREAD_RUNNING); in rcu_boost_kthread()
1124 more2boost = rcu_boost(rnp); in rcu_boost_kthread()
1130 WRITE_ONCE(rnp->boost_kthread_status, RCU_KTHREAD_YIELDING); in rcu_boost_kthread()
1152 static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags) in rcu_initiate_boost() argument
1153 __releases(rnp->lock) in rcu_initiate_boost()
1155 raw_lockdep_assert_held_rcu_node(rnp); in rcu_initiate_boost()
1156 if (!rnp->boost_kthread_task || in rcu_initiate_boost()
1157 (!rcu_preempt_blocked_readers_cgp(rnp) && !rnp->exp_tasks)) { in rcu_initiate_boost()
1158 raw_spin_unlock_irqrestore_rcu_node(rnp, flags); in rcu_initiate_boost()
1161 if (rnp->exp_tasks != NULL || in rcu_initiate_boost()
1162 (rnp->gp_tasks != NULL && in rcu_initiate_boost()
1163 rnp->boost_tasks == NULL && in rcu_initiate_boost()
1164 rnp->qsmask == 0 && in rcu_initiate_boost()
1165 (!time_after(rnp->boost_time, jiffies) || rcu_state.cbovld || in rcu_initiate_boost()
1167 if (rnp->exp_tasks == NULL) in rcu_initiate_boost()
1168 WRITE_ONCE(rnp->boost_tasks, rnp->gp_tasks); in rcu_initiate_boost()
1169 raw_spin_unlock_irqrestore_rcu_node(rnp, flags); in rcu_initiate_boost()
1170 rcu_wake_cond(rnp->boost_kthread_task, in rcu_initiate_boost()
1171 READ_ONCE(rnp->boost_kthread_status)); in rcu_initiate_boost()
1173 raw_spin_unlock_irqrestore_rcu_node(rnp, flags); in rcu_initiate_boost()
1182 static void rcu_preempt_boost_start_gp(struct rcu_node *rnp) in rcu_preempt_boost_start_gp() argument
1184 rnp->boost_time = jiffies + RCU_BOOST_DELAY_JIFFIES; in rcu_preempt_boost_start_gp()
1191 static void rcu_spawn_one_boost_kthread(struct rcu_node *rnp) in rcu_spawn_one_boost_kthread() argument
1194 int rnp_index = rnp - rcu_get_root(); in rcu_spawn_one_boost_kthread()
1198 mutex_lock(&rnp->boost_kthread_mutex); in rcu_spawn_one_boost_kthread()
1199 if (rnp->boost_kthread_task || !rcu_scheduler_fully_active) in rcu_spawn_one_boost_kthread()
1202 t = kthread_create(rcu_boost_kthread, (void *)rnp, in rcu_spawn_one_boost_kthread()
1207 raw_spin_lock_irqsave_rcu_node(rnp, flags); in rcu_spawn_one_boost_kthread()
1208 rnp->boost_kthread_task = t; in rcu_spawn_one_boost_kthread()
1209 raw_spin_unlock_irqrestore_rcu_node(rnp, flags); in rcu_spawn_one_boost_kthread()
1215 mutex_unlock(&rnp->boost_kthread_mutex); in rcu_spawn_one_boost_kthread()
1229 static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu) in rcu_boost_kthread_setaffinity() argument
1231 struct task_struct *t = rnp->boost_kthread_task; in rcu_boost_kthread_setaffinity()
1240 mutex_lock(&rnp->boost_kthread_mutex); in rcu_boost_kthread_setaffinity()
1241 mask = rcu_rnp_online_cpus(rnp); in rcu_boost_kthread_setaffinity()
1242 for_each_leaf_node_possible_cpu(rnp, cpu) in rcu_boost_kthread_setaffinity()
1243 if ((mask & leaf_node_cpu_bit(rnp, cpu)) && in rcu_boost_kthread_setaffinity()
1253 mutex_unlock(&rnp->boost_kthread_mutex); in rcu_boost_kthread_setaffinity()
1259 static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags) in rcu_initiate_boost() argument
1260 __releases(rnp->lock) in rcu_initiate_boost()
1262 raw_spin_unlock_irqrestore_rcu_node(rnp, flags); in rcu_initiate_boost()
1265 static void rcu_preempt_boost_start_gp(struct rcu_node *rnp) in rcu_preempt_boost_start_gp() argument
1269 static void rcu_spawn_one_boost_kthread(struct rcu_node *rnp) in rcu_spawn_one_boost_kthread() argument
1273 static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu) in rcu_boost_kthread_setaffinity() argument