Print this page
patch vm-cleanup


1159                 /*
1160                  * This block has already been removed from the zulu_hat,
1161                  * it's on a free list waiting for our thread to release
1162                  * a mutex so it can be freed
1163                  */
1164                 do_delete = 0;
1165 
1166                 TNF_PROBE_0(zulu_hat_pageunload_skip, "zulu_hat",
1167                     /* CSTYLED */);
1168         }
1169         mutex_exit(&zhat->lock);
1170 
1171         if (do_delete) {
1172                 (void) xhat_delete_xhatblk(xblk, 1);
1173         }
1174 
1175         return (0);
1176 }
1177 
1178 static void
1179 zulu_hat_swapout(struct xhat *xhat)
1180 {
1181         struct zulu_hat *zhat = (struct zulu_hat *)xhat;
1182         struct zulu_hat_blk *zblk;
1183         struct zulu_hat_blk *free_list = NULL;
1184         int     i;
1185         int     nblks = 0;
1186 
1187         TNF_PROBE_1(zulu_hat_swapout, "zulu_hat", /* CSTYLED */,
1188                 tnf_int, zulu_ctx, zhat->zulu_ctx);
1189 
1190         mutex_enter(&zhat->lock);
1191 
1192         /*
1193          * real swapout calls are rare so we don't do anything in
1194          * particular to optimize them.
1195          *
1196          * Just loop over all buckets in the hash table and free each
1197          * zblk.
1198          */
1199         for (i = 0; i < ZULU_HASH_TBL_NUM; i++) {
1200                 struct zulu_hat_blk *next;
1201                 for (zblk = zhat->hash_tbl[i]; zblk != NULL; zblk = next) {
1202                         next = zblk->zulu_hash_next;
1203                         zulu_hat_remove_map(zhat, zblk);
1204                         add_to_free_list(&free_list, zblk);
1205                         nblks++;
1206                 }
1207         }
1208 
1209         /*
1210          * remove all mappings for this context from zulu hardware.
1211          */
1212         zulu_hat_demap_ctx(zhat->zdev, zhat->zulu_ctx);
1213 
1214         mutex_exit(&zhat->lock);
1215 
1216         free_zblks(free_list);
1217 
1218         TNF_PROBE_1(zulu_hat_swapout_done, "zulu_hat", /* CSTYLED */,
1219                 tnf_int, nblks, nblks);
1220 }
1221 
1222 
1223 static void
1224 zulu_hat_unshare(struct xhat *xhat, caddr_t vaddr, size_t size)
1225 {
1226         TNF_PROBE_0(zulu_hat_unshare, "zulu_hat", /* CSTYLED */);
1227 
1228         zulu_hat_unload(xhat, vaddr, size, 0);
1229 }
1230 
1231 /*
1232  * Functions to manage changes in protections for mappings.
1233  *
1234  * These are rarely called in normal operation so for now just unload
1235  * the region.
1236  * If the mapping is still needed, it will fault in later with the new
1237  * attrributes.
1238  */
1239 typedef enum {
1240         ZULU_HAT_CHGATTR,
1241         ZULU_HAT_SETATTR,
1242         ZULU_HAT_CLRATTR
1243 } zulu_hat_prot_op;


1295 {
1296         struct zulu_hat *zhat = (struct zulu_hat *)xhat;
1297         TNF_PROBE_3(zulu_hat_chgattr, "zulu_hat", /* CSTYLED */,
1298             tnf_int, ctx, zhat->zulu_ctx,
1299             tnf_opaque, vaddr, vaddr,
1300             tnf_opaque, flags, flags);
1301 #ifdef DEBUG
1302         printf("zulu_hat_chgattr: ctx: %d addr: %lx, size: %lx flags: %x\n",
1303             zhat->zulu_ctx, (uint64_t)vaddr, size, flags);
1304 #endif
1305         zulu_hat_update_attr(xhat, vaddr, size, flags, ZULU_HAT_CHGATTR);
1306 }
1307 
1308 
1309 struct xhat_ops zulu_hat_ops = {
1310         zulu_hat_alloc,         /* xhat_alloc */
1311         zulu_hat_free,          /* xhat_free */
1312         zulu_hat_free_start,    /* xhat_free_start */
1313         NULL,                   /* xhat_free_end */
1314         NULL,                   /* xhat_dup */
1315         NULL,                   /* xhat_swapin */
1316         zulu_hat_swapout,       /* xhat_swapout */
1317         zulu_hat_memload,       /* xhat_memload */
1318         zulu_hat_memload_array, /* xhat_memload_array */
1319         zulu_hat_devload,       /* xhat_devload */
1320         zulu_hat_unload,        /* xhat_unload */
1321         zulu_hat_unload_callback, /* xhat_unload_callback */
1322         zulu_hat_setattr,       /* xhat_setattr */
1323         zulu_hat_clrattr,       /* xhat_clrattr */
1324         zulu_hat_chgattr,       /* xhat_chgattr */
1325         zulu_hat_unshare,       /* xhat_unshare */
1326         zulu_hat_chgprot,       /* xhat_chgprot */
1327         zulu_hat_pageunload,    /* xhat_pageunload */
1328 };
1329 
1330 xblk_cache_t zulu_xblk_cache = {
1331     NULL,
1332     NULL,
1333     NULL,
1334     xhat_xblkcache_reclaim
1335 };
1336 




