Re: limited size for variable in kernel stack?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 17 March 2005 12:44, aq wrote:
> hello,
> 
> I am writing a kernel module, and in one function i have a small array
> of char. I declare it like this:
> 
> char arr[PAGE_SIZE];

That is hardly small.  It is a major percentage of the
total stack size.

> But knowing that the kernel stack size is rather limited, I am afraid
> that the above array wastes too much stack memory. So I would like to
> know what is the recommended size for a variable on the stack?

Very very small.  Even for arrays/structs that are only
a few words long, you may want to at least consider dynamically
allocating them instead.  Just because they are small today, doesn't 
mean they'll stay that small next week/month/year.

> Should 
> I allocate the above array using kmalloc() instead of putting it on
> stack?

That sounds much better.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux