tmpfs round robin page allocation & finer grained iflib affinity ctrl

This commit is contained in:
quackerd 2022-11-21 14:35:29 +01:00
parent c8c2762402
commit 3a3649ec3f
2 changed files with 21 additions and 9 deletions

View File

@ -96,6 +96,7 @@ tmpfs_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
vm_object_deallocate(object);
object = NULL;
}
object->domain.dr_policy = DOMAINSET_RR();
return (object);
}

View File

@ -594,7 +594,14 @@ SYSCTL_INT(_net_iflib, OID_AUTO, timer_default, CTLFLAG_RW,
#define IFLIB_CPU_OVERRIDE_MAX_SIZE (256)
static char iflib_override_cpu_bdfs[IFLIB_CPU_OVERRIDE_MAX_SIZE] = "";
SYSCTL_STRING(_net_iflib, OID_AUTO, override_cpu_bdfs, CTLFLAG_RWTUN,
iflib_override_cpu_bdfs, sizeof(iflib_override_cpu_bdfs), "a device's bdfs identifier to affinitze to all cpus");
iflib_override_cpu_bdfs, sizeof(iflib_override_cpu_bdfs), "a device's bdfs identifier to affinitze to a subset of cores");
#define IFLIB_CPU_LIST_MAX_SIZE (256)
static int iflib_override_cpu_base = 0;
SYSCTL_INT(_net_iflib, OID_AUTO, override_cpu_base, CTLFLAG_RWTUN,
&iflib_override_cpu_base, 0, "the base cpu for the the subset of cores");
static int iflib_override_cpu_stride = 2;
SYSCTL_INT(_net_iflib, OID_AUTO, override_cpu_stride, CTLFLAG_RWTUN,
&iflib_override_cpu_stride, 0, "the stride for the the subset of cores");
#if IFLIB_DEBUG_COUNTERS
@ -5015,6 +5022,7 @@ iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ct
kobj_method_t *kobj_method;
int err, msix, rid;
int num_txd, num_rxd;
int cpu_count;
unsigned int bus = pci_get_bus(dev);
unsigned int device = pci_get_slot(dev);
unsigned int function = pci_get_function(dev);
@ -5116,15 +5124,18 @@ iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ct
NULL, NULL, "admin");
if (strcmp(iflib_override_cpu_bdfs, bdf_str) == 0) {
cpuset_t cset;
device_printf(dev, "override cpu to all cpus\n");
CPU_COPY(&all_cpus, &ctx->ifc_cpus);
CPU_ZERO(&cset);
for (int i = 0; i < 32; i++) {
CPU_SET(i*2, &cset);
CPU_ZERO(&ctx->ifc_cpus);
cpu_count = CPU_COUNT(&all_cpus);
if (iflib_override_cpu_stride <= 0) {
device_printf(dev, "invalid cpu stride %d detected, resetting to 2\n", iflib_override_cpu_stride);
iflib_override_cpu_stride = 2;
}
CPU_AND(&ctx->ifc_cpus, &ctx->ifc_cpus, &cset);
ctx->ifc_cpus_are_physical_cores = true;
device_printf(dev, "overriding core affinty to base %d, stride %d, total cores %d\n", iflib_override_cpu_base, iflib_override_cpu_stride, cpu_count);
for (int i = iflib_override_cpu_base; i < cpu_count; i+= iflib_override_cpu_stride) {
device_printf(dev, "setting affinty to core %d\n", i);
CPU_SET(i, &ctx->ifc_cpus);
}
ctx->ifc_cpus_are_physical_cores = false;
}
/* Set up cpu set. If it fails, use the set of all CPUs. */
else if (bus_get_cpus(dev, INTR_CPUS, sizeof(ctx->ifc_cpus), &ctx->ifc_cpus) != 0) {