Merge branch 'for-3.18-consistent-ops' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 15 Oct 2014 05:48:18 +0000 (07:48 +0200)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 15 Oct 2014 05:48:18 +0000 (07:48 +0200)
Pull percpu consistent-ops changes from Tejun Heo:
 "Way back, before the current percpu allocator was implemented, static
  and dynamic percpu memory areas were allocated and handled separately
  and had their own accessors.  The distinction has been gone for many
  years now; however, the now duplicate two sets of accessors remained
  with the pointer based ones - this_cpu_*() - evolving various other
  operations over time.  During the process, we also accumulated other
  inconsistent operations.

  This pull request contains Christoph's patches to clean up the
  duplicate accessor situation.  __get_cpu_var() uses are replaced with
  with this_cpu_ptr() and __this_cpu_ptr() with raw_cpu_ptr().

  Unfortunately, the former sometimes is tricky thanks to C being a bit
  messy with the distinction between lvalues and pointers, which led to
  a rather ugly solution for cpumask_var_t involving the introduction of
  this_cpu_cpumask_var_ptr().

  This converts most of the uses but not all.  Christoph will follow up
  with the remaining conversions in this merge window and hopefully
  remove the obsolete accessors"

* 'for-3.18-consistent-ops' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu: (38 commits)
  irqchip: Properly fetch the per cpu offset
  percpu: Resolve ambiguities in __get_cpu_var/cpumask_var_t -fix
  ia64: sn_nodepda cannot be assigned to after this_cpu conversion. Use __this_cpu_write.
  percpu: Resolve ambiguities in __get_cpu_var/cpumask_var_t
  Revert "powerpc: Replace __get_cpu_var uses"
  percpu: Remove __this_cpu_ptr
  clocksource: Replace __this_cpu_ptr with raw_cpu_ptr
  sparc: Replace __get_cpu_var uses
  avr32: Replace __get_cpu_var with __this_cpu_write
  blackfin: Replace __get_cpu_var uses
  tile: Use this_cpu_ptr() for hardware counters
  tile: Replace __get_cpu_var uses
  powerpc: Replace __get_cpu_var uses
  alpha: Replace __get_cpu_var
  ia64: Replace __get_cpu_var uses
  s390: cio driver &__get_cpu_var replacements
  s390: Replace __get_cpu_var uses
  mips: Replace __get_cpu_var uses
  MIPS: Replace __get_cpu_var uses in FPU emulator.
  arm: Replace __this_cpu_ptr with raw_cpu_ptr
  ...

51 files changed:
1  2 
arch/blackfin/mach-common/ints-priority.c
arch/mips/kernel/perf_event_mipsxx.c
arch/powerpc/include/asm/cputime.h
arch/s390/include/asm/irq.h
arch/s390/kernel/idle.c
arch/s390/kernel/kprobes.c
arch/s390/kernel/nmi.c
arch/s390/kernel/processor.c
arch/s390/kernel/time.c
arch/sparc/kernel/perf_event.c
arch/tile/kernel/smp.c
arch/tile/kernel/time.c
arch/tile/mm/init.c
arch/x86/kernel/cpu/common.c
arch/x86/kernel/cpu/perf_event.c
arch/x86/kernel/cpu/perf_event_intel.c
arch/x86/kernel/cpu/perf_event_intel_ds.c
arch/x86/kernel/cpu/perf_event_intel_lbr.c
arch/x86/kernel/kvm.c
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c
arch/x86/kvm/x86.c
arch/x86/xen/enlighten.c
drivers/irqchip/irq-gic.c
drivers/net/ethernet/tile/tilepro.c
drivers/s390/cio/cio.c
fs/ext4/mballoc.c
include/net/snmp.h
kernel/events/callchain.c
kernel/events/core.c
kernel/irq/chip.c
kernel/irq_work.c
kernel/printk/printk.c
kernel/sched/deadline.c
kernel/sched/fair.c
kernel/sched/rt.c
kernel/sched/sched.h
kernel/smp.c
kernel/softirq.c
kernel/time/hrtimer.c
kernel/time/tick-common.c
kernel/time/tick-sched.c
kernel/time/timer.c
kernel/watchdog.c
net/core/dev.c
net/core/skbuff.c
net/ipv4/route.c
net/ipv4/syncookies.c
net/ipv4/tcp.c
net/ipv4/tcp_output.c
net/ipv6/syncookies.c

