Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1429145
| From | Joe Perches <joe@perches.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] mellanox: mlx5: Use logging functions to reduce text ~10k/5% |
| Date | 2016-06-23 00:30 +0200 |
| Message-ID | <rMYOL-XK-59@gated-at.bofh.it> (permalink) |
| References | <rMV4t-6Zs-13@gated-at.bofh.it> <rMXfX-8kd-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed, 2016-06-22 at 14:40 -0600, Jason Gunthorpe wrote:
> On Wed, Jun 22, 2016 at 11:23:59AM -0700, Joe Perches wrote:
> > The output changes now do not include line #, but do include the
> > function offset.
> I've been using a technique like this in some code with good results:
>
> struct source_location
> {
> const char *file;
> const char *func;
> const char *format;
> uint16_t line;
> };
> #define _LOCATION(format) ({static const source_location __location__
> = {\
> __FILE__,__PRETTY_FUNCTION__,format,__LINE__};\
> &__location__;})
>
> void _mlx5_core_err(const struct source_location *loc,struct
> mlx5_core_dev *dev, ...);
> #define mlx5_core_err(dev,format,...)
> _mlx_core_err(_LOCATION(format),dev,__VA_ARGS__)
>
> The call site .text overhead is the about same as what you have, but
> this still retains the function and line number information in
> .rodata.
Hello Jason.
As far as I know, no kernel code currently uses a _LOCATION
like macro.
I think your proposal is nearly identical code size to the
existing call. Also, compiler format/argument checking is
eliminated and I think that is a significant negative.
Using the kernel vsprintf %pS or %ps extension is pretty common.
Using printk("%pS", __builtin_return_address(0)); in the called
function is no overhead at all and returns almost exactly
the same information.
Using more expressive messages is generally better than using
printk("%d", __LINE__);
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] mellanox: mlx5: Use logging functions to reduce text ~10k/5% Joe Perches <joe@perches.com> - 2016-06-22 20:30 +0200
Re: [PATCH] mellanox: mlx5: Use logging functions to reduce text ~10k/5% Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-06-22 22:50 +0200
Re: [PATCH] mellanox: mlx5: Use logging functions to reduce text ~10k/5% Joe Perches <joe@perches.com> - 2016-06-23 00:30 +0200
Re: [PATCH] mellanox: mlx5: Use logging functions to reduce text ~10k/5% Saeed Mahameed <saeedm@dev.mellanox.co.il> - 2016-06-23 10:20 +0200
Re: [PATCH] mellanox: mlx5: Use logging functions to reduce text ~10k/5% Saeed Mahameed <saeedm@dev.mellanox.co.il> - 2016-06-23 10:20 +0200
csiph-web