Lines Matching defs:mhp

769 	struct mem_handle *mhp;
771 mhp = kmem_zalloc(sizeof (struct mem_handle), KM_SLEEP);
772 mutex_init(&mhp->mh_mutex, NULL, MUTEX_DEFAULT, NULL);
774 mutex_enter(&mhp->mh_mutex);
776 mhp->mh_exthandle = (memhandle_t)(uintptr_t)(++handle_gen);
777 mhp->mh_next = mem_handle_head;
778 mem_handle_head = mhp;
781 return (mhp);
785 kphysm_free_mem_handle(struct mem_handle *mhp)
789 ASSERT(mutex_owned(&mhp->mh_mutex));
790 ASSERT(mhp->mh_state == MHND_FREE);
796 mutex_exit(&mhp->mh_mutex);
800 while (*mhpp != NULL && *mhpp != mhp)
802 ASSERT(*mhpp == mhp);
806 * can be referncing mhp.
808 *mhpp = mhp->mh_next;
811 mutex_destroy(&mhp->mh_mutex);
812 kmem_free(mhp, sizeof (struct mem_handle));
822 struct mem_handle *mhp;
825 for (mhp = mem_handle_head; mhp != NULL; mhp = mhp->mh_next) {
826 if (mhp->mh_exthandle == handle) {
827 mutex_enter(&mhp->mh_mutex);
832 if (mhp->mh_state == MHND_FREE) {
833 mutex_exit(&mhp->mh_mutex);
840 return (mhp);
846 struct mem_handle *mhp;
848 mhp = kphysm_allocate_mem_handle();
854 ASSERT(mhp->mh_state == MHND_FREE);
855 mhp->mh_state = MHND_INIT;
856 *xmhp = mhp->mh_exthandle;
857 mutex_exit(&mhp->mh_mutex);
1089 struct mem_handle *mhp;
1098 mhp = kphysm_lookup_mem_handle(handle);
1099 if (mhp == NULL) {
1102 if (mhp->mh_state != MHND_INIT) {
1103 mutex_exit(&mhp->mh_mutex);
1123 mutex_exit(&mhp->mh_mutex);
1129 if (delspan_insert(&mhp->mh_transit, mdsp_new) == 0) {
1135 for (mdsp = mhp->mh_transit.trl_spans; mdsp != NULL;
1143 mutex_exit(&mhp->mh_mutex);
1162 for (mdsp = mhp->mh_transit.trl_spans; mdsp != NULL;
1256 mhp->mh_phys_pages += phys_pages;
1257 mhp->mh_vm_pages += vm_pages;
1262 delspan_remove(&mhp->mh_transit, base, npgs);
1264 mutex_exit(&mhp->mh_mutex);
1430 struct mem_handle *mhp;
1432 mhp = kphysm_lookup_mem_handle(handle);
1433 if (mhp == NULL) {
1436 switch (mhp->mh_state) {
1439 mutex_exit(&mhp->mh_mutex);
1442 ASSERT(mhp->mh_state != MHND_FREE);
1443 mutex_exit(&mhp->mh_mutex);
1450 mutex_exit(&mhp->mh_mutex);
1455 (void *)mhp, mhp->mh_state);
1457 mutex_exit(&mhp->mh_mutex);
1465 mhp->mh_state = MHND_RELEASE;
1470 mutex_exit(&mhp->mh_mutex);
1472 delspan_remove(&mhp->mh_transit, 0, 0);
1473 mhp->mh_phys_pages = 0;
1474 mhp->mh_vm_pages = 0;
1475 mhp->mh_hold_todo = 0;
1476 mhp->mh_delete_complete = NULL;
1477 mhp->mh_delete_complete_arg = NULL;
1478 mhp->mh_cancel = 0;
1480 mutex_enter(&mhp->mh_mutex);
1481 ASSERT(mhp->mh_state == MHND_RELEASE);
1482 mhp->mh_state = MHND_FREE;
1484 kphysm_free_mem_handle(mhp);
1495 struct mem_handle *mhp;
1497 mhp = kphysm_lookup_mem_handle(handle);
1498 if (mhp == NULL) {
1501 if (mhp->mh_state != MHND_STARTING && mhp->mh_state != MHND_RUNNING) {
1502 mutex_exit(&mhp->mh_mutex);
1510 if (mhp->mh_cancel == 0) {
1511 mhp->mh_cancel = KPHYSM_ECANCELLED;
1512 cv_signal(&mhp->mh_cv);
1514 mutex_exit(&mhp->mh_mutex);
1523 struct mem_handle *mhp;
1525 mhp = kphysm_lookup_mem_handle(handle);
1526 if (mhp == NULL) {
1533 if (mhp->mh_state != MHND_INIT && mhp->mh_state != MHND_STARTING &&
1534 mhp->mh_state != MHND_RUNNING) {
1535 mutex_exit(&mhp->mh_mutex);
1538 mdstp->phys_pages = mhp->mh_phys_pages;
1539 mdstp->managed = mhp->mh_vm_pages;
1540 mdstp->collected = mhp->mh_vm_pages - mhp->mh_hold_todo;
1541 mutex_exit(&mhp->mh_mutex);
1596 delthr_get_freemem(struct mem_handle *mhp)
1601 ASSERT(MUTEX_HELD(&mhp->mh_mutex));
1603 MDSTAT_INCR(mhp, need_free);
1608 if (free_get > mhp->mh_hold_todo)
1609 free_get = mhp->mh_hold_todo;
1615 while (!mhp->mh_cancel) {
1616 mutex_exit(&mhp->mh_mutex);
1617 MDSTAT_INCR(mhp, free_loop);
1623 MDSTAT_INCR(mhp, free_low);
1629 MDSTAT_INCR(mhp, free_failed);
1633 mutex_enter(&mhp->mh_mutex);
1643 mutex_enter(&mhp->mh_mutex);
1644 (void) cv_reltimedwait(&mhp->mh_cv, &mhp->mh_mutex,
1646 mutex_exit(&mhp->mh_mutex);
1649 mutex_enter(&mhp->mh_mutex);
1671 struct mem_handle *mhp;
1674 mhp = (struct mem_handle *)amhp;
1675 ASSERT(mhp != NULL);
1676 pcancel = &mhp->mh_dr_aio_cleanup_cancel;
1678 mhp->mh_aio_cleanup_done = 1;
1685 mhp->mh_aio_cleanup_done = 1;
1711 mhp->mh_aio_cleanup_done = 1;
1718 struct mem_handle *mhp;
1734 mhp = (struct mem_handle *)amhp;
1740 CALLB_CPR_INIT(&cprinfo, &mhp->mh_mutex,
1743 mutex_enter(&mhp->mh_mutex);
1744 ASSERT(mhp->mh_state == MHND_STARTING);
1746 mhp->mh_state = MHND_RUNNING;
1747 mhp->mh_thread_id = curthread;
1749 mhp->mh_hold_todo = mhp->mh_vm_pages;
1750 mutex_exit(&mhp->mh_mutex);
1759 if (!get_availrmem(mhp->mh_vm_pages)) {
1761 mutex_enter(&mhp->mh_mutex);
1765 ret = kphysm_setup_pre_del(mhp->mh_vm_pages);
1767 mutex_enter(&mhp->mh_mutex);
1770 mhp->mh_cancel = KPHYSM_EREFUSED;
1774 transit_list_collect(mhp, 1);
1776 for (mdsp = mhp->mh_transit.trl_spans; mdsp != NULL;
1796 mhp->mh_dr_aio_cleanup_cancel = 0;
1797 mhp->mh_aio_cleanup_done = 0;
1799 (caddr_t)mhp, 0, &p0, TS_RUN, maxclsyspri - 1);
1800 while ((mhp->mh_hold_todo != 0) && (mhp->mh_cancel == 0)) {
1803 MDSTAT_INCR(mhp, nloop);
1805 for (mdsp = mhp->mh_transit.trl_spans; (mdsp != NULL) &&
1806 (mhp->mh_cancel == 0); mdsp = mdsp->mds_next) {
1811 (mhp->mh_cancel == 0); pfn++) {
1822 MDSTAT_INCR(mhp, already_done);
1826 freemem_left += delthr_get_freemem(mhp);
1836 mutex_exit(&mhp->mh_mutex);
1837 MDSTAT_INCR(mhp, ncheck);
1845 MDSTAT_INCR(mhp, nopaget);
1846 mutex_enter(&mhp->mh_mutex);
1857 MDSTAT_INCR(mhp, lockfail);
1858 mutex_enter(&mhp->mh_mutex);
1868 mutex_enter(&mhp->mh_mutex);
1869 mhp->mh_cancel = KPHYSM_ENONRELOC;
1879 MDSTAT_INCR(mhp, retired);
1880 mutex_enter(&mhp->mh_mutex);
1886 mhp->mh_hold_todo--;
1895 MDSTAT_INCR(mhp, nfree);
1907 mutex_enter(&mhp->mh_mutex);
1908 page_delete_collect(pp, mhp);
1916 MDSTAT_INCR(mhp, first_notfree);
1918 mutex_enter(&mhp->mh_mutex);
1926 MDSTAT_INCR(mhp, toxic);
1928 MDSTAT_INCR(mhp, failing);
1953 MDSTAT_INCR(mhp,
1957 &mhp->mh_mutex);
1960 MDSTAT_INCR(mhp, npplocked);
1971 MDSTAT_PGRP(mhp,
1973 MDSTAT_INCR(mhp,
1984 MDSTAT_PGRP(mhp, ntick_pgrp);
1985 MDSTAT_INCR(mhp, nnorepl);
1986 mutex_enter(&mhp->mh_mutex);
1994 MDSTAT_INCR(mhp, npplkdtoxic);
1996 mutex_enter(&mhp->mh_mutex);
2018 MDSTAT_INCR(mhp, gptlmodfail);
2020 mutex_enter(&mhp->mh_mutex);
2026 MDSTAT_INCR(mhp, nmodreloc);
2032 MDSTAT_PGRP(mhp, ntick_pgrp);
2039 MDSTAT_INCR(mhp, demotefail);
2045 MDSTAT_PGRP(mhp, ntick_pgrp);
2046 mutex_enter(&mhp->mh_mutex);
2054 MDSTAT_INCR(mhp, ndestroy);
2070 MDSTAT_PGRP(mhp, ntick_pgrp);
2071 mutex_enter(&mhp->mh_mutex);
2072 page_delete_collect(pp, mhp);
2088 MDSTAT_PGRP(mhp, ntick_pgrp);
2089 MDSTAT_INCR(mhp, modtoxic);
2090 mutex_enter(&mhp->mh_mutex);
2093 MDSTAT_INCR(mhp, nputpage);
2105 MDSTAT_PGRP(mhp, ntick_pgrp);
2112 MDSTAT_INCR(mhp, nnoreclaim);
2123 (void *)mhp, pfn);
2125 mutex_enter(&mhp->mh_mutex);
2135 MDSTAT_INCR(mhp, nnoreclaim);
2136 mutex_enter(&mhp->mh_mutex);
2146 MDSTAT_INCR(mhp, nreloc);
2164 MDSTAT_PGRP(mhp, ntick_pgrp);
2166 MDSTAT_INCR(mhp, nrelocfail);
2176 mutex_enter(&mhp->mh_mutex);
2184 mutex_enter(&mhp->mh_mutex);
2190 (!mhp->mh_cancel)) {
2192 delthr_get_freemem(mhp);
2198 if (mhp->mh_cancel) {
2243 page_delete_collect(tpp, mhp);
2252 if ((mhp->mh_cancel == 0) && (mhp->mh_hold_todo != 0) &&
2262 MDSTAT_INCR(mhp, ndelay);
2264 (void) cv_reltimedwait(&mhp->mh_cv, &mhp->mh_mutex,
2266 CALLB_CPR_SAFE_END(&cprinfo, &mhp->mh_mutex);
2270 mhp->mh_dr_aio_cleanup_cancel = 1;
2271 transit_list_collect(mhp, 0);
2280 MDSTAT_TOTAL(mhp, ntick_total);
2281 MDSTAT_PRINT(mhp);
2288 for (mdsp = mhp->mh_transit.trl_spans; mdsp != NULL;
2298 if (mhp->mh_cancel) {
2317 if (mhp->mh_cancel != 0) {
2323 mhp->mh_hold_todo++;
2334 for (mdsp = mhp->mh_transit.trl_spans; mdsp != NULL;
2345 while (!(mhp->mh_aio_cleanup_done)) {
2348 CALLB_CPR_SAFE_END(&cprinfo, &mhp->mh_mutex);
2351 if (mhp->mh_cancel != 0) {
2354 comp_code = mhp->mh_cancel;
2359 while ((pp = mhp->mh_deleted) != NULL) {
2360 mhp->mh_deleted = pp->p_next;
2361 mhp->mh_hold_todo++;
2362 mutex_exit(&mhp->mh_mutex);
2371 mutex_enter(&mhp->mh_mutex);
2373 ASSERT(mhp->mh_hold_todo == mhp->mh_vm_pages);
2375 mutex_exit(&mhp->mh_mutex);
2376 put_availrmem(mhp->mh_vm_pages);
2377 mutex_enter(&mhp->mh_mutex);
2386 mhp->mh_deleted = NULL;
2388 kphysm_del_cleanup(mhp);
2394 for (mdsp = mhp->mh_transit.trl_spans; mdsp != NULL;
2405 mutex_exit(&mhp->mh_mutex);
2406 kphysm_setup_post_del(mhp->mh_vm_pages,
2408 mutex_enter(&mhp->mh_mutex);
2411 /* mhp->mh_mutex exited by CALLB_CPR_EXIT() */
2412 mhp->mh_state = MHND_DONE;
2413 del_complete_funcp = mhp->mh_delete_complete;
2414 del_complete_arg = mhp->mh_delete_complete_arg;
2430 struct mem_handle *mhp;
2432 mhp = kphysm_lookup_mem_handle(handle);
2433 if (mhp == NULL) {
2436 switch (mhp->mh_state) {
2438 ASSERT(mhp->mh_state != MHND_FREE);
2439 mutex_exit(&mhp->mh_mutex);
2445 mutex_exit(&mhp->mh_mutex);
2448 mutex_exit(&mhp->mh_mutex);
2451 mutex_exit(&mhp->mh_mutex);
2456 (void *)mhp, mhp->mh_state);
2458 mutex_exit(&mhp->mh_mutex);
2462 if (mhp->mh_transit.trl_spans == NULL) {
2463 mutex_exit(&mhp->mh_mutex);
2468 mhp->mh_delete_complete = complete;
2469 mhp->mh_delete_complete_arg = complete_arg;
2470 mhp->mh_state = MHND_STARTING;
2474 mutex_exit(&mhp->mh_mutex);
2481 (void) thread_create(NULL, 0, delete_memory_thread, mhp, 0, &p0,
2641 kphysm_del_cleanup(struct mem_handle *mhp)
2652 avpgs = mhp->mh_vm_pages;
2661 for (mdsp = mhp->mh_transit.trl_spans; mdsp != NULL;
2706 mutex_exit(&mhp->mh_mutex);
2807 mutex_enter(&mhp->mh_mutex);
2815 struct mem_handle *mhp)
2833 pp->p_next = mhp->mh_deleted;
2834 mhp->mh_deleted = pp;
2835 ASSERT(mhp->mh_hold_todo != 0);
2836 mhp->mh_hold_todo--;
2840 transit_list_collect(struct mem_handle *mhp, int v)
2846 mhp->mh_transit.trl_collect = v;
2919 mem_del_stat_print_func(struct mem_handle *mhp)
2925 (uint_t)mhp->mh_transit.trl_spans->mds_base,
2926 (uint_t)mhp->mh_transit.trl_spans->mds_npgs,
2927 (mhp->mh_cancel ? " (cancelled)" : ""));
2928 printf("\t%8u nloop\n", mhp->mh_delstat.nloop);
2929 printf("\t%8u need_free\n", mhp->mh_delstat.need_free);
2930 printf("\t%8u free_loop\n", mhp->mh_delstat.free_loop);
2931 printf("\t%8u free_low\n", mhp->mh_delstat.free_low);
2932 printf("\t%8u free_failed\n", mhp->mh_delstat.free_failed);
2933 printf("\t%8u ncheck\n", mhp->mh_delstat.ncheck);
2934 printf("\t%8u nopaget\n", mhp->mh_delstat.nopaget);
2935 printf("\t%8u lockfail\n", mhp->mh_delstat.lockfail);
2936 printf("\t%8u nfree\n", mhp->mh_delstat.nfree);
2937 printf("\t%8u nreloc\n", mhp->mh_delstat.nreloc);
2938 printf("\t%8u nrelocfail\n", mhp->mh_delstat.nrelocfail);
2939 printf("\t%8u already_done\n", mhp->mh_delstat.already_done);
2940 printf("\t%8u first_notfree\n", mhp->mh_delstat.first_notfree);
2941 printf("\t%8u npplocked\n", mhp->mh_delstat.npplocked);
2942 printf("\t%8u nlockreloc\n", mhp->mh_delstat.nlockreloc);
2943 printf("\t%8u nnorepl\n", mhp->mh_delstat.nnorepl);
2944 printf("\t%8u nmodreloc\n", mhp->mh_delstat.nmodreloc);
2945 printf("\t%8u ndestroy\n", mhp->mh_delstat.ndestroy);
2946 printf("\t%8u nputpage\n", mhp->mh_delstat.nputpage);
2947 printf("\t%8u nnoreclaim\n", mhp->mh_delstat.nnoreclaim);
2948 printf("\t%8u ndelay\n", mhp->mh_delstat.ndelay);
2949 printf("\t%8u demotefail\n", mhp->mh_delstat.demotefail);
2950 printf("\t%8u retired\n", mhp->mh_delstat.retired);
2951 printf("\t%8u toxic\n", mhp->mh_delstat.toxic);
2952 printf("\t%8u failing\n", mhp->mh_delstat.failing);
2953 printf("\t%8u modtoxic\n", mhp->mh_delstat.modtoxic);
2954 printf("\t%8u npplkdtoxic\n", mhp->mh_delstat.npplkdtoxic);
2955 printf("\t%8u gptlmodfail\n", mhp->mh_delstat.gptlmodfail);
2956 printf("\t%8u gptllckfail\n", mhp->mh_delstat.gptllckfail);
2957 tmp = mhp->mh_delstat.nticks_total / hz; /* seconds */
2960 mhp->mh_delstat.nticks_total, tmp / 60, tmp % 60);
2962 tmp = mhp->mh_delstat.nticks_pgrp / hz; /* seconds */
2965 mhp->mh_delstat.nticks_pgrp, tmp / 60, tmp % 60);