diff options
author | Dennis Zhou <dennisszhou@gmail.com> | 2017-09-27 16:35:00 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2017-09-28 07:39:27 -0700 |
commit | 1fa4df3e688902d033dfda796eb83ae6ad8d0488 (patch) | |
tree | 8b2212d5142ff1e0c12a5de1955ccff194132126 /mm/percpu.c | |
parent | 2e08d20d777e997bf37806b22b471f98fbe6b693 (diff) | |
download | linux-1fa4df3e688902d033dfda796eb83ae6ad8d0488.tar.gz linux-1fa4df3e688902d033dfda796eb83ae6ad8d0488.tar.bz2 linux-1fa4df3e688902d033dfda796eb83ae6ad8d0488.zip |
percpu: fix iteration to prevent skipping over block
The iterator functions pcpu_next_md_free_region and
pcpu_next_fit_region use the block offset to determine if they have
checked the area in the prior iteration. However, this causes an issue
when the block offset is greater than subsequent block contig hints. If
within the iterator it moves to check subsequent blocks, it may fail in
the second predicate due to the block offset not being cleared. Thus,
this causes the allocator to skip over blocks leading to false failures
when allocating from the reserved chunk. While this happens in the
general case as well, it will only fail if it cannot allocate a new
chunk.
This patch resets the block offset to 0 to pass the second predicate
when checking subseqent blocks within the iterator function.
Signed-off-by: Dennis Zhou <dennisszhou@gmail.com>
Reported-and-tested-by: Luis Henriques <lhenriques@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'mm/percpu.c')
-rw-r--r-- | mm/percpu.c | 4 |
1 files changed, 4 insertions, 0 deletions
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, block->contig_hint_start); return; } + /* reset to satisfy the second predicate above */ + block_off = 0; *bits = block->right_free; *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, *bit_off = pcpu_block_off_to_off(i, block->first_free); return; } + /* reset to satisfy the second predicate above */ + block_off = 0; *bit_off = ALIGN(PCPU_BITMAP_BLOCK_BITS - block->right_free, align); |