[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[question] what can trigger BUG at fork.c:251?
Hello,
I am writing a module and have this strange problem.
I start a kernel thread. When it runs, first ps ax passes ok, but
the second one thiggers this BUG. It does so between printing
kswapd and bdflush. The bug is triggered, when &init->mm count
gets to zero, which points to I am miscounting it somewhere.
But I dont touch it directly. Please suggest to me, what operations
could mater in triggering this problem.
Here is what I do when I start the thread:
i declare global variable loop_pid of type pid_t.
Then I start the kenrel thread with:
loop_pid = kernel_thread(dfs_main_loop_thread, NULL,
CLONE_FS|CLONE_FILES|CLONE_VM);
(After initializing some of my data).
In dfs_mail_loop_thread followin code exists.
static int dfs_main_loop_thread(void *arg)
{
int rv;
DEBUG("kernel", 7, ("Initializing dfs main loop thread."));
dsem_down_ni(&dfs_event_loop_sem); /* FIXME kontrola "nemozneho" stavu
"ten semafor je ale dole!" */
DEBUG("kernel", 7, ("daemonize"));
daemonize(); /* magicka funkce co se musi volat v kernel-threadu */
/* FIXME - pokud opravdu nebudeme handlovat signaly, tak se tady musi
* zablokovat (viz reiserfs_journal_commit_thread) */
sprintf(current->comm, "kdfsd");
DEBUG("kernel", 7, ("daemonized"));
DEBUG("kernel", 7, ("dnet_init"));
rv = dnet_init();
DEBUG("kernel", 7, ("dnet_init %i",rv));
DEBUG("kernel", 7, ("dfs_identity_net_init"));
rv = dfs_identity_net_init();
DEBUG("kernel", 7, ("dfs_identity_net_init %i", rv));
DEBUG("kernel", 7, ("event_loop"));
dnet_event_loop();
DEBUG("kernel", 7, ("event_looped"));
DEBUG("kernel", 7, ("dnet_done"));
rv = dnet_done();
DEBUG("kernel", 7, ("dnet_done %i",rv));
DEBUG("kernel", 7, ("Shuting down dfs main loop thread."));
dsem_up(&dfs_event_loop_sem);
return 0; /* Nikdo neceka na ukonceni (init, ale tomu je to jedno) */
}
The debug stuff are (bit insane) macros to print log - they do kmallocs/kfrees
and printks. The dnet_init adds current to a wait-queue if that could matter.
The dnet_event_loop() returns only when removind is reuqested (and cleanup
waits for it on the semoaphore).
Thanks
Jan Hudec
--------------------------------------------------------------------------------
- Jan Hudec `Bulb' <bulb@ucw.cz>
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
IRC Channel: irc.openprojects.net / #kernelnewbies
Web Page: http://www.kernelnewbies.org/