mbox series

[v4,0/4] mm/mremap: cleanup move_page_tables() a little

Message ID 20200708095028.41706-1-richard.weiyang@linux.alibaba.com (mailing list archive)
Headers show
Series mm/mremap: cleanup move_page_tables() a little | expand

Message

Wei Yang July 8, 2020, 9:50 a.m. UTC
move_page_tables() tries to move page table by PMD or PTE.

The root reason is if it tries to move PMD, both old and new range should be
PMD aligned. But current code calculate old range and new range separately.
This leads to some redundant check and calculation.

This cleanup tries to consolidate the range check in one place to reduce some
extra range handling.

v4:
  * remove a redundant parentheses pointed by Kirill

v3:
  * merge patch 1 with 2 as suggested by Kirill
  * add patch 4 to simplify the logic to calculate next and extent

v2:
  * remove 3rd patch which doesn't work on ARM platform. Thanks report and
    test from Dmitry Osipenko

Wei Yang (4):
  mm/mremap: it is sure to have enough space when extent meets
    requirement
  mm/mremap: calculate extent in one place
  mm/mremap: start addresses are properly aligned
  mm/mremap: use pmd_addr_end to simplify the calculate of extent

 include/linux/huge_mm.h |  2 +-
 mm/huge_memory.c        |  8 +-------
 mm/mremap.c             | 27 ++++++++++-----------------
 3 files changed, 12 insertions(+), 25 deletions(-)

Comments

Dmitry Osipenko July 9, 2020, 7:38 p.m. UTC | #1
08.07.2020 12:50, Wei Yang пишет:
> move_page_tables() tries to move page table by PMD or PTE.
> 
> The root reason is if it tries to move PMD, both old and new range should be
> PMD aligned. But current code calculate old range and new range separately.
> This leads to some redundant check and calculation.
> 
> This cleanup tries to consolidate the range check in one place to reduce some
> extra range handling.
> 
> v4:
>   * remove a redundant parentheses pointed by Kirill
> 
> v3:
>   * merge patch 1 with 2 as suggested by Kirill

>   * add patch 4 to simplify the logic to calculate next and extent

Hello, Wei!

Unfortunately you re-introduced the offending change that was fixed in
v2 and today's next-20200709 on ARM32 is broken once again:

BUG: Bad rss-counter state mm:db85ec46 type:MM_ANONPAGES val:190

Please don't do it ;)

> v2:
>   * remove 3rd patch which doesn't work on ARM platform. Thanks report and
>     test from Dmitry Osipenko
> 
> Wei Yang (4):
>   mm/mremap: it is sure to have enough space when extent meets
>     requirement
>   mm/mremap: calculate extent in one place
>   mm/mremap: start addresses are properly aligned
>   mm/mremap: use pmd_addr_end to simplify the calculate of extent
> 
>  include/linux/huge_mm.h |  2 +-
>  mm/huge_memory.c        |  8 +-------
>  mm/mremap.c             | 27 ++++++++++-----------------
>  3 files changed, 12 insertions(+), 25 deletions(-)
>
Wei Yang July 10, 2020, 1:14 a.m. UTC | #2
On Thu, Jul 09, 2020 at 10:38:58PM +0300, Dmitry Osipenko wrote:
>08.07.2020 12:50, Wei Yang пишет:
>> move_page_tables() tries to move page table by PMD or PTE.
>> 
>> The root reason is if it tries to move PMD, both old and new range should be
>> PMD aligned. But current code calculate old range and new range separately.
>> This leads to some redundant check and calculation.
>> 
>> This cleanup tries to consolidate the range check in one place to reduce some
>> extra range handling.
>> 
>> v4:
>>   * remove a redundant parentheses pointed by Kirill
>> 
>> v3:
>>   * merge patch 1 with 2 as suggested by Kirill
>
>>   * add patch 4 to simplify the logic to calculate next and extent
>
>Hello, Wei!
>
>Unfortunately you re-introduced the offending change that was fixed in
>v2 and today's next-20200709 on ARM32 is broken once again:
>
>BUG: Bad rss-counter state mm:db85ec46 type:MM_ANONPAGES val:190
>

Ah, my bad, I forget the error we met last time. It is the different format of
pmd_addr_end.

Sorry for that.

@ Kirill

If you agree, I would leave the extent/next calculation as it is in patch 3.

>Please don't do it ;)
>
>> v2:
>>   * remove 3rd patch which doesn't work on ARM platform. Thanks report and
>>     test from Dmitry Osipenko
>> 
>> Wei Yang (4):
>>   mm/mremap: it is sure to have enough space when extent meets
>>     requirement
>>   mm/mremap: calculate extent in one place
>>   mm/mremap: start addresses are properly aligned
>>   mm/mremap: use pmd_addr_end to simplify the calculate of extent
>> 
>>  include/linux/huge_mm.h |  2 +-
>>  mm/huge_memory.c        |  8 +-------
>>  mm/mremap.c             | 27 ++++++++++-----------------
>>  3 files changed, 12 insertions(+), 25 deletions(-)
>>
Kirill A. Shutemov July 10, 2020, 8:14 a.m. UTC | #3
On Fri, Jul 10, 2020 at 09:14:10AM +0800, Wei Yang wrote:
> On Thu, Jul 09, 2020 at 10:38:58PM +0300, Dmitry Osipenko wrote:
> >08.07.2020 12:50, Wei Yang пишет:
> >> move_page_tables() tries to move page table by PMD or PTE.
> >> 
> >> The root reason is if it tries to move PMD, both old and new range should be
> >> PMD aligned. But current code calculate old range and new range separately.
> >> This leads to some redundant check and calculation.
> >> 
> >> This cleanup tries to consolidate the range check in one place to reduce some
> >> extra range handling.
> >> 
> >> v4:
> >>   * remove a redundant parentheses pointed by Kirill
> >> 
> >> v3:
> >>   * merge patch 1 with 2 as suggested by Kirill
> >
> >>   * add patch 4 to simplify the logic to calculate next and extent
> >
> >Hello, Wei!
> >
> >Unfortunately you re-introduced the offending change that was fixed in
> >v2 and today's next-20200709 on ARM32 is broken once again:
> >
> >BUG: Bad rss-counter state mm:db85ec46 type:MM_ANONPAGES val:190
> >
> 
> Ah, my bad, I forget the error we met last time. It is the different format of
> pmd_addr_end.
> 
> Sorry for that.
> 
> @ Kirill
> 
> If you agree, I would leave the extent/next calculation as it is in patch 3.

Okay.