linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Mike Rapoport <rppt@kernel.org>
Cc: Mateusz Nosek <mateusznosek0@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	akpm@linux-foundation.org
Subject: Re: [PATCH] mm/mmu_notifier.c: micro-optimization substitute kzalloc with kmalloc
Date: Tue, 8 Sep 2020 20:32:20 -0300	[thread overview]
Message-ID: <20200908233220.GC87483@ziepe.ca> (raw)
In-Reply-To: <20200908064245.GE1976319@kernel.org>

On Tue, Sep 08, 2020 at 09:42:45AM +0300, Mike Rapoport wrote:
> On Sun, Sep 06, 2020 at 06:06:39PM +0200, Mateusz Nosek wrote:
> > Hi,
> > 
> > I performed simple benchmarks using custom kernel module with the code
> > fragment in question 'copy-pasted' in there in both versions. In case of 1k,
> > 10k and 100k iterations the average time for kzalloc version was 5.1 and for
> > kmalloc 3.9, for each iterations number.
> > The time was measured using 'ktime_get(void)' function and the results given
> > here are in ktime_t units.
> > The machine I use has 4 core Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz CPU.
> > 
> > The performance increase happens, but as you wrote it is probably not really
> > noticeable.
> 
> I don't think that saving a few cylces of memset() in a function that
> called only on the initialization path in very particular cases is worth
> risking uninitialized variables when somebody will add a new field to
> the 'struct mmu_notifier_subscriptions' and will forget to explicitly
> set it.

Indeed, it is not a common path, it is already very expensive if code
is running here (eg it does mm_take_all_locks()).

So there is no reason at all to optimize this and risk problems down
the road.

Jason


      reply	other threads:[~2020-09-08 23:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-06 11:43 [PATCH] mm/mmu_notifier.c: micro-optimization substitute kzalloc with kmalloc mateusznosek0
2020-09-06 14:26 ` Mike Rapoport
2020-09-06 16:06   ` Mateusz Nosek
2020-09-08  6:42     ` Mike Rapoport
2020-09-08 23:32       ` Jason Gunthorpe [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=20200908233220.GC87483@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mateusznosek0@gmail.com \
    --cc=rppt@kernel.org \
    /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).