mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Rakib Mullick <rakib.mullick@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>,
	Cyrill Gorcunov <gorcunov@openvz.org>,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86,APIC: Detect lapic_is_integrated() once - use on and on.
Date: Fri, 22 May 2009 22:33:32 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LFD.2.00.0905222227250.3570@localhost.localdomain> (raw)
In-Reply-To: <b9df5fa10905220631y7b1a094dn9a6e13de1b9c43af@mail.gmail.com>

On Fri, 22 May 2009, Rakib Mullick wrote:
>   Impact: Reduce text space through efficient coding
> 
>  Determine apic is integrated or not - by calling
> lapic_is_integrated() once from APIC_init_uniprocessor() and keep it
> in a variable integrated_lapic. Thus we can determine apic is
> integrated or not, by checking the variable instead of calling
> lapic_is_integrated() on and on. Marking lapic_is_integrated() as
> __init, which reduces some text space. Also allows us to get away from
> messy #ifdef and inline.
> 
> ---
> Signed-off-by: Rakib Mullick <rakib.mullick@gmail.com>
> 
> --- linus/arch/x86/kernel/apic/apic.c	2009-05-21 22:22:15.000000000 +0600
> +++ rakib/arch/x86/kernel/apic/apic.c	2009-05-21 23:27:26.000000000 +0600
> @@ -127,6 +127,9 @@ early_param("nox2apic", setup_nox2apic);
> 
>  unsigned long mp_lapic_addr;
>  int disable_apic;
> +
> +static int integrated_lapic;
> +
>  /* Disable local APIC timer from the kernel commandline or via dmi quirk */
>  static int disable_apic_timer __cpuinitdata;
>  /* Local APIC timer works in C2 */
> @@ -188,13 +191,12 @@ static inline int lapic_get_version(void
>  /*
>   * Check, if the APIC is integrated or a separate chip
>   */
> -static inline int lapic_is_integrated(void)
> +void __init lapic_is_integrated(void)
>  {
> -#ifdef CONFIG_X86_64
> -	return 1;
> -#else
> -	return APIC_INTEGRATED(lapic_get_version());
> -#endif
> +	if (APIC_INTEGRATED(lapic_get_version()))
> +		integrated_lapic = 1;
> +	else
> +		integrated_lapic = 0;
>  }

I agree in general, but the patch is flawed as it prevents the
compiler to optimize the X86_64 case out.

What you really want is:

#ifdef CONFIG_X86_64
# define integrated_lapic (1)
#else
static int integrated_lapic __read_mostly;
#endif

static inline void lapic_is_integrated(void)
{
#ifdef CONFIG_X86_32
	integrate_lapic = APIC_INTEGRATED(lapic_get_version());
#endif
}

So that way the check is only done for 32bit systems and the compiler
will optimize out the code which depends on !integrated_lapic.

Thanks,

	tglx

      parent reply	other threads:[~2009-05-22 20:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-22 13:31 Rakib Mullick
2009-05-22 20:02 ` Cyrill Gorcunov
2009-05-22 20:12   ` H. Peter Anvin
2009-05-22 20:21     ` Cyrill Gorcunov
2009-05-22 20:23       ` H. Peter Anvin
2009-05-22 20:30         ` Cyrill Gorcunov
2009-05-22 20:35         ` Cyrill Gorcunov
2009-05-22 20:59           ` H. Peter Anvin
2009-05-22 22:18     ` Maciej W. Rozycki
2009-05-23 13:07       ` Cyrill Gorcunov
2009-05-22 20:33 ` Thomas Gleixner [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=alpine.LFD.2.00.0905222227250.3570@localhost.localdomain \
    --to=tglx@linutronix.de \
    --cc=akpm@linux-foundation.org \
    --cc=gorcunov@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rakib.mullick@gmail.com \
    /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®