Re: [PATCH v4.1 02/13] perf hist: Save raw_data/size for tracepoint events
Em Thu, Dec 24, 2015 at 10:05:34AM +0900, Namhyung Kim escreveu: > The raw_data and raw_size fields are to provide tracepoint specific > information. They will be used by dynamic sort keys later. > > Signed-off-by: Namhyung Kim > --- > make a copy of raw_data > > tools/perf/util/hist.c | 27 +++ > tools/perf/util/sort.h | 2 ++ > 2 files changed, 29 insertions(+) > > diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c > index 039bb91d0a92..df5567fff986 100644 > --- a/tools/perf/util/hist.c > +++ b/tools/perf/util/hist.c > @@ -369,6 +369,28 @@ static struct hist_entry *hist_entry__new(struct > hist_entry *template, > if (symbol_conf.use_callchain) > callchain_init(he->callchain); > > + if (he->raw_data) { > + void *data = malloc(he->raw_size); if this is really needed, please use memdup(), I.e.: memdup(he->raw_data, he->raw_size); > + if (data == NULL) { > + map__put(he->ms.map); > + if (he->branch_info) { > + map__put(he->branch_info->from.map); > + map__put(he->branch_info->to.map); > + free(he->branch_info); > + } > + if (he->mem_info) { > + map__put(he->mem_info->iaddr.map); > + map__put(he->mem_info->daddr.map); > + } > + free(he->stat_acc); > + free(he); > + return NULL; > + } > + > + memcpy(data, he->raw_data, he->raw_size); > + he->raw_data = data; > + } > INIT_LIST_HEAD(>pairs.node); > thread__get(he->thread); > } > @@ -487,6 +509,8 @@ struct hist_entry *__hists__add_entry(struct hists *hists, > .branch_info = bi, > .mem_info = mi, > .transaction = sample->transaction, > + .raw_data = sample->raw_data, > + .raw_size = sample->raw_size, > }; > > return hists__findnew_entry(hists, , al, sample_self); > @@ -801,6 +825,8 @@ iter_add_next_cumulative_entry(struct hist_entry_iter > *iter, > .sym = al->sym, > }, > .parent = iter->parent, > + .raw_data = sample->raw_data, > + .raw_size = sample->raw_size, > }; > int i; > struct callchain_cursor cursor; > @@ -974,6 +1000,7 @@ void hist_entry__delete(struct hist_entry *he) > if (he->srcfile && he->srcfile[0]) > free(he->srcfile); > free_callchain(he->callchain); > + free(he->raw_data); > free(he); > } > > diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h > index 86f05e7a5566..d29898708dbd 100644 > --- a/tools/perf/util/sort.h > +++ b/tools/perf/util/sort.h > @@ -122,6 +122,8 @@ struct hist_entry { > struct branch_info *branch_info; > struct hists*hists; > struct mem_info *mem_info; > + void*raw_data; > + u32 raw_size; > struct callchain_root callchain[0]; /* must be last member */ > }; > > -- > 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v4.1 02/13] perf hist: Save raw_data/size for tracepoint events
The raw_data and raw_size fields are to provide tracepoint specific information. They will be used by dynamic sort keys later. Signed-off-by: Namhyung Kim --- make a copy of raw_data tools/perf/util/hist.c | 27 +++ tools/perf/util/sort.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 039bb91d0a92..df5567fff986 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -369,6 +369,28 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template, if (symbol_conf.use_callchain) callchain_init(he->callchain); + if (he->raw_data) { + void *data = malloc(he->raw_size); + + if (data == NULL) { + map__put(he->ms.map); + if (he->branch_info) { + map__put(he->branch_info->from.map); + map__put(he->branch_info->to.map); + free(he->branch_info); + } + if (he->mem_info) { + map__put(he->mem_info->iaddr.map); + map__put(he->mem_info->daddr.map); + } + free(he->stat_acc); + free(he); + return NULL; + } + + memcpy(data, he->raw_data, he->raw_size); + he->raw_data = data; + } INIT_LIST_HEAD(>pairs.node); thread__get(he->thread); } @@ -487,6 +509,8 @@ struct hist_entry *__hists__add_entry(struct hists *hists, .branch_info = bi, .mem_info = mi, .transaction = sample->transaction, + .raw_data = sample->raw_data, + .raw_size = sample->raw_size, }; return hists__findnew_entry(hists, , al, sample_self); @@ -801,6 +825,8 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter, .sym = al->sym, }, .parent = iter->parent, + .raw_data = sample->raw_data, + .raw_size = sample->raw_size, }; int i; struct callchain_cursor cursor; @@ -974,6 +1000,7 @@ void hist_entry__delete(struct hist_entry *he) if (he->srcfile && he->srcfile[0]) free(he->srcfile); free_callchain(he->callchain); + free(he->raw_data); free(he); } diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 86f05e7a5566..d29898708dbd 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -122,6 +122,8 @@ struct hist_entry { struct branch_info *branch_info; struct hists*hists; struct mem_info *mem_info; + void*raw_data; + u32 raw_size; struct callchain_root callchain[0]; /* must be last member */ }; -- 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4.1 02/13] perf hist: Save raw_data/size for tracepoint events
Em Thu, Dec 24, 2015 at 10:05:34AM +0900, Namhyung Kim escreveu: > The raw_data and raw_size fields are to provide tracepoint specific > information. They will be used by dynamic sort keys later. > > Signed-off-by: Namhyung Kim> --- > make a copy of raw_data > > tools/perf/util/hist.c | 27 +++ > tools/perf/util/sort.h | 2 ++ > 2 files changed, 29 insertions(+) > > diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c > index 039bb91d0a92..df5567fff986 100644 > --- a/tools/perf/util/hist.c > +++ b/tools/perf/util/hist.c > @@ -369,6 +369,28 @@ static struct hist_entry *hist_entry__new(struct > hist_entry *template, > if (symbol_conf.use_callchain) > callchain_init(he->callchain); > > + if (he->raw_data) { > + void *data = malloc(he->raw_size); if this is really needed, please use memdup(), I.e.: memdup(he->raw_data, he->raw_size); > + if (data == NULL) { > + map__put(he->ms.map); > + if (he->branch_info) { > + map__put(he->branch_info->from.map); > + map__put(he->branch_info->to.map); > + free(he->branch_info); > + } > + if (he->mem_info) { > + map__put(he->mem_info->iaddr.map); > + map__put(he->mem_info->daddr.map); > + } > + free(he->stat_acc); > + free(he); > + return NULL; > + } > + > + memcpy(data, he->raw_data, he->raw_size); > + he->raw_data = data; > + } > INIT_LIST_HEAD(>pairs.node); > thread__get(he->thread); > } > @@ -487,6 +509,8 @@ struct hist_entry *__hists__add_entry(struct hists *hists, > .branch_info = bi, > .mem_info = mi, > .transaction = sample->transaction, > + .raw_data = sample->raw_data, > + .raw_size = sample->raw_size, > }; > > return hists__findnew_entry(hists, , al, sample_self); > @@ -801,6 +825,8 @@ iter_add_next_cumulative_entry(struct hist_entry_iter > *iter, > .sym = al->sym, > }, > .parent = iter->parent, > + .raw_data = sample->raw_data, > + .raw_size = sample->raw_size, > }; > int i; > struct callchain_cursor cursor; > @@ -974,6 +1000,7 @@ void hist_entry__delete(struct hist_entry *he) > if (he->srcfile && he->srcfile[0]) > free(he->srcfile); > free_callchain(he->callchain); > + free(he->raw_data); > free(he); > } > > diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h > index 86f05e7a5566..d29898708dbd 100644 > --- a/tools/perf/util/sort.h > +++ b/tools/perf/util/sort.h > @@ -122,6 +122,8 @@ struct hist_entry { > struct branch_info *branch_info; > struct hists*hists; > struct mem_info *mem_info; > + void*raw_data; > + u32 raw_size; > struct callchain_root callchain[0]; /* must be last member */ > }; > > -- > 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v4.1 02/13] perf hist: Save raw_data/size for tracepoint events
The raw_data and raw_size fields are to provide tracepoint specific information. They will be used by dynamic sort keys later. Signed-off-by: Namhyung Kim--- make a copy of raw_data tools/perf/util/hist.c | 27 +++ tools/perf/util/sort.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 039bb91d0a92..df5567fff986 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -369,6 +369,28 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template, if (symbol_conf.use_callchain) callchain_init(he->callchain); + if (he->raw_data) { + void *data = malloc(he->raw_size); + + if (data == NULL) { + map__put(he->ms.map); + if (he->branch_info) { + map__put(he->branch_info->from.map); + map__put(he->branch_info->to.map); + free(he->branch_info); + } + if (he->mem_info) { + map__put(he->mem_info->iaddr.map); + map__put(he->mem_info->daddr.map); + } + free(he->stat_acc); + free(he); + return NULL; + } + + memcpy(data, he->raw_data, he->raw_size); + he->raw_data = data; + } INIT_LIST_HEAD(>pairs.node); thread__get(he->thread); } @@ -487,6 +509,8 @@ struct hist_entry *__hists__add_entry(struct hists *hists, .branch_info = bi, .mem_info = mi, .transaction = sample->transaction, + .raw_data = sample->raw_data, + .raw_size = sample->raw_size, }; return hists__findnew_entry(hists, , al, sample_self); @@ -801,6 +825,8 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter, .sym = al->sym, }, .parent = iter->parent, + .raw_data = sample->raw_data, + .raw_size = sample->raw_size, }; int i; struct callchain_cursor cursor; @@ -974,6 +1000,7 @@ void hist_entry__delete(struct hist_entry *he) if (he->srcfile && he->srcfile[0]) free(he->srcfile); free_callchain(he->callchain); + free(he->raw_data); free(he); } diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 86f05e7a5566..d29898708dbd 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -122,6 +122,8 @@ struct hist_entry { struct branch_info *branch_info; struct hists*hists; struct mem_info *mem_info; + void*raw_data; + u32 raw_size; struct callchain_root callchain[0]; /* must be last member */ }; -- 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/