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

u64_stats: Introduce IRQs disabled helpers

Introduce light versions of u64_stats helpers for context where
either preempt or IRQs are disabled. This way we can make this library
usable by scheduler irqtime accounting which currenty implement its
ad-hoc version.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Wanpeng Li <wanpeng.li@hotmail.com>
Link: http://lkml.kernel.org/r/1474849761-12678-4-git-send-email-fweisbec@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Frederic Weisbecker and committed by
Ingo Molnar
68107df5 2810f611

+25 -22
+25 -22
include/linux/u64_stats_sync.h
··· 103 103 #endif 104 104 } 105 105 106 - static inline unsigned int u64_stats_fetch_begin(const struct u64_stats_sync *syncp) 106 + static inline unsigned int __u64_stats_fetch_begin(const struct u64_stats_sync *syncp) 107 107 { 108 108 #if BITS_PER_LONG==32 && defined(CONFIG_SMP) 109 109 return read_seqcount_begin(&syncp->seq); 110 110 #else 111 - #if BITS_PER_LONG==32 111 + return 0; 112 + #endif 113 + } 114 + 115 + static inline unsigned int u64_stats_fetch_begin(const struct u64_stats_sync *syncp) 116 + { 117 + #if BITS_PER_LONG==32 && !defined(CONFIG_SMP) 112 118 preempt_disable(); 113 119 #endif 114 - return 0; 120 + return __u64_stats_fetch_begin(syncp); 121 + } 122 + 123 + static inline bool __u64_stats_fetch_retry(const struct u64_stats_sync *syncp, 124 + unsigned int start) 125 + { 126 + #if BITS_PER_LONG==32 && defined(CONFIG_SMP) 127 + return read_seqcount_retry(&syncp->seq, start); 128 + #else 129 + return false; 115 130 #endif 116 131 } 117 132 118 133 static inline bool u64_stats_fetch_retry(const struct u64_stats_sync *syncp, 119 134 unsigned int start) 120 135 { 121 - #if BITS_PER_LONG==32 && defined(CONFIG_SMP) 122 - return read_seqcount_retry(&syncp->seq, start); 123 - #else 124 - #if BITS_PER_LONG==32 136 + #if BITS_PER_LONG==32 && !defined(CONFIG_SMP) 125 137 preempt_enable(); 126 138 #endif 127 - return false; 128 - #endif 139 + return __u64_stats_fetch_retry(syncp, start); 129 140 } 130 141 131 142 /* ··· 147 136 */ 148 137 static inline unsigned int u64_stats_fetch_begin_irq(const struct u64_stats_sync *syncp) 149 138 { 150 - #if BITS_PER_LONG==32 && defined(CONFIG_SMP) 151 - return read_seqcount_begin(&syncp->seq); 152 - #else 153 - #if BITS_PER_LONG==32 139 + #if BITS_PER_LONG==32 && !defined(CONFIG_SMP) 154 140 local_irq_disable(); 155 141 #endif 156 - return 0; 157 - #endif 142 + return __u64_stats_fetch_begin(syncp); 158 143 } 159 144 160 145 static inline bool u64_stats_fetch_retry_irq(const struct u64_stats_sync *syncp, 161 - unsigned int start) 146 + unsigned int start) 162 147 { 163 - #if BITS_PER_LONG==32 && defined(CONFIG_SMP) 164 - return read_seqcount_retry(&syncp->seq, start); 165 - #else 166 - #if BITS_PER_LONG==32 148 + #if BITS_PER_LONG==32 && !defined(CONFIG_SMP) 167 149 local_irq_enable(); 168 150 #endif 169 - return false; 170 - #endif 151 + return __u64_stats_fetch_retry(syncp, start); 171 152 } 172 153 173 154 #endif /* _LINUX_U64_STATS_SYNC_H */