Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
* [ltt-dev] [PATCH] Change malloc to zmalloc for libust
@ 2010-09-07 13:03 David Goulet
  2010-09-07 13:08 ` David Goulet
  2010-09-07 13:09 ` Mathieu Desnoyers
  0 siblings, 2 replies; 3+ messages in thread
From: David Goulet @ 2010-09-07 13:03 UTC (permalink / raw)


Signed-off-by: David Goulet <david.goulet at polymtl.ca>
---
 libust/buffers.c    |    4 ++--
 libust/marker.c     |    6 +++---
 libust/tracectl.c   |    4 ++--
 libust/tracepoint.c |    8 ++++----
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/libust/buffers.c b/libust/buffers.c
index 5d9bb8e..374ec61 100644
--- a/libust/buffers.c
+++ b/libust/buffers.c
@@ -777,11 +777,11 @@ static int ust_buffers_create_channel(const char *trace_name, struct ust_trace *
 	ltt_chan->commit_count_mask = (~0UL >> ltt_chan->n_subbufs_order);
 	ltt_chan->n_cpus = get_n_cpus();
 //ust//	ltt_chan->buf = percpu_alloc_mask(sizeof(struct ltt_channel_buf_struct), GFP_KERNEL, cpu_possible_map);
-	ltt_chan->buf = (void *) malloc(ltt_chan->n_cpus * sizeof(void *));
+	ltt_chan->buf = (void *) zmalloc(ltt_chan->n_cpus * sizeof(void *));
 	if(ltt_chan->buf == NULL) {
 		goto error;
 	}
-	ltt_chan->buf_struct_shmids = (int *) malloc(ltt_chan->n_cpus * sizeof(int));
+	ltt_chan->buf_struct_shmids = (int *) zmalloc(ltt_chan->n_cpus * sizeof(int));
 	if(ltt_chan->buf_struct_shmids == NULL)
 		goto free_buf;
 
diff --git a/libust/marker.c b/libust/marker.c
index 19467d1..3351726 100644
--- a/libust/marker.c
+++ b/libust/marker.c
@@ -428,10 +428,10 @@ static struct marker_entry *add_marker(const char *channel, const char *name,
 		}
 	}
 	/*
-	 * Using malloc here to allocate a variable length element. Could
+	 * Using zmalloc here to allocate a variable length element. Could
 	 * cause some memory fragmentation if overused.
 	 */
