9694 * aka T1) lgrp. Currently text replication is only optimized for
9695 * workloads that either have all threads of a process on the same
9696 * lgrp or execute their large text primarily on main thread.
9697 */
9698 lgrp_id = p->p_t1_lgrpid;
9699 if (lgrp_id == LGRP_NONE) {
9700 /*
9701 * In case exec() prefaults text on non main thread use
9702 * current thread lgrpid. It will become main thread anyway
9703 * soon.
9704 */
9705 lgrp_id = lgrp_home_id(curthread);
9706 }
9707 /*
9708 * Set p_tr_lgrpid to lgrpid if it hasn't been set yet. Otherwise
9709 * just set it to NLGRPS_MAX if it's different from current process T1
9710 * home lgrp. p_tr_lgrpid is used to detect if process uses text
9711 * replication and T1 new home is different from lgrp used for text
9712 * replication. When this happens asyncronous segvn thread rechecks if
9713 * segments should change lgrps used for text replication. If we fail
9714 * to set p_tr_lgrpid with cas32 then set it to NLGRPS_MAX without cas
9715 * if it's not already NLGRPS_MAX and not equal lgrp_id we want to
9716 * use. We don't need to use cas in this case because another thread
9717 * that races in between our non atomic check and set may only change
9718 * p_tr_lgrpid to NLGRPS_MAX at this point.
9719 */
9720 ASSERT(lgrp_id != LGRP_NONE && lgrp_id < NLGRPS_MAX);
9721 olid = p->p_tr_lgrpid;
9722 if (lgrp_id != olid && olid != NLGRPS_MAX) {
9723 lgrp_id_t nlid = (olid == LGRP_NONE) ? lgrp_id : NLGRPS_MAX;
9724 if (cas32((uint32_t *)&p->p_tr_lgrpid, olid, nlid) != olid) {
9725 olid = p->p_tr_lgrpid;
9726 ASSERT(olid != LGRP_NONE);
9727 if (olid != lgrp_id && olid != NLGRPS_MAX) {
9728 p->p_tr_lgrpid = NLGRPS_MAX;
9729 }
9730 }
9731 ASSERT(p->p_tr_lgrpid != LGRP_NONE);
9732 membar_producer();
9733 /*
9734 * lgrp_move_thread() won't schedule async recheck after
9735 * p->p_t1_lgrpid update unless p->p_tr_lgrpid is not
9736 * LGRP_NONE. Recheck p_t1_lgrpid once now that p->p_tr_lgrpid
9737 * is not LGRP_NONE.
9738 */
9739 if (first && p->p_t1_lgrpid != LGRP_NONE &&
9740 p->p_t1_lgrpid != lgrp_id) {
9741 first = 0;
9742 goto again;
9743 }
9744 }
|
9694 * aka T1) lgrp. Currently text replication is only optimized for
9695 * workloads that either have all threads of a process on the same
9696 * lgrp or execute their large text primarily on main thread.
9697 */
9698 lgrp_id = p->p_t1_lgrpid;
9699 if (lgrp_id == LGRP_NONE) {
9700 /*
9701 * In case exec() prefaults text on non main thread use
9702 * current thread lgrpid. It will become main thread anyway
9703 * soon.
9704 */
9705 lgrp_id = lgrp_home_id(curthread);
9706 }
9707 /*
9708 * Set p_tr_lgrpid to lgrpid if it hasn't been set yet. Otherwise
9709 * just set it to NLGRPS_MAX if it's different from current process T1
9710 * home lgrp. p_tr_lgrpid is used to detect if process uses text
9711 * replication and T1 new home is different from lgrp used for text
9712 * replication. When this happens asyncronous segvn thread rechecks if
9713 * segments should change lgrps used for text replication. If we fail
9714 * to set p_tr_lgrpid with atomic_cas_32 then set it to NLGRPS_MAX
9715 * without cas if it's not already NLGRPS_MAX and not equal lgrp_id
9716 * we want to use. We don't need to use cas in this case because
9717 * another thread that races in between our non atomic check and set
9718 * may only change p_tr_lgrpid to NLGRPS_MAX at this point.
9719 */
9720 ASSERT(lgrp_id != LGRP_NONE && lgrp_id < NLGRPS_MAX);
9721 olid = p->p_tr_lgrpid;
9722 if (lgrp_id != olid && olid != NLGRPS_MAX) {
9723 lgrp_id_t nlid = (olid == LGRP_NONE) ? lgrp_id : NLGRPS_MAX;
9724 if (atomic_cas_32((uint32_t *)&p->p_tr_lgrpid, olid, nlid) !=
9725 olid) {
9726 olid = p->p_tr_lgrpid;
9727 ASSERT(olid != LGRP_NONE);
9728 if (olid != lgrp_id && olid != NLGRPS_MAX) {
9729 p->p_tr_lgrpid = NLGRPS_MAX;
9730 }
9731 }
9732 ASSERT(p->p_tr_lgrpid != LGRP_NONE);
9733 membar_producer();
9734 /*
9735 * lgrp_move_thread() won't schedule async recheck after
9736 * p->p_t1_lgrpid update unless p->p_tr_lgrpid is not
9737 * LGRP_NONE. Recheck p_t1_lgrpid once now that p->p_tr_lgrpid
9738 * is not LGRP_NONE.
9739 */
9740 if (first && p->p_t1_lgrpid != LGRP_NONE &&
9741 p->p_t1_lgrpid != lgrp_id) {
9742 first = 0;
9743 goto again;
9744 }
9745 }
|