From: Pavel Roskin <proski@gnu.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-wireless@vger.kernel.org,
"John W. Linville" <linville@tuxdriver.com>
Subject: Re: [PATCH] wireless: at76c50x: fix multithread access to hex2str
Date: Wed, 28 Sep 2011 17:19:09 -0400 [thread overview]
Message-ID: <20110928171909.6889916c@mj> (raw)
In-Reply-To: <21514bff06a915d2edd0a83c74ac512eb8b80b3f.1317215809.git.andriy.shevchenko@linux.intel.com>
On Wed, 28 Sep 2011 16:17:31 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> The original hex2str uses finite array of buffers to keep output
> data. It's a wrong approach, because we can't say at compile time how
> many threads will be used.
>
> This patch introduces one buffer and global mutex to access this
> function. All calls of it are wrapped by locking this mutex. It saves
> some memory as a side effect.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: "John W. Linville" <linville@tuxdriver.com>
The reason for having 4 buffers is to allow using hex2str() more than
once in the same printk() statement. As you can see, hex2str() is
never used in one statement more than once. Your solution would make
it impossible to use hex2str() twice in the same printk(), as the
buffer would be reused. Actually, wrong data would be printed with no
warning! Such code doesn't exist in the driver, but it could be added
by somebody looking for a problem. And that would hamper debugging
instead of helping it.
I think we can live with a debug function printing wrong data if it's
called by 5 callers at once.
And if you want a perfectly correct fix, I suggest that you use
buffers allocated by the callers on the stack. That's less intrusive
than mutexes, and it would allow using more than one hex2str() in one
statement as long as the buffers are different.
Or maybe hex2str() should be replaced with calls to
print_hex_dump_bytes()? That would add extra lines to the kernel
output, but it's no big deal. Of course, if you are concerned about 5
callers printing bytes in the same time, the output may be hard to
understand, but I don't think it a problem that needs addressing.
Or maybe you could develop an extension for printk() format that would
dump strings of the given length? Something like %pM, but with an
extra argument (and make sure it would not trigger a gcc warning).
This way, everybody would benefit.
Please rethink whether it's helpful to send such "fixes" for old and
little maintained drivers. There are few people who can work on them,
and they have little time for the old drivers. Their time is better
spent fixing real problems than reviewing untested or badly conceived
patches for imaginary problems and style issues. Besides, there are few
users who could test the driver and report breakage.
--
Regards,
Pavel Roskin
next prev parent reply other threads:[~2011-09-28 21:19 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-28 13:17 [PATCH] wireless: at76c50x: fix multithread access to hex2str Andy Shevchenko
2011-09-28 21:19 ` Pavel Roskin [this message]
2011-09-29 10:46 ` Andy Shevchenko
2011-09-30 15:53 ` Pavel Roskin
2012-06-29 15:58 ` [RFC][PATCH 1/2] lib: printf: append support of '%*p[Mm][FR]' Andy Shevchenko
2012-06-29 15:58 ` [RFC][PATCH 2/2] wireless: at76c50x: eliminate hex2str() Andy Shevchenko
2012-06-29 16:35 ` Larry Finger
2012-06-29 16:08 ` [RFC][PATCH 1/2] lib: printf: append support of '%*p[Mm][FR]' Joe Perches
2012-06-29 23:26 ` Andrew Morton
2012-06-30 14:48 ` Joe Perches
2012-07-02 17:32 ` Andy Shevchenko
2012-07-02 21:23 ` Joe Perches
2012-07-03 10:06 ` [RFC][PATCHv2 1/3] lib: printf: update documentation to cover all of %p[Mm][FR] Andy Shevchenko
2012-07-03 10:06 ` [RFC][PATCHv2 2/3] lib: printf: append support of '%*p[Mm][FR]' Andy Shevchenko
2012-07-03 15:33 ` Joe Perches
2012-07-03 18:32 ` Andy Shevchenko
2012-07-03 18:48 ` Joe Perches
2012-07-04 8:45 ` [PATCHv3 1/3] lib: printf: update documentation to cover all of %p[Mm][FR] Andy Shevchenko
2012-07-04 8:45 ` [PATCHv3 2/3] lib: printf: append support of '%*ph[CDN]' Andy Shevchenko
2012-07-04 15:09 ` Joe Perches
2012-07-05 8:02 ` Andy Shevchenko
2012-07-05 13:21 ` [PATCHv3.6] " Andy Shevchenko
2012-07-04 8:45 ` [PATCHv3 3/3] wireless: at76c50x: eliminate hex2str() Andy Shevchenko
2012-09-05 8:52 ` [resend][PATCH] " Andy Shevchenko
2012-09-10 18:34 ` John W. Linville
2012-09-11 7:04 ` Andy Shevchenko
2012-07-24 8:07 ` [PATCHv3 1/3] lib: printf: update documentation to cover all of %p[Mm][FR] andrei.emeltchenko.news
2012-07-09 12:03 ` [RFC][PATCHv2 2/3] lib: printf: append support of '%*p[Mm][FR]' Andrei Emeltchenko
2012-07-03 10:06 ` [RFC][PATCHv2 3/3] wireless: at76c50x: eliminate hex2str() Andy Shevchenko
2012-07-03 13:18 ` Larry Finger
2012-07-03 19:02 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110928171909.6889916c@mj \
--to=proski@gnu.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).