From: kernel test robot <lkp@intel.com>
To: deepakraog <gaikwad.dcg@gmail.com>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
0day robot <lkp@intel.com>
Subject: mm/vmalloc.c:4442:57: error: use of undeclared identifier 'gfp'
Date: Thu, 16 Jul 2026 01:07:27 +0200 [thread overview]
Message-ID: <202607160153.yE2uZTbP-lkp@intel.com> (raw)
tree: https://github.com/intel-lab-lkp/linux/commits/deepakraog/selftests-proc-expand-smaps-field-coverage-and-require-TMPFS/20260715-235653
head: d9d0f9a9456e0c39c577578411fdf41e0e54deff
commit: 9d4dde17d9bbfd6739f223d0dcd79a76b445abcc mm: vrealloc: grow vm_area mappings in place
date: 7 hours ago
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20260716/202607160153.yE2uZTbP-lkp@intel.com/config)
compiler: clang version 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260716/202607160153.yE2uZTbP-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202607160153.yE2uZTbP-lkp@intel.com/
All errors (new ones prefixed by >>):
>> mm/vmalloc.c:4442:57: error: use of undeclared identifier 'gfp'
4442 | pages = kvmalloc_array(extra, sizeof(struct page *), gfp);
| ^~~
>> mm/vmalloc.c:4442:57: error: use of undeclared identifier 'gfp'
4442 | pages = kvmalloc_array(extra, sizeof(struct page *), gfp);
| ^~~
>> mm/vmalloc.c:4442:57: error: use of undeclared identifier 'gfp'
4442 | pages = kvmalloc_array(extra, sizeof(struct page *), gfp);
| ^~~
mm/vmalloc.c:4446:47: error: use of undeclared identifier 'gfp'
4446 | if (vm_area_alloc_pages(vmalloc_gfp_adjust(gfp, 0), nid,
| ^~~
4 errors generated.
vim +/gfp +4442 mm/vmalloc.c
4281
4282 /**
4283 * vrealloc_node_align - reallocate virtually contiguous memory; contents
4284 * remain unchanged
4285 * @p: object to reallocate memory for
4286 * @size: the size to reallocate
4287 * @align: requested alignment
4288 * @flags: the flags for the page level allocator
4289 * @nid: node number of the target node
4290 *
4291 * If @p is %NULL, vrealloc_XXX() behaves exactly like vmalloc_XXX(). If @size
4292 * is 0 and @p is not a %NULL pointer, the object pointed to is freed.
4293 *
4294 * If the caller wants the new memory to be on specific node *only*,
4295 * __GFP_THISNODE flag should be set, otherwise the function will try to avoid
4296 * reallocation and possibly disregard the specified @nid.
4297 *
4298 * If __GFP_ZERO logic is requested, callers must ensure that, starting with the
4299 * initial memory allocation, every subsequent call to this API for the same
4300 * memory allocation is flagged with __GFP_ZERO. Otherwise, it is possible that
4301 * __GFP_ZERO is not fully honored by this API.
4302 *
4303 * Requesting an alignment that is bigger than the alignment of the existing
4304 * allocation will fail.
4305 *
4306 * In any case, the contents of the object pointed to are preserved up to the
4307 * lesser of the new and old sizes.
4308 *
4309 * This function must not be called concurrently with itself or vfree() for the
4310 * same memory allocation.
4311 *
4312 * Return: pointer to the allocated memory; %NULL if @size is zero or in case of
4313 * failure
4314 */
4315 void *vrealloc_node_align_noprof(const void *p, size_t size, unsigned long align,
4316 gfp_t flags, int nid)
4317 {
4318 struct vm_struct *vm = NULL;
4319 size_t alloced_size = 0;
4320 size_t old_size = 0;
4321 void *n;
4322
4323 if (!size) {
4324 vfree(p);
4325 return NULL;
4326 }
4327
4328 if (p) {
4329 vm = find_vm_area(p);
4330 if (unlikely(!vm)) {
4331 WARN(1, "Trying to vrealloc() nonexistent vm area (%p)\n", p);
4332 return NULL;
4333 }
4334
4335 alloced_size = get_vm_area_size(vm);
4336 old_size = vm->requested_size;
4337 if (WARN(alloced_size < old_size,
4338 "vrealloc() has mismatched area vs requested sizes (%p)\n", p))
4339 return NULL;
4340 if (WARN(!IS_ALIGNED((unsigned long)p, align),
4341 "will not reallocate with a bigger alignment (0x%lx)\n", align))
4342 return NULL;
4343 if (unlikely(flags & __GFP_THISNODE) && nid != NUMA_NO_NODE &&
4344 nid != page_to_nid(vmalloc_to_page(p)))
4345 goto need_realloc;
4346 } else {
4347 /*
4348 * If p is NULL, vrealloc behaves exactly like vmalloc.
4349 * Skip the shrink and in-place grow paths.
4350 */
4351 goto need_realloc;
4352 }
4353
4354 if (size <= old_size) {
4355 unsigned int new_nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
4356
4357 /* Zero out "freed" memory, potentially for future realloc. */
4358 if (want_init_on_free() || want_init_on_alloc(flags))
4359 memset((void *)p + size, 0, old_size - size);
4360
4361 /*
4362 * Free tail pages when shrink crosses a page boundary.
4363 *
4364 * Skip huge page allocations (page_order > 0) as partial
4365 * freeing would require splitting.
4366 *
4367 * Skip VM_FLUSH_RESET_PERMS, as direct-map permissions must
4368 * be reset before pages are returned to the allocator.
4369 *
4370 * Skip VM_USERMAP, as remap_vmalloc_range_partial() validates
4371 * mapping requests against the unchanged vm->size; freeing
4372 * tail pages would cause vmalloc_to_page() to return NULL for
4373 * the unmapped range.
4374 *
4375 * Skip if either GFP_NOFS or GFP_NOIO are used.
4376 * kmemleak_free_part() internally allocates with
4377 * GFP_KERNEL, which could trigger a recursive deadlock
4378 * if we are under filesystem or I/O reclaim.
4379 */
4380 if (new_nr_pages < vm->nr_pages && !vm_area_page_order(vm) &&
4381 !(vm->flags & (VM_FLUSH_RESET_PERMS | VM_USERMAP)) &&
4382 gfp_has_io_fs(flags)) {
4383 unsigned long addr = (unsigned long)kasan_reset_tag(p);
4384 unsigned int old_nr_pages = vm->nr_pages;
4385
4386 /*
4387 * Use the node lock to synchronize with concurrent
4388 * readers (vmalloc_info_show).
4389 */
4390 struct vmap_node *vn = addr_to_node(addr);
4391
4392 spin_lock(&vn->busy.lock);
4393 vm->nr_pages = new_nr_pages;
4394 spin_unlock(&vn->busy.lock);
4395
4396 /* Notify kmemleak of the reduced allocation size before unmapping. */
4397 kmemleak_free_part(
4398 (void *)addr + ((unsigned long)new_nr_pages
4399 << PAGE_SHIFT),
4400 (unsigned long)(old_nr_pages - new_nr_pages)
4401 << PAGE_SHIFT);
4402
4403 vunmap_range(addr + ((unsigned long)new_nr_pages
4404 << PAGE_SHIFT),
4405 addr + ((unsigned long)old_nr_pages
4406 << PAGE_SHIFT));
4407
4408 vm_area_free_pages(vm, new_nr_pages, old_nr_pages);
4409 }
4410 vm->requested_size = size;
4411 kasan_vrealloc(p, old_size, size);
4412 return (void *)p;
4413 }
4414
4415 /*
4416 * We already have the bytes available in the allocation; use them.
4417 */
4418 if (size <= vm->nr_pages << PAGE_SHIFT) {
4419 /*
4420 * No need to zero memory here, as unused memory will have
4421 * already been zeroed at initial allocation time or during
4422 * realloc shrink time.
4423 */
4424 vm->requested_size = size;
4425 kasan_vrealloc(p, old_size, size);
4426 return (void *)p;
4427 }
4428
4429 {
4430 unsigned int new_nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
4431 unsigned int old_nr_pages = vm->nr_pages;
4432
4433 if (new_nr_pages > old_nr_pages && !vm_area_page_order(vm) &&
4434 !(vm->flags & (VM_FLUSH_RESET_PERMS | VM_USERMAP)) &&
4435 gfp_has_io_fs(flags)) {
4436 unsigned int extra = new_nr_pages - old_nr_pages;
4437 unsigned long addr = (unsigned long)kasan_reset_tag(p);
4438 struct vmap_node *vn = addr_to_node(addr);
4439 struct page **pages;
4440 int ret;
4441
> 4442 pages = kvmalloc_array(extra, sizeof(struct page *), gfp);
4443 if (!pages)
4444 goto need_realloc;
4445
4446 if (vm_area_alloc_pages(vmalloc_gfp_adjust(gfp, 0), nid,
4447 0, extra, pages) != extra) {
4448 kvfree(pages);
4449 goto need_realloc;
4450 }
4451
4452 spin_lock(&vn->busy.lock);
4453 ret = vmap_pages_range(addr + ((unsigned long)old_nr_pages
4454 << PAGE_SHIFT),
4455 addr + ((unsigned long)new_nr_pages
4456 << PAGE_SHIFT),
4457 PAGE_KERNEL, pages, PAGE_SHIFT);
4458 spin_unlock(&vn->busy.lock);
4459 if (ret < 0) {
4460 free_pages_bulk(pages, extra);
4461 kvfree(pages);
4462 goto need_realloc;
4463 }
4464
4465 memcpy(&vm->pages[old_nr_pages], pages,
4466 extra * sizeof(struct page *));
4467 kvfree(pages);
4468 vm->nr_pages = new_nr_pages;
4469 vm->requested_size = size;
4470 kasan_vrealloc(p, old_size, size);
4471 if (want_init_on_alloc(flags))
4472 memset((void *)p + old_size, 0, size - old_size);
4473 return (void *)p;
4474 }
4475 }
4476
4477 need_realloc:
4478 /* Fall back to a fresh vm_area when in-place grow is not possible. */
4479 n = __vmalloc_node_noprof(size, align, flags, nid, __builtin_return_address(0));
4480
4481 if (!n)
4482 return NULL;
4483
4484 if (p) {
4485 memcpy(n, p, min(size, old_size));
4486 vfree(p);
4487 }
4488
4489 return n;
4490 }
4491 EXPORT_SYMBOL(vrealloc_node_align_noprof);
4492
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2026-07-15 23:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202607160153.yE2uZTbP-lkp@intel.com \
--to=lkp@intel.com \
--cc=gaikwad.dcg@gmail.com \
--cc=llvm@lists.linux.dev \
--cc=oe-kbuild-all@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox