mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-28 16:52:18 +00:00
9c4ba50565
Use TYPEOF_UNQUAL() to declare variables as a corresponding type without named address space qualifier to avoid "`__seg_gs' specified for auto variable `var'" errors. Link: https://lkml.kernel.org/r/20241208204708.3742696-4-ubizjak@gmail.com Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Acked-by: Nadav Amit <nadav.amit@gmail.com> Acked-by: Christoph Lameter <cl@linux.com> Acked-by: Dennis Zhou <dennis@kernel.org> Cc: Tejun Heo <tj@kernel.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Kent Overstreet <kent.overstreet@linux.dev> Cc: Arnd Bergmann <arnd@arndb.de> Cc: "David S. Miller" <davem@davemloft.net> Cc: Eric Dumazet <edumazet@google.com> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Paolo Abeni <pabeni@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Will Deacon <will@kernel.org> Cc: Waiman Long <longman@redhat.com> Cc: Boqun Feng <boqun.feng@gmail.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
83 lines
2.4 KiB
C
83 lines
2.4 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _LINUX_PART_STAT_H
|
|
#define _LINUX_PART_STAT_H
|
|
|
|
#include <linux/blkdev.h>
|
|
#include <asm/local.h>
|
|
|
|
struct disk_stats {
|
|
u64 nsecs[NR_STAT_GROUPS];
|
|
unsigned long sectors[NR_STAT_GROUPS];
|
|
unsigned long ios[NR_STAT_GROUPS];
|
|
unsigned long merges[NR_STAT_GROUPS];
|
|
unsigned long io_ticks;
|
|
local_t in_flight[2];
|
|
};
|
|
|
|
/*
|
|
* Macros to operate on percpu disk statistics:
|
|
*
|
|
* {disk|part|all}_stat_{add|sub|inc|dec}() modify the stat counters and should
|
|
* be called between disk_stat_lock() and disk_stat_unlock().
|
|
*
|
|
* part_stat_read() can be called at any time.
|
|
*/
|
|
#define part_stat_lock() preempt_disable()
|
|
#define part_stat_unlock() preempt_enable()
|
|
|
|
#define part_stat_get_cpu(part, field, cpu) \
|
|
(per_cpu_ptr((part)->bd_stats, (cpu))->field)
|
|
|
|
#define part_stat_get(part, field) \
|
|
part_stat_get_cpu(part, field, smp_processor_id())
|
|
|
|
#define part_stat_read(part, field) \
|
|
({ \
|
|
TYPEOF_UNQUAL((part)->bd_stats->field) res = 0; \
|
|
unsigned int _cpu; \
|
|
for_each_possible_cpu(_cpu) \
|
|
res += per_cpu_ptr((part)->bd_stats, _cpu)->field; \
|
|
res; \
|
|
})
|
|
|
|
static inline void part_stat_set_all(struct block_device *part, int value)
|
|
{
|
|
int i;
|
|
|
|
for_each_possible_cpu(i)
|
|
memset(per_cpu_ptr(part->bd_stats, i), value,
|
|
sizeof(struct disk_stats));
|
|
}
|
|
|
|
#define part_stat_read_accum(part, field) \
|
|
(part_stat_read(part, field[STAT_READ]) + \
|
|
part_stat_read(part, field[STAT_WRITE]) + \
|
|
part_stat_read(part, field[STAT_DISCARD]))
|
|
|
|
#define __part_stat_add(part, field, addnd) \
|
|
__this_cpu_add((part)->bd_stats->field, addnd)
|
|
|
|
#define part_stat_add(part, field, addnd) do { \
|
|
__part_stat_add((part), field, addnd); \
|
|
if (bdev_is_partition(part)) \
|
|
__part_stat_add(bdev_whole(part), field, addnd); \
|
|
} while (0)
|
|
|
|
#define part_stat_dec(part, field) \
|
|
part_stat_add(part, field, -1)
|
|
#define part_stat_inc(part, field) \
|
|
part_stat_add(part, field, 1)
|
|
#define part_stat_sub(part, field, subnd) \
|
|
part_stat_add(part, field, -subnd)
|
|
|
|
#define part_stat_local_dec(part, field) \
|
|
local_dec(&(part_stat_get(part, field)))
|
|
#define part_stat_local_inc(part, field) \
|
|
local_inc(&(part_stat_get(part, field)))
|
|
#define part_stat_local_read(part, field) \
|
|
local_read(&(part_stat_get(part, field)))
|
|
#define part_stat_local_read_cpu(part, field, cpu) \
|
|
local_read(&(part_stat_get_cpu(part, field, cpu)))
|
|
|
|
#endif /* _LINUX_PART_STAT_H */
|