* Memory allocation inside target handler
@ 2007-08-17 15:17 Thomas Jarosch
2007-08-17 15:22 ` Thomas Jarosch
2007-08-17 15:42 ` Jan Engelhardt
0 siblings, 2 replies; 7+ messages in thread
From: Thomas Jarosch @ 2007-08-17 15:17 UTC (permalink / raw)
To: netfilter-devel
[-- Attachment #1: Type: text/plain, Size: 1006 bytes --]
Hi there,
I'm currently debugging a memory allocation issue in ipt_ACCOUNT running on
2.6.21.7. The module allocates memory using get_zeroed_page(GFP_ATOMIC)
inside the target handler code (interrupt context).
This worked so far without problems. After upgrading from 2.4.32
to 2.6.21.7, I get a kernel oops after 15 to 30 minutes. Attached you'll
find a picture of the oops (sorry, no serial console available).
You can see the kernel is allocating memory when an interrupt is fired.
It then enters netfilter and ends up in ipt_ACCOUNT
which also tries to allocate memory -> Boom.
My question is now:
- Is it ok to use get_zeroed_page(GFP_ATOMIC) in interrupt context?
- Do I need some special locking before I can allocate memory inside
the target handler? Is f.e. kmalloc protected by some special locking?
In addition ipt_ACCOUNT allocates some memory during the module init code
with kmalloc(GFP_KERNEL), but I guess this is not an issue here.
Thanks in advance for any help,
Thomas Jarosch
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Memory allocation inside target handler
2007-08-17 15:17 Memory allocation inside target handler Thomas Jarosch
@ 2007-08-17 15:22 ` Thomas Jarosch
2007-08-17 15:25 ` Thomas Jarosch
2007-08-17 15:42 ` Jan Engelhardt
1 sibling, 1 reply; 7+ messages in thread
From: Thomas Jarosch @ 2007-08-17 15:22 UTC (permalink / raw)
To: netfilter-devel
[-- Attachment #1: Type: text/plain, Size: 40 bytes --]
... and now the picture of the oops ;-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Memory allocation inside target handler
2007-08-17 15:17 Memory allocation inside target handler Thomas Jarosch
2007-08-17 15:22 ` Thomas Jarosch
@ 2007-08-17 15:42 ` Jan Engelhardt
2007-08-20 9:46 ` Thomas Jarosch
1 sibling, 1 reply; 7+ messages in thread
From: Jan Engelhardt @ 2007-08-17 15:42 UTC (permalink / raw)
To: Thomas Jarosch; +Cc: netfilter-devel
On Aug 17 2007 17:17, Thomas Jarosch wrote:
>
>My question is now:
>- Is it ok to use get_zeroed_page(GFP_ATOMIC) in interrupt context?
I suppose so. There is code that checks for __GFP_WAIT.
(GFP_ATOMIC has __GFP_WAIT _cleared_)
>- Do I need some special locking before I can allocate memory inside
> the target handler? Is f.e. kmalloc protected by some special locking?
Only locking for your own structures, if needed.
kmalloc alone does not. (You can write a memory leak without any locks, so to
speak.)
Jan
--
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Memory allocation inside target handler
2007-08-17 15:42 ` Jan Engelhardt
@ 2007-08-20 9:46 ` Thomas Jarosch
0 siblings, 0 replies; 7+ messages in thread
From: Thomas Jarosch @ 2007-08-20 9:46 UTC (permalink / raw)
To: netfilter-devel; +Cc: Jan Engelhardt
On Friday, 17. August 2007, Jan Engelhardt wrote:
> On Aug 17 2007 17:17, Thomas Jarosch wrote:
> >My question is now:
> >- Is it ok to use get_zeroed_page(GFP_ATOMIC) in interrupt context?
>
> I suppose so. There is code that checks for __GFP_WAIT.
> (GFP_ATOMIC has __GFP_WAIT _cleared_)
>
> >- Do I need some special locking before I can allocate memory inside
> > the target handler? Is f.e. kmalloc protected by some special locking?
>
> Only locking for your own structures, if needed.
> kmalloc alone does not. (You can write a memory leak without any locks, so
> to speak.)
ipt_ACCOUNT spinlocks the internal data structures, so that should be ok.
I've changed the code to allocate and free memory for every packet instead of
every read from userpace, now the machine survives only 10 seconds. To me it
looks like a missing locking in the kernel memory handler,
I'll try to get a backtrace via serial console.
Thomas
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-08-20 9:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-17 15:17 Memory allocation inside target handler Thomas Jarosch
2007-08-17 15:22 ` Thomas Jarosch
2007-08-17 15:25 ` Thomas Jarosch
2007-08-17 20:39 ` Carl-Daniel Hailfinger
2007-08-20 9:29 ` Thomas Jarosch
2007-08-17 15:42 ` Jan Engelhardt
2007-08-20 9:46 ` Thomas Jarosch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).