我看到Linux内核在大于某个阈值时使用它vmalloc来分配内存。fdtable我想知道这种情况何时发生,并有一些更明确的信息。
static void *alloc_fdmem(size_t size)
{
       /*
       * Very large allocations can stress page reclaim, so fall back to
       * vmalloc() if the allocation size will be considered "large" by the VM.
       */
       if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) {
              void *data = kmalloc(size, GFP_KERNEL|__GFP_NOWARN);
              if (data != NULL)
                     return data;
       }
       return vmalloc(size);
}
alloc_fdmem调用 fromalloc_fdtable并且最后一个函数调用 fromexpand_fdtable
我写了这段代码来打印尺寸。
#include <stdio.h>
#define PAGE_ALLOC_COSTLY_ORDER 3
#define PAGE_SIZE 4096
int main(){
      printf("\t%d\n", PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER);
}
输出
 ./printo
  32768
那么,内核切换到使用vmalloc分配需要多少个文件fdtable?