Skip to content

Commit cb8d68e

Browse files
kiryltorvalds
authored andcommitted
thp: change deferred_split_count() to return number of THP in queue
I've got meaning of shrinker::count_objects() wrong: it should return number of potentially freeable objects, which is not necessary correlate with freeable memory. Returning 256 per THP in queue is not reasonable: shrinker::scan_objects() never called with nr_to_scan > 128 in my setup. Let's return 1 per THP and correct scan_object accordingly. Signed-off-by: Kirill A. Shutemov <[email protected]> Reviewed-by: Andrea Arcangeli <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: "Aneesh Kumar K.V" <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Jerome Marchand <[email protected]> Cc: Sasha Levin <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent a3d0a91 commit cb8d68e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

mm/huge_memory.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3465,12 +3465,7 @@ static unsigned long deferred_split_count(struct shrinker *shrink,
34653465
struct shrink_control *sc)
34663466
{
34673467
struct pglist_data *pgdata = NODE_DATA(sc->nid);
3468-
/*
3469-
* Split a page from split_queue will free up at least one page,
3470-
* at most HPAGE_PMD_NR - 1. We don't track exact number.
3471-
* Let's use HPAGE_PMD_NR / 2 as ballpark.
3472-
*/
3473-
return ACCESS_ONCE(pgdata->split_queue_len) * HPAGE_PMD_NR / 2;
3468+
return ACCESS_ONCE(pgdata->split_queue_len);
34743469
}
34753470

34763471
static unsigned long deferred_split_scan(struct shrinker *shrink,
@@ -3511,7 +3506,13 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
35113506
list_splice_tail(&list, &pgdata->split_queue);
35123507
spin_unlock_irqrestore(&pgdata->split_queue_lock, flags);
35133508

3514-
return split * HPAGE_PMD_NR / 2;
3509+
/*
3510+
* Stop shrinker if we didn't split any page, but the queue is empty.
3511+
* This can happen if pages were freed under us.
3512+
*/
3513+
if (!split && list_empty(&pgdata->split_queue))
3514+
return SHRINK_STOP;
3515+
return split;
35153516
}
35163517

35173518
static struct shrinker deferred_split_shrinker = {

0 commit comments

Comments
 (0)