* [PATCH v2 0/2] softmmu/dirtylimit: Fix memory leak issue @ 2023-08-25 2:29 alloc.young 2023-08-25 2:31 ` [PATCH v2 1/2] softmmu: Fix dirtylimit memory leak alloc.young 2023-08-25 2:32 ` [PATCH v2 2/2] softmmu/dirtylimit: Convert free to g_free alloc.young 0 siblings, 2 replies; 5+ messages in thread From: alloc.young @ 2023-08-25 2:29 UTC (permalink / raw) To: yong.huang; +Cc: mjt, qemu-devel, alloc From: alloc <alloc.young@outlook.com> Changes in v2: - Split into two patches, one fixing memory leak issue and another converting free to g_free. - Fix typos alloc (1): softmmu/dirtylimit: Convert free to g_free alloc.young (1): softmmu: Fix dirtylimit memory leak softmmu/dirtylimit.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) -- 2.39.3 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] softmmu: Fix dirtylimit memory leak 2023-08-25 2:29 [PATCH v2 0/2] softmmu/dirtylimit: Fix memory leak issue alloc.young @ 2023-08-25 2:31 ` alloc.young 2023-08-25 2:32 ` [PATCH v2 2/2] softmmu/dirtylimit: Convert free to g_free alloc.young 1 sibling, 0 replies; 5+ messages in thread From: alloc.young @ 2023-08-25 2:31 UTC (permalink / raw) To: yong.huang; +Cc: mjt, qemu-devel, alloc.young From: "alloc.young" <alloc.young@outlook.com> Fix memory leak in hmp_info_vcpu_dirty_limit,use g_autoptr to handle memory deallocation. Signed-off-by: alloc.young <alloc.young@outlook.com> --- softmmu/dirtylimit.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/softmmu/dirtylimit.c b/softmmu/dirtylimit.c index 3c275ee55b..e3ff53b8fc 100644 --- a/softmmu/dirtylimit.c +++ b/softmmu/dirtylimit.c @@ -653,7 +653,8 @@ struct DirtyLimitInfoList *qmp_query_vcpu_dirty_limit(Error **errp) void hmp_info_vcpu_dirty_limit(Monitor *mon, const QDict *qdict) { - DirtyLimitInfoList *limit, *head, *info = NULL; + DirtyLimitInfoList *info; + g_autoptr(DirtyLimitInfoList) head = NULL; Error *err = NULL; if (!dirtylimit_in_service()) { @@ -661,20 +662,17 @@ void hmp_info_vcpu_dirty_limit(Monitor *mon, const QDict *qdict) return; } - info = qmp_query_vcpu_dirty_limit(&err); + head = qmp_query_vcpu_dirty_limit(&err); if (err) { hmp_handle_error(mon, err); return; } - head = info; - for (limit = head; limit != NULL; limit = limit->next) { + for (info = head; info != NULL; info = info->next) { monitor_printf(mon, "vcpu[%"PRIi64"], limit rate %"PRIi64 " (MB/s)," " current rate %"PRIi64 " (MB/s)\n", - limit->value->cpu_index, - limit->value->limit_rate, - limit->value->current_rate); + info->value->cpu_index, + info->value->limit_rate, + info->value->current_rate); } - - g_free(info); } -- 2.39.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] softmmu/dirtylimit: Convert free to g_free 2023-08-25 2:29 [PATCH v2 0/2] softmmu/dirtylimit: Fix memory leak issue alloc.young 2023-08-25 2:31 ` [PATCH v2 1/2] softmmu: Fix dirtylimit memory leak alloc.young @ 2023-08-25 2:32 ` alloc.young 2023-08-25 2:42 ` Yong Huang 2023-08-25 7:26 ` Philippe Mathieu-Daudé 1 sibling, 2 replies; 5+ messages in thread From: alloc.young @ 2023-08-25 2:32 UTC (permalink / raw) To: yong.huang; +Cc: mjt, qemu-devel, alloc From: alloc <alloc.young@outlook.com> Convert free to g_free to match g_new and g_malloc functions. Signed-off-by: alloc <alloc.young@outlook.com> --- softmmu/dirtylimit.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/softmmu/dirtylimit.c b/softmmu/dirtylimit.c index e3ff53b8fc..fa959d7743 100644 --- a/softmmu/dirtylimit.c +++ b/softmmu/dirtylimit.c @@ -100,7 +100,7 @@ static void vcpu_dirty_rate_stat_collect(void) stat.rates[i].dirty_rate; } - free(stat.rates); + g_free(stat.rates); } static void *vcpu_dirty_rate_stat_thread(void *opaque) @@ -171,10 +171,10 @@ void vcpu_dirty_rate_stat_initialize(void) void vcpu_dirty_rate_stat_finalize(void) { - free(vcpu_dirty_rate_stat->stat.rates); + g_free(vcpu_dirty_rate_stat->stat.rates); vcpu_dirty_rate_stat->stat.rates = NULL; - free(vcpu_dirty_rate_stat); + g_free(vcpu_dirty_rate_stat); vcpu_dirty_rate_stat = NULL; } @@ -220,10 +220,10 @@ void dirtylimit_state_initialize(void) void dirtylimit_state_finalize(void) { - free(dirtylimit_state->states); + g_free(dirtylimit_state->states); dirtylimit_state->states = NULL; - free(dirtylimit_state); + g_free(dirtylimit_state); dirtylimit_state = NULL; trace_dirtylimit_state_finalize(); -- 2.39.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] softmmu/dirtylimit: Convert free to g_free 2023-08-25 2:32 ` [PATCH v2 2/2] softmmu/dirtylimit: Convert free to g_free alloc.young @ 2023-08-25 2:42 ` Yong Huang 2023-08-25 7:26 ` Philippe Mathieu-Daudé 1 sibling, 0 replies; 5+ messages in thread From: Yong Huang @ 2023-08-25 2:42 UTC (permalink / raw) To: alloc.young; +Cc: mjt, qemu-devel [-- Attachment #1: Type: text/plain, Size: 1612 bytes --] On Fri, Aug 25, 2023 at 10:33 AM <alloc.young@outlook.com> wrote: > From: alloc <alloc.young@outlook.com> > > Convert free to g_free to match g_new and g_malloc functions. > > Signed-off-by: alloc <alloc.young@outlook.com> > --- > softmmu/dirtylimit.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/softmmu/dirtylimit.c b/softmmu/dirtylimit.c > index e3ff53b8fc..fa959d7743 100644 > --- a/softmmu/dirtylimit.c > +++ b/softmmu/dirtylimit.c > @@ -100,7 +100,7 @@ static void vcpu_dirty_rate_stat_collect(void) > stat.rates[i].dirty_rate; > } > > - free(stat.rates); > + g_free(stat.rates); > } > > static void *vcpu_dirty_rate_stat_thread(void *opaque) > @@ -171,10 +171,10 @@ void vcpu_dirty_rate_stat_initialize(void) > > void vcpu_dirty_rate_stat_finalize(void) > { > - free(vcpu_dirty_rate_stat->stat.rates); > + g_free(vcpu_dirty_rate_stat->stat.rates); > vcpu_dirty_rate_stat->stat.rates = NULL; > > - free(vcpu_dirty_rate_stat); > + g_free(vcpu_dirty_rate_stat); > vcpu_dirty_rate_stat = NULL; > } > > @@ -220,10 +220,10 @@ void dirtylimit_state_initialize(void) > > void dirtylimit_state_finalize(void) > { > - free(dirtylimit_state->states); > + g_free(dirtylimit_state->states); > dirtylimit_state->states = NULL; > > - free(dirtylimit_state); > + g_free(dirtylimit_state); > dirtylimit_state = NULL; > > trace_dirtylimit_state_finalize(); > -- > 2.39.3 > > Reviewed-by: Hyman Huang <yong.huang@smartx.com> -- Best regards [-- Attachment #2: Type: text/html, Size: 3051 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] softmmu/dirtylimit: Convert free to g_free 2023-08-25 2:32 ` [PATCH v2 2/2] softmmu/dirtylimit: Convert free to g_free alloc.young 2023-08-25 2:42 ` Yong Huang @ 2023-08-25 7:26 ` Philippe Mathieu-Daudé 1 sibling, 0 replies; 5+ messages in thread From: Philippe Mathieu-Daudé @ 2023-08-25 7:26 UTC (permalink / raw) To: alloc.young, yong.huang; +Cc: mjt, qemu-devel On 25/8/23 04:32, alloc.young@outlook.com wrote: > From: alloc <alloc.young@outlook.com> > > Convert free to g_free to match g_new and g_malloc functions. > > Signed-off-by: alloc <alloc.young@outlook.com> Fixes: cc2b33eab0 ("softmmu/dirtylimit: Implement vCPU dirtyrate calculation periodically") Fixes: baa609832e ("softmmu/dirtylimit: Implement virtual CPU throttle") Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > softmmu/dirtylimit.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-08-25 7:27 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-08-25 2:29 [PATCH v2 0/2] softmmu/dirtylimit: Fix memory leak issue alloc.young 2023-08-25 2:31 ` [PATCH v2 1/2] softmmu: Fix dirtylimit memory leak alloc.young 2023-08-25 2:32 ` [PATCH v2 2/2] softmmu/dirtylimit: Convert free to g_free alloc.young 2023-08-25 2:42 ` Yong Huang 2023-08-25 7:26 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).