Simple merge
Simple merge
Simple merge
index c846aee7372f391b6d975bad40d2a7ad7f7c1cf8,0000000000000000000000000000000000000000..7559f1beab2918f84831791ae93a901cd826bb57
mode 100644,000000..100644
--- /dev/null
@@@ -1,124 -1,0 +1,124 @@@
-       struct s390_idle_data *idle = &__get_cpu_var(s390_idle);
 +/*
 + * Idle functions for s390.
 + *
 + * Copyright IBM Corp. 2014
 + *
 + * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
 + */
 +
 +#include <linux/kernel.h>
 +#include <linux/kernel_stat.h>
 +#include <linux/kprobes.h>
 +#include <linux/notifier.h>
 +#include <linux/init.h>
 +#include <linux/cpu.h>
 +#include <asm/cputime.h>
 +#include <asm/nmi.h>
 +#include <asm/smp.h>
 +#include "entry.h"
 +
 +static DEFINE_PER_CPU(struct s390_idle_data, s390_idle);
 +
 +void __kprobes enabled_wait(void)
 +{
++      struct s390_idle_data *idle = this_cpu_ptr(&s390_idle);
 +      unsigned long long idle_time;
 +      unsigned long psw_mask;
 +
 +      trace_hardirqs_on();
 +
 +      /* Wait for external, I/O or machine check interrupt. */
 +      psw_mask = PSW_KERNEL_BITS | PSW_MASK_WAIT | PSW_MASK_DAT |
 +              PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK;
 +      clear_cpu_flag(CIF_NOHZ_DELAY);
 +
 +      /* Call the assembler magic in entry.S */
 +      psw_idle(idle, psw_mask);
 +
 +      /* Account time spent with enabled wait psw loaded as idle time. */
 +      idle->sequence++;
 +      smp_wmb();
 +      idle_time = idle->clock_idle_exit - idle->clock_idle_enter;
 +      idle->clock_idle_enter = idle->clock_idle_exit = 0ULL;
 +      idle->idle_time += idle_time;
 +      idle->idle_count++;
 +      account_idle_time(idle_time);
 +      smp_wmb();
 +      idle->sequence++;
 +}
 +
 +static ssize_t show_idle_count(struct device *dev,
 +                              struct device_attribute *attr, char *buf)
 +{
 +      struct s390_idle_data *idle = &per_cpu(s390_idle, dev->id);
 +      unsigned long long idle_count;
 +      unsigned int sequence;
 +
 +      do {
 +              sequence = ACCESS_ONCE(idle->sequence);
 +              idle_count = ACCESS_ONCE(idle->idle_count);
 +              if (ACCESS_ONCE(idle->clock_idle_enter))
 +                      idle_count++;
 +      } while ((sequence & 1) || (ACCESS_ONCE(idle->sequence) != sequence));
 +      return sprintf(buf, "%llu\n", idle_count);
 +}
 +DEVICE_ATTR(idle_count, 0444, show_idle_count, NULL);
 +
 +static ssize_t show_idle_time(struct device *dev,
 +                              struct device_attribute *attr, char *buf)
 +{
 +      struct s390_idle_data *idle = &per_cpu(s390_idle, dev->id);
 +      unsigned long long now, idle_time, idle_enter, idle_exit;
 +      unsigned int sequence;
 +
 +      do {
 +              now = get_tod_clock();
 +              sequence = ACCESS_ONCE(idle->sequence);
 +              idle_time = ACCESS_ONCE(idle->idle_time);
 +              idle_enter = ACCESS_ONCE(idle->clock_idle_enter);
 +              idle_exit = ACCESS_ONCE(idle->clock_idle_exit);
 +      } while ((sequence & 1) || (ACCESS_ONCE(idle->sequence) != sequence));
 +      idle_time += idle_enter ? ((idle_exit ? : now) - idle_enter) : 0;
 +      return sprintf(buf, "%llu\n", idle_time >> 12);
 +}
 +DEVICE_ATTR(idle_time_us, 0444, show_idle_time, NULL);
 +
 +cputime64_t arch_cpu_idle_time(int cpu)
 +{
 +      struct s390_idle_data *idle = &per_cpu(s390_idle, cpu);
 +      unsigned long long now, idle_enter, idle_exit;
 +      unsigned int sequence;
 +
 +      do {
 +              now = get_tod_clock();
 +              sequence = ACCESS_ONCE(idle->sequence);
 +              idle_enter = ACCESS_ONCE(idle->clock_idle_enter);
 +              idle_exit = ACCESS_ONCE(idle->clock_idle_exit);
 +      } while ((sequence & 1) || (ACCESS_ONCE(idle->sequence) != sequence));
 +      return idle_enter ? ((idle_exit ?: now) - idle_enter) : 0;
 +}
 +
 +void arch_cpu_idle_enter(void)
 +{
 +      local_mcck_disable();
 +}
 +
 +void arch_cpu_idle(void)
 +{
 +      if (!test_cpu_flag(CIF_MCCK_PENDING))
 +              /* Halt the cpu and keep track of cpu time accounting. */
 +              enabled_wait();
 +      local_irq_enable();
 +}
 +
 +void arch_cpu_idle_exit(void)
 +{
 +      local_mcck_enable();
 +      if (test_cpu_flag(CIF_MCCK_PENDING))
 +              s390_handle_mcck();
 +}
 +
 +void arch_cpu_idle_dead(void)
 +{
 +      cpu_die();
 +}
Simple merge
Simple merge
index edefead3b43a55dee5e197fae4a68011a1c3c41c,f0305b1189aaeb93c7a7415082e3ab148cb2b615..dbdd33ee010204f0e03c9c1fd48ad30acad59b4c
@@@ -23,7 -23,8 +23,7 @@@ static DEFINE_PER_CPU(struct cpuid, cpu
   */
  void cpu_init(void)
  {
-       struct cpuid *id = &__get_cpu_var(cpu_id);
 -      struct s390_idle_data *idle = this_cpu_ptr(&s390_idle);
+       struct cpuid *id = this_cpu_ptr(&cpu_id);
  
        get_cpu_id(id);
        atomic_inc(&init_mm.mm_count);
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index d5a6f287d2fed8ef18c3702c0ec1ab1684cbe79f,dacdaaa44919c16af22bbae0a028cfd02cfcccc7..10eb738fc81a88e4e510be25e7fa69b0f32463df
@@@ -561,9 -561,9 +561,9 @@@ static irqreturn_t do_cio_interrupt(in
        struct subchannel *sch;
        struct irb *irb;
  
 -      __this_cpu_write(s390_idle.nohz_delay, 1);
 +      set_cpu_flag(CIF_NOHZ_DELAY);
        tpi_info = (struct tpi_info *) &get_irq_regs()->int_code;
-       irb = &__get_cpu_var(cio_irb);
+       irb = this_cpu_ptr(&cio_irb);
        sch = (struct subchannel *)(unsigned long) tpi_info->intparm;
        if (!sch) {
                /* Clear pending interrupt condition. */
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 385b85aded199f5f2be0ee590278b559ac53b136,345d19edcdaed81a5c0194fb9256f3b113b7f402..3ab9048483fa9c9041747b10bd0c8ec192b9a413
@@@ -113,12 -113,10 +113,12 @@@ bool irq_work_needs_cpu(void
  {
        struct llist_head *raised, *lazy;
  
-       raised = &__get_cpu_var(raised_list);
-       lazy = &__get_cpu_var(lazy_list);
+       raised = this_cpu_ptr(&raised_list);
+       lazy = this_cpu_ptr(&lazy_list);
 -      if (llist_empty(raised) && llist_empty(lazy))
 -              return false;
 +
 +      if (llist_empty(raised) || arch_irq_work_has_interrupt())
 +              if (llist_empty(lazy))
 +                      return false;
  
        /* All work should have been flushed before going offline */
        WARN_ON_ONCE(cpu_is_offline(smp_processor_id()));
Simple merge
Simple merge
Simple merge
Simple merge
index 6130251de28013a06dd9ce1aeb076a6a7b86c7c3,77d92f8130e8c6c6318504a72a8ed161b452ef9f..24156c8434d1ebbe679a3fa6df45725aa7db3647
@@@ -660,13 -647,13 +660,13 @@@ static inline int cpu_of(struct rq *rq
  #endif
  }
  
 -DECLARE_PER_CPU(struct rq, runqueues);
 +DECLARE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);
  
  #define cpu_rq(cpu)           (&per_cpu(runqueues, (cpu)))
- #define this_rq()             (&__get_cpu_var(runqueues))
+ #define this_rq()             this_cpu_ptr(&runqueues)
  #define task_rq(p)            cpu_rq(task_cpu(p))
  #define cpu_curr(cpu)         (cpu_rq(cpu)->curr)
- #define raw_rq()              (&__raw_get_cpu_var(runqueues))
+ #define raw_rq()              raw_cpu_ptr(&runqueues)
  
  static inline u64 rq_clock(struct rq *rq)
  {
diff --cc kernel/smp.c
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc net/core/dev.c
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc net/ipv4/tcp.c
Simple merge
Simple merge
Simple merge