[ofa-general] [PATCH] opensm: is_new osm_port_t field instead of new_ports_list

Sasha Khapyorsky sashak at voltaire.com
Sun Aug 12 13:50:38 PDT 2007


Use is_new osm_port_t field instead of maintaining separate
new_ports_list list. Finally it prevents per port list scans.
It is simpler, faster and safer.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 opensm/include/opensm/osm_port.h   |    1 +
 opensm/include/opensm/osm_subnet.h |    5 ----
 opensm/opensm/osm_drop_mgr.c       |   21 ------------------
 opensm/opensm/osm_lid_mgr.c        |   14 ++---------
 opensm/opensm/osm_node_info_rcv.c  |   41 +++--------------------------------
 opensm/opensm/osm_state_mgr.c      |   21 ++++++++++--------
 opensm/opensm/osm_subnet.c         |    5 ----
 7 files changed, 20 insertions(+), 88 deletions(-)

diff --git a/opensm/include/opensm/osm_port.h b/opensm/include/opensm/osm_port.h
index 44323ab..b5acd7f 100644
--- a/opensm/include/opensm/osm_port.h
+++ b/opensm/include/opensm/osm_port.h
@@ -1284,6 +1284,7 @@ typedef struct _osm_port
 	struct _osm_node		*p_node;
 	ib_net64_t			guid;
 	uint32_t			discovery_count;
+	unsigned			is_new;
 	osm_physp_t			*p_physp;
 	cl_qlist_t			mcm_list;
 } osm_port_t;
diff --git a/opensm/include/opensm/osm_subnet.h b/opensm/include/opensm/osm_subnet.h
index 84ed6d4..e8b9f96 100644
--- a/opensm/include/opensm/osm_subnet.h
+++ b/opensm/include/opensm/osm_subnet.h
@@ -567,7 +567,6 @@ typedef struct _osm_subn
   boolean_t                subnet_initialization_error;
   boolean_t                force_immediate_heavy_sweep;
   boolean_t                force_delayed_heavy_sweep;
-  cl_list_t		   new_ports_list;
   boolean_t                in_sweep_hop_0;
   boolean_t                moved_to_master_state;
   boolean_t                first_time_master_sweep;
@@ -675,10 +674,6 @@ typedef struct _osm_subn
 *     If we had some trouble on the subnet, that caused a strange dropping
 *     of ports - we will try to do another heavy sweep on our next sweep.
 *
-*  new_ports_list
-*     Container of pointers to port objects that were discovered for
-*     the first time during a current sweep.
-*
 *  in_sweep_hop_0
 *     When in_sweep_hop_0 flag is set to TRUE - this means we are
 *     in sweep_hop_0 - meaning we do not want to continue beyond
