X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=lttng-events.c;h=e377deb9b4523ea7dfc24169f276f63ecb3b5165;hb=b02a8b73f7702849eb2ac5f2e567212e040bad07;hp=1e79b0d1c53f07fbe89f18cbed47a302c77536e6;hpb=54028e45a003826223c6b7185a1e752ed7d0bcd1;p=lttng-modules.git diff --git a/lttng-events.c b/lttng-events.c index 1e79b0d1..e377deb9 100644 --- a/lttng-events.c +++ b/lttng-events.c @@ -28,6 +28,8 @@ #include #include #include +#include + #include "wrapper/uuid.h" #include "wrapper/vmalloc.h" /* for wrapper_vmalloc_sync_all() */ #include "wrapper/random.h" @@ -90,8 +92,7 @@ struct lttng_session *lttng_session_create(void) GFP_KERNEL); if (!metadata_cache) goto err_free_session; - metadata_cache->data = kzalloc(METADATA_CACHE_DEFAULT_SIZE, - GFP_KERNEL); + metadata_cache->data = vzalloc(METADATA_CACHE_DEFAULT_SIZE); if (!metadata_cache->data) goto err_free_cache; metadata_cache->cache_alloc = METADATA_CACHE_DEFAULT_SIZE; @@ -118,7 +119,7 @@ void metadata_cache_destroy(struct kref *kref) { struct lttng_metadata_cache *cache = container_of(kref, struct lttng_metadata_cache, refcount); - kfree(cache->data); + vfree(cache->data); kfree(cache); } @@ -675,10 +676,16 @@ 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); - tmp_cache_realloc = krealloc(session->metadata_cache->data, - tmp_cache_alloc_size, GFP_KERNEL); + tmp_cache_realloc = vzalloc(tmp_cache_alloc_size); if (!tmp_cache_realloc) goto err; + if (session->metadata_cache->data) { + memcpy(tmp_cache_realloc, + session->metadata_cache->data, + session->metadata_cache->cache_alloc); + vfree(session->metadata_cache->data); + } + session->metadata_cache->cache_alloc = tmp_cache_alloc_size; session->metadata_cache->data = tmp_cache_realloc; }