0

Hello and a happy new year,

I'm working on a kernel-module. It is necessary to do a numeric calculation of some parameter to set up the device correctly. The function works perfectly but the gcc compiler (I'm using kbuild) gives me the warning:

warning: the frame size of 1232 bytes is larger than 1024 bytes [-Wframe-larger-than=]

If I'm right this means that space local variables exceed a limitation given by the machine the module compiled on.

There are some questions now:

  1. Does this warning refer to the whole memory space needed for the module, this explicit function or this function and its sub-functions?
  2. How critical is this?
  3. I don't see a way to reduce the needed memory. Are there some suggestions to handle this? Any how-to?

Maybe it is helpful: The calculation uses a 64bit fixed-point-arithmetic. All the functions of this library are inline functions.

Thanks in advance

Alex


Following the advice from @Tsyvarev the problem could reduce to the allocation in a function as this example shows (I know that the code doesn't make sense - it's only for showing how I declare the variables inside the functions):

uint8_t getVal ( uint8_t )
{
  uint64_t ar1[128] = {0};
  uint64_t ar2[128] = {0};
  uint8_t val;

  // a much of stuff

  return val;
}

void fun ( void )
{
  uint64_t ar1[128] = {0};
  uint64_t ar2[128] = {0};
  uint8_t cnt;

  for(cnt=0; cnt<128; cnt++)
  {
    ar1[cnt] = getVal(cnt);
    ar1[cnt] = getVal(cnt);
  }
}
4

1 回答 1

2

第3点:

正如建议的那样,解决方案是将数据存储到堆kmalloc而不是堆栈。

uint8_t getVal ( uint8_t )
{
  uint64_t *ar1;
  uint64_t *ar2;
  uint8_t val, cnt;

  // allocate memory on the heap
  ar1 = kmalloc(sizeof(uint64_t), 128);
  ar2 = kmalloc(sizeof(uint64_t), 128);

  // initialize the arrays
  for(cnt=0; cnt<128; cnt++)
  {
    ar1[cnt] = 0;
    ar2[cnt] = 0;
  }

  // a much of stuff

  return val;
}

void fun ( void )
{
  uint64_t *ar1;
  uint64_t *ar2;
  uint8_t cnt;

  // allocate memory on the heap
  ar1 = kmalloc(sizeof(uint64_t), 128);
  ar2 = kmalloc(sizeof(uint64_t), 128);

  // initialize the arrays
  for(cnt=0; cnt<128; cnt++)
  {
    ar1[cnt] = 0;
    ar2[cnt] = 0;
  }

 for(cnt=0; cnt<128; cnt++)
  {
    ar1[cnt] = getVal(cnt);
    ar1[cnt] = getVal(cnt);
  }
}
于 2016-01-08T22:02:00.210 回答