1. 11 Oct, 2007 1 commit
    • Paul Mackerras's avatar
      [POWERPC] Prevent decrementer clockevents from firing early · d968014b
      Paul Mackerras authored
      On old powermacs, we sometimes set the decrementer to 1 in order to
      trigger a decrementer interrupt, which we use to handle an interrupt
      that was pending at the time when it was re-enabled.  This was causing
      the decrementer clock event device to call the event function for the
      next event early, which was causing problems when high-res timers were
      not enabled.
      This fixes the problem by recording the timebase value at which the
      next event should occur, and checking the current timebase against the
      recorded value in timer_interrupt.  If it isn't time for the next
      event, it just reprograms the decrementer and returns.
      This also subtracts 1 from the value stored into the decrementer,
      which is appropriate because the decrementer interrupts on the
      transition from 0 to -1, not when the decrementer reaches 0.
      Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
  2. 02 Oct, 2007 3 commits
  3. 18 Sep, 2007 1 commit
  4. 20 Aug, 2007 1 commit
  5. 16 Aug, 2007 1 commit
  6. 20 Jul, 2007 1 commit
  7. 10 Jul, 2007 1 commit
    • Tony Breeds's avatar
      [POWERPC] Modify sched_clock() to make CONFIG_PRINTK_TIME more sane · fc9069fe
      Tony Breeds authored
      When booting a current kernel with CONFIG_PRINTK_TIME enabled you'll
      see messages like:
      [    0.000000] time_init: decrementer frequency = 188.044000 MHz
      [    0.000000] time_init: processor frequency   = 1504.352000 MHz
      [3712914.436297] Console: colour dummy device 80x25
      This cause by the initialisation of tb_to_ns_scale in time_init(), suddenly the
      multiplication in sched_clock() now does something :).  This patch modifies
      sched_clock() to report the offset since the machine booted so the same
      printk's now look like:
      [    0.000000] time_init: decrementer frequency = 188.044000 MHz
      [    0.000000] time_init: processor frequency   = 1504.352000 MHz
      [    0.000135] Console: colour dummy device 80x25
      Effectivly including the uptime in printk()s.
      This patch makes tb_to_ns_scale and tb_to_ns_shift static and
      read_mostly for good measure.
      Signed-off-by: default avatarTony Breeds <tony@bakeyournoodle.com>
      Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
  8. 28 Jun, 2007 1 commit
    • Tony Breeds's avatar
      [POWERPC] Move iSeries_tb_recal into its own late_initcall. · 71712b45
      Tony Breeds authored
      Currently iSeries will recalibrate the cputime_factors in the first
      settimeofday() call.
      It seems the reason for doing this is to ensure a resaonable time delta after
      time_init().  On current kernels (with udev), this call is made 40-60 seconds
      into the boot process, by moving it to a late initcall it is called
      approximately 5 seconds after time_init() is called.  This is sufficient to
      recalibrate the timebase.
      Signed-off-by: default avatarTony Breeds <tony@bakeyournoodle.com>
      CC: Stephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
  9. 25 Jun, 2007 2 commits
  10. 11 May, 2007 1 commit
    • will schmidt's avatar
      [POWERPC] Simplify smp_space_timers · e147ec8f
      will schmidt authored
      Greatly simplify the function smp_space_timers.
      The stolen time calculation (per comment within the code) doesn't need the
      half-jiffy stagger any more.  There isn't an issue with bouncing off global
      locks, so we really shouldn't need any sort of staggering at all.
      However, the last_jiffy value still needs to be set.   This removes the
      extra stagger logic, and just sets the values.
      This change should benefit applications that rely on barrier
      synchronization, and will help cut down OS jitter.
      Boot tested across the board (G5,power3,power4,power5,970mp blade).
      Signed-off-by: default avatarWill Schmidt <will_schmidt@vnet.ibm.com>
      Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
  11. 12 Apr, 2007 1 commit
  12. 04 Dec, 2006 1 commit
  13. 21 Nov, 2006 1 commit
  14. 23 Oct, 2006 1 commit
    • Stephen Rothwell's avatar
      [POWERPC] Simplify stolen time calculation · cbcdb93d
      Stephen Rothwell authored
      In calculating stolen time, we were trying to actually account for time
      spent in the hypervisor.  We don't really have enough information to do
      that accurately, so don't try.  Instead, we now calculate stolen time as
      time that the current cpu thread is not actually dispatching instructions.
      On chips without a PURR, we cannot do this, so stolen time will always
      be zero.  On chips with a PURR, this is merely the difference between
      the elapsed PURR values and the elapsed TB values.
      This gives us much more sane vaules from tools such as mpstat, even if
      they are still a bit strange e.g. 2 busy threads on one cpu will both
      appear to have 50% user time and 50% stolen time while 1 busy thread on
      a cpu will look like 100% user on one of them and 100% idle on the other.
      Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
  15. 07 Oct, 2006 1 commit
  16. 05 Oct, 2006 1 commit
    • David Howells's avatar
      IRQ: Maintain regs pointer globally rather than passing to IRQ handlers · 7d12e780
      David Howells authored
      Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
      of passing regs around manually through all ~1800 interrupt handlers in the
      Linux kernel.
      The regs pointer is used in few places, but it potentially costs both stack
      space and code to pass it around.  On the FRV arch, removing the regs parameter
      from all the genirq function results in a 20% speed up of the IRQ exit path
      (ie: from leaving timer_interrupt() to leaving do_IRQ()).
      Where appropriate, an arch may override the generic storage facility and do
      something different with the variable.  On FRV, for instance, the address is
      maintained in GR28 at all times inside the kernel as part of general exception
      Having looked over the code, it appears that the parameter may be handed down
      through up to twenty or so layers of functions.  Consider a USB character
      device attached to a USB hub, attached to a USB controller that posts its
      interrupts through a cascaded auxiliary interrupt controller.  A character
      device driver may want to pass regs to the sysrq handler through the input
      layer which adds another few layers of parameter passing.
      I've build this code with allyesconfig for x86_64 and i386.  I've runtested the
      main part of the code on FRV and i386, though I can't test most of the drivers.
      I've also done partial conversion for powerpc and MIPS - these at least compile
      with minimal configurations.
      This will affect all archs.  Mostly the changes should be relatively easy.
      Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
      	struct pt_regs *old_regs = set_irq_regs(regs);
      And put the old one back at the end:
      Don't pass regs through to generic_handle_irq() or __do_IRQ().
      In timer_interrupt(), this sort of change will be necessary:
      	-	update_process_times(user_mode(regs));
      	-	profile_tick(CPU_PROFILING, regs);
      	+	update_process_times(user_mode(get_irq_regs()));
      	+	profile_tick(CPU_PROFILING);
      I'd like to move update_process_times()'s use of get_irq_regs() into itself,
      except that i386, alone of the archs, uses something other than user_mode().
      Some notes on the interrupt handling in the drivers:
       (*) input_dev() is now gone entirely.  The regs pointer is no longer stored in
           the input_dev struct.
       (*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking.  It does
           something different depending on whether it's been supplied with a regs
           pointer or not.
       (*) Various IRQ handler function pointers have been moved to type
      Signed-Off-By: default avatarDavid Howells <dhowells@redhat.com>
      (cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
  17. 02 Oct, 2006 1 commit
  18. 01 Oct, 2006 1 commit
    • Atsushi Nemoto's avatar
      [PATCH] kill wall_jiffies · 8ef38609
      Atsushi Nemoto authored
      With 2.6.18-rc4-mm2, now wall_jiffies will always be the same as jiffies.
      So we can kill wall_jiffies completely.
      This is just a cleanup and logically should not change any real behavior
      except for one thing: RTC updating code in (old) ppc and xtensa use a
      condition "jiffies - wall_jiffies == 1".  This condition is never met so I
      suppose it is just a bug.  I just remove that condition only instead of
      kill the whole "if" block.
      [heiko.carstens@de.ibm.com: s390 build fix and cleanup]
      Signed-off-by: default avatarAtsushi Nemoto <anemo@mba.ocn.ne.jp>
      Cc: Andi Kleen <ak@muc.de>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Russell King <rmk@arm.linux.org.uk>
      Cc: Ian Molton <spyro@f2s.com>
      Cc: Mikael Starvik <starvik@axis.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Hirokazu Takata <takata.hirokazu@renesas.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Kyle McMartin <kyle@mcmartin.ca>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
      Cc: Richard Curnow <rc@rc0.org.uk>
      Cc: William Lee Irwin III <wli@holomorphy.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jeff Dike <jdike@addtoit.com>
      Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
      Cc: Miles Bader <uclinux-v850@lsi.nec.co.jp>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: "Luck, Tony" <tony.luck@intel.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Roman Zippel <zippel@linux-m68k.org>
      Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
  19. 29 Sep, 2006 1 commit
    • Atsushi Nemoto's avatar
      [PATCH] simplify update_times (avoid jiffies/jiffies_64 aliasing problem) · 3171a030
      Atsushi Nemoto authored
      Pass ticks to do_timer() and update_times(), and adjust x86_64 and s390
      timer interrupt handler with this change.
      Currently update_times() calculates ticks by "jiffies - wall_jiffies", but
      callers of do_timer() should know how many ticks to update.  Passing ticks
      get rid of this redundant calculation.  Also there are another redundancy
      pointed out by Martin Schwidefsky.
      This cleanup make a barrier added by
       needless.  So this patch removes
      As a bonus, this cleanup make wall_jiffies can be removed easily, since now
      wall_jiffies is always synced with jiffies.  (This patch does not really
      remove wall_jiffies.  It would be another cleanup patch)
      Signed-off-by: default avatarAtsushi Nemoto <anemo@mba.ocn.ne.jp>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: john stultz <johnstul@us.ibm.com>
      Cc: Andi Kleen <ak@muc.de>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Acked-by: default avatarRussell King <rmk@arm.linux.org.uk>
      Cc: Ian Molton <spyro@f2s.com>
      Cc: Mikael Starvik <starvik@axis.com>
      Acked-by: default avatarDavid Howells <dhowells@redhat.com>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Hirokazu Takata <takata.hirokazu@renesas.com>
      Acked-by: default avatarRalf Baechle <ralf@linux-mips.org>
      Cc: Kyle McMartin <kyle@mcmartin.ca>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
      Cc: Richard Curnow <rc@rc0.org.uk>
      Cc: William Lee Irwin III <wli@holomorphy.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jeff Dike <jdike@addtoit.com>
      Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
      Cc: Miles Bader <uclinux-v850@lsi.nec.co.jp>
      Cc: Chris Zankel <chris@zankel.net>
      Acked-by: default avatar"Luck, Tony" <tony.luck@intel.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Roman Zippel <zippel@linux-m68k.org>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
  20. 19 Sep, 2006 1 commit
    • Paul Mackerras's avatar
      [POWERPC] Define of_read_ulong helper · a4dc7ff0
      Paul Mackerras authored
      There are various places where we want to extract an unsigned long
      value from a device-tree property that can be 1 or 2 cells in length.
      This replaces some open-coded calculations, and one place where we
      assumed without checking that properties were the length we wanted,
      with a little of_read_ulong() helper.
      Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
  21. 30 Aug, 2006 2 commits
    • Paul Mackerras's avatar
      [PATCH] ppc32: fix last_jiffy time comparison · eb36c288
      Paul Mackerras authored
      This fixes a hang on ppc32.
      The problem was that I was comparing a 32-bit quantity with a 64-bit
      quantity, and consequently time wasn't advancing.  This makes us use a
      64-bit quantity on all platforms, which ends up simplifying the code
      since we can now get rid of the tb_last_stamp variable (which actually
      fixes another bug that Ben H and I noticed while going carefully through
      the code).
      This works fine on my G4 tibook.  Let me know how it goes on your
      Acked-by: default avatarOlaf Hering <olaf@aepfle.de>
      Acked-by: default avatarMikael Pettersson <mikpe@it.uu.se>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    • Paul Mackerras's avatar
      [POWERPC] Fix problem with time not advancing on 32-bit platforms · e0d872d5
      Paul Mackerras authored
      This fixes a problem introduced in 5db9fa95
      The last_jiffy per-cpu variable is only 32 bits on 32-bit machines, but it
      was being compared with a 64-bit quantity (tb_next_jiffy), which resulted in
      time not advancing.
      This fixes it by changing last_jiffy to be 64 bits on all platforms.  With
      this, we no longer need tb_last_stamp as a 32-bit version of tb_last_jiffy,
      so this gets rid of tb_last_stamp and we just use tb_last_jiffy instead.
      This also fixes a bug when the boot cpu is not online, because using
      tb_last_stamp could have caused the wrong timebase origin value to be used
      when calculating the time of day.
      Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
  22. 22 Aug, 2006 1 commit
    • Nathan Lynch's avatar
      [POWERPC] Fix gettimeofday inaccuracies · 5db9fa95
      Nathan Lynch authored
      There are two problems in the powerpc gettimeofday code which can
      cause incorrect results to be returned.
      The first is that there is a race between do_gettimeofday and the
      timer interrupt:
      1. do_gettimeofday does get_tb()
      2. decrementer exception on boot cpu which runs timer_recalc_offset,
         which also samples the timebase and updates the do_gtod structure
         with a greater timebase value.
      3. do_gettimeofday calls __do_gettimeofday, which leads to the
         negative result from tb_val - temp_varp->tb_orig_stamp.
      The second is caused by taking the boot cpu offline, which can cause
      the value of tb_last_jiffy to be increased past the currently
      available timebase, causing the same underflow as above.
      [paulus@samba.org - define and use data_barrier() instead of mb().]
      Signed-off-by: default avatarNathan Lynch <ntl@pobox.com>
      Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
  23. 30 Jul, 2006 1 commit
  24. 30 Jun, 2006 1 commit
  25. 26 Jun, 2006 2 commits
  26. 20 Jun, 2006 1 commit
  27. 22 Apr, 2006 2 commits
  28. 28 Mar, 2006 1 commit
  29. 15 Mar, 2006 1 commit
    • Paul Mackerras's avatar
      powerpc: Fix problem with time going backwards · 0a45d449
      Paul Mackerras authored
      The recent changes to keep gettimeofday in sync with xtime had the side
      effect that it was occasionally possible for the time reported by
      gettimeofday to go back by a microsecond.  There were two reasons:
      (1) when we recalculated the offsets used by gettimeofday every 2^31
      timebase ticks, we lost an accumulated fractional microsecond, and
      (2) because the update is done some time after the notional start of
      jiffy, if ntp is slowing the clock, it is possible to see time go backwards
      when the timebase factor gets reduced.
      This fixes it by (a) slowing the gettimeofday clock by about 1us in
      2^31 timebase ticks (a factor of less than 1 in 3.7 million), and (b)
      adjusting the timebase offsets in the rare case that the gettimeofday
      result could possibly go backwards (i.e. when ntp is slowing the clock
      and the timer interrupt is late).  In this case the adjustment will
      reduce to zero eventually because of (a).
      Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
  30. 26 Feb, 2006 1 commit
  31. 23 Feb, 2006 1 commit
    • Paul Mackerras's avatar
      powerpc: Implement accurate task and CPU time accounting · c6622f63
      Paul Mackerras authored
      This implements accurate task and cpu time accounting for 64-bit
      powerpc kernels.  Instead of accounting a whole jiffy of time to a
      task on a timer interrupt because that task happened to be running at
      the time, we now account time in units of timebase ticks according to
      the actual time spent by the task in user mode and kernel mode.  We
      also count the time spent processing hardware and software interrupts
      accurately.  This is conditional on CONFIG_VIRT_CPU_ACCOUNTING.  If
      that is not set, we do tick-based approximate accounting as before.
      To get this accurate information, we read either the PURR (processor
      utilization of resources register) on POWER5 machines, or the timebase
      on other machines on
      * each entry to the kernel from usermode
      * each exit to usermode
      * transitions between process context, hard irq context and soft irq
        context in kernel mode
      * context switches.
      On POWER5 systems with shared-processor logical partitioning we also
      read both the PURR and the timebase at each timer interrupt and
      context switch in order to determine how much time has been taken by
      the hypervisor to run other partitions ("steal" time).  Unfortunately,
      since we need values of the PURR on both threads at the same time to
      accurately calculate the steal time, and since we can only calculate
      steal time on a per-core basis, the apportioning of the steal time
      between idle time (time which we ceded to the hypervisor in the idle
      loop) and actual stolen time is somewhat approximate at the moment.
      This is all based quite heavily on what s390 does, and it uses the
      generic interfaces that were added by the s390 developers,
      i.e. account_system_time(), account_user_time(), etc.
      This patch doesn't add any new interfaces between the kernel and
      userspace, and doesn't change the units in which time is reported to
      userspace by things such as /proc/stat, /proc/<pid>/stat, getrusage(),
      times(), etc.  Internally the various task and cpu times are stored in
      timebase units, but they are converted to USER_HZ units (1/100th of a
      second) when reported to userspace.  Some precision is therefore lost
      but there should not be any accumulating error, since the internal
      accumulation is at full precision.
      Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
  32. 19 Feb, 2006 1 commit
    • Paul Mackerras's avatar
      powerpc: Keep xtime and gettimeofday in sync · 092b8f34
      Paul Mackerras authored
      This fixes a regression which was introduced by moving ppc32 to use
      the same sort of lockless gettimeofday as ppc64 has been using for
      some time.  This involves getting the timebase and performing some
      simple arithmetic to convert it to seconds and microseconds.  However,
      the factor and offset used there weren't being updated when NTP
      varied the tick length using adjtimex.  64-bit didn't notice the
      problem because it had a hook in the 32-bit adjtimex compat routine
      that attempted to work out what the generic timekeeping code would
      do and alter the factor and offset to match.  However, that code
      was very complex and it wasn't clear that it still matched what the
      generic code would do.
      Now we use the generic current_tick_length() routine that was recently
      added to check that the current tick will be as long as we expect; if
      not we recompute the factor and offset.  This keeps gettimeofday and
      xtime in sync.  In addition we check that gettimeofday hasn't got ahead
      of xtime on each timer interrupt; if it has, we resync.
      Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
  33. 07 Feb, 2006 1 commit
  34. 13 Jan, 2006 1 commit
    • David Gibson's avatar
      [PATCH] powerpc: Remove lppaca structure from the PACA · 3356bb9f
      David Gibson authored
      At present the lppaca - the structure shared with the iSeries
      hypervisor and phyp - is contained within the PACA, our own low-level
      per-cpu structure.  This doesn't have to be so, the patch below
      removes it, making a separate array of lppaca structures.
      This saves approximately 500*NR_CPUS bytes of image size and kernel
      memory, because we don't need aligning gap between the Linux and
      hypervisor portions of every PACA.  On the other hand it means an
      extra level of dereference in many accesses to the lppaca.
      The patch also gets rid of several places where we assign the paca
      address to a local variable for no particular reason.
      Signed-off-by: default avatarDavid Gibson <dwg@au1.ibm.com>
      Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>