public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: Frederik Deweerdt <frederik.deweerdt@xprog.eu>
Cc: Andi Kleen <andi@firstfloor.org>,
	mingo@elte.hu, tglx@linutronix.de, hpa@zytor.com,
	linux-kernel@vger.kernel.org
Subject: Re: [patch] tlb flush_data: replace per_cpu with an array
Date: Mon, 12 Jan 2009 23:32:20 +0100	[thread overview]
Message-ID: <20090112223220.GK23848@one.firstfloor.org> (raw)
In-Reply-To: <20090112221023.GB10720@gambetta>

On Mon, Jan 12, 2009 at 11:10:23PM +0100, Frederik Deweerdt wrote:
> On Mon, Jan 12, 2009 at 10:57:02PM +0100, Andi Kleen wrote:
> > On Mon, Jan 12, 2009 at 10:35:42PM +0100, Frederik Deweerdt wrote:
> > > Hi,
> > > 
> > > On x86_64 flush tlb data is stored in per_cpu variables. This is
> > > unnecessary because only the first NUM_INVALIDATE_TLB_VECTORS entries
> > > are accessed.
> > > This patch aims at making the code less confusing (there's nothing
> > > really "per_cpu") by using a plain array. It also would save some memory
> > > on most distros out there (Ubuntu x86_64 has NR_CPUS=64 by default).
> > 
> > Nope it doesn't save memory on most systems because per cpu is only allocated
> > based on the CPUs that are actually there. And if you have more than 8
> > cores you can likely afford a few bytes per CPU.
> I did not understand that, thanks for clarifiying
> > 
> > You would need to cache line pad each entry then, otherwise you risk
> > false sharing. That would make the array 1K on 128 bytes cache line 
> > system.  This means on small systems this would actually waste
> > much more memory.
> > 
> > per cpu avoids that problem completely.
> It is also slower (or so percpu.h says), and confusing I'd say.

Well it's something like 3 instructions versus one. You would
have a hard time benchmarking it unless you run it in a very tight 
loop. It will be lost in the noise compared to all the other costs
of the IPI.

Also why i don't like this patch is that on the typical small single/dual
core system running a 128 byte cache line distro kernel you always pay the 
1K cost now, while with per cpu it only needed one/two entries.

Admittedly it could have been better commented.

Not that it matters now unfortunately it's already applied. Sometimes
wonder why I still bother to do patch review...

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only.

  reply	other threads:[~2009-01-12 22:18 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-12 21:35 [patch] tlb flush_data: replace per_cpu with an array Frederik Deweerdt
2009-01-12 21:46 ` Ingo Molnar
2009-01-12 21:57 ` Andi Kleen
2009-01-12 22:10   ` Frederik Deweerdt
2009-01-12 22:32     ` Andi Kleen [this message]
2009-01-12 22:50       ` Ingo Molnar
2009-01-12 22:40   ` Ingo Molnar
2009-01-12 22:59     ` H. Peter Anvin
2009-01-13  2:43     ` Andi Kleen
2009-01-13 12:28       ` Ingo Molnar
2009-01-12 22:34 ` Ravikiran G Thirumalai
2009-01-12 23:00   ` Ingo Molnar
2009-01-12 23:09     ` Ingo Molnar
2009-01-13  2:14     ` Ravikiran G Thirumalai
2009-01-13 12:00     ` Peter Zijlstra
2009-01-13 12:33       ` Ingo Molnar
2009-01-13 18:13         ` Ravikiran G Thirumalai
2009-01-13 18:34           ` Ingo Molnar
2009-01-13 18:42             ` Ravikiran G Thirumalai
2009-01-14  7:31               ` Ingo Molnar
2009-01-15  7:15                 ` Ravikiran G Thirumalai
2009-01-14  9:08       ` Andi Kleen
2009-01-14 14:41         ` Frederik Deweerdt
2009-01-14 15:20           ` Andi Kleen
2009-01-14 15:10             ` Frederik Deweerdt
2009-01-12 22:54 ` Mike Travis
2009-01-12 23:51   ` Frederik Deweerdt
2009-01-12 23:57     ` Mike Travis
2009-01-13  0:01       ` Ingo Molnar
2009-01-13  3:36         ` Andi Kleen
2009-01-13 12:14           ` Ingo Molnar

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=20090112223220.GK23848@one.firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=frederik.deweerdt@xprog.eu \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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