* [PATCH] mm/page_vma_mapped.c: Exactly compare hugetlbfs page's pfn in pfn_in_hpage()
@ 2020-01-09 6:44 Li Xinhai
2020-01-09 12:30 ` Kirill A. Shutemov
0 siblings, 1 reply; 5+ messages in thread
From: Li Xinhai @ 2020-01-09 6:44 UTC (permalink / raw)
To: linux-mm; +Cc: Kirill A. Shutemov
check_pte is called for hugetlbfs page and comparing pfn in pfn_in_page,
where pfn is compared in range [hpage_pfn, hpage_pfn+HPAGE_PMD_NR). Now
change it to match exactly for hugetlbfs page to avoid hiding any
potential problems.
Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
mm/page_vma_mapped.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c
index eff4b45..434978b 100644
--- a/mm/page_vma_mapped.c
+++ b/mm/page_vma_mapped.c
@@ -55,6 +55,8 @@ static bool map_pte(struct page_vma_mapped_walk *pvmw)
static inline bool pfn_in_hpage(struct page *hpage, unsigned long pfn)
{
unsigned long hpage_pfn = page_to_pfn(hpage);
+ if (unlikely(PageHuge(hpage)))
+ return pfn == hpage_pfn;
/* THP can be referenced by any subpage */
return pfn >= hpage_pfn && pfn - hpage_pfn < hpage_nr_pages(hpage);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] mm/page_vma_mapped.c: Exactly compare hugetlbfs page's pfn in pfn_in_hpage()
2020-01-09 6:44 [PATCH] mm/page_vma_mapped.c: Exactly compare hugetlbfs page's pfn in pfn_in_hpage() Li Xinhai
@ 2020-01-09 12:30 ` Kirill A. Shutemov
2020-01-09 13:55 ` Li Xinhai
0 siblings, 1 reply; 5+ messages in thread
From: Kirill A. Shutemov @ 2020-01-09 12:30 UTC (permalink / raw)
To: Li Xinhai; +Cc: linux-mm, Kirill A. Shutemov
On Thu, Jan 09, 2020 at 06:44:40AM +0000, Li Xinhai wrote:
> check_pte is called for hugetlbfs page and comparing pfn in pfn_in_page,
> where pfn is compared in range [hpage_pfn, hpage_pfn+HPAGE_PMD_NR). Now
> change it to match exactly for hugetlbfs page to avoid hiding any
> potential problems.
Hm. What potential problems do you talk about?
I understand that for hugetlb pages pfn is always has to be equal
hpage_pfn, but returning false for pfn in the range of the hugetlb page
just because it's not head is not helpful.
I would rather have
VM_BUG_ON_PAGE(PageHuge(hpage) && pfn != hpage_pfn, hpage);
there.
>
> Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> ---
> mm/page_vma_mapped.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c
> index eff4b45..434978b 100644
> --- a/mm/page_vma_mapped.c
> +++ b/mm/page_vma_mapped.c
> @@ -55,6 +55,8 @@ static bool map_pte(struct page_vma_mapped_walk *pvmw)
> static inline bool pfn_in_hpage(struct page *hpage, unsigned long pfn)
> {
> unsigned long hpage_pfn = page_to_pfn(hpage);
> + if (unlikely(PageHuge(hpage)))
> + return pfn == hpage_pfn;
>
> /* THP can be referenced by any subpage */
> return pfn >= hpage_pfn && pfn - hpage_pfn < hpage_nr_pages(hpage);
> --
> 1.8.3.1
>
>
--
Kirill A. Shutemov
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm/page_vma_mapped.c: Exactly compare hugetlbfs page's pfn in pfn_in_hpage()
2020-01-09 12:30 ` Kirill A. Shutemov
@ 2020-01-09 13:55 ` Li Xinhai
0 siblings, 0 replies; 5+ messages in thread
From: Li Xinhai @ 2020-01-09 13:55 UTC (permalink / raw)
To: Kirill A. Shutemov; +Cc: linux-mm, kirill.shutemov
On 2020-01-09 at 20:30 Kirill A. Shutemov wrote:
>On Thu, Jan 09, 2020 at 06:44:40AM +0000, Li Xinhai wrote:
>> check_pte is called for hugetlbfs page and comparing pfn in pfn_in_page,
>> where pfn is compared in range [hpage_pfn, hpage_pfn+HPAGE_PMD_NR). Now
>> change it to match exactly for hugetlbfs page to avoid hiding any
>> potential problems.
>
>Hm. What potential problems do you talk about?
>
>I understand that for hugetlb pages pfn is always has to be equal
>hpage_pfn, but returning false for pfn in the range of the hugetlb page
>just because it's not head is not helpful.
>
>I would rather have
>
> VM_BUG_ON_PAGE(PageHuge(hpage) && pfn != hpage_pfn, hpage);
>
>there.
Yes, that is better to report BUG as we already catch it.
>>
>> Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
>> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
>> ---
>> mm/page_vma_mapped.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c
>> index eff4b45..434978b 100644
>> --- a/mm/page_vma_mapped.c
>> +++ b/mm/page_vma_mapped.c
>> @@ -55,6 +55,8 @@ static bool map_pte(struct page_vma_mapped_walk *pvmw)
>> static inline bool pfn_in_hpage(struct page *hpage, unsigned long pfn)
>> {
>> unsigned long hpage_pfn = page_to_pfn(hpage);
>> + if (unlikely(PageHuge(hpage)))
>> + return pfn == hpage_pfn;
>>
>> /* THP can be referenced by any subpage */
>> return pfn >= hpage_pfn && pfn - hpage_pfn < hpage_nr_pages(hpage);
>> --
>> 1.8.3.1
>>
>>
>
>--
> Kirill A. Shutemov
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm/page_vma_mapped.c: Exactly compare hugetlbfs page's pfn in pfn_in_hpage()
2020-01-09 14:26 ` [PATCH] mm/page_vma_mapped.c: Exactly compare hugetlbfs page's pfn " Li Xinhai
@ 2020-01-09 14:31 ` Li Xinhai
0 siblings, 0 replies; 5+ messages in thread
From: Li Xinhai @ 2020-01-09 14:31 UTC (permalink / raw)
To: linux-mm; +Cc: kirill.shutemov
On 2020-01-09 at 22:26 Li Xinhai wrote:
>check_pte is called for hugetlbfs page and comparing pfn in pfn_in_page,
>where pfn is compared in range [hpage_pfn, hpage_pfn+HPAGE_PMD_NR). Now
>change it to match exactly for hugetlbfs page to avoid hiding any
>potential problems.
>
>Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
>Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
>---
> mm/page_vma_mapped.c | 2 ++
> 1 file changed, 2 insertions(+)
>
>diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c
>index eff4b45..434978b 100644
>--- a/mm/page_vma_mapped.c
>+++ b/mm/page_vma_mapped.c
>@@ -55,6 +55,8 @@ static bool map_pte(struct page_vma_mapped_walk *pvmw)
> static inline bool pfn_in_hpage(struct page *hpage, unsigned long pfn)
> {
> unsigned long hpage_pfn = page_to_pfn(hpage);
>+ if (unlikely(PageHuge(hpage)))
>+ return pfn == hpage_pfn;
>
> /* THP can be referenced by any subpage */
> return pfn >= hpage_pfn && pfn - hpage_pfn < hpage_nr_pages(hpage);
>--
>1.8.3.1
>
sorry this been sent twice, please ignore this mail.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] mm/page_vma_mapped.c: Exactly compare hugetlbfs page's pfn in pfn_in_hpage()
2020-01-09 14:26 [PATCH v2] mm/page_vma_mapped.c: Detect mismatched pfn of hugetlbfs page " Li Xinhai
@ 2020-01-09 14:26 ` Li Xinhai
2020-01-09 14:31 ` Li Xinhai
0 siblings, 1 reply; 5+ messages in thread
From: Li Xinhai @ 2020-01-09 14:26 UTC (permalink / raw)
To: linux-mm; +Cc: Kirill A. Shutemov
check_pte is called for hugetlbfs page and comparing pfn in pfn_in_page,
where pfn is compared in range [hpage_pfn, hpage_pfn+HPAGE_PMD_NR). Now
change it to match exactly for hugetlbfs page to avoid hiding any
potential problems.
Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
mm/page_vma_mapped.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c
index eff4b45..434978b 100644
--- a/mm/page_vma_mapped.c
+++ b/mm/page_vma_mapped.c
@@ -55,6 +55,8 @@ static bool map_pte(struct page_vma_mapped_walk *pvmw)
static inline bool pfn_in_hpage(struct page *hpage, unsigned long pfn)
{
unsigned long hpage_pfn = page_to_pfn(hpage);
+ if (unlikely(PageHuge(hpage)))
+ return pfn == hpage_pfn;
/* THP can be referenced by any subpage */
return pfn >= hpage_pfn && pfn - hpage_pfn < hpage_nr_pages(hpage);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-01-09 14:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-09 6:44 [PATCH] mm/page_vma_mapped.c: Exactly compare hugetlbfs page's pfn in pfn_in_hpage() Li Xinhai
2020-01-09 12:30 ` Kirill A. Shutemov
2020-01-09 13:55 ` Li Xinhai
2020-01-09 14:26 [PATCH v2] mm/page_vma_mapped.c: Detect mismatched pfn of hugetlbfs page " Li Xinhai
2020-01-09 14:26 ` [PATCH] mm/page_vma_mapped.c: Exactly compare hugetlbfs page's pfn " Li Xinhai
2020-01-09 14:31 ` Li Xinhai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.