[lkml]   [2019]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRE: [PATCH] mm/mmap: fix the adjusted length error
Thank you for your reply! 
> How significant is this problem in real-world use cases? How much trouble is it causing?
In my opinion, this problem is very rare in real-world use cases. In arm64
or x86 environment, the virtual memory is enough. In arm32 environment,
each process has only 3G or 4G or less, but we seldom use out all of the virtual memory,
it only happens in some special environment. They almost use out all the virtual memory, and
in some moment, they will change their working mode so they will release and allocate
memory again. This current length limitation will cause this problem. I explain it's the memory
length limitation. But they can't accept the reason, it is unreasonable that we fail to allocate
memory even though the memory gap is enough.

> Have you looked further into this? Michel is concerned about the performance cost of the current solution.
The current algorithm(change before) is wonderful, and it has been used for a long time, I don't
think it is worthy to change the whole algorithm in order to fix this problem. Therefore, I just
adjust the gap_start and gap_end value in place of the length. My change really affects the
performance because I calculate the gap_start and gap_end value again and again. Does it affect
too much performance? I have no complex environment, so I can't test it, but I don't think it will cause
too much performance loss. First, I don't change the whole algorithm. Second, unmapped_area and
unmapped_area_topdown function aren't used frequently. Maybe there are some big performance problems
I'm not concerned about. But I think if that's not a problem, there should be a limitation description.

-----Original Message-----
From: Andrew Morton []
Sent: Friday, July 12, 2019 9:20 AM
To: chenjianhong (A) <>
Cc: Michel Lespinasse <>; Greg Kroah-Hartman <>;; Vlastimil Babka <>; Kirill A. Shutemov <>; Yang Shi <>;;;; LKML <>; linux-mm <>;;
Subject: Re: [PATCH] mm/mmap: fix the adjusted length error

On Sat, 18 May 2019 07:05:07 +0000 "chenjianhong (A)" <> wrote:

> I explain my test code and the problem in detail. This problem is
> found in 32-bit user process, because its virtual is limited, 3G or 4G.
> First, I explain the bug I found. Function unmapped_area and
> unmapped_area_topdowns adjust search length to account for worst case
> alignment overhead, the code is ' length = info->length + info->align_mask; '.
> The variable info->length is the length we allocate and the variable
> info->align_mask accounts for the alignment, because the gap_start or
> info->gap_end
> value also should be an alignment address, but we can't know the alignment offset.
> So in the current algorithm, it uses the max alignment offset, this
> value maybe zero or other(0x1ff000 for shmat function).
> Is it reasonable way? The required value is longer than what I allocate.
> What's more, why for the first time I can allocate the memory
> successfully Via shmat, but after releasing the memory via shmdt and I
> want to attach again, it fails. This is not acceptable for many people.
> Second, I explain my test code. The code I have sent an email. The
> following is the step. I don't think it's something unusual or
> unreasonable, because the virtual memory space is enough, but the
> process can allocate from it. And we can't pass explicit addresses to
> function mmap or shmat, the address is getting from the left vma gap.
> 1, we allocat large virtual memory;
> 2, we allocate hugepage memory via shmat, and release one of the
> hugepage memory block; 3, we allocate hugepage memory by shmat again,
> this will fail.

How significant is this problem in real-world use cases? How much trouble is it causing?

> Third, I want to introduce my change in the current algorithm. I don't
> change the current algorithm. Also, I think there maybe a better way
> to fix this error. Nowadays, I can just adjust the gap_start value.

Have you looked further into this? Michel is concerned about the performance cost of the current solution.

 \ /
  Last update: 2019-07-12 12:54    [W:0.053 / U:1.260 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site