Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clocksource: Replace vread with generic arch data

The vread field was bloating struct clocksource everywhere except
x86_64, and I want to change the way this works on x86_64, so let's
split it out into per-arch data.

Cc: x86@kernel.org
Cc: Clemens Ladisch <clemens@ladisch.de>
Cc: linux-ia64@vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: John Stultz <johnstul@us.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andy Lutomirski <luto@mit.edu>
Link: http://lkml.kernel.org/r/3ae5ec76a168eaaae63f08a2a1060b91aa0b7759.1310563276.git.luto@mit.edu
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>

authored by

Andy Lutomirski and committed by
H. Peter Anvin
433bd805 7f79ad15

+31 -5
+16
arch/x86/include/asm/clocksource.h
··· 1 + /* x86-specific clocksource additions */ 2 + 3 + #ifndef _ASM_X86_CLOCKSOURCE_H 4 + #define _ASM_X86_CLOCKSOURCE_H 5 + 6 + #ifdef CONFIG_X86_64 7 + 8 + #define __ARCH_HAS_CLOCKSOURCE_DATA 9 + 10 + struct arch_clocksource_data { 11 + cycle_t (*vread)(void); 12 + }; 13 + 14 + #endif /* CONFIG_X86_64 */ 15 + 16 + #endif /* _ASM_X86_CLOCKSOURCE_H */
+1 -1
arch/x86/kernel/hpet.c
··· 753 753 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 754 754 .resume = hpet_resume_counter, 755 755 #ifdef CONFIG_X86_64 756 - .vread = vread_hpet, 756 + .archdata = { .vread = vread_hpet }, 757 757 #endif 758 758 }; 759 759
+1 -1
arch/x86/kernel/tsc.c
··· 777 777 .flags = CLOCK_SOURCE_IS_CONTINUOUS | 778 778 CLOCK_SOURCE_MUST_VERIFY, 779 779 #ifdef CONFIG_X86_64 780 - .vread = vread_tsc, 780 + .archdata = { .vread = vread_tsc }, 781 781 #endif 782 782 }; 783 783
+1 -1
arch/x86/kernel/vsyscall_64.c
··· 74 74 write_seqlock_irqsave(&vsyscall_gtod_data.lock, flags); 75 75 76 76 /* copy vsyscall data */ 77 - vsyscall_gtod_data.clock.vread = clock->vread; 77 + vsyscall_gtod_data.clock.vread = clock->archdata.vread; 78 78 vsyscall_gtod_data.clock.cycle_last = clock->cycle_last; 79 79 vsyscall_gtod_data.clock.mask = clock->mask; 80 80 vsyscall_gtod_data.clock.mult = mult;
+4
include/asm-generic/clocksource.h
··· 1 + /* 2 + * Architectures should override this file to add private userspace 3 + * clock magic if needed. 4 + */
+8 -2
include/linux/clocksource.h
··· 22 22 typedef u64 cycle_t; 23 23 struct clocksource; 24 24 25 + #include <asm/clocksource.h> 26 + 25 27 /** 26 28 * struct cyclecounter - hardware abstraction for a free running counter 27 29 * Provides completely state-free accessors to the underlying hardware. ··· 155 153 * @shift: cycle to nanosecond divisor (power of two) 156 154 * @max_idle_ns: max idle time permitted by the clocksource (nsecs) 157 155 * @flags: flags describing special properties 158 - * @vread: vsyscall based read 156 + * @archdata: arch-specific data 159 157 * @suspend: suspend function for the clocksource, if necessary 160 158 * @resume: resume function for the clocksource, if necessary 161 159 */ ··· 177 175 #else 178 176 #define CLKSRC_FSYS_MMIO_SET(mmio, addr) do { } while (0) 179 177 #endif 178 + 179 + #ifdef __ARCH_HAS_CLOCKSOURCE_DATA 180 + struct arch_clocksource_data archdata; 181 + #endif 182 + 180 183 const char *name; 181 184 struct list_head list; 182 185 int rating; 183 - cycle_t (*vread)(void); 184 186 int (*enable)(struct clocksource *cs); 185 187 void (*disable)(struct clocksource *cs); 186 188 unsigned long flags;