diff --git a/opensm/opensm/osm_drop_mgr.c b/opensm/opensm/osm_drop_mgr.c
index 2b9bfac..f61769b 100644
--- a/opensm/opensm/osm_drop_mgr.c
+++ b/opensm/opensm/osm_drop_mgr.c
@@ -217,8 +217,6 @@ __osm_drop_mgr_remove_port(
 {
   ib_net64_t port_guid;
   osm_port_t *p_port_check;
-  cl_list_t* p_new_ports_list;
-  cl_list_iterator_t cl_list_item;
   cl_qmap_t* p_sm_guid_tbl;
   osm_mcm_info_t* p_mcm;
   osm_mgrp_t*  p_mgrp;
@@ -240,25 +238,6 @@ __osm_drop_mgr_remove_port(
            "Unreachable port 0x%016" PRIx64 "\n",
            cl_ntoh64( port_guid ) );
 
-  /*
-    Remove this port from the new_ports_list, if it exists there.
-    Remove this port from the guid and LID tables.
-    Remove also from the sm guid table - if the object
-    exists there.
-  */
-  p_new_ports_list = &p_mgr->p_subn->new_ports_list;
-  cl_list_item = cl_list_head(p_new_ports_list);
-  while( cl_list_item != cl_list_end(p_new_ports_list) )
-  {
-    if ( (osm_port_t*)(cl_list_obj(cl_list_item)) == p_port )
-    {
-      /* Found the port in the new_ports_list. Remove it from there. */
-      cl_list_remove_item(p_new_ports_list, cl_list_item);
-      break;
-    }
-    cl_list_item = cl_list_next(cl_list_item);
-  }
-
   p_port_check = (osm_port_t*)cl_qmap_remove( &p_mgr->p_subn->port_guid_tbl,
                                               port_guid );
   if( p_port_check != p_port )
diff --git a/opensm/opensm/osm_lid_mgr.c b/opensm/opensm/osm_lid_mgr.c
index f1f4707..a99c7c1 100644
--- a/opensm/opensm/osm_lid_mgr.c
+++ b/opensm/opensm/osm_lid_mgr.c
@@ -967,7 +967,6 @@ __osm_lid_mgr_set_physp_pi(
   uint8_t               op_vls;
   uint8_t               port_num;
   boolean_t             send_set = FALSE;
-  boolean_t             new_port = FALSE;
 
   OSM_LOG_ENTER( p_mgr->p_log, __osm_lid_mgr_set_physp_pi );
 
@@ -1214,17 +1213,10 @@ __osm_lid_mgr_set_physp_pi(
     We need to set the cli_rereg bit when we are in first_time_master_sweep for
     ports supporting the ClientReregistration Vol1 (v1.2) p811 14.4.11
     Also, if this port was just now discovered, then we should also set the
-    cli_rereg bit. We know that the port was just discovered if it is in
-    the p_subn->new_ports_list list.
+    cli_rereg bit. We know that the port was just discovered if its is_new
+    field is set.
   */
-  if ( cl_is_object_in_list(&p_mgr->p_subn->new_ports_list, p_port) )
-  {
-    /* p_port is in new_ports_list, mark new_port as TRUE */
-    new_port = TRUE;
-  }
-
-  if ( ( p_mgr->p_subn->first_time_master_sweep == TRUE ||
-         new_port == TRUE ) &&
+  if ( ( p_mgr->p_subn->first_time_master_sweep == TRUE || p_port->is_new ) &&
        !p_mgr->p_subn->opt.no_clients_rereg &&
        ( (p_old_pi->capability_mask & IB_PORT_CAP_HAS_CLIENT_REREG) != 0 ) )
     ib_port_info_set_client_rereg( p_pi, 1 );
diff --git a/opensm/opensm/osm_node_info_rcv.c b/opensm/opensm/osm_node_info_rcv.c
index 53bc051..72245ce 100644
--- a/opensm/opensm/osm_node_info_rcv.c
+++ b/opensm/opensm/osm_node_info_rcv.c
@@ -441,7 +441,6 @@ __osm_ni_rcv_process_existing_ca_or_router(
   ib_api_status_t status;
   osm_dr_path_t *p_dr_path;
   osm_bind_handle_t h_bind;
-  cl_status_t cl_status;
 
   OSM_LOG_ENTER( p_rcv->p_log, __osm_ni_rcv_process_existing_ca_or_router );
 
@@ -495,29 +494,14 @@ __osm_ni_rcv_process_existing_ca_or_router(
     }
 
     /* If we are a master, then this means the port is new on the subnet.
-       Add it to the new_ports_list - need to send trap 64 on these ports.
+       Mark it as new - need to send trap 64 on these ports.
        The condition that we are master is true, since if we are in discovering
        state (meaning we woke up from standby or we are just initializing),
        then these ports may be new to us, but are not new on the subnet.
        If we are master, then the subnet as we know it is the updated one,
        and any new ports we encounter should cause trap 64. C14-72.1.1 */
     if ( p_rcv->p_subn->sm_state == IB_SMINFO_STATE_MASTER )
-    {
-      cl_status = cl_list_insert_tail( &p_rcv->p_subn->new_ports_list, p_port );
-      if( cl_status != CL_SUCCESS )
-      {
-        osm_log( p_rcv->p_log, OSM_LOG_ERROR,
-                 "__osm_ni_rcv_process_existing_ca_or_router: ERR 0D08: "
-                 "Error %s adding to list\n",
-                 CL_STATUS_MSG( cl_status ) );
-        osm_port_delete( &p_port );
-        goto Exit;
-      }
-      osm_log( p_rcv->p_log, OSM_LOG_DEBUG,
-               "__osm_ni_rcv_process_existing_ca_or_router: "
-               "Adding port GUID:0x%016" PRIx64 " to new_ports_list\n",
-               cl_ntoh64(osm_node_get_node_guid( p_port->p_node )) );
-    }
+      p_port->is_new = 1;
 
     p_physp = osm_node_get_physp_ptr( p_node, port_num );
   }
@@ -690,7 +674,6 @@ __osm_ni_rcv_process_new(
   ib_smp_t *p_smp;
   osm_ni_context_t *p_ni_context;
   uint8_t port_num;
-  cl_status_t status;
 
   OSM_LOG_ENTER( p_rcv->p_log, __osm_ni_rcv_process_new );
 
@@ -760,30 +743,14 @@ __osm_ni_rcv_process_new(
   }
 
   /* If we are a master, then this means the port is new on the subnet.
-     Add it to the new_ports_list - need to send trap 64 on these ports.
+     Mark it as new - need to send trap 64 on these ports.
      The condition that we are master is true, since if we are in discovering
      state (meaning we woke up from standby or we are just initializing),
      then these ports may be new to us, but are not new on the subnet.
      If we are master, then the subnet as we know it is the updated one,
      and any new ports we encounter should cause trap 64. C14-72.1.1 */
   if ( p_rcv->p_subn->sm_state == IB_SMINFO_STATE_MASTER )
-  {
-    status = cl_list_insert_tail( &p_rcv->p_subn->new_ports_list, p_port );
-    if( status != CL_SUCCESS )
-    {
-      osm_log( p_rcv->p_log, OSM_LOG_ERROR,
-               "__osm_ni_rcv_process_new: ERR 0D05: "
-               "Error %s adding to new_ports_list\n",
-               CL_STATUS_MSG( status ) );
-      osm_port_delete( &p_port );
-      osm_node_delete( &p_node );
-      goto Exit;
-    }
-    osm_log( p_rcv->p_log, OSM_LOG_DEBUG,
-             "__osm_ni_rcv_process_new: "
-             "Adding port GUID:0x%016" PRIx64 " to new_ports_list\n",
-             cl_ntoh64( osm_node_get_node_guid( p_port->p_node ) ) );
-  }
+    p_port->is_new = 1;
 
   /* If there were RouterInfo or other router attribute,
      this would be elsewhere */
diff --git a/opensm/opensm/osm_state_mgr.c b/opensm/opensm/osm_state_mgr.c
index c64c21a..17b66d7 100644
--- a/opensm/opensm/osm_state_mgr.c
+++ b/opensm/opensm/osm_state_mgr.c
@@ -1630,28 +1630,33 @@ __osm_state_mgr_send_handover(
 }
 
 /**********************************************************************
- * Send Trap 64 on all ports in new_ports_list.
+ * Send Trap 64 on all new ports.
  **********************************************************************/
 static void
 __osm_state_mgr_report_new_ports(
    IN osm_state_mgr_t * const p_mgr )
 {
-   osm_port_t *p_port;
    ib_gid_t port_gid;
    ib_mad_notice_attr_t notice;
    ib_api_status_t status;
    ib_net64_t port_guid;
+   cl_map_item_t *p_next;
+   osm_port_t *p_port;
    uint16_t min_lid_ho;
    uint16_t max_lid_ho;
 
    OSM_LOG_ENTER( p_mgr->p_log, __osm_state_mgr_report_new_ports );
 
    CL_PLOCK_ACQUIRE( p_mgr->p_lock );
-   p_port =
-      ( osm_port_t
-        * ) ( cl_list_remove_head( &p_mgr->p_subn->new_ports_list ) );
-   while( p_port != NULL )
+   p_next = cl_qmap_head(&p_mgr->p_subn->port_guid_tbl);
+   while (p_next != cl_qmap_end(&p_mgr->p_subn->port_guid_tbl))
    {
+      p_port = (osm_port_t *)p_next;
+      p_next = cl_qmap_next(p_next);
+
+      if (!p_port->is_new)
+         continue;
+
       port_guid = osm_port_get_guid( p_port );
       /* issue a notice - trap 64 */
 
@@ -1692,9 +1697,7 @@ __osm_state_mgr_report_new_ports(
                min_lid_ho, max_lid_ho,
                p_port->p_node ? p_port->p_node->print_desc : "UNKNOWN" );
 
-      p_port =
-         ( osm_port_t
-           * ) ( cl_list_remove_head( &p_mgr->p_subn->new_ports_list ) );
+      p_port->is_new = 0;
    }
    CL_PLOCK_RELEASE( p_mgr->p_lock );
 
diff --git a/opensm/opensm/osm_subnet.c b/opensm/opensm/osm_subnet.c
index 7e7a4d5..f95864c 100644
--- a/opensm/opensm/osm_subnet.c
+++ b/opensm/opensm/osm_subnet.c
@@ -95,8 +95,6 @@ osm_subn_construct(
   cl_qmap_init( &p_subn->rtr_guid_tbl );
   cl_qmap_init( &p_subn->prtn_pkey_tbl );
   cl_qmap_init( &p_subn->mgrp_mlid_tbl );
-  cl_list_construct( &p_subn->new_ports_list );
-  cl_list_init( &p_subn->new_ports_list, 10 );
   cl_list_construct( &p_subn->light_sweep_physp_list );
   cl_list_init( &p_subn->light_sweep_physp_list, 5 );
 }
@@ -172,9 +170,6 @@ osm_subn_destroy(
     osm_infr_delete( p_infr );
   }
 
-  cl_list_remove_all( &p_subn->new_ports_list );
-  cl_list_destroy( &p_subn->new_ports_list );
-
   cl_list_remove_all( &p_subn->light_sweep_physp_list );
   cl_list_destroy( &p_subn->light_sweep_physp_list );
 
-- 
1.5.3.rc2.38.g11308




More information about the general mailing list