mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
dpif-netdev: Fix unsafe access to pmd polling lists.
All accesses to 'pmd->poll_list' should be guarded by
'pmd->port_mutex'. Additionally fixed inappropriate usage
of 'HMAP_FOR_EACH_SAFE' (hmap doesn't change in a loop)
and dropped not needed local variable 'proc_cycles'.
CC: Nitin Katiyar <nitin.katiyar@ericsson.com>
Fixes: 5bf8428248
("Adding support for PMD auto load balancing")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Acked-by: Aaron Conole <aconole@redhat.com>
This commit is contained in:
@@ -5098,7 +5098,7 @@ pmd_rebalance_dry_run(struct dp_netdev *dp)
|
||||
uint64_t improvement = 0;
|
||||
uint32_t num_pmds;
|
||||
uint32_t *pmd_corelist;
|
||||
struct rxq_poll *poll, *poll_next;
|
||||
struct rxq_poll *poll;
|
||||
bool ret;
|
||||
|
||||
num_pmds = cmap_count(&dp->poll_threads);
|
||||
@@ -5124,13 +5124,14 @@ pmd_rebalance_dry_run(struct dp_netdev *dp)
|
||||
/* Estimate the cycles to cover all intervals. */
|
||||
total_cycles *= PMD_RXQ_INTERVAL_MAX;
|
||||
|
||||
HMAP_FOR_EACH_SAFE (poll, poll_next, node, &pmd->poll_list) {
|
||||
uint64_t proc_cycles = 0;
|
||||
ovs_mutex_lock(&pmd->port_mutex);
|
||||
HMAP_FOR_EACH (poll, node, &pmd->poll_list) {
|
||||
for (unsigned i = 0; i < PMD_RXQ_INTERVAL_MAX; i++) {
|
||||
proc_cycles += dp_netdev_rxq_get_intrvl_cycles(poll->rxq, i);
|
||||
total_proc += dp_netdev_rxq_get_intrvl_cycles(poll->rxq, i);
|
||||
}
|
||||
total_proc += proc_cycles;
|
||||
}
|
||||
ovs_mutex_unlock(&pmd->port_mutex);
|
||||
|
||||
if (total_proc) {
|
||||
curr_pmd_usage[num_pmds] = (total_proc * 100) / total_cycles;
|
||||
}
|
||||
|
Reference in New Issue
Block a user