ia64/xen-unstable

changeset 9353:eb2a2529f96c

New SMP IPI interface function called on_selected_cpus(), currently implemented
only for x86. The x86 implementation of smp_call_function has been simplified
and is now based on on_slected_cpus().

Signed-off-by: Nitin A Kamble <nitin.a.kamble@intel.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Mar 21 11:28:03 2006 +0100 (2006-03-21)
parents 25e1c3b1a9f2
children 96d606c074f8
files xen/arch/x86/smp.c xen/include/xen/smp.h
line diff
     1.1 --- a/xen/arch/x86/smp.c	Tue Mar 21 09:53:00 2006 +0100
     1.2 +++ b/xen/arch/x86/smp.c	Tue Mar 21 11:28:03 2006 +0100
     1.3 @@ -266,7 +266,7 @@ void smp_send_event_check_mask(cpumask_t
     1.4  }
     1.5  
     1.6  /*
     1.7 - * Structure and data for smp_call_function().
     1.8 + * Structure and data for smp_call_function()/on_selected_cpus().
     1.9   */
    1.10  
    1.11  struct call_data_struct {
    1.12 @@ -275,41 +275,48 @@ struct call_data_struct {
    1.13      int wait;
    1.14      atomic_t started;
    1.15      atomic_t finished;
    1.16 +    cpumask_t selected;
    1.17  };
    1.18  
    1.19 -static spinlock_t call_lock = SPIN_LOCK_UNLOCKED;
    1.20 +static DEFINE_SPINLOCK(call_lock);
    1.21  static struct call_data_struct *call_data;
    1.22  
    1.23 -/*
    1.24 - * Run a function on all other CPUs.
    1.25 - *  @func: The function to run. This must be fast and non-blocking.
    1.26 - *  @info: An arbitrary pointer to pass to the function.
    1.27 - *  @wait: If true, spin until function has completed on other CPUs.
    1.28 - *  Returns: 0 on success, else a negative status code.
    1.29 - */
    1.30  int smp_call_function(
    1.31 -    void (*func) (void *info), void *info, int unused, int wait)
    1.32 +    void (*func) (void *info),
    1.33 +    void *info,
    1.34 +    int retry,
    1.35 +    int wait)
    1.36 +{
    1.37 +    cpumask_t allbutself = cpu_online_map;
    1.38 +    cpu_clear(smp_processor_id(), allbutself);
    1.39 +    return on_selected_cpus(allbutself, func, info, retry, wait);
    1.40 +}
    1.41 +
    1.42 +extern int on_selected_cpus(
    1.43 +    cpumask_t selected,
    1.44 +    void (*func) (void *info),
    1.45 +    void *info,
    1.46 +    int retry,
    1.47 +    int wait)
    1.48  {
    1.49      struct call_data_struct data;
    1.50 -    unsigned int nr_cpus = num_online_cpus() - 1;
    1.51 +    unsigned int nr_cpus = cpus_weight(selected);
    1.52  
    1.53      ASSERT(local_irq_is_enabled());
    1.54  
    1.55 -    if ( nr_cpus == 0 )
    1.56 -        return 0;
    1.57 -
    1.58      data.func = func;
    1.59      data.info = info;
    1.60      data.wait = wait;
    1.61      atomic_set(&data.started, 0);
    1.62      atomic_set(&data.finished, 0);
    1.63 +    data.selected = selected;
    1.64  
    1.65      spin_lock(&call_lock);
    1.66  
    1.67      call_data = &data;
    1.68      wmb();
    1.69  
    1.70 -    send_IPI_allbutself(CALL_FUNCTION_VECTOR);
    1.71 +    send_IPI_mask(selected, CALL_FUNCTION_VECTOR);
    1.72  
    1.73      while ( atomic_read(wait ? &data.finished : &data.started) != nr_cpus )
    1.74          cpu_relax();
    1.75 @@ -353,6 +360,9 @@ fastcall void smp_call_function_interrup
    1.76      ack_APIC_irq();
    1.77      perfc_incrc(ipis);
    1.78  
    1.79 +    if ( !cpu_isset(smp_processor_id(), call_data->selected) )
    1.80 +        return;
    1.81 +
    1.82      if ( call_data->wait )
    1.83      {
    1.84          (*func)(info);
     2.1 --- a/xen/include/xen/smp.h	Tue Mar 21 09:53:00 2006 +0100
     2.2 +++ b/xen/include/xen/smp.h	Tue Mar 21 11:28:03 2006 +0100
     2.3 @@ -45,33 +45,35 @@ extern void smp_cpus_done(unsigned int m
     2.4   * Call a function on all other processors
     2.5   */
     2.6  extern int smp_call_function(
     2.7 -    void (*func) (void *info), void *info, int retry, int wait);
     2.8 +    void (*func) (void *info),
     2.9 +    void *info,
    2.10 +    int retry,
    2.11 +    int wait);
    2.12 +
    2.13 +/* 
    2.14 + * Call a function on a selection of processors
    2.15 + */
    2.16 +extern int on_selected_cpus(
    2.17 +    cpumask_t selected,
    2.18 +    void (*func) (void *info),
    2.19 +    void *info,
    2.20 +    int retry,
    2.21 +    int wait);
    2.22  
    2.23  /*
    2.24   * Call a function on all processors
    2.25   */
    2.26 -static inline int on_each_cpu(void (*func) (void *info), void *info,
    2.27 -                              int retry, int wait)
    2.28 +static inline int on_each_cpu(
    2.29 +    void (*func) (void *info),
    2.30 +    void *info,
    2.31 +    int retry,
    2.32 +    int wait)
    2.33  {
    2.34      int ret = smp_call_function(func, info, retry, wait);
    2.35      func(info);
    2.36      return ret;
    2.37  }
    2.38  
    2.39 -extern volatile unsigned long smp_msg_data;
    2.40 -extern volatile int smp_src_cpu;
    2.41 -extern volatile int smp_msg_id;
    2.42 -
    2.43 -#define MSG_ALL_BUT_SELF	0x8000	/* Assume <32768 CPU's */
    2.44 -#define MSG_ALL			0x8001
    2.45 -
    2.46 -#define MSG_INVALIDATE_TLB	0x0001	/* Remote processor TLB invalidate */
    2.47 -#define MSG_STOP_CPU		0x0002	/* Sent to shut down slave CPU's
    2.48 -					 * when rebooting
    2.49 -					 */
    2.50 -#define MSG_RESCHEDULE		0x0003	/* Reschedule request from master CPU*/
    2.51 -#define MSG_CALL_FUNCTION       0x0004  /* Call function on all other CPUs */
    2.52 -
    2.53  /*
    2.54   * Mark the boot cpu "online" so that it can call console drivers in
    2.55   * printk() and can access its per-cpu storage.
    2.56 @@ -93,6 +95,18 @@ void smp_prepare_boot_cpu(void);
    2.57  #define num_booting_cpus()			1
    2.58  #define smp_prepare_boot_cpu()			do {} while (0)
    2.59  
    2.60 +static inline int on_selected_cpus(
    2.61 +    cpumask_t selected,
    2.62 +    void (*func) (void *info),
    2.63 +    void *info,
    2.64 +    int retry,
    2.65 +    int wait)
    2.66 +{
    2.67 +    if ( cpu_isset(0, selected) )
    2.68 +        func(info);
    2.69 +    return 0;
    2.70 +}
    2.71 +
    2.72  #endif
    2.73  
    2.74  #define smp_processor_id() raw_smp_processor_id()