linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ijc@hellion.org.uk>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>, Brian Gerst <brgerst@gmail.com>,
	Jan Beulich <JBeulich@novell.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [Q x86-64] on kernel_eflags
Date: Tue, 05 Jul 2011 12:00:56 +0100	[thread overview]
Message-ID: <1309863656.634.111.camel@zakaz.uk.xensource.com> (raw)
In-Reply-To: <20110705104742.GO17941@sun>

On Tue, 2011-07-05 at 14:47 +0400, Cyrill Gorcunov wrote:
> While were looking into ret_from_fork code I somehow wondered
> about the global kernel_eflags variable here.
> 
> arch/x86/cpu/common.c
> ---------------------
> unsigned long kernel_eflags;
> 
> void __cpuinit cpu_init(void)
> {
> 	...
> 	raw_local_save_flags(kernel_eflags);
> }
> 
> arch/x86/kernel/entry_64.S
> --------------------------
> ENTRY(ret_from_fork)
> 	DEFAULT_FRAME
> 	LOCK ; btr $TIF_FORK,TI_flags(%r8)
> 	pushq_cfi kernel_eflags(%rip)
> 	popfq_cfi                               # reset kernel eflags
> 
> Every call to cpu_init renew global kernel_eflags
> and every task switching does use this variable in a
> sake of cleaning carry bit of flags register as far as
> I can tell.
> 
> Should not every cpu has own copy of kernel_eflags? Just
> to be consistent in style? Or this would be space waisting
> and an optimization is done here?

I noticed this a while ago and couldn't figure out why it was done this
way. On 32-bit the initial EFLAGS is simply hardcoded and that seems to
make sense to me since it's not clear that the specific value of EFLAGS
at the point it is saved in cpu_init() has any particular meaning.

I posted http://lkml.org/lkml/2010/2/9/155 to switch to the hardcoded
version for 64 bit too. Is it worth my rebasing and reposting that?

(http://lkml.org/lkml/2010/2/9/152 and http://lkml.org/lkml/2010/2/9/154
were followon cleanups).

Ian.

-- 
Ian Campbell
Current Noise: Kylesa - Drop Out

"... all the modern inconveniences ..."
		-- Mark Twain


  reply	other threads:[~2011-07-05 11:01 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05 10:47 [Q x86-64] on kernel_eflags Cyrill Gorcunov
2011-07-05 11:00 ` Ian Campbell [this message]
2011-07-05 11:15   ` Cyrill Gorcunov
2011-07-05 13:00     ` [PATCH 1/3] x86: drop unnecessary kernel_eflags variable from 64 bit Ian Campbell
2011-07-05 13:28       ` Cyrill Gorcunov
2011-07-06  9:25         ` Ian Campbell
2011-07-06  9:46           ` Cyrill Gorcunov
2011-07-06  9:57             ` Ian Campbell
2011-07-06 10:12               ` Cyrill Gorcunov
2011-07-06  9:39       ` Pekka Enberg
2011-07-06 23:17         ` Andi Kleen
2011-07-07  0:00           ` H. Peter Anvin
2011-07-05 13:00     ` [PATCH 2/3] x86: make 64 bit ret_from_fork a little more similar to 32 bit Ian Campbell
2011-07-06  9:41       ` Pekka Enberg
2011-07-05 13:00     ` [PATCH 3/3] x86: ret_from_fork: use symbolic contants for bits in EFLAGS Ian Campbell
2011-07-06  9:36       ` Pekka Enberg
2011-07-05 17:47 ` [Q x86-64] on kernel_eflags H. Peter Anvin
2011-07-05 17:56   ` Cyrill Gorcunov
2011-07-06  9:25   ` Ian Campbell

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=1309863656.634.111.camel@zakaz.uk.xensource.com \
    --to=ijc@hellion.org.uk \
    --cc=JBeulich@novell.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=brgerst@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=gorcunov@gmail.com \
    --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;
as well as URLs for NNTP newsgroup(s).