* [PATCH] mm: Change count_mm_mlocked_page_nr return type
@ 2019-04-22 10:38 Weikang shi
2019-05-11 8:10 ` Souptick Joarder
0 siblings, 1 reply; 4+ messages in thread
From: Weikang shi @ 2019-04-22 10:38 UTC (permalink / raw)
To: linux-mm; +Cc: linux-kernel, swkhack
From: swkhack <swkhack@gmail.com>
In 64-bit machine,the value of "vma->vm_end - vma->vm_start"
maybe negative in 32bit int and the "count >> PAGE_SHIFT"'s rusult
will be wrong.So change the local variable and return
value to unsigned long will fix the problem.
Signed-off-by: swkhack <swkhack@gmail.com>
---
mm/mlock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/mlock.c b/mm/mlock.c
index 080f3b364..d614163f5 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -636,11 +636,11 @@ static int apply_vma_lock_flags(unsigned long start, size_t len,
* is also counted.
* Return value: previously mlocked page counts
*/
-static int count_mm_mlocked_page_nr(struct mm_struct *mm,
+static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm,
unsigned long start, size_t len)
{
struct vm_area_struct *vma;
- int count = 0;
+ unsigned long count = 0;
if (mm == NULL)
mm = current->mm;
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: Change count_mm_mlocked_page_nr return type
2019-04-22 10:38 [PATCH] mm: Change count_mm_mlocked_page_nr return type Weikang shi
@ 2019-05-11 8:10 ` Souptick Joarder
0 siblings, 0 replies; 4+ messages in thread
From: Souptick Joarder @ 2019-05-11 8:10 UTC (permalink / raw)
To: Weikang shi; +Cc: Linux-MM, linux-kernel
On Mon, Apr 22, 2019 at 4:08 PM Weikang shi <swkhack@gmail.com> wrote:
>
> From: swkhack <swkhack@gmail.com>
>
> In 64-bit machine,the value of "vma->vm_end - vma->vm_start"
> maybe negative in 32bit int and the "count >> PAGE_SHIFT"'s rusult
s/rusult/result.
> will be wrong.So change the local variable and return
> value to unsigned long will fix the problem.
>
> Signed-off-by: swkhack <swkhack@gmail.com>
> ---
> mm/mlock.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/mlock.c b/mm/mlock.c
> index 080f3b364..d614163f5 100644
> --- a/mm/mlock.c
> +++ b/mm/mlock.c
> @@ -636,11 +636,11 @@ static int apply_vma_lock_flags(unsigned long start, size_t len,
> * is also counted.
> * Return value: previously mlocked page counts
> */
> -static int count_mm_mlocked_page_nr(struct mm_struct *mm,
> +static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm,
> unsigned long start, size_t len)
> {
> struct vm_area_struct *vma;
> - int count = 0;
> + unsigned long count = 0;
>
> if (mm == NULL)
> mm = current->mm;
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: Change count_mm_mlocked_page_nr return type
2019-05-13 2:37 Weikang shi
@ 2019-05-13 9:15 ` Michal Hocko
0 siblings, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2019-05-13 9:15 UTC (permalink / raw)
To: Weikang shi; +Cc: linux-mm, linux-kernel
On Mon 13-05-19 10:37:01, Weikang shi wrote:
> From: swkhack <swkhack@gmail.com>
>
> In 64-bit machine,the value of "vma->vm_end - vma->vm_start"
> maybe negative in 32bit int and the "count >> PAGE_SHIFT"'s result
> will be wrong.So change the local variable and return
> value to unsigned long will fix the problem.
>
> Signed-off-by: swkhack <swkhack@gmail.com>
Fixes: 0cf2f6f6dc60 ("mm: mlock: check against vma for actual mlock() size")
Acked-by: Michal Hocko <mhocko@suse.com>
Most users probably never noticed because large mlocked areas are not
allowed by default. So I am not really sure this is worth backporting to
stable trees.
> ---
> mm/mlock.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/mlock.c b/mm/mlock.c
> index 080f3b364..d614163f5 100644
> --- a/mm/mlock.c
> +++ b/mm/mlock.c
> @@ -636,11 +636,11 @@ static int apply_vma_lock_flags(unsigned long start, size_t len,
> * is also counted.
> * Return value: previously mlocked page counts
> */
> -static int count_mm_mlocked_page_nr(struct mm_struct *mm,
> +static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm,
> unsigned long start, size_t len)
> {
> struct vm_area_struct *vma;
> - int count = 0;
> + unsigned long count = 0;
>
> if (mm == NULL)
> mm = current->mm;
> --
> 2.17.1
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] mm: Change count_mm_mlocked_page_nr return type
@ 2019-05-13 2:37 Weikang shi
2019-05-13 9:15 ` Michal Hocko
0 siblings, 1 reply; 4+ messages in thread
From: Weikang shi @ 2019-05-13 2:37 UTC (permalink / raw)
To: linux-mm; +Cc: linux-kernel, swkhack
From: swkhack <swkhack@gmail.com>
In 64-bit machine,the value of "vma->vm_end - vma->vm_start"
maybe negative in 32bit int and the "count >> PAGE_SHIFT"'s result
will be wrong.So change the local variable and return
value to unsigned long will fix the problem.
Signed-off-by: swkhack <swkhack@gmail.com>
---
mm/mlock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/mlock.c b/mm/mlock.c
index 080f3b364..d614163f5 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -636,11 +636,11 @@ static int apply_vma_lock_flags(unsigned long start, size_t len,
* is also counted.
* Return value: previously mlocked page counts
*/
-static int count_mm_mlocked_page_nr(struct mm_struct *mm,
+static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm,
unsigned long start, size_t len)
{
struct vm_area_struct *vma;
- int count = 0;
+ unsigned long count = 0;
if (mm == NULL)
mm = current->mm;
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-05-13 9:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-22 10:38 [PATCH] mm: Change count_mm_mlocked_page_nr return type Weikang shi
2019-05-11 8:10 ` Souptick Joarder
2019-05-13 2:37 Weikang shi
2019-05-13 9:15 ` Michal Hocko
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).