Re: [PATCH 2/8] perf tools: Make __hpp__fmt() receive an additional len argument
Hi Arnaldo, On Mon, 11 Aug 2014 10:17:38 -0300, Arnaldo Carvalho de Melo wrote: > Em Mon, Aug 11, 2014 at 05:05:33PM +0900, Namhyung Kim escreveu: >> Hi Arnaldo, >> >> On Sat, 2 Aug 2014 10:30:26 -0300, Arnaldo Carvalho de Melo wrote: >> > Em Thu, Jul 31, 2014 at 02:47:36PM +0900, Namhyung Kim escreveu: >> >> So that it can properly handle alignment requirements later. To do >> >> that, add percent_color_len_snprintf() fucntion to help coloring of >> >> overhead columns. >> > >> > Can you elaborate on this description? What is not possible to do before >> > this patch? >> >> This patch is a preparation that moves hard-coded print width out of the >> format string so that it can be passed from external settings later. > > Ok, please add this to the patch description? Will do. Btw, do you want me to resend the series? It seems your tree already merged it.. Thanks, Namhyung -- 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 2/8] perf tools: Make __hpp__fmt() receive an additional len argument
Hi Arnaldo, On Mon, 11 Aug 2014 10:17:38 -0300, Arnaldo Carvalho de Melo wrote: Em Mon, Aug 11, 2014 at 05:05:33PM +0900, Namhyung Kim escreveu: Hi Arnaldo, On Sat, 2 Aug 2014 10:30:26 -0300, Arnaldo Carvalho de Melo wrote: Em Thu, Jul 31, 2014 at 02:47:36PM +0900, Namhyung Kim escreveu: So that it can properly handle alignment requirements later. To do that, add percent_color_len_snprintf() fucntion to help coloring of overhead columns. Can you elaborate on this description? What is not possible to do before this patch? This patch is a preparation that moves hard-coded print width out of the format string so that it can be passed from external settings later. Ok, please add this to the patch description? Will do. Btw, do you want me to resend the series? It seems your tree already merged it.. Thanks, Namhyung -- 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 2/8] perf tools: Make __hpp__fmt() receive an additional len argument
Em Mon, Aug 11, 2014 at 05:05:33PM +0900, Namhyung Kim escreveu: > Hi Arnaldo, > > On Sat, 2 Aug 2014 10:30:26 -0300, Arnaldo Carvalho de Melo wrote: > > Em Thu, Jul 31, 2014 at 02:47:36PM +0900, Namhyung Kim escreveu: > >> So that it can properly handle alignment requirements later. To do > >> that, add percent_color_len_snprintf() fucntion to help coloring of > >> overhead columns. > > > > Can you elaborate on this description? What is not possible to do before > > this patch? > > This patch is a preparation that moves hard-coded print width out of the > format string so that it can be passed from external settings later. Ok, please add this to the patch description? > > Perhaps a formatted line before this patch and then the same line > > formatted after the patch? > The default behavior wasn't changed, it's only meaningful when user > gives field width using -w option. You can see the difference in the > description 0/8. - Arnaldo -- 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 2/8] perf tools: Make __hpp__fmt() receive an additional len argument
Hi Arnaldo, On Sat, 2 Aug 2014 10:30:26 -0300, Arnaldo Carvalho de Melo wrote: > Em Thu, Jul 31, 2014 at 02:47:36PM +0900, Namhyung Kim escreveu: >> So that it can properly handle alignment requirements later. To do >> that, add percent_color_len_snprintf() fucntion to help coloring of >> overhead columns. > > Can you elaborate on this description? What is not possible to do before > this patch? This patch is a preparation that moves hard-coded print width out of the format string so that it can be passed from external settings later. > > Perhaps a formatted line before this patch and then the same line > formatted after the patch? The default behavior wasn't changed, it's only meaningful when user gives field width using -w option. You can see the difference in the description 0/8. Thanks, Namhyung -- 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 2/8] perf tools: Make __hpp__fmt() receive an additional len argument
Hi Arnaldo, On Sat, 2 Aug 2014 10:30:26 -0300, Arnaldo Carvalho de Melo wrote: Em Thu, Jul 31, 2014 at 02:47:36PM +0900, Namhyung Kim escreveu: So that it can properly handle alignment requirements later. To do that, add percent_color_len_snprintf() fucntion to help coloring of overhead columns. Can you elaborate on this description? What is not possible to do before this patch? This patch is a preparation that moves hard-coded print width out of the format string so that it can be passed from external settings later. Perhaps a formatted line before this patch and then the same line formatted after the patch? The default behavior wasn't changed, it's only meaningful when user gives field width using -w option. You can see the difference in the description 0/8. Thanks, Namhyung -- 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 2/8] perf tools: Make __hpp__fmt() receive an additional len argument
Em Mon, Aug 11, 2014 at 05:05:33PM +0900, Namhyung Kim escreveu: Hi Arnaldo, On Sat, 2 Aug 2014 10:30:26 -0300, Arnaldo Carvalho de Melo wrote: Em Thu, Jul 31, 2014 at 02:47:36PM +0900, Namhyung Kim escreveu: So that it can properly handle alignment requirements later. To do that, add percent_color_len_snprintf() fucntion to help coloring of overhead columns. Can you elaborate on this description? What is not possible to do before this patch? This patch is a preparation that moves hard-coded print width out of the format string so that it can be passed from external settings later. Ok, please add this to the patch description? Perhaps a formatted line before this patch and then the same line formatted after the patch? The default behavior wasn't changed, it's only meaningful when user gives field width using -w option. You can see the difference in the description 0/8. - Arnaldo -- 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 2/8] perf tools: Make __hpp__fmt() receive an additional len argument
Em Thu, Jul 31, 2014 at 02:47:36PM +0900, Namhyung Kim escreveu: > So that it can properly handle alignment requirements later. To do > that, add percent_color_len_snprintf() fucntion to help coloring of > overhead columns. Can you elaborate on this description? What is not possible to do before this patch? Perhaps a formatted line before this patch and then the same line formatted after the patch? > Signed-off-by: Namhyung Kim > --- > tools/perf/ui/browsers/hists.c | 14 -- > tools/perf/ui/gtk/hists.c | 8 +--- > tools/perf/ui/hist.c | 43 > +- > tools/perf/util/color.c| 16 > tools/perf/util/color.h| 1 + > tools/perf/util/hist.h | 4 ++-- > 6 files changed, 54 insertions(+), 32 deletions(-) > > diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c > index a94b11fc5e00..02507ba944e3 100644 > --- a/tools/perf/ui/browsers/hists.c > +++ b/tools/perf/ui/browsers/hists.c > @@ -653,17 +653,18 @@ struct hpp_arg { > static int __hpp__slsmg_color_printf(struct perf_hpp *hpp, const char *fmt, > ...) > { > struct hpp_arg *arg = hpp->ptr; > - int ret; > + int ret, len; > va_list args; > double percent; > > va_start(args, fmt); > + len = va_arg(args, int); > percent = va_arg(args, double); > va_end(args); > > ui_browser__set_percent_color(arg->b, percent, arg->current_entry); > > - ret = scnprintf(hpp->buf, hpp->size, fmt, percent); > + ret = scnprintf(hpp->buf, hpp->size, fmt, len, percent); > slsmg_printf("%s", hpp->buf); > > advance_hpp(hpp, ret); > @@ -681,7 +682,7 @@ hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt > __maybe_unused,\ > struct perf_hpp *hpp, \ > struct hist_entry *he) \ > {\ > - return __hpp__fmt(hpp, he, __hpp_get_##_field, " %6.2f%%", \ > + return __hpp__fmt(hpp, he, __hpp_get_##_field, " %*.2f%%", 6, \ > __hpp__slsmg_color_printf, true); \ > } > > @@ -697,13 +698,14 @@ hist_browser__hpp_color_##_type(struct perf_hpp_fmt > *fmt __maybe_unused,\ > struct hist_entry *he) \ > {\ > if (!symbol_conf.cumulate_callchain) { \ > - int ret = scnprintf(hpp->buf, hpp->size, "%8s", "N/A"); \ > + int ret = scnprintf(hpp->buf, hpp->size,\ > + "%*s", 8, "N/A"); \ > slsmg_printf("%s", hpp->buf); \ > \ > return ret; \ > } \ > - return __hpp__fmt(hpp, he, __hpp_get_acc_##_field, " %6.2f%%", \ > - __hpp__slsmg_color_printf, true); \ > + return __hpp__fmt(hpp, he, __hpp_get_acc_##_field, " %*.2f%%", \ > + 6, __hpp__slsmg_color_printf, true); \ > } > > __HPP_COLOR_PERCENT_FN(overhead, period) > diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c > index 6ca60e482cdc..91f6cd7d2312 100644 > --- a/tools/perf/ui/gtk/hists.c > +++ b/tools/perf/ui/gtk/hists.c > @@ -11,6 +11,7 @@ > static int __percent_color_snprintf(struct perf_hpp *hpp, const char *fmt, > ...) > { > int ret = 0; > + int len; > va_list args; > double percent; > const char *markup; > @@ -18,6 +19,7 @@ static int __percent_color_snprintf(struct perf_hpp *hpp, > const char *fmt, ...) > size_t size = hpp->size; > > va_start(args, fmt); > + len = va_arg(args, int); > percent = va_arg(args, double); > va_end(args); > > @@ -25,7 +27,7 @@ static int __percent_color_snprintf(struct perf_hpp *hpp, > const char *fmt, ...) > if (markup) > ret += scnprintf(buf, size, markup); > > - ret += scnprintf(buf + ret, size - ret, fmt, percent); > + ret += scnprintf(buf + ret, size - ret, fmt, len, percent); > > if (markup) > ret += scnprintf(buf + ret, size - ret, ""); > @@ -43,7 +45,7 @@ static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt > *fmt __maybe_unused, > struct perf_hpp *hpp, > \ > struct hist_entry *he) > \ > { > \ > - return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", > \ > + return __hpp__fmt(hpp, he, he_get_##_field, "
Re: [PATCH 2/8] perf tools: Make __hpp__fmt() receive an additional len argument
Em Thu, Jul 31, 2014 at 02:47:36PM +0900, Namhyung Kim escreveu: So that it can properly handle alignment requirements later. To do that, add percent_color_len_snprintf() fucntion to help coloring of overhead columns. Can you elaborate on this description? What is not possible to do before this patch? Perhaps a formatted line before this patch and then the same line formatted after the patch? Signed-off-by: Namhyung Kim namhy...@kernel.org --- tools/perf/ui/browsers/hists.c | 14 -- tools/perf/ui/gtk/hists.c | 8 +--- tools/perf/ui/hist.c | 43 +- tools/perf/util/color.c| 16 tools/perf/util/color.h| 1 + tools/perf/util/hist.h | 4 ++-- 6 files changed, 54 insertions(+), 32 deletions(-) diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index a94b11fc5e00..02507ba944e3 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -653,17 +653,18 @@ struct hpp_arg { static int __hpp__slsmg_color_printf(struct perf_hpp *hpp, const char *fmt, ...) { struct hpp_arg *arg = hpp-ptr; - int ret; + int ret, len; va_list args; double percent; va_start(args, fmt); + len = va_arg(args, int); percent = va_arg(args, double); va_end(args); ui_browser__set_percent_color(arg-b, percent, arg-current_entry); - ret = scnprintf(hpp-buf, hpp-size, fmt, percent); + ret = scnprintf(hpp-buf, hpp-size, fmt, len, percent); slsmg_printf(%s, hpp-buf); advance_hpp(hpp, ret); @@ -681,7 +682,7 @@ hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,\ struct perf_hpp *hpp, \ struct hist_entry *he) \ {\ - return __hpp__fmt(hpp, he, __hpp_get_##_field, %6.2f%%, \ + return __hpp__fmt(hpp, he, __hpp_get_##_field, %*.2f%%, 6, \ __hpp__slsmg_color_printf, true); \ } @@ -697,13 +698,14 @@ hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,\ struct hist_entry *he) \ {\ if (!symbol_conf.cumulate_callchain) { \ - int ret = scnprintf(hpp-buf, hpp-size, %8s, N/A); \ + int ret = scnprintf(hpp-buf, hpp-size,\ + %*s, 8, N/A); \ slsmg_printf(%s, hpp-buf); \ \ return ret; \ } \ - return __hpp__fmt(hpp, he, __hpp_get_acc_##_field, %6.2f%%, \ - __hpp__slsmg_color_printf, true); \ + return __hpp__fmt(hpp, he, __hpp_get_acc_##_field, %*.2f%%, \ + 6, __hpp__slsmg_color_printf, true); \ } __HPP_COLOR_PERCENT_FN(overhead, period) diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index 6ca60e482cdc..91f6cd7d2312 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c @@ -11,6 +11,7 @@ static int __percent_color_snprintf(struct perf_hpp *hpp, const char *fmt, ...) { int ret = 0; + int len; va_list args; double percent; const char *markup; @@ -18,6 +19,7 @@ static int __percent_color_snprintf(struct perf_hpp *hpp, const char *fmt, ...) size_t size = hpp-size; va_start(args, fmt); + len = va_arg(args, int); percent = va_arg(args, double); va_end(args); @@ -25,7 +27,7 @@ static int __percent_color_snprintf(struct perf_hpp *hpp, const char *fmt, ...) if (markup) ret += scnprintf(buf, size, markup); - ret += scnprintf(buf + ret, size - ret, fmt, percent); + ret += scnprintf(buf + ret, size - ret, fmt, len, percent); if (markup) ret += scnprintf(buf + ret, size - ret, /span); @@ -43,7 +45,7 @@ static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, struct perf_hpp *hpp, \ struct hist_entry *he) \ { \ - return __hpp__fmt(hpp, he, he_get_##_field, %6.2f%%, \ + return __hpp__fmt(hpp, he, he_get_##_field, %*.2f%%, 6, \ __percent_color_snprintf, true); \ } @@ -57,7