mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
mm/vma: minor cleanup of expand_[upwards, downwards]()
Adjust the stack expansion functions expand_upwards() and expand_downwards() such that they are expressed in terms of named constant values, and make use of vma_start_pgoff(). This clearly documents that we are referencing the page offset of the start of the VMA. Additionally this cleans up the overflow check in expand_upwards(). No functional change intended. Link: https://lore.kernel.org/20260710-b4-pre-scalable-cow-v2-16-2a5aa403d977@kernel.org Signed-off-by: Lorenzo Stoakes <ljs@kernel.org> Reviewed-by: Pedro Falcato <pfalcato@suse.de> Reviewed-by: Gregory Price <gourry@gourry.net> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> Cc: Ackerley Tng <ackerleytng@google.com> Cc: David Hildenbrand (Arm) <david@kernel.org> Cc: Kai Huang <kai.huang@intel.com> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: SJ Park <sj@kernel.org> Cc: Thomas Zimmermann <tzimmermann@suse.de> Cc: Liam R. Howlett (Oracle) <liam@infradead.org> Cc: Zi Yan <ziy@nvidia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
a30574d073
commit
68d307442b
17
mm/vma.c
17
mm/vma.c
|
|
@ -3216,13 +3216,12 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
|
|||
|
||||
/* Somebody else might have raced and expanded it already */
|
||||
if (address > vma->vm_end) {
|
||||
unsigned long size, grow;
|
||||
|
||||
size = address - vma->vm_start;
|
||||
grow = (address - vma->vm_end) >> PAGE_SHIFT;
|
||||
const unsigned long size = address - vma->vm_start;
|
||||
const unsigned long grow = (address - vma->vm_end) >> PAGE_SHIFT;
|
||||
const pgoff_t pgoff = vma_start_pgoff(vma);
|
||||
|
||||
error = -ENOMEM;
|
||||
if (vma->vm_pgoff + (size >> PAGE_SHIFT) >= vma->vm_pgoff) {
|
||||
if (pgoff + (size >> PAGE_SHIFT) >= pgoff) {
|
||||
error = acct_stack_growth(vma, size, grow);
|
||||
if (!error) {
|
||||
if (vma_test(vma, VMA_LOCKED_BIT))
|
||||
|
|
@ -3295,13 +3294,11 @@ int expand_downwards(struct vm_area_struct *vma, unsigned long address)
|
|||
|
||||
/* Somebody else might have raced and expanded it already */
|
||||
if (address < vma->vm_start) {
|
||||
unsigned long size, grow;
|
||||
|
||||
size = vma->vm_end - address;
|
||||
grow = (vma->vm_start - address) >> PAGE_SHIFT;
|
||||
const unsigned long size = vma->vm_end - address;
|
||||
const unsigned long grow = (vma->vm_start - address) >> PAGE_SHIFT;
|
||||
|
||||
error = -ENOMEM;
|
||||
if (grow <= vma->vm_pgoff) {
|
||||
if (grow <= vma_start_pgoff(vma)) {
|
||||
error = acct_stack_growth(vma, size, grow);
|
||||
if (!error) {
|
||||
if (vma_test(vma, VMA_LOCKED_BIT))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user