diff options
author | nwhitehorn <nwhitehorn@FreeBSD.org> | 2016-07-06 14:09:49 +0000 |
---|---|---|
committer | nwhitehorn <nwhitehorn@FreeBSD.org> | 2016-07-06 14:09:49 +0000 |
commit | 89d01c24d15d07f044ec78b4f662e6df23069c91 (patch) | |
tree | 9241a6d42fe0265d4c88af6ad2c2c916b4f9f0d3 /sys/net | |
parent | 6716d2f9c59a7e486e25adf6deb45918be1898ef (diff) | |
download | FreeBSD-src-89d01c24d15d07f044ec78b4f662e6df23069c91.zip FreeBSD-src-89d01c24d15d07f044ec78b4f662e6df23069c91.tar.gz |
Replace a number of conflations of mp_ncpus and mp_maxid with either
mp_maxid or CPU_FOREACH() as appropriate. This fixes a number of places in
the kernel that assumed CPU IDs are dense in [0, mp_ncpus) and would try,
for example, to run tasks on CPUs that did not exist or to allocate too
few buffers on systems with sparse CPU IDs in which there are holes in the
range and mp_maxid > mp_ncpus. Such circumstances generally occur on
systems with SMT, but on which SMT is disabled. This patch restores system
operation at least on POWER8 systems configured in this way.
There are a number of other places in the kernel with potential problems
in these situations, but where sparse CPU IDs are not currently known
to occur, mostly in the ARM machine-dependent code. These will be fixed
in a follow-up commit after the stable/11 branch.
PR: kern/210106
Reviewed by: jhb
Approved by: re (glebius)
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/flowtable.c | 2 | ||||
-rw-r--r-- | sys/net/iflib.c | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/sys/net/flowtable.c b/sys/net/flowtable.c index b837a8e..48f7ff0 100644 --- a/sys/net/flowtable.c +++ b/sys/net/flowtable.c @@ -746,7 +746,7 @@ flowtable_alloc(struct flowtable *ft) ft->ft_table[i] = uma_zalloc(pcpu_zone_ptr, M_WAITOK | M_ZERO); ft->ft_masks = uma_zalloc(pcpu_zone_ptr, M_WAITOK); - for (int i = 0; i < mp_ncpus; i++) { + CPU_FOREACH(i) { bitstr_t **b; b = zpcpu_get_cpu(ft->ft_masks, i); diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 955a1b2..67282b7 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -3848,7 +3848,7 @@ iflib_queues_alloc(if_ctx_t ctx) iflib_txq_t txq; iflib_rxq_t rxq; iflib_fl_t fl = NULL; - int i, j, err, txconf, rxconf, fl_ifdi_offset; + int i, j, cpu, err, txconf, rxconf, fl_ifdi_offset; iflib_dma_info_t ifdip; uint32_t *rxqsizes = sctx->isc_rxqsizes; uint32_t *txqsizes = sctx->isc_txqsizes; @@ -3897,7 +3897,7 @@ iflib_queues_alloc(if_ctx_t ctx) /* * XXX handle allocation failure */ - for (txconf = i = 0; i < ntxqsets; i++, txconf++, txq++) { + for (txconf = i = 0, cpu = CPU_FIRST(); i < ntxqsets; i++, txconf++, txq++, cpu = CPU_NEXT(cpu)) { /* Set up some basics */ if ((ifdip = malloc(sizeof(struct iflib_dma_info) * ntxqs, M_IFLIB, M_WAITOK|M_ZERO)) == NULL) { @@ -3917,8 +3917,8 @@ iflib_queues_alloc(if_ctx_t ctx) txq->ift_ctx = ctx; txq->ift_id = i; /* XXX fix this */ - txq->ift_timer.c_cpu = i % mp_ncpus; - txq->ift_db_check.c_cpu = i % mp_ncpus; + txq->ift_timer.c_cpu = cpu; + txq->ift_db_check.c_cpu = cpu; txq->ift_nbr = nbuf_rings; if (iflib_txsd_alloc(txq)) { |