Skip to contentSkip to conversation

Fix: build failure on 2.6.36

PATCH Mathieu Desnoyers 1 participant 1 message Aug 29, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 13 lines · ----- On Aug 29, 2015, at 1:03 PM, Michael Jeanson [email protected] wrote:

Fixes build failure on the 2.6.36 kernel branch which misses the vzalloc() function.

---
lttng-events.c | 10 ++++++++++

1 file changed, 10 insertions(+)
lttng-events.c +0 -0
index b49851b..422a2dd 100644

lttng-events.c struct lttng_session *lttng_session_create(void) · line 138

Quoted 6 lines
lttng-events.c +3 -0
@@ -133,7 +133,12 @@ struct lttng_session *lttng_session_create(void)
 			GFP_KERNEL);
 	if (!metadata_cache)
 		goto err_free_session;
+#if LTTNG_KERNEL_RANGE(2,6,36, 2,6,37)
+	metadata_cache->data = vmalloc(METADATA_CACHE_DEFAULT_SIZE);
+	memset(metadata_cache->data, 0, METADATA_CACHE_DEFAULT_SIZE);

You need to test whether vmalloc returned NULL before writing to it.

Moreover, I'm against putting such preprocessor conditionals in the code. We should create a wrapper header for vzalloc implementing lttng_vzalloc instead.

Thanks,

Mathieu

Quoted 21 lines
lttng-events.c +7 -1
+#else
 	metadata_cache->data = vzalloc(METADATA_CACHE_DEFAULT_SIZE);
+#endif
 	if (!metadata_cache->data)
 		goto err_free_cache;
 	metadata_cache->cache_alloc = METADATA_CACHE_DEFAULT_SIZE;
@@ -1531,7 +1536,12 @@ int lttng_metadata_printf(struct lttng_session *session,
 		tmp_cache_alloc_size = max_t(unsigned int,
 				session->metadata_cache->cache_alloc + len,
 				session->metadata_cache->cache_alloc << 1);
+#if LTTNG_KERNEL_RANGE(2,6,36, 2,6,37)
+		tmp_cache_realloc = vmalloc(tmp_cache_alloc_size);
+		memset(tmp_cache_realloc, 0, tmp_cache_alloc_size);
+#else
 		tmp_cache_realloc = vzalloc(tmp_cache_alloc_size);
+#endif
 		if (!tmp_cache_realloc)
 			goto err;
 		if (session->metadata_cache->data) {
--

1.9.1

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com