lib/test_hmm: reduce stack usage

The various test ioctl handlers use arrays of 64 integers that add up to
1KiB of stack data, which in turn leads to exceeding the warning limit in
some configurations:

lib/test_hmm.c:935:12: error: stack frame size (1408) exceeds limit (1280)
in 'dmirror_migrate_to_device' [-Werror,-Wframe-larger-than]

Use half the size for these arrays, in order to stay under the warning
limits.  The code can already deal with arbitrary lengths, but this may be
a little less efficient.

Link: https://lkml.kernel.org/r/20250610092159.2639515-1-arnd@kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
pull/1311/head
Arnd Bergmann 2025-06-10 11:21:50 +02:00 committed by Andrew Morton
parent ba78585585
commit 6046a3bed1
1 changed files with 7 additions and 7 deletions

View File

@ -330,7 +330,7 @@ static int dmirror_fault(struct dmirror *dmirror, unsigned long start,
{ {
struct mm_struct *mm = dmirror->notifier.mm; struct mm_struct *mm = dmirror->notifier.mm;
unsigned long addr; unsigned long addr;
unsigned long pfns[64]; unsigned long pfns[32];
struct hmm_range range = { struct hmm_range range = {
.notifier = &dmirror->notifier, .notifier = &dmirror->notifier,
.hmm_pfns = pfns, .hmm_pfns = pfns,
@ -879,8 +879,8 @@ static int dmirror_migrate_to_system(struct dmirror *dmirror,
unsigned long size = cmd->npages << PAGE_SHIFT; unsigned long size = cmd->npages << PAGE_SHIFT;
struct mm_struct *mm = dmirror->notifier.mm; struct mm_struct *mm = dmirror->notifier.mm;
struct vm_area_struct *vma; struct vm_area_struct *vma;
unsigned long src_pfns[64] = { 0 }; unsigned long src_pfns[32] = { 0 };
unsigned long dst_pfns[64] = { 0 }; unsigned long dst_pfns[32] = { 0 };
struct migrate_vma args = { 0 }; struct migrate_vma args = { 0 };
unsigned long next; unsigned long next;
int ret; int ret;
@ -939,8 +939,8 @@ static int dmirror_migrate_to_device(struct dmirror *dmirror,
unsigned long size = cmd->npages << PAGE_SHIFT; unsigned long size = cmd->npages << PAGE_SHIFT;
struct mm_struct *mm = dmirror->notifier.mm; struct mm_struct *mm = dmirror->notifier.mm;
struct vm_area_struct *vma; struct vm_area_struct *vma;
unsigned long src_pfns[64] = { 0 }; unsigned long src_pfns[32] = { 0 };
unsigned long dst_pfns[64] = { 0 }; unsigned long dst_pfns[32] = { 0 };
struct dmirror_bounce bounce; struct dmirror_bounce bounce;
struct migrate_vma args = { 0 }; struct migrate_vma args = { 0 };
unsigned long next; unsigned long next;
@ -1144,8 +1144,8 @@ static int dmirror_snapshot(struct dmirror *dmirror,
unsigned long size = cmd->npages << PAGE_SHIFT; unsigned long size = cmd->npages << PAGE_SHIFT;
unsigned long addr; unsigned long addr;
unsigned long next; unsigned long next;
unsigned long pfns[64]; unsigned long pfns[32];
unsigned char perm[64]; unsigned char perm[32];
char __user *uptr; char __user *uptr;
struct hmm_range range = { struct hmm_range range = {
.hmm_pfns = pfns, .hmm_pfns = pfns,