[ovs-dev] [PATCH v3 10/18] dpif-netdev: Make 'static_tx_qid' const.

Daniele Di Proietto diproiettod at vmware.com
Mon Jan 9 03:15:08 UTC 2017


Since previous commit, 'static_tx_qid' doesn't need to be atomic and is
actually never touched (except for initialization), so it can be made
const.

Signed-off-by: Daniele Di Proietto <diproiettod at vmware.com>
---
 lib/dpif-netdev.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 432bac814..436f945b7 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -496,7 +496,7 @@ struct dp_netdev_pmd_thread {
     /* Queue id used by this pmd thread to send packets on all netdevs if
      * XPS disabled for this netdev. All static_tx_qid's are unique and less
      * than 'ovs_numa_get_n_cores() + 1'. */
-    atomic_int static_tx_qid;
+    const int static_tx_qid;
 
     struct ovs_mutex port_mutex;    /* Mutex for 'poll_list' and 'tx_ports'. */
     /* List of rx queues to poll. */
@@ -3286,10 +3286,9 @@ dp_netdev_configure_pmd(struct dp_netdev_pmd_thread *pmd, struct dp_netdev *dp,
     pmd->numa_id = numa_id;
     pmd->poll_cnt = 0;
 
-    atomic_init(&pmd->static_tx_qid,
-                (core_id == NON_PMD_CORE_ID)
-                ? ovs_numa_get_n_cores()
-                : get_n_pmd_threads(dp));
+    *CONST_CAST(int *, &pmd->static_tx_qid) = (core_id == NON_PMD_CORE_ID)
+                                              ? ovs_numa_get_n_cores()
+                                              : get_n_pmd_threads(dp);
 
     ovs_refcount_init(&pmd->ref_cnt);
     latch_init(&pmd->exit_latch);
@@ -4394,7 +4393,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
             if (dynamic_txqs) {
                 tx_qid = dpif_netdev_xps_get_tx_qid(pmd, p, now);
             } else {
-                atomic_read_relaxed(&pmd->static_tx_qid, &tx_qid);
+                tx_qid = pmd->static_tx_qid;
             }
 
             netdev_send(p->port->netdev, tx_qid, packets_, may_steal,
-- 
2.11.0



More information about the dev mailing list