From patchwork Wed Oct 14 13:14:35 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 53667 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 n9EDKYno002585 for ; Wed, 14 Oct 2009 13:20:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756387AbZJNNOe (ORCPT ); Wed, 14 Oct 2009 09:14:34 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760747AbZJNNOe (ORCPT ); Wed, 14 Oct 2009 09:14:34 -0400 Received: from qmta13.westchester.pa.mail.comcast.net ([76.96.59.243]:56099 "EHLO QMTA13.westchester.pa.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756387AbZJNNOd (ORCPT ); Wed, 14 Oct 2009 09:14:33 -0400 Received: from OMTA12.westchester.pa.mail.comcast.net ([76.96.62.44]) by QMTA13.westchester.pa.mail.comcast.net with comcast id scB81c00G0xGWP85DdDxm0; Wed, 14 Oct 2009 13:13:57 +0000 Received: from hal.comcast.net ([75.69.247.31]) by OMTA12.westchester.pa.mail.comcast.net with comcast id sdDw1c00X0hNrtn3YdDxSd; Wed, 14 Oct 2009 13:13:57 +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 n9EDEnBG023925; Wed, 14 Oct 2009 09:14:54 -0400 Received: (from hnrose@localhost) by hal.comcast.net (8.14.3/8.14.3/Submit) id n9EDEZ3Z023895; Wed, 14 Oct 2009 09:14:35 -0400 Date: Wed, 14 Oct 2009 09:14:35 -0400 From: Hal Rosenstock To: sashak@voltaire.com Cc: linux-rdma@vger.kernel.org Subject: [PATCH] opensm/osm_ucast_updn.c: Reduce temporary allocation of cas_per_sw Message-ID: <20091014131435.GA23890@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 bb9ccda..a2acdbd 100644 --- a/opensm/opensm/osm_ucast_updn.c +++ b/opensm/opensm/osm_ucast_updn.c @@ -2,6 +2,7 @@ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved. * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved. * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. + * Copyright (c) 2009 HNR Consulting. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU @@ -431,13 +432,12 @@ 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((IB_LID_UCAST_END_HO + 1) * sizeof(*cas_per_sw)); + cas_per_sw = calloc(p_osm->subn.max_ucast_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, (IB_LID_UCAST_END_HO + 1) * sizeof(*cas_per_sw)); /* Find the Maximum number of CAs (and routers) for histogram normalization */ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,