* [PATCH] mm, thp: Do not queue fully unmapped pages for deferred split
@ 2019-09-13 9:18 Kirill A. Shutemov
2019-09-16 10:36 ` Michal Hocko
2019-09-16 17:22 ` Yang Shi
0 siblings, 2 replies; 5+ messages in thread
From: Kirill A. Shutemov @ 2019-09-13 9:18 UTC (permalink / raw)
To: Andrew Morton; +Cc: Michal Hocko, linux-mm, linux-kernel, Kirill A. Shutemov
Adding fully unmapped pages into deferred split queue is not productive:
these pages are about to be freed or they are pinned and cannot be split
anyway.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
mm/rmap.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/mm/rmap.c b/mm/rmap.c
index 003377e24232..45388f1bf317 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1271,12 +1271,20 @@ static void page_remove_anon_compound_rmap(struct page *page)
if (TestClearPageDoubleMap(page)) {
/*
* Subpages can be mapped with PTEs too. Check how many of
- * themi are still mapped.
+ * them are still mapped.
*/
for (i = 0, nr = 0; i < HPAGE_PMD_NR; i++) {
if (atomic_add_negative(-1, &page[i]._mapcount))
nr++;
}
+
+ /*
+ * Queue the page for deferred split if at least one small
+ * page of the compound page is unmapped, but at least one
+ * small page is still mapped.
+ */
+ if (nr && nr < HPAGE_PMD_NR)
+ deferred_split_huge_page(page);
} else {
nr = HPAGE_PMD_NR;
}
@@ -1284,10 +1292,8 @@ static void page_remove_anon_compound_rmap(struct page *page)
if (unlikely(PageMlocked(page)))
clear_page_mlock(page);
- if (nr) {
+ if (nr)
__mod_node_page_state(page_pgdat(page), NR_ANON_MAPPED, -nr);
- deferred_split_huge_page(page);
- }
}
/**
--
2.21.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] mm, thp: Do not queue fully unmapped pages for deferred split
2019-09-13 9:18 [PATCH] mm, thp: Do not queue fully unmapped pages for deferred split Kirill A. Shutemov
@ 2019-09-16 10:36 ` Michal Hocko
2019-09-16 11:11 ` Vlastimil Babka
2019-09-16 17:22 ` Yang Shi
1 sibling, 1 reply; 5+ messages in thread
From: Michal Hocko @ 2019-09-16 10:36 UTC (permalink / raw)
To: Kirill A. Shutemov
Cc: Andrew Morton, linux-mm, linux-kernel, Kirill A. Shutemov
On Fri 13-09-19 12:18:49, Kirill A. Shutemov wrote:
> Adding fully unmapped pages into deferred split queue is not productive:
> these pages are about to be freed or they are pinned and cannot be split
> anyway.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> ---
> mm/rmap.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/mm/rmap.c b/mm/rmap.c
> index 003377e24232..45388f1bf317 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -1271,12 +1271,20 @@ static void page_remove_anon_compound_rmap(struct page *page)
> if (TestClearPageDoubleMap(page)) {
> /*
> * Subpages can be mapped with PTEs too. Check how many of
> - * themi are still mapped.
> + * them are still mapped.
> */
> for (i = 0, nr = 0; i < HPAGE_PMD_NR; i++) {
> if (atomic_add_negative(-1, &page[i]._mapcount))
> nr++;
> }
> +
> + /*
> + * Queue the page for deferred split if at least one small
> + * page of the compound page is unmapped, but at least one
> + * small page is still mapped.
> + */
> + if (nr && nr < HPAGE_PMD_NR)
> + deferred_split_huge_page(page);
You've set nr to zero in the for loop so this cannot work AFAICS.
> } else {
> nr = HPAGE_PMD_NR;
> }
> @@ -1284,10 +1292,8 @@ static void page_remove_anon_compound_rmap(struct page *page)
> if (unlikely(PageMlocked(page)))
> clear_page_mlock(page);
>
> - if (nr) {
> + if (nr)
> __mod_node_page_state(page_pgdat(page), NR_ANON_MAPPED, -nr);
> - deferred_split_huge_page(page);
> - }
> }
>
> /**
> --
> 2.21.0
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm, thp: Do not queue fully unmapped pages for deferred split
2019-09-16 10:36 ` Michal Hocko
@ 2019-09-16 11:11 ` Vlastimil Babka
2019-09-16 11:37 ` Michal Hocko
0 siblings, 1 reply; 5+ messages in thread
From: Vlastimil Babka @ 2019-09-16 11:11 UTC (permalink / raw)
To: Michal Hocko, Kirill A. Shutemov
Cc: Andrew Morton, linux-mm, linux-kernel, Kirill A. Shutemov
On 9/16/19 12:36 PM, Michal Hocko wrote:
> On Fri 13-09-19 12:18:49, Kirill A. Shutemov wrote:
>> Adding fully unmapped pages into deferred split queue is not productive:
>> these pages are about to be freed or they are pinned and cannot be split
>> anyway.
>>
>> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
>> ---
>> mm/rmap.c | 14 ++++++++++----
>> 1 file changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/mm/rmap.c b/mm/rmap.c
>> index 003377e24232..45388f1bf317 100644
>> --- a/mm/rmap.c
>> +++ b/mm/rmap.c
>> @@ -1271,12 +1271,20 @@ static void page_remove_anon_compound_rmap(struct page *page)
>> if (TestClearPageDoubleMap(page)) {
>> /*
>> * Subpages can be mapped with PTEs too. Check how many of
>> - * themi are still mapped.
>> + * them are still mapped.
>> */
>> for (i = 0, nr = 0; i < HPAGE_PMD_NR; i++) {
>> if (atomic_add_negative(-1, &page[i]._mapcount))
>> nr++;
>> }
>> +
>> + /*
>> + * Queue the page for deferred split if at least one small
>> + * page of the compound page is unmapped, but at least one
>> + * small page is still mapped.
>> + */
>> + if (nr && nr < HPAGE_PMD_NR)
>> + deferred_split_huge_page(page);
>
> You've set nr to zero in the for loop so this cannot work AFAICS.
The for loop then does nr++ for each subpage that's still mapped?
>> } else {
>> nr = HPAGE_PMD_NR;
>> }
>> @@ -1284,10 +1292,8 @@ static void page_remove_anon_compound_rmap(struct page *page)
>> if (unlikely(PageMlocked(page)))
>> clear_page_mlock(page);
>>
>> - if (nr) {
>> + if (nr)
>> __mod_node_page_state(page_pgdat(page), NR_ANON_MAPPED, -nr);
>> - deferred_split_huge_page(page);
>> - }
>> }
>>
>> /**
>> --
>> 2.21.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm, thp: Do not queue fully unmapped pages for deferred split
2019-09-16 11:11 ` Vlastimil Babka
@ 2019-09-16 11:37 ` Michal Hocko
0 siblings, 0 replies; 5+ messages in thread
From: Michal Hocko @ 2019-09-16 11:37 UTC (permalink / raw)
To: Vlastimil Babka
Cc: Kirill A. Shutemov, Andrew Morton, linux-mm, linux-kernel,
Kirill A. Shutemov
On Mon 16-09-19 13:11:37, Vlastimil Babka wrote:
> On 9/16/19 12:36 PM, Michal Hocko wrote:
> > On Fri 13-09-19 12:18:49, Kirill A. Shutemov wrote:
> >> Adding fully unmapped pages into deferred split queue is not productive:
> >> these pages are about to be freed or they are pinned and cannot be split
> >> anyway.
> >>
> >> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> >> ---
> >> mm/rmap.c | 14 ++++++++++----
> >> 1 file changed, 10 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/mm/rmap.c b/mm/rmap.c
> >> index 003377e24232..45388f1bf317 100644
> >> --- a/mm/rmap.c
> >> +++ b/mm/rmap.c
> >> @@ -1271,12 +1271,20 @@ static void page_remove_anon_compound_rmap(struct page *page)
> >> if (TestClearPageDoubleMap(page)) {
> >> /*
> >> * Subpages can be mapped with PTEs too. Check how many of
> >> - * themi are still mapped.
> >> + * them are still mapped.
> >> */
> >> for (i = 0, nr = 0; i < HPAGE_PMD_NR; i++) {
> >> if (atomic_add_negative(-1, &page[i]._mapcount))
> >> nr++;
> >> }
> >> +
> >> + /*
> >> + * Queue the page for deferred split if at least one small
> >> + * page of the compound page is unmapped, but at least one
> >> + * small page is still mapped.
> >> + */
> >> + if (nr && nr < HPAGE_PMD_NR)
> >> + deferred_split_huge_page(page);
> >
> > You've set nr to zero in the for loop so this cannot work AFAICS.
>
> The for loop then does nr++ for each subpage that's still mapped?
I am blind obviously. Sorry about the noise. Then the patch looks
correct.
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm, thp: Do not queue fully unmapped pages for deferred split
2019-09-13 9:18 [PATCH] mm, thp: Do not queue fully unmapped pages for deferred split Kirill A. Shutemov
2019-09-16 10:36 ` Michal Hocko
@ 2019-09-16 17:22 ` Yang Shi
1 sibling, 0 replies; 5+ messages in thread
From: Yang Shi @ 2019-09-16 17:22 UTC (permalink / raw)
To: Kirill A. Shutemov
Cc: Andrew Morton, Michal Hocko, Linux MM, Linux Kernel Mailing List,
Kirill A. Shutemov
On Fri, Sep 13, 2019 at 2:18 AM Kirill A. Shutemov <kirill@shutemov.name> wrote:
>
> Adding fully unmapped pages into deferred split queue is not productive:
> these pages are about to be freed or they are pinned and cannot be split
> anyway.
This change looks good to me. Reviewed-by: Yang Shi <yang.shi@linux.alibaba.com>
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> ---
> mm/rmap.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/mm/rmap.c b/mm/rmap.c
> index 003377e24232..45388f1bf317 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -1271,12 +1271,20 @@ static void page_remove_anon_compound_rmap(struct page *page)
> if (TestClearPageDoubleMap(page)) {
> /*
> * Subpages can be mapped with PTEs too. Check how many of
> - * themi are still mapped.
> + * them are still mapped.
> */
> for (i = 0, nr = 0; i < HPAGE_PMD_NR; i++) {
> if (atomic_add_negative(-1, &page[i]._mapcount))
> nr++;
> }
> +
> + /*
> + * Queue the page for deferred split if at least one small
> + * page of the compound page is unmapped, but at least one
> + * small page is still mapped.
> + */
> + if (nr && nr < HPAGE_PMD_NR)
> + deferred_split_huge_page(page);
> } else {
> nr = HPAGE_PMD_NR;
> }
> @@ -1284,10 +1292,8 @@ static void page_remove_anon_compound_rmap(struct page *page)
> if (unlikely(PageMlocked(page)))
> clear_page_mlock(page);
>
> - if (nr) {
> + if (nr)
> __mod_node_page_state(page_pgdat(page), NR_ANON_MAPPED, -nr);
> - deferred_split_huge_page(page);
> - }
> }
>
> /**
> --
> 2.21.0
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-09-16 17:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-13 9:18 [PATCH] mm, thp: Do not queue fully unmapped pages for deferred split Kirill A. Shutemov
2019-09-16 10:36 ` Michal Hocko
2019-09-16 11:11 ` Vlastimil Babka
2019-09-16 11:37 ` Michal Hocko
2019-09-16 17:22 ` Yang Shi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).