Commit 94ef0394 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

pstree: Add general core_entry_free helper

This facrots out common core members freeing into pstree.c
helper. Per-arch freeing helpers are now symmetrical to the
allocating ones.

This is a merge of two Cyrill's patches.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 38e75bc8
...@@ -192,22 +192,17 @@ err: ...@@ -192,22 +192,17 @@ err:
return 0; return 0;
} }
void core_entry_free(CoreEntry *core) void arch_free_thread_info(CoreEntry *core)
{ {
if (core) {
if (CORE_THREAD_ARCH_INFO(core)) { if (CORE_THREAD_ARCH_INFO(core)) {
if (CORE_THREAD_ARCH_INFO(core)->fpstate) { if (CORE_THREAD_ARCH_INFO(core)->fpstate) {
xfree(CORE_THREAD_ARCH_INFO(core)->fpstate->vfp_regs); xfree(CORE_THREAD_ARCH_INFO(core)->fpstate->vfp_regs);
xfree(CORE_THREAD_ARCH_INFO(core)->fpstate); xfree(CORE_THREAD_ARCH_INFO(core)->fpstate);
} }
xfree(CORE_THREAD_ARCH_INFO(core)->gpregs); xfree(CORE_THREAD_ARCH_INFO(core)->gpregs);
}
xfree(CORE_THREAD_ARCH_INFO(core)); xfree(CORE_THREAD_ARCH_INFO(core));
xfree(core->thread_core); CORE_THREAD_ARCH_INFO(core) = NULL;
xfree(core->tc);
xfree(core->ids);
} }
} }
int sigreturn_prep_fpu_frame(struct thread_restore_args *args, CoreEntry *core) int sigreturn_prep_fpu_frame(struct thread_restore_args *args, CoreEntry *core)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
extern int get_task_regs(pid_t pid, CoreEntry *core, const struct parasite_ctl *ctl); extern int get_task_regs(pid_t pid, CoreEntry *core, const struct parasite_ctl *ctl);
extern int arch_alloc_thread_info(CoreEntry *core); extern int arch_alloc_thread_info(CoreEntry *core);
extern void core_entry_free(CoreEntry *core); extern void arch_free_thread_info(CoreEntry *core);
static inline void core_put_tls(CoreEntry *core, u32 tls) static inline void core_put_tls(CoreEntry *core, u32 tls)
......
...@@ -285,9 +285,8 @@ err: ...@@ -285,9 +285,8 @@ err:
return 1; return 1;
} }
void core_entry_free(CoreEntry *core) void arch_free_thread_info(CoreEntry *core)
{ {
if (core) {
if (core->thread_info) { if (core->thread_info) {
if (core->thread_info->fpregs) { if (core->thread_info->fpregs) {
if (core->thread_info->fpregs->xsave) if (core->thread_info->fpregs->xsave)
...@@ -299,11 +298,8 @@ void core_entry_free(CoreEntry *core) ...@@ -299,11 +298,8 @@ void core_entry_free(CoreEntry *core)
} }
xfree(core->thread_info->gpregs); xfree(core->thread_info->gpregs);
xfree(core->thread_info->fpregs); xfree(core->thread_info->fpregs);
}
xfree(core->thread_info); xfree(core->thread_info);
xfree(core->thread_core); core->thread_info = NULL;
xfree(core->tc);
xfree(core->ids);
} }
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
extern int get_task_regs(pid_t pid, CoreEntry *core, const struct parasite_ctl *ctl); extern int get_task_regs(pid_t pid, CoreEntry *core, const struct parasite_ctl *ctl);
extern int arch_alloc_thread_info(CoreEntry *core); extern int arch_alloc_thread_info(CoreEntry *core);
extern void core_entry_free(CoreEntry *core); extern void arch_free_thread_info(CoreEntry *core);
#define core_put_tls(core, tls) #define core_put_tls(core, tls)
......
...@@ -76,4 +76,6 @@ extern struct task_entries *task_entries; ...@@ -76,4 +76,6 @@ extern struct task_entries *task_entries;
int get_task_ids(struct pstree_item *); int get_task_ids(struct pstree_item *);
extern struct _TaskKobjIdsEntry *root_ids; extern struct _TaskKobjIdsEntry *root_ids;
extern void core_entry_free(CoreEntry *core);
#endif /* __CR_PSTREE_H__ */ #endif /* __CR_PSTREE_H__ */
...@@ -9,11 +9,23 @@ ...@@ -9,11 +9,23 @@
#include "namespaces.h" #include "namespaces.h"
#include "files.h" #include "files.h"
#include "asm/dump.h"
#include "protobuf.h" #include "protobuf.h"
#include "protobuf/pstree.pb-c.h" #include "protobuf/pstree.pb-c.h"
struct pstree_item *root_item; struct pstree_item *root_item;
void core_entry_free(CoreEntry *core)
{
if (core) {
arch_free_thread_info(core);
xfree(core->thread_core);
xfree(core->tc);
xfree(core->ids);
}
}
void free_pstree(struct pstree_item *root_item) void free_pstree(struct pstree_item *root_item)
{ {
struct pstree_item *item = root_item, *parent; struct pstree_item *item = root_item, *parent;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment