Skip to content

Commit a50cf15

Browse files
committed
Merge branch 'for-5.10-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu
Pull percpu fix and cleanup from Dennis Zhou: "A fix for a Wshadow warning in the asm-generic percpu macros came in and then I tacked on the removal of flexible array initializers in the percpu allocator" * 'for-5.10-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu: percpu: convert flexible array initializers to use struct_size() asm-generic: percpu: avoid Wshadow warning
2 parents e28c0d7 + 61cf93d commit a50cf15

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

include/asm-generic/percpu.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,21 @@ do { \
114114

115115
#define __this_cpu_generic_read_nopreempt(pcp) \
116116
({ \
117-
typeof(pcp) __ret; \
117+
typeof(pcp) ___ret; \
118118
preempt_disable_notrace(); \
119-
__ret = READ_ONCE(*raw_cpu_ptr(&(pcp))); \
119+
___ret = READ_ONCE(*raw_cpu_ptr(&(pcp))); \
120120
preempt_enable_notrace(); \
121-
__ret; \
121+
___ret; \
122122
})
123123

124124
#define __this_cpu_generic_read_noirq(pcp) \
125125
({ \
126-
typeof(pcp) __ret; \
127-
unsigned long __flags; \
128-
raw_local_irq_save(__flags); \
129-
__ret = raw_cpu_generic_read(pcp); \
130-
raw_local_irq_restore(__flags); \
131-
__ret; \
126+
typeof(pcp) ___ret; \
127+
unsigned long ___flags; \
128+
raw_local_irq_save(___flags); \
129+
___ret = raw_cpu_generic_read(pcp); \
130+
raw_local_irq_restore(___flags); \
131+
___ret; \
132132
})
133133

134134
#define this_cpu_generic_read(pcp) \

mm/percpu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,8 +1315,8 @@ static struct pcpu_chunk * __init pcpu_alloc_first_chunk(unsigned long tmp_addr,
13151315
region_size = ALIGN(start_offset + map_size, lcm_align);
13161316

13171317
/* allocate chunk */
1318-
alloc_size = sizeof(struct pcpu_chunk) +
1319-
BITS_TO_LONGS(region_size >> PAGE_SHIFT) * sizeof(unsigned long);
1318+
alloc_size = struct_size(chunk, populated,
1319+
BITS_TO_LONGS(region_size >> PAGE_SHIFT));
13201320
chunk = memblock_alloc(alloc_size, SMP_CACHE_BYTES);
13211321
if (!chunk)
13221322
panic("%s: Failed to allocate %zu bytes\n", __func__,
@@ -2521,8 +2521,8 @@ void __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
25212521
pcpu_unit_pages = ai->unit_size >> PAGE_SHIFT;
25222522
pcpu_unit_size = pcpu_unit_pages << PAGE_SHIFT;
25232523
pcpu_atom_size = ai->atom_size;
2524-
pcpu_chunk_struct_size = sizeof(struct pcpu_chunk) +
2525-
BITS_TO_LONGS(pcpu_unit_pages) * sizeof(unsigned long);
2524+
pcpu_chunk_struct_size = struct_size(chunk, populated,
2525+
BITS_TO_LONGS(pcpu_unit_pages));
25262526

25272527
pcpu_stats_save_ai(ai);
25282528

0 commit comments

Comments
 (0)