From: Tejun Heo <tj@kernel.org>
To: pang.xunlei@zte.com.cn
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Lai Jiangshan <laijs@cn.fujitsu.com>
Subject: Re: [PATCH] idr: optimize ida_init() to avoid an extra memset
Date: Wed, 29 Oct 2014 10:38:38 -0400 [thread overview]
Message-ID: <20141029143838.GC25226@htj.dyndns.org> (raw)
In-Reply-To: <OF73B80F6F.959BED11-ON48257D80.00327936-48257D80.00341CEF@zte.com.cn>
On Wed, Oct 29, 2014 at 05:26:34PM +0800, pang.xunlei@zte.com.cn wrote:
> The memset in ida_init() already handles idr, so there's some
> redundancy in the following idr_init().
>
> This patch removes the memset, and clears ida->free_bitmap instead.
>
> Signed-off-by: pang.xunlei <pang.xunlei@zte.com.cn>
> ---
> lib/idr.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/lib/idr.c b/lib/idr.c
> index e654aeb..bbe5779 100644
> --- a/lib/idr.c
> +++ b/lib/idr.c
> @@ -1141,8 +1141,7 @@ EXPORT_SYMBOL(ida_simple_remove);
> */
> void ida_init(struct ida *ida)
> {
> - memset(ida, 0, sizeof(struct ida));
> idr_init(&ida->idr);
> -
> + ida->free_bitmap = NULL;
I don't know. Does this matter? If this *really* matters, I'd much
rather have memset(&ida->FIRST_FIELD, 0, sizeof(struct ida) - offset
of FIRST_FIELD) to ensure that all fields get reset or implement an
internal function like __idr_init_without_zeroing(); however, given
the size of an idr and the low frequency of the operation, I'd prefer
to just leave it as-is.
Thanks.
--
tejun
next parent reply other threads:[~2014-10-29 14:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <OF73B80F6F.959BED11-ON48257D80.00327936-48257D80.00341CEF@zte.com.cn>
2014-10-29 14:38 ` Tejun Heo [this message]
2014-10-30 2:06 ` [PATCH] idr: optimize ida_init() to avoid an extra memset Lai Jiangshan
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=20141029143838.GC25226@htj.dyndns.org \
--to=tj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pang.xunlei@zte.com.cn \
/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