Lines Matching +full:sys +full:- +full:mgr

7  * Copyright (c) 2004-2009 Silicon Graphics, Inc.  All Rights Reserved.
11 * Cross Partition Communication (XPC) support - standard version.
82 /* systune related variables for /proc/sys directories */
128 /* non-zero if any remote partition disengage was timed out */
170 DBUG_ON(time_is_after_jiffies(part->disengage_timeout)); in xpc_timeout_partition_disengage()
174 DBUG_ON(part->disengage_timeout != 0); in xpc_timeout_partition_disengage()
231 if (part->act_state == XPC_P_AS_INACTIVE || in xpc_check_remote_hb()
232 part->act_state == XPC_P_AS_DEACTIVATING) { in xpc_check_remote_hb()
263 (int)(xpc_hb_check_timeout - jiffies), in xpc_hb_checker()
332 while (part->act_state != XPC_P_AS_DEACTIVATING || in xpc_channel_mgr()
333 atomic_read(&part->nchannels_active) > 0 || in xpc_channel_mgr()
344 * This is done to prevent the channel mgr from making one pass in xpc_channel_mgr()
348 * that the channel mgr is running and won't bother trying to in xpc_channel_mgr()
351 atomic_dec(&part->channel_mgr_requests); in xpc_channel_mgr()
352 (void)wait_event_interruptible(part->channel_mgr_wq, in xpc_channel_mgr()
353 (atomic_read(&part->channel_mgr_requests) > 0 || in xpc_channel_mgr()
354 part->chctl.all_flags != 0 || in xpc_channel_mgr()
355 (part->act_state == XPC_P_AS_DEACTIVATING && in xpc_channel_mgr()
356 atomic_read(&part->nchannels_active) == 0 && in xpc_channel_mgr()
358 atomic_set(&part->channel_mgr_requests, 1); in xpc_channel_mgr()
402 DBUG_ON(part->channels != NULL); in xpc_setup_ch_structures()
403 part->channels = kcalloc(XPC_MAX_NCHANNELS, in xpc_setup_ch_structures()
406 if (part->channels == NULL) { in xpc_setup_ch_structures()
413 part->remote_openclose_args = in xpc_setup_ch_structures()
415 GFP_KERNEL, &part-> in xpc_setup_ch_structures()
417 if (part->remote_openclose_args == NULL) { in xpc_setup_ch_structures()
423 part->chctl.all_flags = 0; in xpc_setup_ch_structures()
424 spin_lock_init(&part->chctl_lock); in xpc_setup_ch_structures()
426 atomic_set(&part->channel_mgr_requests, 1); in xpc_setup_ch_structures()
427 init_waitqueue_head(&part->channel_mgr_wq); in xpc_setup_ch_structures()
429 part->nchannels = XPC_MAX_NCHANNELS; in xpc_setup_ch_structures()
431 atomic_set(&part->nchannels_active, 0); in xpc_setup_ch_structures()
432 atomic_set(&part->nchannels_engaged, 0); in xpc_setup_ch_structures()
434 for (ch_number = 0; ch_number < part->nchannels; ch_number++) { in xpc_setup_ch_structures()
435 ch = &part->channels[ch_number]; in xpc_setup_ch_structures()
437 ch->partid = partid; in xpc_setup_ch_structures()
438 ch->number = ch_number; in xpc_setup_ch_structures()
439 ch->flags = XPC_C_DISCONNECTED; in xpc_setup_ch_structures()
441 atomic_set(&ch->kthreads_assigned, 0); in xpc_setup_ch_structures()
442 atomic_set(&ch->kthreads_idle, 0); in xpc_setup_ch_structures()
443 atomic_set(&ch->kthreads_active, 0); in xpc_setup_ch_structures()
445 atomic_set(&ch->references, 0); in xpc_setup_ch_structures()
446 atomic_set(&ch->n_to_notify, 0); in xpc_setup_ch_structures()
448 spin_lock_init(&ch->lock); in xpc_setup_ch_structures()
449 init_completion(&ch->wdisconnect_wait); in xpc_setup_ch_structures()
451 atomic_set(&ch->n_on_msg_allocate_wq, 0); in xpc_setup_ch_structures()
452 init_waitqueue_head(&ch->msg_allocate_wq); in xpc_setup_ch_structures()
453 init_waitqueue_head(&ch->idle_wq); in xpc_setup_ch_structures()
464 part->setup_state = XPC_P_SS_SETUP; in xpc_setup_ch_structures()
470 kfree(part->remote_openclose_args_base); in xpc_setup_ch_structures()
471 part->remote_openclose_args = NULL; in xpc_setup_ch_structures()
473 kfree(part->channels); in xpc_setup_ch_structures()
474 part->channels = NULL; in xpc_setup_ch_structures()
485 DBUG_ON(atomic_read(&part->nchannels_engaged) != 0); in xpc_teardown_ch_structures()
486 DBUG_ON(atomic_read(&part->nchannels_active) != 0); in xpc_teardown_ch_structures()
493 DBUG_ON(part->setup_state != XPC_P_SS_SETUP); in xpc_teardown_ch_structures()
494 part->setup_state = XPC_P_SS_WTEARDOWN; in xpc_teardown_ch_structures()
496 wait_event(part->teardown_wq, (atomic_read(&part->references) == 0)); in xpc_teardown_ch_structures()
502 kfree(part->remote_openclose_args_base); in xpc_teardown_ch_structures()
503 part->remote_openclose_args = NULL; in xpc_teardown_ch_structures()
504 kfree(part->channels); in xpc_teardown_ch_structures()
505 part->channels = NULL; in xpc_teardown_ch_structures()
507 part->setup_state = XPC_P_SS_TORNDOWN; in xpc_teardown_ch_structures()
530 spin_lock_irqsave(&part->act_lock, irq_flags); in xpc_activating()
532 if (part->act_state == XPC_P_AS_DEACTIVATING) { in xpc_activating()
533 part->act_state = XPC_P_AS_INACTIVE; in xpc_activating()
534 spin_unlock_irqrestore(&part->act_lock, irq_flags); in xpc_activating()
535 part->remote_rp_pa = 0; in xpc_activating()
540 DBUG_ON(part->act_state != XPC_P_AS_ACTIVATION_REQ); in xpc_activating()
541 part->act_state = XPC_P_AS_ACTIVATING; in xpc_activating()
544 spin_unlock_irqrestore(&part->act_lock, irq_flags); in xpc_activating()
566 if (part->reason == xpReactivating) { in xpc_activating()
581 spin_lock_irqsave(&part->act_lock, irq_flags); in xpc_activate_partition()
583 DBUG_ON(part->act_state != XPC_P_AS_INACTIVE); in xpc_activate_partition()
585 part->act_state = XPC_P_AS_ACTIVATION_REQ; in xpc_activate_partition()
588 spin_unlock_irqrestore(&part->act_lock, irq_flags); in xpc_activate_partition()
593 spin_lock_irqsave(&part->act_lock, irq_flags); in xpc_activate_partition()
594 part->act_state = XPC_P_AS_INACTIVE; in xpc_activate_partition()
596 spin_unlock_irqrestore(&part->act_lock, irq_flags); in xpc_activate_partition()
603 int idle = atomic_read(&ch->kthreads_idle); in xpc_activate_kthreads()
604 int assigned = atomic_read(&ch->kthreads_assigned); in xpc_activate_kthreads()
611 needed -= wakeup; in xpc_activate_kthreads()
614 "channel=%d\n", wakeup, ch->partid, ch->number); in xpc_activate_kthreads()
617 wake_up_nr(&ch->idle_wq, wakeup); in xpc_activate_kthreads()
623 if (needed + assigned > ch->kthreads_assigned_limit) { in xpc_activate_kthreads()
624 needed = ch->kthreads_assigned_limit - assigned; in xpc_activate_kthreads()
630 needed, ch->partid, ch->number); in xpc_activate_kthreads()
648 !(ch->flags & XPC_C_DISCONNECTING)) { in xpc_kthread_waitmsgs()
652 if (atomic_inc_return(&ch->kthreads_idle) > in xpc_kthread_waitmsgs()
653 ch->kthreads_idle_limit) { in xpc_kthread_waitmsgs()
655 atomic_dec(&ch->kthreads_idle); in xpc_kthread_waitmsgs()
662 (void)wait_event_interruptible_exclusive(ch->idle_wq, in xpc_kthread_waitmsgs()
664 (ch->flags & XPC_C_DISCONNECTING))); in xpc_kthread_waitmsgs()
666 atomic_dec(&ch->kthreads_idle); in xpc_kthread_waitmsgs()
668 } while (!(ch->flags & XPC_C_DISCONNECTING)); in xpc_kthread_waitmsgs()
686 ch = &part->channels[ch_number]; in xpc_kthread_start()
688 if (!(ch->flags & XPC_C_DISCONNECTING)) { in xpc_kthread_start()
692 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_kthread_start()
693 if (!(ch->flags & XPC_C_CONNECTEDCALLOUT)) { in xpc_kthread_start()
694 ch->flags |= XPC_C_CONNECTEDCALLOUT; in xpc_kthread_start()
695 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
699 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_kthread_start()
700 ch->flags |= XPC_C_CONNECTEDCALLOUT_MADE; in xpc_kthread_start()
701 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
710 n_needed = n_of_deliverable_payloads(ch) - 1; in xpc_kthread_start()
711 if (n_needed > 0 && !(ch->flags & XPC_C_DISCONNECTING)) in xpc_kthread_start()
715 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
723 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_kthread_start()
724 if ((ch->flags & XPC_C_CONNECTEDCALLOUT_MADE) && in xpc_kthread_start()
725 !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) { in xpc_kthread_start()
726 ch->flags |= XPC_C_DISCONNECTINGCALLOUT; in xpc_kthread_start()
727 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
731 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_kthread_start()
732 ch->flags |= XPC_C_DISCONNECTINGCALLOUT_MADE; in xpc_kthread_start()
734 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
736 if (atomic_dec_return(&ch->kthreads_assigned) == 0 && in xpc_kthread_start()
737 atomic_dec_return(&part->nchannels_engaged) == 0) { in xpc_kthread_start()
767 u64 args = XPC_PACK_ARGS(ch->partid, ch->number); in xpc_create_kthreads()
768 struct xpc_partition *part = &xpc_partitions[ch->partid]; in xpc_create_kthreads()
773 while (needed-- > 0) { in xpc_create_kthreads()
781 if (!atomic_inc_not_zero(&ch->kthreads_assigned)) { in xpc_create_kthreads()
783 BUG_ON(!(ch->flags & in xpc_create_kthreads()
788 } else if (ch->flags & XPC_C_DISCONNECTING) { in xpc_create_kthreads()
791 } else if (atomic_inc_return(&ch->kthreads_assigned) == 1 && in xpc_create_kthreads()
792 atomic_inc_return(&part->nchannels_engaged) == 1) { in xpc_create_kthreads()
799 "xpc%02dc%d", ch->partid, ch->number); in xpc_create_kthreads()
805 * !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) is true, in xpc_create_kthreads()
813 if (atomic_dec_return(&ch->kthreads_assigned) == 0 && in xpc_create_kthreads()
814 atomic_dec_return(&part->nchannels_engaged) == 0) { in xpc_create_kthreads()
820 if (atomic_read(&ch->kthreads_assigned) < in xpc_create_kthreads()
821 ch->kthreads_idle_limit) { in xpc_create_kthreads()
827 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_create_kthreads()
830 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_create_kthreads()
853 ch = &part->channels[ch_number]; in xpc_disconnect_wait()
855 if (!(ch->flags & XPC_C_WDISCONNECT)) { in xpc_disconnect_wait()
860 wait_for_completion(&ch->wdisconnect_wait); in xpc_disconnect_wait()
862 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_disconnect_wait()
863 DBUG_ON(!(ch->flags & XPC_C_DISCONNECTED)); in xpc_disconnect_wait()
866 if (ch->delayed_chctl_flags) { in xpc_disconnect_wait()
867 if (part->act_state != XPC_P_AS_DEACTIVATING) { in xpc_disconnect_wait()
868 spin_lock(&part->chctl_lock); in xpc_disconnect_wait()
869 part->chctl.flags[ch->number] |= in xpc_disconnect_wait()
870 ch->delayed_chctl_flags; in xpc_disconnect_wait()
871 spin_unlock(&part->chctl_lock); in xpc_disconnect_wait()
874 ch->delayed_chctl_flags = 0; in xpc_disconnect_wait()
877 ch->flags &= ~XPC_C_WDISCONNECT; in xpc_disconnect_wait()
878 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_disconnect_wait()
898 return -ENOMEM; in xpc_setup_partitions()
914 part->activate_IRQ_rcvd = 0; in xpc_setup_partitions()
915 spin_lock_init(&part->act_lock); in xpc_setup_partitions()
916 part->act_state = XPC_P_AS_INACTIVE; in xpc_setup_partitions()
919 timer_setup(&part->disengage_timer, in xpc_setup_partitions()
922 part->setup_state = XPC_P_SS_UNSET; in xpc_setup_partitions()
923 init_waitqueue_head(&part->teardown_wq); in xpc_setup_partitions()
924 atomic_set(&part->references, 0); in xpc_setup_partitions()
977 part->act_state == XPC_P_AS_INACTIVE) { in xpc_do_exit()
985 if (part->disengage_timeout > disengage_timeout) in xpc_do_exit()
986 disengage_timeout = part->disengage_timeout; in xpc_do_exit()
993 "%ld seconds\n", (disengage_timeout - in xpc_do_exit()
1097 part->act_state != XPC_P_AS_INACTIVE) { in xpc_die_deactivate()
1108 * Given that one iteration through the following while-loop takes in xpc_die_deactivate()
1122 if (!keep_waiting--) { in xpc_die_deactivate()
1134 if (!wait_to_print--) { in xpc_die_deactivate()
1161 if (die_args->trapnr == X86_TRAP_DF) in xpc_system_die()
1164 if (((die_args->trapnr == X86_TRAP_MF) || in xpc_system_die()
1165 (die_args->trapnr == X86_TRAP_XF)) && in xpc_system_die()
1166 !user_mode(die_args->regs)) in xpc_system_die()
1195 ret = -ENODEV; in xpc_init()
1232 * The real work-horse behind xpc. This processes incoming in xpc_init()
1238 ret = -EBUSY; in xpc_init()
1252 /* mark this new thread as a non-starter */ in xpc_init()
1256 return -EBUSY; in xpc_init()