Re: [Freedreno] [PATCH 05/13] drm: Add put callback for the coredump printer
On Thu, Jul 12, 2018 at 2:59 PM, Jordan Crouse wrote: > Add a put function for the coredump printer to bypass printf() > for constant strings for a speed boost. s/put/puts/ (and in the $subject) BR, -R > > v2: Add EXPORT_SYMBOL for _drm_puts_coredump > Signed-off-by: Jordan Crouse > --- > drivers/gpu/drm/drm_print.c | 43 + > include/drm/drm_print.h | 2 ++ > 2 files changed, 45 insertions(+) > > diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c > index bef8f0ec5d73..ff20f4a764c8 100644 > --- a/drivers/gpu/drm/drm_print.c > +++ b/drivers/gpu/drm/drm_print.c > @@ -30,6 +30,49 @@ > #include > #include > > +void __drm_puts_coredump(struct drm_printer *p, const char *str) > +{ > + struct drm_print_iterator *iterator = p->arg; > + > + ssize_t len; > + > + if (!iterator->remain) > + return; > + > + if (iterator->offset < iterator->start) { > + ssize_t copy; > + > + len = strlen(str); > + > + if (iterator->offset + len <= iterator->start) { > + iterator->offset += len; > + return; > + } > + > + copy = len - (iterator->start - iterator->offset); > + > + if (copy > iterator->remain) > + copy = iterator->remain; > + > + /* Copy out the bit of the string that we need */ > + memcpy(iterator->data, > + str + (iterator->start - iterator->offset), copy); > + > + iterator->offset = iterator->start + copy; > + iterator->remain -= copy; > + } else { > + ssize_t pos = iterator->offset - iterator->start; > + > + len = min_t(ssize_t, strlen(str), iterator->remain); > + > + memcpy(iterator->data + pos, str, len); > + > + iterator->offset += len; > + iterator->remain -= len; > + } > +} > +EXPORT_SYMBOL(__drm_puts_coredump); > + > void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf) > { > struct drm_print_iterator *iterator = p->arg; > diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h > index 3bc6ba4b7b2c..2a903ee7b428 100644 > --- a/include/drm/drm_print.h > +++ b/include/drm/drm_print.h > @@ -75,6 +75,7 @@ struct drm_printer { > }; > > void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf); > +void __drm_puts_coredump(struct drm_printer *p, const char *str); > void __drm_printfn_seq_file(struct drm_printer *p, struct va_format *vaf); > void __drm_puts_seq_file(struct drm_printer *p, const char *str); > void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf); > @@ -129,6 +130,7 @@ drm_coredump_printer(struct drm_print_iterator *iter) > { > struct drm_printer p = { > .printfn = __drm_printfn_coredump, > + .puts = __drm_puts_coredump, > .arg = iter, > }; > return p; > -- > 2.17.1 > > ___ > Freedreno mailing list > Freedreno@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/freedreno ___ Freedreno mailing list Freedreno@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/freedreno
Re: [Freedreno] [PATCH 05/13] drm: Add put callback for the coredump printer
Quoting Jordan Crouse (2018-07-12 19:59:22) > Add a put function for the coredump printer to bypass printf() > for constant strings for a speed boost. > > v2: Add EXPORT_SYMBOL for _drm_puts_coredump > Signed-off-by: Jordan Crouse > --- > drivers/gpu/drm/drm_print.c | 43 + > include/drm/drm_print.h | 2 ++ > 2 files changed, 45 insertions(+) > > diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c > index bef8f0ec5d73..ff20f4a764c8 100644 > --- a/drivers/gpu/drm/drm_print.c > +++ b/drivers/gpu/drm/drm_print.c > @@ -30,6 +30,49 @@ > #include > #include > > +void __drm_puts_coredump(struct drm_printer *p, const char *str) > +{ > + struct drm_print_iterator *iterator = p->arg; > + > + ssize_t len; > + > + if (!iterator->remain) > + return; > + > + if (iterator->offset < iterator->start) { > + ssize_t copy; > + > + len = strlen(str); > + printfn_coredump looks like it would then wrap puts_coredump? -Chris ___ Freedreno mailing list Freedreno@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/freedreno
[Freedreno] [PATCH 05/13] drm: Add put callback for the coredump printer
Add a put function for the coredump printer to bypass printf() for constant strings for a speed boost. v2: Add EXPORT_SYMBOL for _drm_puts_coredump Signed-off-by: Jordan Crouse --- drivers/gpu/drm/drm_print.c | 43 + include/drm/drm_print.h | 2 ++ 2 files changed, 45 insertions(+) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index bef8f0ec5d73..ff20f4a764c8 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -30,6 +30,49 @@ #include #include +void __drm_puts_coredump(struct drm_printer *p, const char *str) +{ + struct drm_print_iterator *iterator = p->arg; + + ssize_t len; + + if (!iterator->remain) + return; + + if (iterator->offset < iterator->start) { + ssize_t copy; + + len = strlen(str); + + if (iterator->offset + len <= iterator->start) { + iterator->offset += len; + return; + } + + copy = len - (iterator->start - iterator->offset); + + if (copy > iterator->remain) + copy = iterator->remain; + + /* Copy out the bit of the string that we need */ + memcpy(iterator->data, + str + (iterator->start - iterator->offset), copy); + + iterator->offset = iterator->start + copy; + iterator->remain -= copy; + } else { + ssize_t pos = iterator->offset - iterator->start; + + len = min_t(ssize_t, strlen(str), iterator->remain); + + memcpy(iterator->data + pos, str, len); + + iterator->offset += len; + iterator->remain -= len; + } +} +EXPORT_SYMBOL(__drm_puts_coredump); + void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf) { struct drm_print_iterator *iterator = p->arg; diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 3bc6ba4b7b2c..2a903ee7b428 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -75,6 +75,7 @@ struct drm_printer { }; void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf); +void __drm_puts_coredump(struct drm_printer *p, const char *str); void __drm_printfn_seq_file(struct drm_printer *p, struct va_format *vaf); void __drm_puts_seq_file(struct drm_printer *p, const char *str); void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf); @@ -129,6 +130,7 @@ drm_coredump_printer(struct drm_print_iterator *iter) { struct drm_printer p = { .printfn = __drm_printfn_coredump, + .puts = __drm_puts_coredump, .arg = iter, }; return p; -- 2.17.1 ___ Freedreno mailing list Freedreno@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/freedreno
[Freedreno] [PATCH 05/13] drm: Add put callback for the coredump printer
Add a put function for the coredump printer to bypass printf() for constant strings for a speed boost. Signed-off-by: Jordan Crouse --- drivers/gpu/drm/drm_print.c | 42 + include/drm/drm_print.h | 2 ++ 2 files changed, 44 insertions(+) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index bef8f0ec5d73..bec912215b35 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -30,6 +30,48 @@ #include #include +void __drm_puts_coredump(struct drm_printer *p, const char *str) +{ + struct drm_print_iterator *iterator = p->arg; + + ssize_t len; + + if (!iterator->remain) + return; + + if (iterator->offset < iterator->start) { + ssize_t copy; + + len = strlen(str); + + if (iterator->offset + len <= iterator->start) { + iterator->offset += len; + return; + } + + copy = len - (iterator->start - iterator->offset); + + if (copy > iterator->remain) + copy = iterator->remain; + + /* Copy out the bit of the string that we need */ + memcpy(iterator->data, + str + (iterator->start - iterator->offset), copy); + + iterator->offset = iterator->start + copy; + iterator->remain -= copy; + } else { + ssize_t pos = iterator->offset - iterator->start; + + len = min_t(ssize_t, strlen(str), iterator->remain); + + memcpy(iterator->data + pos, str, len); + + iterator->offset += len; + iterator->remain -= len; + } +} + void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf) { struct drm_print_iterator *iterator = p->arg; diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 3bc6ba4b7b2c..2a903ee7b428 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -75,6 +75,7 @@ struct drm_printer { }; void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf); +void __drm_puts_coredump(struct drm_printer *p, const char *str); void __drm_printfn_seq_file(struct drm_printer *p, struct va_format *vaf); void __drm_puts_seq_file(struct drm_printer *p, const char *str); void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf); @@ -129,6 +130,7 @@ drm_coredump_printer(struct drm_print_iterator *iter) { struct drm_printer p = { .printfn = __drm_printfn_coredump, + .puts = __drm_puts_coredump, .arg = iter, }; return p; -- 2.17.1 ___ Freedreno mailing list Freedreno@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/freedreno