* [PATCH 0/2] percpu: fix block iterators and reserved chunk stats
@ 2017-09-27 21:34 ` Dennis Zhou
0 siblings, 0 replies; 14+ messages in thread
From: Dennis Zhou @ 2017-09-27 21:34 UTC (permalink / raw)
To: Tejun Heo, Christoph Lameter, Luis Henriques
Cc: linux-mm, linux-kernel, Dennis Zhou
Hi everyone,
This patchset includes two bug fixes related to bitmap percpu memory
allocator.
The first is a problem with how the start offset is managed in bytes, but
the bitmaps are traversed in bits. The start offset is maintained to keep
alignment true within the actual allocation area in the chunk. With the
reserved and dynamic chunk, this may unintentionally skip over a portion
proportional to the start offset and PCPU_MIN_ALLOC_SIZE.
The second is an issue reported by Luis in [1]. The allocator was unable
to allocate from the reserved chunk due to the block offset not being
reset within the iterator. This caused subsequently checked blocks to
check against a potentially higher block offset. This may lead the
iterator to believe it had checked this area in the prior iteration. The
fix is to simply reset the block offset to 0 after it is used allowing
the predicate to always evaluate to true for subsequent blocks.
[1] https://lkml.org/lkml/2017/9/26/506
This patchset contains the following 2 patches:
0001-percpu-fix-starting-offset-for-chunk-statistics-trav.patch
0002-percpu-fix-iteration-to-prevent-skipping-over-block.patch
0001 fixes the chunk start offset issue. 0002 fixes the iteration bug.
This patchset is on top of linus#v4.14-rc2 e19b205be4.
diffstats below:
Dennis Zhou (2):
percpu: fix starting offset for chunk statistics traversal
percpu: fix iteration to prevent skipping over block
mm/percpu-stats.c | 2 +-
mm/percpu.c | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
Thanks,
Dennis
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/2] percpu: fix starting offset for chunk statistics traversal
2017-09-27 21:34 ` Dennis Zhou
@ 2017-09-27 21:34 ` Dennis Zhou
-1 siblings, 0 replies; 14+ messages in thread
From: Dennis Zhou @ 2017-09-27 21:34 UTC (permalink / raw)
To: Tejun Heo, Christoph Lameter, Luis Henriques
Cc: linux-mm, linux-kernel, Dennis Zhou
This patch fixes the starting offset used when scanning chunks to
compute the chunk statistics. The value start_offset (and end_offset)
are managed in bytes while the traversal occurs over bits. Thus for the
reserved and dynamic chunk, it may incorrectly skip over the initial
allocations.
Signed-off-by: Dennis Zhou <dennisszhou@gmail.com>
---
mm/percpu-stats.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/percpu-stats.c b/mm/percpu-stats.c
index 6142484..7a58460 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,
last_alloc + 1 : 0;
as_len = 0;
- start = chunk->start_offset;
+ start = chunk->start_offset / PCPU_MIN_ALLOC_SIZE;
/*
* If a bit is set in the allocation map, the bound_map identifies
--
1.8.3.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 1/2] percpu: fix starting offset for chunk statistics traversal
@ 2017-09-27 21:34 ` Dennis Zhou
0 siblings, 0 replies; 14+ messages in thread
From: Dennis Zhou @ 2017-09-27 21:34 UTC (permalink / raw)
To: Tejun Heo, Christoph Lameter, Luis Henriques
Cc: linux-mm, linux-kernel, Dennis Zhou
This patch fixes the starting offset used when scanning chunks to
compute the chunk statistics. The value start_offset (and end_offset)
are managed in bytes while the traversal occurs over bits. Thus for the
reserved and dynamic chunk, it may incorrectly skip over the initial
allocations.
Signed-off-by: Dennis Zhou <dennisszhou@gmail.com>
---
mm/percpu-stats.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/percpu-stats.c b/mm/percpu-stats.c
index 6142484..7a58460 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,
last_alloc + 1 : 0;
as_len = 0;
- start = chunk->start_offset;
+ start = chunk->start_offset / PCPU_MIN_ALLOC_SIZE;
/*
* If a bit is set in the allocation map, the bound_map identifies
--
1.8.3.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] percpu: fix starting offset for chunk statistics traversal
2017-09-27 21:34 ` Dennis Zhou
@ 2017-09-27 21:46 ` Tejun Heo
-1 siblings, 0 replies; 14+ messages in thread
From: Tejun Heo @ 2017-09-27 21:46 UTC (permalink / raw)
To: Dennis Zhou; +Cc: Christoph Lameter, Luis Henriques, linux-mm, linux-kernel
On Wed, Sep 27, 2017 at 04:34:59PM -0500, Dennis Zhou wrote:
> This patch fixes the starting offset used when scanning chunks to
> compute the chunk statistics. The value start_offset (and end_offset)
> are managed in bytes while the traversal occurs over bits. Thus for the
> reserved and dynamic chunk, it may incorrectly skip over the initial
> allocations.
>
> Signed-off-by: Dennis Zhou <dennisszhou@gmail.com>
Applied to percpu/for-4.14-fixes.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] percpu: fix starting offset for chunk statistics traversal
@ 2017-09-27 21:46 ` Tejun Heo
0 siblings, 0 replies; 14+ messages in thread
From: Tejun Heo @ 2017-09-27 21:46 UTC (permalink / raw)
To: Dennis Zhou; +Cc: Christoph Lameter, Luis Henriques, linux-mm, linux-kernel
On Wed, Sep 27, 2017 at 04:34:59PM -0500, Dennis Zhou wrote:
> This patch fixes the starting offset used when scanning chunks to
> compute the chunk statistics. The value start_offset (and end_offset)
> are managed in bytes while the traversal occurs over bits. Thus for the
> reserved and dynamic chunk, it may incorrectly skip over the initial
> allocations.
>
> Signed-off-by: Dennis Zhou <dennisszhou@gmail.com>
Applied to percpu/for-4.14-fixes.
Thanks.
--
tejun
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/2] percpu: fix iteration to prevent skipping over block
2017-09-27 21:34 ` Dennis Zhou
@ 2017-09-27 21:35 ` Dennis Zhou
-1 siblings, 0 replies; 14+ messages in thread
From: Dennis Zhou @ 2017-09-27 21:35 UTC (permalink / raw)
To: Tejun Heo, Christoph Lameter, Luis Henriques
Cc: linux-mm, linux-kernel, Dennis Zhou
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-by: Luis Henriques <lhenriques@suse.com>
---
mm/percpu.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mm/percpu.c b/mm/percpu.c
index 59d44d6..aa121ce 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);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/2] percpu: fix iteration to prevent skipping over block
@ 2017-09-27 21:35 ` Dennis Zhou
0 siblings, 0 replies; 14+ messages in thread
From: Dennis Zhou @ 2017-09-27 21:35 UTC (permalink / raw)
To: Tejun Heo, Christoph Lameter, Luis Henriques
Cc: linux-mm, linux-kernel, Dennis Zhou
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-by: Luis Henriques <lhenriques@suse.com>
---
mm/percpu.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mm/percpu.c b/mm/percpu.c
index 59d44d6..aa121ce 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);
--
1.8.3.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] percpu: fix iteration to prevent skipping over block
2017-09-27 21:35 ` Dennis Zhou
@ 2017-09-27 21:51 ` Tejun Heo
-1 siblings, 0 replies; 14+ messages in thread
From: Tejun Heo @ 2017-09-27 21:51 UTC (permalink / raw)
To: Dennis Zhou; +Cc: Christoph Lameter, Luis Henriques, linux-mm, linux-kernel
On Wed, Sep 27, 2017 at 04:35:00PM -0500, Dennis Zhou wrote:
> 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-by: Luis Henriques <lhenriques@suse.com>
Luis, can you please verify that this fixes the allocaiton failure you
were seeing?
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] percpu: fix iteration to prevent skipping over block
@ 2017-09-27 21:51 ` Tejun Heo
0 siblings, 0 replies; 14+ messages in thread
From: Tejun Heo @ 2017-09-27 21:51 UTC (permalink / raw)
To: Dennis Zhou; +Cc: Christoph Lameter, Luis Henriques, linux-mm, linux-kernel
On Wed, Sep 27, 2017 at 04:35:00PM -0500, Dennis Zhou wrote:
> 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-by: Luis Henriques <lhenriques@suse.com>
Luis, can you please verify that this fixes the allocaiton failure you
were seeing?
Thanks.
--
tejun
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] percpu: fix iteration to prevent skipping over block
2017-09-27 21:51 ` Tejun Heo
@ 2017-09-28 8:31 ` Luis Henriques
-1 siblings, 0 replies; 14+ messages in thread
From: Luis Henriques @ 2017-09-28 8:31 UTC (permalink / raw)
To: Tejun Heo; +Cc: Dennis Zhou, Christoph Lameter, linux-mm, linux-kernel
Tejun Heo <tj@kernel.org> writes:
> On Wed, Sep 27, 2017 at 04:35:00PM -0500, Dennis Zhou wrote:
>> 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-by: Luis Henriques <lhenriques@suse.com>
>
> Luis, can you please verify that this fixes the allocaiton failure you
> were seeing?
I can confirm that I'm no longer seeing the allocation failure after
applying these patches. Feel free to add my:
Tested-by: Luis Henriques <lhenriques@suse.com>
Cheers,
--
Luis
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] percpu: fix iteration to prevent skipping over block
@ 2017-09-28 8:31 ` Luis Henriques
0 siblings, 0 replies; 14+ messages in thread
From: Luis Henriques @ 2017-09-28 8:31 UTC (permalink / raw)
To: Tejun Heo; +Cc: Dennis Zhou, Christoph Lameter, linux-mm, linux-kernel
Tejun Heo <tj@kernel.org> writes:
> On Wed, Sep 27, 2017 at 04:35:00PM -0500, Dennis Zhou wrote:
>> 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-by: Luis Henriques <lhenriques@suse.com>
>
> Luis, can you please verify that this fixes the allocaiton failure you
> were seeing?
I can confirm that I'm no longer seeing the allocation failure after
applying these patches. Feel free to add my:
Tested-by: Luis Henriques <lhenriques@suse.com>
Cheers,
--
Luis
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] percpu: fix iteration to prevent skipping over block
2017-09-27 21:35 ` Dennis Zhou
@ 2017-09-28 14:40 ` Tejun Heo
-1 siblings, 0 replies; 14+ messages in thread
From: Tejun Heo @ 2017-09-28 14:40 UTC (permalink / raw)
To: Dennis Zhou; +Cc: Christoph Lameter, Luis Henriques, linux-mm, linux-kernel
On Wed, Sep 27, 2017 at 04:35:00PM -0500, Dennis Zhou wrote:
> 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-by: Luis Henriques <lhenriques@suse.com>
Applied to percpu/for-4.14-fixes.
Thanks!
--
tejun
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] percpu: fix iteration to prevent skipping over block
@ 2017-09-28 14:40 ` Tejun Heo
0 siblings, 0 replies; 14+ messages in thread
From: Tejun Heo @ 2017-09-28 14:40 UTC (permalink / raw)
To: Dennis Zhou; +Cc: Christoph Lameter, Luis Henriques, linux-mm, linux-kernel
On Wed, Sep 27, 2017 at 04:35:00PM -0500, Dennis Zhou wrote:
> 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-by: Luis Henriques <lhenriques@suse.com>
Applied to percpu/for-4.14-fixes.
Thanks!
--
tejun
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 14+ messages in thread