[PATCH][2.6.7-mm4] perfctr update 4/6: PPC32 cleanups

From: Mikael Pettersson (mikpe_at_csd.uu.se)
Date: 06/30/04

  • Next message: Mikael Pettersson: "[PATCH][2.6.7-mm4] perfctr update 3/6: __user annotations"
    Date:	Wed, 30 Jun 2004 14:21:11 +0200 (MEST)
    To: akpm@osdl.org
    
    

    - PPC32 cleanups: change get_cpu_cache() to return a pointer instead
      of an lvalue; eliminate duplicated initialisation and cleanup code;
      reduce size of non-preemptible code regions

    Signed-off-by: Mikael Pettersson <mikpe@csd.uu.se>

    --- linux-2.6.7-mm4/drivers/perfctr/ppc.c.~1~ 2004-06-29 18:05:23.000000000 +0200
    +++ linux-2.6.7-mm4/drivers/perfctr/ppc.c 2004-06-29 21:29:23.221577000 +0200
    @@ -22,7 +22,7 @@
             unsigned int ppc_mmcr[3];
     } ____cacheline_aligned;
     static DEFINE_PER_CPU(struct per_cpu_cache, per_cpu_cache);
    -#define get_cpu_cache() __get_cpu_var(per_cpu_cache)
    +#define get_cpu_cache() (&__get_cpu_var(per_cpu_cache))
     
     /* Structure for counter snapshots, as 32-bit values. */
     struct perfctr_low_ctrs {
    @@ -245,7 +245,7 @@
             if (state->cstatus & (1<<30)) {
                     unsigned int mmcr0 = mfspr(SPRN_MMCR0);
                     state->ppc_mmcr[0] = mmcr0;
    - get_cpu_cache().ppc_mmcr[0] = mmcr0;
    + get_cpu_cache()->ppc_mmcr[0] = mmcr0;
             }
     }
     
    @@ -367,7 +367,7 @@
             struct per_cpu_cache *cache;
             unsigned int value;
     
    - cache = &get_cpu_cache();
    + cache = get_cpu_cache();
             if (cache->k1.id == state->k1.id)
                     return;
             /*
    @@ -466,7 +466,7 @@
     #ifdef CONFIG_SMP
             clear_isuspend_cpu(state);
     #else
    - get_cpu_cache().k1.id = 0;
    + get_cpu_cache()->k1.id = 0;
     #endif
     }
     
    @@ -609,7 +609,7 @@
     {
             struct per_cpu_cache *cache;
     
    - cache = &get_cpu_cache();
    + cache = get_cpu_cache();
             memset(cache, 0, sizeof *cache);
             cache->k1.id = -1;
     
    @@ -848,18 +848,17 @@
             return 0;
     }
     
    -static void __init perfctr_cpu_init_one(void *ignore)
    +static void perfctr_cpu_clear_one(void *ignore)
     {
    - /* PREEMPT note: when called via smp_call_function(),
    + /* PREEMPT note: when called via on_each_cpu(),
                this is in IRQ context with preemption disabled. */
             perfctr_cpu_clear_counters();
     }
     
    -static void __exit perfctr_cpu_exit_one(void *ignore)
    +static void perfctr_cpu_reset(void)
     {
    - /* PREEMPT note: when called via smp_call_function(),
    - this is in IRQ context with preemption disabled. */
    - perfctr_cpu_clear_counters();
    + on_each_cpu(perfctr_cpu_clear_one, NULL, 1, 1);
    + perfctr_cpu_set_ihandler(NULL);
     }
     
     static int init_done;
    @@ -868,8 +867,6 @@
     {
             int err;
     
    - preempt_disable();
    -
             perfctr_info.cpu_features = 0;
     
             err = known_init();
    @@ -879,22 +876,15 @@
                             goto out;
             }
     
    - perfctr_cpu_init_one(NULL);
    - smp_call_function(perfctr_cpu_init_one, NULL, 1, 1);
    - perfctr_cpu_set_ihandler(NULL);
    + perfctr_cpu_reset();
             init_done = 1;
      out:
    - preempt_enable();
             return err;
     }
     
     void __exit perfctr_cpu_exit(void)
     {
    - preempt_disable();
    - perfctr_cpu_exit_one(NULL);
    - smp_call_function(perfctr_cpu_exit_one, NULL, 1, 1);
    - perfctr_cpu_set_ihandler(NULL);
    - preempt_enable();
    + perfctr_cpu_reset();
     }
     
     /****************************************************************
    @@ -920,13 +910,6 @@
             return ret;
     }
     
    -static void perfctr_cpu_clear_one(void *ignore)
    -{
    - /* PREEMPT note: when called via smp_call_function(),
    - this is in IRQ context with preemption disabled. */
    - perfctr_cpu_clear_counters();
    -}
    -
     void perfctr_cpu_release(const char *service)
     {
             down(&mutex);
    @@ -935,8 +918,7 @@
                            __FUNCTION__, service, current_service);
             } else {
                     /* power down the counters */
    - on_each_cpu(perfctr_cpu_clear_one, NULL, 1, 1);
    - perfctr_cpu_set_ihandler(NULL);
    + perfctr_cpu_reset();
                     current_service = 0;
             }
             up(&mutex);
    --- linux-2.6.7-mm4/drivers/perfctr/ppc_tests.c.~1~ 2004-06-29 12:43:27.000000000 +0200
    +++ linux-2.6.7-mm4/drivers/perfctr/ppc_tests.c 2004-06-29 21:20:28.591577000 +0200
    @@ -282,5 +282,7 @@
     
     void __init perfctr_ppc_init_tests(int have_mmcr1)
     {
    + preempt_disable();
             measure_overheads(have_mmcr1);
    + preempt_enable();
     }
    -
    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/


  • Next message: Mikael Pettersson: "[PATCH][2.6.7-mm4] perfctr update 3/6: __user annotations"

    Relevant Pages

    • [PATCH 2/2] page table iterators
      ... * for_each_pmd - iterate through pmd entries in a given pud ... */ void clear_page_range{ ... int err = 0; ... } return err;} static void zap_pte_range(struct mmu_gather *tlb, ...
      (Linux-Kernel)
    • [PATCH,RFC] Move Cell platform code to arch/powerpc
      ... The platform is officially known as 'Cell Broadband Engine Architecture', ... +static inline void ... +static void cell_free_coherent(struct device *hwdev, size_t size, ... +static unsigned int iic_startup(unsigned int irq) ...
      (Linux-Kernel)
    • [PATCH][4/6] perfctr-2.7.3 for 2.6.7-rc1-mm1: PowerPC
      ... +static unsigned int new_id ... +static void perfctr_default_ihandler ... +static void ppc_isuspend ... +static int __init generic_init ...
      (Linux-Kernel)
    • [PATCH 2.6.18] drivers: add lcd display support
      ... Adds support for the cfag12864b LCD Display as a device driver. ... extern void class_destroy; ... +static void cfag12864b_setbit(unsigned char state, ...
      (Linux-Kernel)
    • [PATCH 2.6.18 V5] drivers: add lcd display support
      ... Adds support for the cfag12864b LCD Display as a device driver. ... extern void class_destroy; ... +static void cfag12864b_setbit(unsigned char state, ...
      (Linux-Kernel)