* [PATCH] mm/mempolicy: Move VMA address bound checks inside mpol_misplaced()
@ 2017-09-01 7:02 Anshuman Khandual
2017-09-01 9:05 ` Vlastimil Babka
0 siblings, 1 reply; 6+ messages in thread
From: Anshuman Khandual @ 2017-09-01 7:02 UTC (permalink / raw)
To: linux-mm; +Cc: akpm
The VMA address bound checks are applicable to all memory policy modes,
not just MPOL_INTERLEAVE. Hence move it to the front and make it common.
Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
mm/mempolicy.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 618ab12..7ec6694 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -2173,6 +2173,8 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long
int ret = -1;
BUG_ON(!vma);
+ BUG_ON(addr >= vma->vm_end);
+ BUG_ON(addr < vma->vm_start);
pol = get_vma_policy(vma, addr);
if (!(pol->flags & MPOL_F_MOF))
@@ -2180,9 +2182,6 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long
switch (pol->mode) {
case MPOL_INTERLEAVE:
- BUG_ON(addr >= vma->vm_end);
- BUG_ON(addr < vma->vm_start);
-
pgoff = vma->vm_pgoff;
pgoff += (addr - vma->vm_start) >> PAGE_SHIFT;
polnid = offset_il_node(pol, vma, pgoff);
--
1.8.5.2
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mm/mempolicy: Move VMA address bound checks inside mpol_misplaced()
2017-09-01 7:02 [PATCH] mm/mempolicy: Move VMA address bound checks inside mpol_misplaced() Anshuman Khandual
@ 2017-09-01 9:05 ` Vlastimil Babka
2017-09-01 12:17 ` Anshuman Khandual
0 siblings, 1 reply; 6+ messages in thread
From: Vlastimil Babka @ 2017-09-01 9:05 UTC (permalink / raw)
To: Anshuman Khandual, linux-mm; +Cc: akpm
On 09/01/2017 09:02 AM, Anshuman Khandual wrote:
> The VMA address bound checks are applicable to all memory policy modes,
> not just MPOL_INTERLEAVE.
But only MPOL_INTERLEAVE actually uses addr and vma->vm_start.
> Hence move it to the front and make it common.
>
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
I would just remove them instead. Together with the BUG_ON(!vma). Looks
like just leftover from development.
> ---
> mm/mempolicy.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 618ab12..7ec6694 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -2173,6 +2173,8 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long
> int ret = -1;
>
> BUG_ON(!vma);
> + BUG_ON(addr >= vma->vm_end);
> + BUG_ON(addr < vma->vm_start);
>
> pol = get_vma_policy(vma, addr);
> if (!(pol->flags & MPOL_F_MOF))
> @@ -2180,9 +2182,6 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long
>
> switch (pol->mode) {
> case MPOL_INTERLEAVE:
> - BUG_ON(addr >= vma->vm_end);
> - BUG_ON(addr < vma->vm_start);
> -
> pgoff = vma->vm_pgoff;
> pgoff += (addr - vma->vm_start) >> PAGE_SHIFT;
> polnid = offset_il_node(pol, vma, pgoff);
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mm/mempolicy: Move VMA address bound checks inside mpol_misplaced()
2017-09-01 9:05 ` Vlastimil Babka
@ 2017-09-01 12:17 ` Anshuman Khandual
2017-09-01 12:21 ` Anshuman Khandual
0 siblings, 1 reply; 6+ messages in thread
From: Anshuman Khandual @ 2017-09-01 12:17 UTC (permalink / raw)
To: Vlastimil Babka, Anshuman Khandual, linux-mm; +Cc: akpm
On 09/01/2017 02:35 PM, Vlastimil Babka wrote:
> On 09/01/2017 09:02 AM, Anshuman Khandual wrote:
>> The VMA address bound checks are applicable to all memory policy modes,
>> not just MPOL_INTERLEAVE.
>
> But only MPOL_INTERLEAVE actually uses addr and vma->vm_start.
I thought them to be just general sanity checks.
>
>> Hence move it to the front and make it common.
>>
>> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
>
> I would just remove them instead. Together with the BUG_ON(!vma). Looks
> like just leftover from development.
sure, resend with suggested changes.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mm/mempolicy: Move VMA address bound checks inside mpol_misplaced()
2017-09-01 12:17 ` Anshuman Khandual
@ 2017-09-01 12:21 ` Anshuman Khandual
2017-09-01 13:01 ` [PATCH] mm/mempolicy: Remove BUG_ON() checks for VMA " Anshuman Khandual
0 siblings, 1 reply; 6+ messages in thread
From: Anshuman Khandual @ 2017-09-01 12:21 UTC (permalink / raw)
To: Anshuman Khandual, Vlastimil Babka, linux-mm; +Cc: akpm
On 09/01/2017 05:47 PM, Anshuman Khandual wrote:
> On 09/01/2017 02:35 PM, Vlastimil Babka wrote:
>> On 09/01/2017 09:02 AM, Anshuman Khandual wrote:
>>> The VMA address bound checks are applicable to all memory policy modes,
>>> not just MPOL_INTERLEAVE.
>>
>> But only MPOL_INTERLEAVE actually uses addr and vma->vm_start.
>
> I thought them to be just general sanity checks.
>
>>
>>> Hence move it to the front and make it common.
>>>
>>> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
>>
>> I would just remove them instead. Together with the BUG_ON(!vma). Looks
>> like just leftover from development.
>
> sure, resend with suggested changes.
I meant, I will resend the patch with suggested changes.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] mm/mempolicy: Remove BUG_ON() checks for VMA inside mpol_misplaced()
2017-09-01 12:21 ` Anshuman Khandual
@ 2017-09-01 13:01 ` Anshuman Khandual
2017-09-01 13:16 ` Vlastimil Babka
0 siblings, 1 reply; 6+ messages in thread
From: Anshuman Khandual @ 2017-09-01 13:01 UTC (permalink / raw)
To: linux-mm; +Cc: akpm, vbabka
VMA and its address bounds checks are too late in this function.
They must have been verified earlier in the page fault sequence.
Hence just remove them.
Suggested-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
mm/mempolicy.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 618ab12..3509b84 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -2172,17 +2172,12 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long
int polnid = -1;
int ret = -1;
- BUG_ON(!vma);
-
pol = get_vma_policy(vma, addr);
if (!(pol->flags & MPOL_F_MOF))
goto out;
switch (pol->mode) {
case MPOL_INTERLEAVE:
- BUG_ON(addr >= vma->vm_end);
- BUG_ON(addr < vma->vm_start);
-
pgoff = vma->vm_pgoff;
pgoff += (addr - vma->vm_start) >> PAGE_SHIFT;
polnid = offset_il_node(pol, vma, pgoff);
--
1.8.5.2
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mm/mempolicy: Remove BUG_ON() checks for VMA inside mpol_misplaced()
2017-09-01 13:01 ` [PATCH] mm/mempolicy: Remove BUG_ON() checks for VMA " Anshuman Khandual
@ 2017-09-01 13:16 ` Vlastimil Babka
0 siblings, 0 replies; 6+ messages in thread
From: Vlastimil Babka @ 2017-09-01 13:16 UTC (permalink / raw)
To: Anshuman Khandual, linux-mm; +Cc: akpm
On 09/01/2017 03:01 PM, Anshuman Khandual wrote:
> VMA and its address bounds checks are too late in this function.
> They must have been verified earlier in the page fault sequence.
> Hence just remove them.
>
> Suggested-by: Vlastimil Babka <vbabka@suse.cz>
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> mm/mempolicy.c | 5 -----
> 1 file changed, 5 deletions(-)
>
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 618ab12..3509b84 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -2172,17 +2172,12 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long
> int polnid = -1;
> int ret = -1;
>
> - BUG_ON(!vma);
> -
> pol = get_vma_policy(vma, addr);
> if (!(pol->flags & MPOL_F_MOF))
> goto out;
>
> switch (pol->mode) {
> case MPOL_INTERLEAVE:
> - BUG_ON(addr >= vma->vm_end);
> - BUG_ON(addr < vma->vm_start);
> -
> pgoff = vma->vm_pgoff;
> pgoff += (addr - vma->vm_start) >> PAGE_SHIFT;
> polnid = offset_il_node(pol, vma, pgoff);
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-09-01 13:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-01 7:02 [PATCH] mm/mempolicy: Move VMA address bound checks inside mpol_misplaced() Anshuman Khandual
2017-09-01 9:05 ` Vlastimil Babka
2017-09-01 12:17 ` Anshuman Khandual
2017-09-01 12:21 ` Anshuman Khandual
2017-09-01 13:01 ` [PATCH] mm/mempolicy: Remove BUG_ON() checks for VMA " Anshuman Khandual
2017-09-01 13:16 ` Vlastimil Babka
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).