0

Can i use ksize on memory allocated by vmalloc.

I know ksize is used to determine the actual amount of memory allocated

So, i wanted to find out whether vmalloc round up allocations and return more memory than requested.

Will the below code works?

ptr =vmalloc(1);
printk("I got: %zu bytes of memory\n", ksize(ptr));
vfree(ptr);
red0ct
  • 4,840
  • 3
  • 17
  • 44
md.jamal
  • 4,067
  • 8
  • 45
  • 108
  • 2
    According to the documentation, "The caller must guarantee that objp points to a valid object previously allocated with either kmalloc() or kmem_cache_alloc()." – Ian Abbott Sep 12 '19 at 10:42
  • What is the alternative for it in vmalloc – md.jamal Sep 12 '19 at 13:30
  • I don't think there is an alternative for `vmalloc`, although the size will be rounded up to a multiple of `PAGE_SIZE`. – Ian Abbott Sep 12 '19 at 14:01

0 Answers0