Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6798063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:41:05+00:00 2026-05-26T18:41:05+00:00

When I allocate memory on a specific NUMA node using numa_alloc_onnode() like this :

  • 0

When I allocate memory on a specific NUMA node using numa_alloc_onnode() like this :

char *ptr;
if ((ptr = (char *) numa_alloc_onnode(1024,1)) == NULL) {
  fprintf(stderr,"Problem in %s line %d allocating memory\n",__FILE__,__LINE__);
  return(1);
}

and then use move_pages() to try and confirm that the memory allocated is indeed on node 1 :

  printf("ptr is on node %d\n",get_node(ptr));

where

// This function returns the NUMA node that a pointer address resides on.

int get_node(void *p)
{
  int status[1];
  void *pa;
  unsigned long a;

  // round p down to the nearest page boundary

  a  = (unsigned long) p;
  a  = a - (a % ((unsigned long) getpagesize()));
  pa = (void *) a;    

  if (move_pages(0,1,&pa,NULL,status,0) != 0) {
    fprintf(stderr,"Problem in %s line %d calling move_pages()\n",__FILE__,__LINE__);
    abort();
  }

  return(status[0]);

}

I get the answer “ptr is on node -2”. From errno-base.h I find that 2 is ENOENT, and the move_pages() man page says that a status of -ENOENT in this context means “The page is not present”.

If I replace numa_alloc_onnode() with ordinary malloc() it works fine : I get a node number.

Does anyone have any idea what’s going on here?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:41:06+00:00Added an answer on May 26, 2026 at 6:41 pm

    numa_alloc_onnode(3) says:

       All numa memory allocation policy only takes effect when a
       page is actually faulted into the address space of a process
       by accessing it. The numa_alloc_* functions take care of this
       automatically.
    

    Does this mean you need to store something into the newly-allocated page before the kernel actually gives you the page?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently allocate my memory for arrays using the MS specific mm_malloc. I align
How do I allocate memory for a char variable (not a char pointer) inside
I would like to dynamically allocate memory from the machine_init function in my arm
if this is a bad idea, how to allocate memory in the function?
We know that malloc() and new operation allocate memory from heap dynamically, but where
String a = a; // allocate memory and write address of a memory block
I've read that mysql_store_result() in the MySQL C API will allocate memory for each
That's pretty much it. I need to allocate memory and pass it to a
Help. TCHAR* b; TCHAR* c=TEXT(qwerty); I want to allocate memory and copy content of
If I use .reserve(items) on a vector, the vector will allocate enough memory for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.