diff options
| -rw-r--r-- | include/asm-generic/percpu.h | 24 | ||||
| -rw-r--r-- | mm/percpu-stats.c | 2 | ||||
| -rw-r--r-- | mm/percpu.c | 4 |
3 files changed, 27 insertions, 3 deletions
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h index 0504ef8f3aa3..976f8ac26665 100644 --- a/include/asm-generic/percpu.h +++ b/include/asm-generic/percpu.h | |||
| @@ -115,15 +115,35 @@ do { \ | |||
| 115 | (__ret); \ | 115 | (__ret); \ |
| 116 | }) | 116 | }) |
| 117 | 117 | ||
| 118 | #define this_cpu_generic_read(pcp) \ | 118 | #define __this_cpu_generic_read_nopreempt(pcp) \ |
| 119 | ({ \ | 119 | ({ \ |
| 120 | typeof(pcp) __ret; \ | 120 | typeof(pcp) __ret; \ |
| 121 | preempt_disable_notrace(); \ | 121 | preempt_disable_notrace(); \ |
| 122 | __ret = raw_cpu_generic_read(pcp); \ | 122 | __ret = READ_ONCE(*raw_cpu_ptr(&(pcp))); \ |
| 123 | preempt_enable_notrace(); \ | 123 | preempt_enable_notrace(); \ |
| 124 | __ret; \ | 124 | __ret; \ |
| 125 | }) | 125 | }) |
| 126 | 126 | ||
| 127 | #define __this_cpu_generic_read_noirq(pcp) \ | ||
| 128 | ({ \ | ||
| 129 | typeof(pcp) __ret; \ | ||
| 130 | unsigned long __flags; \ | ||
| 131 | raw_local_irq_save(__flags); \ | ||
| 132 | __ret = raw_cpu_generic_read(pcp); \ | ||
| 133 | raw_local_irq_restore(__flags); \ | ||
| 134 | __ret; \ | ||
| 135 | }) | ||
| 136 | |||
| 137 | #define this_cpu_generic_read(pcp) \ | ||
| 138 | ({ \ | ||
| 139 | typeof(pcp) __ret; \ | ||
| 140 | if (__native_word(pcp)) \ | ||
| 141 | __ret = __this_cpu_generic_read_nopreempt(pcp); \ | ||
| 142 | else \ | ||
| 143 | __ret = __this_cpu_generic_read_noirq(pcp); \ | ||
| 144 | __ret; \ | ||
| 145 | }) | ||
| 146 | |||
| 127 | #define this_cpu_generic_to_op(pcp, val, op) \ | 147 | #define this_cpu_generic_to_op(pcp, val, op) \ |
| 128 | do { \ | 148 | do { \ |
| 129 | unsigned long __flags; \ | 149 | unsigned long __flags; \ |
diff --git a/mm/percpu-stats.c b/mm/percpu-stats.c index 6142484e88f7..7a58460bfd27 100644 --- a/mm/percpu-stats.c +++ b/mm/percpu-stats.c | |||
| @@ -73,7 +73,7 @@ static void chunk_map_stats(struct seq_file *m, struct pcpu_chunk *chunk, | |||
| 73 | last_alloc + 1 : 0; | 73 | last_alloc + 1 : 0; |
| 74 | 74 | ||
| 75 | as_len = 0; | 75 | as_len = 0; |
| 76 | start = chunk->start_offset; | 76 | start = chunk->start_offset / PCPU_MIN_ALLOC_SIZE; |
| 77 | 77 | ||
| 78 | /* | 78 | /* |
| 79 | * If a bit is set in the allocation map, the bound_map identifies | 79 | * If a bit is set in the allocation map, the bound_map identifies |
diff --git a/mm/percpu.c b/mm/percpu.c index 59d44d61f5f1..aa121cef76de 100644 --- a/mm/percpu.c +++ b/mm/percpu.c | |||
| @@ -353,6 +353,8 @@ static void pcpu_next_md_free_region(struct pcpu_chunk *chunk, int *bit_off, | |||
| 353 | block->contig_hint_start); | 353 | block->contig_hint_start); |
| 354 | return; | 354 | return; |
| 355 | } | 355 | } |
| 356 | /* reset to satisfy the second predicate above */ | ||
| 357 | block_off = 0; | ||
| 356 | 358 | ||
| 357 | *bits = block->right_free; | 359 | *bits = block->right_free; |
| 358 | *bit_off = (i + 1) * PCPU_BITMAP_BLOCK_BITS - block->right_free; | 360 | *bit_off = (i + 1) * PCPU_BITMAP_BLOCK_BITS - block->right_free; |
| @@ -407,6 +409,8 @@ static void pcpu_next_fit_region(struct pcpu_chunk *chunk, int alloc_bits, | |||
| 407 | *bit_off = pcpu_block_off_to_off(i, block->first_free); | 409 | *bit_off = pcpu_block_off_to_off(i, block->first_free); |
| 408 | return; | 410 | return; |
| 409 | } | 411 | } |
| 412 | /* reset to satisfy the second predicate above */ | ||
| 413 | block_off = 0; | ||
| 410 | 414 | ||
| 411 | *bit_off = ALIGN(PCPU_BITMAP_BLOCK_BITS - block->right_free, | 415 | *bit_off = ALIGN(PCPU_BITMAP_BLOCK_BITS - block->right_free, |
| 412 | align); | 416 | align); |
