From: Jens Axboe <jens.axboe@oracle.com>
To: wzt wzt <wzt.wzt@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Block: Check major number before allocate the buffer in register_blkdev()
Date: Mon, 10 May 2010 14:35:32 +0200 [thread overview]
Message-ID: <20100510123532.GC27497@kernel.dk> (raw)
In-Reply-To: <AANLkTilVZpXlY294vzHS5gVf4f1M4fuz_vN17LOpoRxc@mail.gmail.com>
Please don't top post when replying to emails, I fixed this one up for
you.
On Mon, May 10 2010, wzt wzt wrote:
> On Mon, May 10, 2010 at 7:56 PM, Jens Axboe <jens.axboe@oracle.com> wrote:
> > On Mon, May 10 2010, wzt.wzt@gmail.com wrote:
> >> Check major number before allocate the buffer, if the major number is not exist,
> >> and the register_blkdev() called many times, kmalloc()/kfree() will be no need
> >> to invoked many times. So check the major number before use kmalloc() to allocate
> >> the buffer will be better.
> >
> > This would generally be sound advice for performance oriented code, but
> > I can't see it making any difference here.
>
> the original code use kmalloc() to allocate struct blk_major_name
> buffer first, then find the major number in major_names array. if
> found it, it will kfree() the unused struct blk_major_name buffer,
> if register_blkdev() called many times like:
> register_blkdev(22, "aa");
> ....
> register_blkdev(22, "aa");
> kmalloc()/kfree() will be no need to invoked many times, my point is
> that find the major number first, then allocate the buffer will be
> better. this patch can handle the special case.
Yes I realize how it works and what your patch does, my point is that it
seems pointless to change code like that. Your 'test case' above isn't a
valid one. If register_blkdev() was called tons of times per second and
hence would be a hot code path, and it additionally most of the time
ended up freeing the buffer, then there would be a case for changing it.
--
Jens Axboe
prev parent reply other threads:[~2010-05-10 12:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-10 6:16 [PATCH] Block: Check major number before allocate the buffer in register_blkdev() wzt.wzt
2010-05-10 11:56 ` Jens Axboe
2010-05-10 12:24 ` wzt wzt
2010-05-10 12:35 ` Jens Axboe [this message]
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=20100510123532.GC27497@kernel.dk \
--to=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=wzt.wzt@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.