1159                 /*
1160                  * This block has already been removed from the zulu_hat,
1161                  * it's on a free list waiting for our thread to release
1162                  * a mutex so it can be freed
1163                  */
1164                 do_delete = 0;
1165 
1166                 TNF_PROBE_0(zulu_hat_pageunload_skip, "zulu_hat",
1167                     /* CSTYLED */);
1168         }
1169         mutex_exit(&zhat->lock);
1170 
1171         if (do_delete) {
1172                 (void) xhat_delete_xhatblk(xblk, 1);
1173         }
1174 
1175         return (0);
1176 }
1177 
1178 static void













































1179 zulu_hat_unshare(struct xhat *xhat, caddr_t vaddr, size_t size)
1180 {
1181         TNF_PROBE_0(zulu_hat_unshare, "zulu_hat", /* CSTYLED */);
1182 
1183         zulu_hat_unload(xhat, vaddr, size, 0);
1184 }
1185 
1186 /*
1187  * Functions to manage changes in protections for mappings.
1188  *
1189  * These are rarely called in normal operation so for now just unload
1190  * the region.
1191  * If the mapping is still needed, it will fault in later with the new
1192  * attrributes.
1193  */
1194 typedef enum {
1195         ZULU_HAT_CHGATTR,
1196         ZULU_HAT_SETATTR,
1197         ZULU_HAT_CLRATTR
1198 } zulu_hat_prot_op;


1250 {
1251         struct zulu_hat *zhat = (struct zulu_hat *)xhat;
1252         TNF_PROBE_3(zulu_hat_chgattr, "zulu_hat", /* CSTYLED */,
1253             tnf_int, ctx, zhat->zulu_ctx,
1254             tnf_opaque, vaddr, vaddr,
1255             tnf_opaque, flags, flags);
1256 #ifdef DEBUG
1257         printf("zulu_hat_chgattr: ctx: %d addr: %lx, size: %lx flags: %x\n",
1258             zhat->zulu_ctx, (uint64_t)vaddr, size, flags);
1259 #endif
1260         zulu_hat_update_attr(xhat, vaddr, size, flags, ZULU_HAT_CHGATTR);
1261 }
1262 
1263 
1264 struct xhat_ops zulu_hat_ops = {
1265         zulu_hat_alloc,         /* xhat_alloc */
1266         zulu_hat_free,          /* xhat_free */
1267         zulu_hat_free_start,    /* xhat_free_start */
1268         NULL,                   /* xhat_free_end */
1269         NULL,                   /* xhat_dup */


1270         zulu_hat_memload,       /* xhat_memload */
1271         zulu_hat_memload_array, /* xhat_memload_array */
1272         zulu_hat_devload,       /* xhat_devload */
1273         zulu_hat_unload,        /* xhat_unload */
1274         zulu_hat_unload_callback, /* xhat_unload_callback */
1275         zulu_hat_setattr,       /* xhat_setattr */
1276         zulu_hat_clrattr,       /* xhat_clrattr */
1277         zulu_hat_chgattr,       /* xhat_chgattr */
1278         zulu_hat_unshare,       /* xhat_unshare */
1279         zulu_hat_chgprot,       /* xhat_chgprot */
1280         zulu_hat_pageunload,    /* xhat_pageunload */
1281 };
1282 
1283 xblk_cache_t zulu_xblk_cache = {
1284     NULL,
1285     NULL,
1286     NULL,
1287     xhat_xblkcache_reclaim
1288 };
1289