mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-14 22:51:50 +03:00
HPA: Fix infinite purging loop
One of the condition to start purging is `hpa_hugify_blocked_by_ndirty` function call returns true. This can happen in cases where we have no dirty memory for this shard at all. In this case purging loop will be an infinite loop. `hpa_hugify_blocked_by_ndirty` was introduced at0f6c420, but at that time purging loop has different form and additional `break` was not required. Purging loop form was re-written at6630c5989, but additional exit condition wasn't added there at the time. Repo code was shared by Patrik Dokoupil at [1], I stripped it down to minimum to reproduce issue in jemalloc unit tests. [1]: https://github.com/jemalloc/jemalloc/pull/2533
This commit is contained in:
parent
fa451de17f
commit
47d69b4eab
2 changed files with 57 additions and 4 deletions
11
src/hpa.c
11
src/hpa.c
|
|
@ -537,9 +537,16 @@ hpa_shard_maybe_do_deferred_work(tsdn_t *tsdn, hpa_shard_t *shard,
|
|||
purged = false;
|
||||
while (hpa_should_purge(tsdn, shard) && nops < max_ops) {
|
||||
purged = hpa_try_purge(tsdn, shard);
|
||||
if (purged) {
|
||||
nops++;
|
||||
if (!purged) {
|
||||
/*
|
||||
* It is fine if we couldn't purge as sometimes
|
||||
* we try to purge just to unblock
|
||||
* hugification, but there is maybe no dirty
|
||||
* pages at all at the moment.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
nops++;
|
||||
}
|
||||
hugified = hpa_try_hugify(tsdn, shard);
|
||||
if (hugified) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue