c - Suggestions to handle `Wframe-larger-than`-warning on kernel module -


hello , happy new year,

i'm working on kernel-module. necessary numeric calculation of parameter set device correctly. function works gcc compiler (i'm using kbuild) gives me warning:

warning: frame size of 1232 bytes larger 1024 bytes [-wframe-larger-than=] 

if i'm right means space local variables exceed limitation given machine module compiled on.

there questions now:

  1. does warning refer whole memory space needed module, explicit function or function , sub-functions?
  2. how critical this?
  3. i don't see way reduce needed memory. there suggestions handle this? how-to?

maybe helpful: calculation uses 64bit fixed-point-arithmetic. functions of library inline functions.

thanks in advance

alex


following advice @tsyvarev problem reduce allocation in function example shows (i know code doesn't make sense - it's showing how declare variables inside functions):

uint8_t getval ( uint8_t ) {   uint64_t ar1[128] = {0};   uint64_t ar2[128] = {0};   uint8_t val;    // 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);   } } 

to point 3:

as suggested solution store data heap kmalloc instead stack.

uint8_t getval ( uint8_t ) {   uint64_t *ar1;   uint64_t *ar2;   uint8_t val, cnt;    // allocate memory on heap   ar1 = kmalloc(sizeof(uint64_t), 128);   ar2 = kmalloc(sizeof(uint64_t), 128);    // initialize arrays   for(cnt=0; cnt<128; cnt++)   {     ar1[cnt] = 0;     ar2[cnt] = 0;   }    // of stuff    return val; }  void fun ( void ) {   uint64_t *ar1;   uint64_t *ar2;   uint8_t cnt;    // allocate memory on heap   ar1 = kmalloc(sizeof(uint64_t), 128);   ar2 = kmalloc(sizeof(uint64_t), 128);    // initialize 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);   } } 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -