From patchwork Thu Oct 15 13:34:45 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 54020 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9FDgrH2023917 for ; Thu, 15 Oct 2009 13:42:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762769AbZJONhI (ORCPT ); Thu, 15 Oct 2009 09:37:08 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1762764AbZJONhI (ORCPT ); Thu, 15 Oct 2009 09:37:08 -0400 Received: from qmta13.westchester.pa.mail.comcast.net ([76.96.59.243]:33418 "EHLO QMTA13.westchester.pa.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762769AbZJONhG (ORCPT ); Thu, 15 Oct 2009 09:37:06 -0400 Received: from OMTA11.westchester.pa.mail.comcast.net ([76.96.62.36]) by QMTA13.westchester.pa.mail.comcast.net with comcast id szXz1c0020mv7h05D1cW6y; Thu, 15 Oct 2009 13:36:30 +0000 Received: from hal.comcast.net ([75.69.247.31]) by OMTA11.westchester.pa.mail.comcast.net with comcast id t1cW1c0020hNrtn3X1cW56; Thu, 15 Oct 2009 13:36:30 +0000 Received: from hal.comcast.net (localhost.localdomain [127.0.0.1]) by hal.comcast.net (8.14.3/8.14.3) with ESMTP id n9FDb2Tk008083; Thu, 15 Oct 2009 09:37:08 -0400 Received: (from hnrose@localhost) by hal.comcast.net (8.14.3/8.14.3/Submit) id n9FDYk5u008044; Thu, 15 Oct 2009 09:34:46 -0400 Date: Thu, 15 Oct 2009 09:34:45 -0400 From: Hal Rosenstock To: sashak@voltaire.com Cc: linux-rdma@vger.kernel.org Subject: [PATCH] opensm/osm_ucast_updn.c: Further reduction in cas_per_sw memory allocation Message-ID: <20091015133445.GA8041@comcast.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/opensm/opensm/osm_ucast_updn.c b/opensm/opensm/osm_ucast_updn.c index ced076a..c46b033 100644 --- a/opensm/opensm/osm_ucast_updn.c +++ b/opensm/opensm/osm_ucast_updn.c @@ -424,7 +424,7 @@ static void updn_find_root_nodes_by_min_hop(OUT updn_t * p_updn) double thd1, thd2; unsigned i, cas_num = 0; unsigned *cas_per_sw; - uint16_t lid_ho; + uint16_t lid_ho = 0; OSM_LOG_ENTER(&p_osm->log); @@ -432,13 +432,21 @@ static void updn_find_root_nodes_by_min_hop(OUT updn_t * p_updn) "Current number of ports in the subnet is %d\n", cl_qmap_count(&p_osm->subn.port_guid_tbl)); - cas_per_sw = malloc(p_osm->subn.max_ucast_lid_ho * sizeof(*cas_per_sw)); + for (item = cl_qmap_head(&p_updn->p_osm->subn.sw_guid_tbl); + item != cl_qmap_end(&p_updn->p_osm->subn.sw_guid_tbl); + item = cl_qmap_next(item)) { + p_sw = (osm_switch_t *)item; + if (p_sw->lft_size > lid_ho) + lid_ho = p_sw->lft_size; + } + + cas_per_sw = malloc(lid_ho * sizeof(*cas_per_sw)); if (!cas_per_sw) { OSM_LOG(&p_osm->log, OSM_LOG_ERROR, "ERR AA14: " "cannot alloc mem for CAs per switch counter array\n"); goto _exit; } - memset(cas_per_sw, 0, p_osm->subn.max_ucast_lid_ho * sizeof(*cas_per_sw)); + memset(cas_per_sw, 0, lid_ho * sizeof(*cas_per_sw)); /* Find the Maximum number of CAs (and routers) for histogram normalization */ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,