linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: george anzinger <george@mvista.com>
To: Andrew Morton <akpm@digeo.com>
Cc: "Martin J. Bligh" <Martin.Bligh@us.ibm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCH]Timer list init is done AFTER use
Date: Sun, 22 Dec 2002 01:58:13 -0800	[thread overview]
Message-ID: <3E058CB5.B810FAED@mvista.com> (raw)
In-Reply-To: 3E0579F8.CF1D94A9@digeo.com

Looks ok.  I will give it a spin on Monday.

-g

Andrew Morton wrote:
> 
> george anzinger wrote:
> >
> > ...
> > I am not sure.  The first question is when does the online
> > bit get set for cpu 0.  The next is that it does inhibit a
> > rather large block of printks.  Is this ok?
> >
> 
> The boot cpu is set online extremely late.  Strangely late.  Why
> is this?
> 
> How about something like the below?  We mark the boot cpu
> online in generic code as soon as it has initialised its per-cpu
> storage (seems appropriate?)
> 
> This will then allow that cpu to actually start calling into console
> drivers, if they have been registered.  If those drivers do a mod_timer()
> (as the vga console does) then that will work OK.
> 
> Secondary CPUs also are not marked online until their per-cpu storage is
> initialised, and their notifiers have been called.
> 
> If a non-online cpu calls printk, its output will be buffered.  It will
> be displayed by the next call to printk by an online CPU.
> 
> (The patch needs set_cpu_online()/set_cpu_possible() implementations
> done for the other architectures)
> 
>  arch/i386/kernel/smpboot.c |    5 -----
>  include/asm-i386/smp.h     |   29 +++++++++++++++++++++++------
>  include/linux/smp.h        |    7 ++++++-
>  init/main.c                |    8 ++++++++
>  kernel/printk.c            |    6 +++++-
>  5 files changed, 42 insertions(+), 13 deletions(-)
> 
> --- 25/kernel/printk.c~ga       Sat Dec 21 23:27:08 2002
> +++ 25-akpm/kernel/printk.c     Sat Dec 21 23:27:08 2002
> @@ -43,7 +43,11 @@
>  #define LOG_BUF_MASK   (LOG_BUF_LEN-1)
> 
>  #ifndef arch_consoles_callable
> -#define arch_consoles_callable() (1)
> +/*
> + * Some console drivers may assume that per-cpu resources have been allocated.
> + * So don't allow them to be called by this CPU until it is officially up.
> + */
> +#define arch_consoles_callable() cpu_online(smp_processor_id())
>  #endif
> 
>  /* printk's without a loglevel use this.. */
> --- 25/init/main.c~ga   Sat Dec 21 23:48:03 2002
> +++ 25-akpm/init/main.c Sat Dec 21 23:55:00 2002
> @@ -361,6 +361,14 @@ asmlinkage void __init start_kernel(void
>         printk(linux_banner);
>         setup_arch(&command_line);
>         setup_per_cpu_areas();
> +
> +       /*
> +        * Once the boot CPU's per-cpu memory is set up it may be considered
> +        * online.  This is mainly to turn on printk output.
> +        */
> +       set_cpu_online(smp_processor_id());
> +       set_cpu_possible(smp_processor_id());
> +
>         build_all_zonelists();
>         page_alloc_init();
>         printk("Kernel command line: %s\n", saved_command_line);
> --- 25/include/asm-i386/smp.h~ga        Sat Dec 21 23:49:43 2002
> +++ 25-akpm/include/asm-i386/smp.h      Sat Dec 21 23:54:16 2002
> @@ -80,15 +80,32 @@ extern volatile int logical_apicid_to_cp
> 
>  extern volatile unsigned long cpu_callout_map;
> 
> -#define cpu_possible(cpu) (cpu_callout_map & (1<<(cpu)))
> -#define cpu_online(cpu) (cpu_online_map & (1<<(cpu)))
> +static inline int cpu_possible(int cpu)
> +{
> +       return cpu_callout_map & (1 << cpu);
> +}
> +
> +static inline void set_cpu_possible(int cpu)
> +{
> +       cpu_callout_map |= (1 << cpu);
> +}
> +
> +static inline int cpu_online(int cpu)
> +{
> +       return cpu_online_map & (1 << cpu);
> +}
> +
> +static inline void set_cpu_online(int cpu)
> +{
> +       cpu_online_map |= (1 << cpu);
> +}
> 
> -extern inline unsigned int num_online_cpus(void)
> +static inline unsigned int num_online_cpus(void)
>  {
>         return hweight32(cpu_online_map);
>  }
> 
> -extern inline int any_online_cpu(unsigned int mask)
> +static inline int any_online_cpu(unsigned int mask)
>  {
>         if (mask & cpu_online_map)
>                 return __ffs(mask & cpu_online_map);
> @@ -96,13 +113,13 @@ extern inline int any_online_cpu(unsigne
>         return -1;
>  }
> 
> -static __inline int hard_smp_processor_id(void)
> +static inline int hard_smp_processor_id(void)
>  {
>         /* we don't want to mark this access volatile - bad code generation */
>         return GET_APIC_ID(*(unsigned long *)(APIC_BASE+APIC_ID));
>  }
> 
> -static __inline int logical_smp_processor_id(void)
> +static inline int logical_smp_processor_id(void)
>  {
>         /* we don't want to mark this access volatile - bad code generation */
>         return GET_APIC_LOGICAL_ID(*(unsigned long *)(APIC_BASE+APIC_LDR));
> --- 25/arch/i386/kernel/smpboot.c~ga    Sat Dec 21 23:52:51 2002
> +++ 25-akpm/arch/i386/kernel/smpboot.c  Sat Dec 21 23:54:43 2002
> @@ -992,11 +992,6 @@ static void __init smp_boot_cpus(unsigne
>         printk("CPU%d: ", 0);
>         print_cpu_info(&cpu_data[0]);
> 
> -       /*
> -        * We have the boot CPU online for sure.
> -        */
> -       set_bit(0, &cpu_online_map);
> -       set_bit(0, &cpu_callout_map);
>         boot_cpu_logical_apicid = logical_smp_processor_id();
>         map_cpu_to_boot_apicid(0, boot_cpu_apicid);
> 
> --- 25/include/linux/smp.h~ga   Sun Dec 22 00:29:05 2002
> +++ 25-akpm/include/linux/smp.h Sun Dec 22 00:30:15 2002
> @@ -94,7 +94,12 @@ static inline void smp_send_reschedule_a
>  #define cpu_online(cpu)                                ({ BUG_ON((cpu) != 0); 1; })
>  #define num_online_cpus()                      1
>  #define num_booting_cpus()                     1
> -#define cpu_possible(cpu)                              ({ BUG_ON((cpu) != 0); 1; })
> +#define cpu_possible(cpu)                      ({ BUG_ON((cpu) != 0); 1; })
> +static inline void set_cpu_online(int cpu)
> +{}
> +static inline void set_cpu_possible(int cpu)
> +{}
> +
> 
>  struct notifier_block;
> 
> 
> _
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
George Anzinger   george@mvista.com
High-res-timers: 
http://sourceforge.net/projects/high-res-timers/
Preemption patch:
http://www.kernel.org/pub/linux/kernel/people/rml

  reply	other threads:[~2002-12-22  9:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-20  8:43 [PATCH]Timer list init is done AFTER use george anzinger
2002-12-20 10:26 ` Andrew Morton
2002-12-20 17:18   ` george anzinger
2002-12-20 19:34     ` Andrew Morton
2002-12-20 20:01       ` george anzinger
2002-12-20 20:31         ` Andrew Morton
2002-12-22  8:38         ` Andrew Morton
2002-12-22  9:58           ` george anzinger [this message]
2002-12-22 21:14           ` Martin J. Bligh

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=3E058CB5.B810FAED@mvista.com \
    --to=george@mvista.com \
    --cc=Martin.Bligh@us.ibm.com \
    --cc=akpm@digeo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    /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).