[ofa-general] Re: [PATCH] opensm/libvendor/osm_vendor_ibumad.c: Add environment variable control for OSM_UMAD_MAX_PENDING
Ira Weiny
weiny2 at llnl.gov
Mon Feb 25 10:31:43 PST 2008
On Sun, 24 Feb 2008 12:14:05 +0000
Sasha Khapyorsky <sashak at voltaire.com> wrote:
> Hi Ira,
>
> On 16:56 Thu 21 Feb , Ira Weiny wrote:
> > From b8fb2151b92ddd4a7d2a4cc2ab38a6b34fffc7ab Mon Sep 17 00:00:00 2001
> > From: Ira K. Weiny <weiny2 at llnl.gov>
> > Date: Thu, 21 Feb 2008 09:10:10 -0800
> > Subject: [PATCH] opensm/libvendor/osm_vendor_ibumad.c: Add environment variable control for OSM_UMAD_MAX_PENDING
> >
> >
<snip>
> > +
> > + osm_log(p_vend->p_log, OSM_LOG_INFO,
> > + "osm_vendor_init: %d pending umads specified\n",
> > + p_vend->mtbl.max);
> > +
> > + p_vend->mtbl.tbl = calloc(p_vend->mtbl.max, sizeof(*(p_vend->mtbl.tbl)));
>
> There is calloc(), I guess we also need free() somewhere?
>
You caught me...
Revised patch attached,
Ira
>From 0c578c3062b3183dcd33e89aec0f1eb8a3a3a04e Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Thu, 21 Feb 2008 09:10:10 -0800
Subject: [PATCH] opensm/libvendor/osm_vendor_ibumad.c: Add environment variable control for OSM_UMAD_MAX_PENDING
Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
opensm/include/vendor/osm_vendor_ibumad.h | 4 ++--
opensm/libvendor/osm_vendor_ibumad.c | 28 +++++++++++++++++++++++++++-
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/opensm/include/vendor/osm_vendor_ibumad.h b/opensm/include/vendor/osm_vendor_ibumad.h
index 84fd21a..3a3f070 100644
--- a/opensm/include/vendor/osm_vendor_ibumad.h
+++ b/opensm/include/vendor/osm_vendor_ibumad.h
@@ -141,12 +141,12 @@ typedef struct _umad_match {
uint32_t version;
} umad_match_t;
-#define OSM_UMAD_MAX_PENDING 1000
+#define DEFAULT_OSM_UMAD_MAX_PENDING 1000
typedef struct vendor_match_tbl {
- umad_match_t tbl[OSM_UMAD_MAX_PENDING];
uint32_t last_version;
int max;
+ umad_match_t *tbl;
} vendor_match_tbl_t;
typedef struct _osm_vendor {
diff --git a/opensm/libvendor/osm_vendor_ibumad.c b/opensm/libvendor/osm_vendor_ibumad.c
index d51bd6d..a1fc140 100644
--- a/opensm/libvendor/osm_vendor_ibumad.c
+++ b/opensm/libvendor/osm_vendor_ibumad.c
@@ -451,6 +451,7 @@ ib_api_status_t
osm_vendor_init(IN osm_vendor_t * const p_vend,
IN osm_log_t * const p_log, IN const uint32_t timeout)
{
+ char *max = NULL;
int r, n_cas;
OSM_LOG_ENTER(p_log);
@@ -480,7 +481,31 @@ osm_vendor_init(IN osm_vendor_t * const p_vend,
}
p_vend->ca_count = n_cas;
- p_vend->mtbl.max = OSM_UMAD_MAX_PENDING;
+ p_vend->mtbl.max = DEFAULT_OSM_UMAD_MAX_PENDING;
+
+ if ((max = getenv("OSM_UMAD_MAX_PENDING")) != NULL) {
+ int tmp = strtol(max, NULL, 0);
+ if (tmp > 0)
+ p_vend->mtbl.max = tmp;
+ else
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_init: Error:"
+ "OSM_UMAD_MAX_PENDING=%d is invalid",
+ tmp);
+ }
+
+ osm_log(p_vend->p_log, OSM_LOG_INFO,
+ "osm_vendor_init: %d pending umads specified\n",
+ p_vend->mtbl.max);
+
+ p_vend->mtbl.tbl = calloc(p_vend->mtbl.max, sizeof(*(p_vend->mtbl.tbl)));
+ if (!p_vend->mtbl.tbl) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_init: Error:"
+ "failed to allocate vendor match table\n");
+ r = IB_INSUFFICIENT_MEMORY;
+ goto Exit;
+ }
Exit:
OSM_LOG_EXIT(p_log);
@@ -535,6 +560,7 @@ void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
pthread_mutex_destroy(&(*pp_vend)->cb_mutex);
pthread_mutex_destroy(&(*pp_vend)->match_tbl_mutex);
+ free((*pp_vend)->mtbl.tbl);
free(*pp_vend);
*pp_vend = NULL;
}
--
1.5.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-opensm-libvendor-osm_vendor_ibumad.c-Add-environmen.patch
Type: application/octet-stream
Size: 2649 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20080225/2e6d9a9d/attachment.obj>
More information about the general
mailing list