-	e = malloc(sizeof(struct marker_entry)
+	e = zmalloc(sizeof(struct marker_entry)
 		    + channel_len + name_len + format_len);
 	if (!e)
 		return ERR_PTR(-ENOMEM);
@@ -1363,7 +1363,7 @@ int marker_register_lib(struct marker *markers_start, int markers_count)
 {
 	struct lib *pl;
 
-	pl = (struct lib *) malloc(sizeof(struct lib));
+	pl = (struct lib *) zmalloc(sizeof(struct lib));
 
 	pl->markers_start = markers_start;
 	pl->markers_count = markers_count;
diff --git a/libust/tracectl.c b/libust/tracectl.c
index 8d57b8f..e64b26f 100644
--- a/libust/tracectl.c
+++ b/libust/tracectl.c
@@ -675,9 +675,9 @@ static int do_cmd_get_subbuffer(const char *recvbuf, struct ustcomm_source *src)
 
 			found = 1;
 
-			bc = (struct blocked_consumer *) malloc(sizeof(struct blocked_consumer));
+			bc = (struct blocked_consumer *) zmalloc(sizeof(struct blocked_consumer));
 			if(bc == NULL) {
-				ERR("malloc returned NULL");
+				ERR("zmalloc returned NULL");
 				goto unlock_traces;
 			}
 			bc->fd_consumer = src->fd;
diff --git a/libust/tracepoint.c b/libust/tracepoint.c
index 620a009..8783b53 100644
--- a/libust/tracepoint.c
+++ b/libust/tracepoint.c
@@ -74,7 +74,7 @@ struct tp_probes {
 
 static inline void *allocate_probes(int count)
 {
-	struct tp_probes *p  = malloc(count * sizeof(struct probe)
+	struct tp_probes *p  = zmalloc(count * sizeof(void *)
 			+ sizeof(struct tp_probes));
 	return p == NULL ? NULL : p->probes;
 }
@@ -225,10 +225,10 @@ static struct tracepoint_entry *add_tracepoint(const char *name)
 		}
 	}
 	/*
-	 * Using kmalloc here to allocate a variable length element. Could
+	 * Using zmalloc here to allocate a variable length element. Could
 	 * cause some memory fragmentation if overused.
 	 */
-	e = malloc(sizeof(struct tracepoint_entry) + name_len);
+	e = zmalloc(sizeof(struct tracepoint_entry) + name_len);
 	if (!e)
 		return ERR_PTR(-ENOMEM);
 	memcpy(&e->name[0], name, name_len);
@@ -661,7 +661,7 @@ int tracepoint_register_lib(struct tracepoint *tracepoints_start, int tracepoint
 {
 	struct tracepoint_lib *pl;
 
-	pl = (struct tracepoint_lib *) malloc(sizeof(struct tracepoint_lib));
+	pl = (struct tracepoint_lib *) zmalloc(sizeof(struct tracepoint_lib));
 
 	pl->tracepoints_start = tracepoints_start;
 	pl->tracepoints_count = tracepoints_count;
-- 
1.7.2.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ltt-dev] [PATCH] Change malloc to zmalloc for libust
  2010-09-07 13:03 [ltt-dev] [PATCH] Change malloc to zmalloc for libust David Goulet
@ 2010-09-07 13:08 ` David Goulet
  2010-09-07 13:09 ` Mathieu Desnoyers
  1 sibling, 0 replies; 3+ messages in thread
From: David Goulet @ 2010-09-07 13:08 UTC (permalink / raw)


This patch was lost in translation I think...

I forgot to change my template, but next time I'll use [UST PATCH] as 
subject. Maybe ust-dev mailing list should be consider soon? It's 
becoming more and more loaded with patches! and It will increase!

Cheers
David

On 10-09-07 09:03 AM, David Goulet wrote:
> Signed-off-by: David Goulet<david.goulet at polymtl.ca>
> ---
>   libust/buffers.c    |    4 ++--
>   libust/marker.c     |    6 +++---
>   libust/tracectl.c   |    4 ++--
>   libust/tracepoint.c |    8 ++++----
>   4 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/libust/buffers.c b/libust/buffers.c
> index 5d9bb8e..374ec61 100644
> --- a/libust/buffers.c
> +++ b/libust/buffers.c
> @@ -777,11 +777,11 @@ static int ust_buffers_create_channel(const char *trace_name, struct ust_trace *
>   	ltt_chan->commit_count_mask = (~0UL>>  ltt_chan->n_subbufs_order);
>   	ltt_chan->n_cpus = get_n_cpus();
>   //ust//	ltt_chan->buf = percpu_alloc_mask(sizeof(struct ltt_channel_buf_struct), GFP_KERNEL, cpu_possible_map);
> -	ltt_chan->buf = (void *) malloc(ltt_chan->n_cpus * sizeof(void *));
> +	ltt_chan->buf = (void *) zmalloc(ltt_chan->n_cpus * sizeof(void *));
>   	if(ltt_chan->buf == NULL) {
>   		goto error;
>   	}
> -	ltt_chan->buf_struct_shmids = (int *) malloc(ltt_chan->n_cpus * sizeof(int));
> +	ltt_chan->buf_struct_shmids = (int *) zmalloc(ltt_chan->n_cpus * sizeof(int));
>   	if(ltt_chan->buf_struct_shmids == NULL)
>   		goto free_buf;
>
> diff --git a/libust/marker.c b/libust/marker.c
> index 19467d1..3351726 100644
> --- a/libust/marker.c
> +++ b/libust/marker.c
> @@ -428,10 +428,10 @@ static struct marker_entry *add_marker(const char *channel, const char *name,
>   		}
>   	}
>   	/*
> -	 * Using malloc here to allocate a variable length element. Could
> +	 * Using zmalloc here to allocate a variable length element. Could
>   	 * cause some memory fragmentation if overused.
>   	 */
> -	e = malloc(sizeof(struct marker_entry)
> +	e = zmalloc(sizeof(struct marker_entry)
>   		    + channel_len + name_len + format_len);
>   	if (!e)
>   		return ERR_PTR(-ENOMEM);
> @@ -1363,7 +1363,7 @@ int marker_register_lib(struct marker *markers_start, int markers_count)
>   {
>   	struct lib *pl;
>
> -	pl = (struct lib *) malloc(sizeof(struct lib));
> +	pl = (struct lib *) zmalloc(sizeof(struct lib));
>
>   	pl->markers_start = markers_start;
>   	pl->markers_count = markers_count;
> diff --git a/libust/tracectl.c b/libust/tracectl.c
> index 8d57b8f..e64b26f 100644
> --- a/libust/tracectl.c
> +++ b/libust/tracectl.c
> @@ -675,9 +675,9 @@ static int do_cmd_get_subbuffer(const char *recvbuf, struct ustcomm_source *src)
>
>   			found = 1;
>
> -			bc = (struct blocked_consumer *) malloc(sizeof(struct blocked_consumer));
> +			bc = (struct blocked_consumer *) zmalloc(sizeof(struct blocked_consumer));
>   			if(bc == NULL) {
> -				ERR("malloc returned NULL");
> +				ERR("zmalloc returned NULL");
>   				goto unlock_traces;
>   			}
>   			bc->fd_consumer = src->fd;
> diff --git a/libust/tracepoint.c b/libust/tracepoint.c
> index 620a009..8783b53 100644
> --- a/libust/tracepoint.c
> +++ b/libust/tracepoint.c
> @@ -74,7 +74,7 @@ struct tp_probes {
>
>   static inline void *allocate_probes(int count)
>   {
> -	struct tp_probes *p  = malloc(count * sizeof(struct probe)
> +	struct tp_probes *p  = zmalloc(count * sizeof(void *)
>   			+ sizeof(struct tp_probes));
>   	return p == NULL ? NULL : p->probes;
>   }
> @@ -225,10 +225,10 @@ static struct tracepoint_entry *add_tracepoint(const char *name)
>   		}
>   	}
>   	/*
> -	 * Using kmalloc here to allocate a variable length element. Could
> +	 * Using zmalloc here to allocate a variable length element. Could
>   	 * cause some memory fragmentation if overused.
>   	 */
> -	e = malloc(sizeof(struct tracepoint_entry) + name_len);
> +	e = zmalloc(sizeof(struct tracepoint_entry) + name_len);
>   	if (!e)
>   		return ERR_PTR(-ENOMEM);
>   	memcpy(&e->name[0], name, name_len);
> @@ -661,7 +661,7 @@ int tracepoint_register_lib(struct tracepoint *tracepoints_start, int tracepoint
>   {
>   	struct tracepoint_lib *pl;
>
> -	pl = (struct tracepoint_lib *) malloc(sizeof(struct tracepoint_lib));
> +	pl = (struct tracepoint_lib *) zmalloc(sizeof(struct tracepoint_lib));
>
>   	pl->tracepoints_start = tracepoints_start;
>   	pl->tracepoints_count = tracepoints_count;

-- 
David Goulet
LTTng project, DORSAL Lab.

PGP/GPG : 1024D/16BD8563
BE3C 672B 9331 9796 291A  14C6 4AF7 C14B 16BD 8563




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ltt-dev] [PATCH] Change malloc to zmalloc for libust
  2010-09-07 13:03 [ltt-dev] [PATCH] Change malloc to zmalloc for libust David Goulet
  2010-09-07 13:08 ` David Goulet
@ 2010-09-07 13:09 ` Mathieu Desnoyers
  1 sibling, 0 replies; 3+ messages in thread
From: Mathieu Desnoyers @ 2010-09-07 13:09 UTC (permalink / raw)


* David Goulet (david.goulet at polymtl.ca) wrote:
> Signed-off-by: David Goulet <david.goulet at polymtl.ca>

Acked-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>

> ---
>  libust/buffers.c    |    4 ++--
>  libust/marker.c     |    6 +++---
>  libust/tracectl.c   |    4 ++--
>  libust/tracepoint.c |    8 ++++----
>  4 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/libust/buffers.c b/libust/buffers.c
> index 5d9bb8e..374ec61 100644
> --- a/libust/buffers.c
> +++ b/libust/buffers.c
> @@ -777,11 +777,11 @@ static int ust_buffers_create_channel(const char *trace_name, struct ust_trace *
>  	ltt_chan->commit_count_mask = (~0UL >> ltt_chan->n_subbufs_order);
>  	ltt_chan->n_cpus = get_n_cpus();
>  //ust//	ltt_chan->buf = percpu_alloc_mask(sizeof(struct ltt_channel_buf_struct), GFP_KERNEL, cpu_possible_map);
> -	ltt_chan->buf = (void *) malloc(ltt_chan->n_cpus * sizeof(void *));
> +	ltt_chan->buf = (void *) zmalloc(ltt_chan->n_cpus * sizeof(void *));
>  	if(ltt_chan->buf == NULL) {
>  		goto error;
>  	}
> -	ltt_chan->buf_struct_shmids = (int *) malloc(ltt_chan->n_cpus * sizeof(int));
> +	ltt_chan->buf_struct_shmids = (int *) zmalloc(ltt_chan->n_cpus * sizeof(int));
>  	if(ltt_chan->buf_struct_shmids == NULL)
>  		goto free_buf;
>  
> diff --git a/libust/marker.c b/libust/marker.c
> index 19467d1..3351726 100644
> --- a/libust/marker.c
> +++ b/libust/marker.c
> @@ -428,10 +428,10 @@ static struct marker_entry *add_marker(const char *channel, const char *name,
>  		}
>  	}
>  	/*
> -	 * Using malloc here to allocate a variable length element. Could
> +	 * Using zmalloc here to allocate a variable length element. Could
>  	 * cause some memory fragmentation if overused.
>  	 */
> -	e = malloc(sizeof(struct marker_entry)
> +	e = zmalloc(sizeof(struct marker_entry)
>  		    + channel_len + name_len + format_len);
>  	if (!e)
>  		return ERR_PTR(-ENOMEM);
> @@ -1363,7 +1363,7 @@ int marker_register_lib(struct marker *markers_start, int markers_count)
>  {
>  	struct lib *pl;
>  
> -	pl = (struct lib *) malloc(sizeof(struct lib));
> +	pl = (struct lib *) zmalloc(sizeof(struct lib));
>  
>  	pl->markers_start = markers_start;
>  	pl->markers_count = markers_count;
> diff --git a/libust/tracectl.c b/libust/tracectl.c
> index 8d57b8f..e64b26f 100644
> --- a/libust/tracectl.c
> +++ b/libust/tracectl.c
> @@ -675,9 +675,9 @@ static int do_cmd_get_subbuffer(const char *recvbuf, struct ustcomm_source *src)
>  
>  			found = 1;
>  
> -			bc = (struct blocked_consumer *) malloc(sizeof(struct blocked_consumer));
> +			bc = (struct blocked_consumer *) zmalloc(sizeof(struct blocked_consumer));
>  			if(bc == NULL) {
> -				ERR("malloc returned NULL");
> +				ERR("zmalloc returned NULL");
>  				goto unlock_traces;
>  			}
>  			bc->fd_consumer = src->fd;
> diff --git a/libust/tracepoint.c b/libust/tracepoint.c
> index 620a009..8783b53 100644
> --- a/libust/tracepoint.c
> +++ b/libust/tracepoint.c
> @@ -74,7 +74,7 @@ struct tp_probes {
>  
>  static inline void *allocate_probes(int count)
>  {
> -	struct tp_probes *p  = malloc(count * sizeof(struct probe)
> +	struct tp_probes *p  = zmalloc(count * sizeof(void *)
>  			+ sizeof(struct tp_probes));
>  	return p == NULL ? NULL : p->probes;
>  }
> @@ -225,10 +225,10 @@ static struct tracepoint_entry *add_tracepoint(const char *name)
>  		}
>  	}
>  	/*
> -	 * Using kmalloc here to allocate a variable length element. Could
> +	 * Using zmalloc here to allocate a variable length element. Could
>  	 * cause some memory fragmentation if overused.
>  	 */
> -	e = malloc(sizeof(struct tracepoint_entry) + name_len);
> +	e = zmalloc(sizeof(struct tracepoint_entry) + name_len);
>  	if (!e)
>  		return ERR_PTR(-ENOMEM);
>  	memcpy(&e->name[0], name, name_len);
> @@ -661,7 +661,7 @@ int tracepoint_register_lib(struct tracepoint *tracepoints_start, int tracepoint
>  {
>  	struct tracepoint_lib *pl;
>  
> -	pl = (struct tracepoint_lib *) malloc(sizeof(struct tracepoint_lib));
> +	pl = (struct tracepoint_lib *) zmalloc(sizeof(struct tracepoint_lib));
>  
>  	pl->tracepoints_start = tracepoints_start;
>  	pl->tracepoints_count = tracepoints_count;
> -- 
> 1.7.2.2
> 
> 
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
> 

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-09-07 13:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-07 13:03 [ltt-dev] [PATCH] Change malloc to zmalloc for libust David Goulet
2010-09-07 13:08 ` David Goulet
2010-09-07 13:09 ` Mathieu Desnoyers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox