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

Re: sleeping function called from invalid context




No. GFP_KERNEL.

Let me explain things more clearly.

I made the following change to the kernel (I've simplified the code):


So, to follow your steps, I did the following,
static void myfunc ()
{
   if (jiffies > 20 * HZ) {
       void *p = kmem_cache_alloc (malloc_sizes->cs_cachep, GFP_KERNEL);
       if (p) {
           printk ("Allocated\n");
       }
       kmem_cache_free (malloc_sizes->cs_cachep, p);
   }
}

asmlinkage NORET_TYPE void do_exit(long code)
{
   struct task_struct *tsk = current;
<snip>

   if (unlikely(current->ptrace & PT_TRACE_EXIT)) {
       current->ptrace_message = code;
       ptrace_notify((PTRACE_EVENT_EXIT << 8) | SIGTRAP);
   }

    myfunc();
   acct_process(code);
   __exit_mm(tsk);

exit_sem(tsk);
<snip>
}
This code did not produce any problems. So I guess there is no problem in calling kmem_cache_alloc from do_exit.
There must be some bug in your code which is manifested this way.


Regards,
Om

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