mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Nick Piggin <npiggin@suse.de>
Cc: Andi Kleen <andi@firstfloor.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [rfc] x86: optimise page fault path a little
Date: Thu, 13 Nov 2008 08:41:09 +0100	[thread overview]
Message-ID: <20081113074109.GB1723@elte.hu> (raw)
In-Reply-To: <20081113072821.GB2946@wotan.suse.de>


* Nick Piggin <npiggin@suse.de> wrote:

> Hi,
> 
> I was just looking around the page fault code for any obvious 
> performance improvements. I noticed do_page_fault is rather big, 
> uses a lot of stack, and generates some branch mispredicts.
> 
> It's only about 1.1% on the profile of the workload I'm looking at, 
> so my improvement is pretty close to in the noise, but I wonder if 
> micro optimisations like the following would be welcome?

it's definitely welcome!

> This patch adds branch hints and moves error condition code out of 
> line. It shrinks do_page_fault from 2410 bytes to 603 bytes, and 
> from 352 to 64 bytes of stack. Total text size does grow by about 
> 500 bytes due to the additional functions added.

Some small cleanliness nits:

> +/* TODO: match order of arguments */

please fix TODO ;)

> +static noinline void no_context(struct pt_regs *regs,
> +			unsigned long error_code, unsigned long address)
> +{
> +	struct task_struct *tsk = current;
> +#ifdef CONFIG_X86_64
> +	unsigned long flags;
> +#endif

we should just do this unconditionally on 32-bit too.

> +	/*
> +	 * Oops. The kernel tried to access some bad page. We'll have to
> +	 * terminate things with extreme prejudice.
> +	 */
> +#ifdef CONFIG_X86_32
> +	bust_spinlocks(1);
> +#else
> +	flags = oops_begin();
> +#endif

32-bit should use oops_begin() too. Solves the previous comment as 
well.

> +#ifdef CONFIG_X86_32
> +	die("Oops", regs, error_code);
> +	bust_spinlocks(0);
> +	do_exit(SIGKILL);
> +#else
> +	if (__die("Oops", regs, error_code))
> +		regs = NULL;
> +	/* Executive summary in case the body of the oops scrolled away */
> +	printk(KERN_EMERG "CR2: %016lx\n", address);
> +	oops_end(flags, regs, SIGKILL);
> +#endif

this difference seems unnecessary too - 32-bit should use oops_end() 
too.

> +/* TODO: fixup for oom handling */

please fix todo ;-)

this flow could be cleaned up further:

[...]
> +		bad_area(regs, error_code, address);
> +		return;
[...]
> +		bad_area(regs, error_code, address);
> +		return;
[...]
> +			bad_area(regs, error_code, address);
> +			return;
[...]
> +		bad_area(regs, error_code, address);
> +		return;

Any reason why that pattern shouldnt be changed to an appropriate goto 
bad_area? (probably the same goes for the nosemaphore error paths too)

	Ingo

  reply	other threads:[~2008-11-13  7:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-13  7:28 Nick Piggin
2008-11-13  7:41 ` Ingo Molnar [this message]
2008-11-13  7:50   ` Nick Piggin
2008-11-13  8:02     ` Ingo Molnar
2008-11-14  1:22       ` Nick Piggin
2008-11-13 16:06     ` Ingo Molnar
2008-11-14  1:16       ` Nick Piggin
2008-11-13  8:35   ` Andi Kleen
2008-11-13 16:00 ` Linus Torvalds
2008-11-14  1:58   ` Nick Piggin
2008-11-14  2:07     ` Linus Torvalds
2008-11-14  2:43       ` Nick Piggin
2008-11-14  3:18         ` Linus Torvalds
2008-11-14  3:30           ` Nick Piggin
2008-11-14  4:44             ` Linus Torvalds

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=20081113074109.GB1723@elte.hu \
    --to=mingo@elte.hu \
    --cc=andi@firstfloor.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@suse.de \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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

all inboxes | Powered by JetHome®