Message ID | 20180712185930.2492-6-jcrouse@codeaurora.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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 <jcrouse@codeaurora.org> > --- > 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 <drm/drmP.h> > #include <drm/drm_print.h> > > +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
On Thu, Jul 12, 2018 at 2:59 PM, Jordan Crouse <jcrouse@codeaurora.org> 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 <jcrouse@codeaurora.org> > --- > 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 <drm/drmP.h> > #include <drm/drm_print.h> > > +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
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 <drm/drmP.h> #include <drm/drm_print.h> +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;
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 <jcrouse@codeaurora.org> --- drivers/gpu/drm/drm_print.c | 43 +++++++++++++++++++++++++++++++++++++ include/drm/drm_print.h | 2 ++ 2 files changed, 45 insertions(+)