MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zone_alloc_sysctl

Function zone_alloc_sysctl

freebsd/vm/uma_core.c:2405–2573  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2403}
2404
2405static void
2406zone_alloc_sysctl(uma_zone_t zone, void *unused)
2407{
2408 uma_zone_domain_t zdom;
2409 uma_domain_t dom;
2410 uma_keg_t keg;
2411 struct sysctl_oid *oid, *domainoid;
2412 int domains, i, cnt;
2413 static const char *nokeg = "cache zone";
2414 char *c;
2415
2416 /*
2417 * Make a sysctl safe copy of the zone name by removing
2418 * any special characters and handling dups by appending
2419 * an index.
2420 */
2421 if (zone->uz_namecnt != 0) {
2422 /* Count the number of decimal digits and '_' separator. */
2423 for (i = 1, cnt = zone->uz_namecnt; cnt != 0; i++)
2424 cnt /= 10;
2425 zone->uz_ctlname = malloc(strlen(zone->uz_name) + i + 1,
2426 M_UMA, M_WAITOK);
2427 sprintf(zone->uz_ctlname, "%s_%d", zone->uz_name,
2428 zone->uz_namecnt);
2429 } else
2430 zone->uz_ctlname = strdup(zone->uz_name, M_UMA);
2431 for (c = zone->uz_ctlname; *c != '\0'; c++)
2432 if (strchr("./\\ -", *c) != NULL)
2433 *c = '_';
2434
2435 /*
2436 * Basic parameters at the root.
2437 */
2438 zone->uz_oid = SYSCTL_ADD_NODE(NULL, SYSCTL_STATIC_CHILDREN(_vm_uma),
2439 OID_AUTO, zone->uz_ctlname, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "");
2440 oid = zone->uz_oid;
2441 SYSCTL_ADD_U32(NULL, SYSCTL_CHILDREN(oid), OID_AUTO,
2442 "size", CTLFLAG_RD, &zone->uz_size, 0, "Allocation size");
2443 SYSCTL_ADD_PROC(NULL, SYSCTL_CHILDREN(oid), OID_AUTO,
2444 "flags", CTLFLAG_RD | CTLTYPE_STRING | CTLFLAG_MPSAFE,
2445 zone, 0, sysctl_handle_uma_zone_flags, "A",
2446 "Allocator configuration flags");
2447 SYSCTL_ADD_U16(NULL, SYSCTL_CHILDREN(oid), OID_AUTO,
2448 "bucket_size", CTLFLAG_RD, &zone->uz_bucket_size, 0,
2449 "Desired per-cpu cache size");
2450 SYSCTL_ADD_U16(NULL, SYSCTL_CHILDREN(oid), OID_AUTO,
2451 "bucket_size_max", CTLFLAG_RD, &zone->uz_bucket_size_max, 0,
2452 "Maximum allowed per-cpu cache size");
2453
2454 /*
2455 * keg if present.
2456 */
2457 if ((zone->uz_flags & UMA_ZFLAG_HASH) == 0)
2458 domains = vm_ndomains;
2459 else
2460 domains = 1;
2461 oid = SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(zone->uz_oid), OID_AUTO,
2462 "keg", CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "");

Callers 1

zone_ctorFunction · 0.85

Calls 4

mallocFunction · 0.85
sprintfFunction · 0.85
strdupFunction · 0.85
strchrFunction · 0.85

Tested by

no test coverage detected