2020-04-03 11:31:42

by Kirill A. Shutemov

[permalink] [raw]
Subject: [PATCHv2 3/8] khugepaged: Drain all LRU caches before scanning pages

Having a page in LRU add cache offsets page refcount and gives
false-negative on PageLRU(). It reduces collapse success rate.

Drain all LRU add caches before scanning. It happens relatively
rare and should not disturb the system too much.

Signed-off-by: Kirill A. Shutemov <[email protected]>
---
mm/khugepaged.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 14d7afc90786..fdc10ffde1ca 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2065,6 +2065,8 @@ static void khugepaged_do_scan(void)

barrier(); /* write khugepaged_pages_to_scan to local stack */

+ lru_add_drain_all();
+
while (progress < pages) {
if (!khugepaged_prealloc_page(&hpage, &wait))
break;
--
2.26.0


2020-04-06 18:17:06

by Yang Shi

[permalink] [raw]
Subject: Re: [PATCHv2 3/8] khugepaged: Drain all LRU caches before scanning pages



On 4/3/20 4:29 AM, Kirill A. Shutemov wrote:
> Having a page in LRU add cache offsets page refcount and gives
> false-negative on PageLRU(). It reduces collapse success rate.
>
> Drain all LRU add caches before scanning. It happens relatively
> rare and should not disturb the system too much.
>
> Signed-off-by: Kirill A. Shutemov <[email protected]>

Acked-by: Yang Shi <[email protected]>

> ---
> mm/khugepaged.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 14d7afc90786..fdc10ffde1ca 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -2065,6 +2065,8 @@ static void khugepaged_do_scan(void)
>
> barrier(); /* write khugepaged_pages_to_scan to local stack */
>
> + lru_add_drain_all();
> +
> while (progress < pages) {
> if (!khugepaged_prealloc_page(&hpage, &wait))
> break;