Re: Please Help. BUG init_mm dropped.

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

 



> On Mon, Feb 18, 2002 at 11:17:01AM +0100, Jan Hudec wrote:
> 
> > The problem seems to be, that while kernel_thread() references the mm of
> 
> check Frey's page linked from the website (don't forget to add reparent_to_init()
> too)

Well, this interface is AFAIK added to 2.5 series, but 1) I do it on 2.4
2) It looks more complicated, than is sane. It's not the way it's generally
done in kernel.

reparent_to_init is called is called 2 or 3 times in kernel, daemonize _much
more_. In addition it's always called _after_ daemonize, but the problem
is already there before daemonize. The problem seems to be there already when
the thread is started.

> it's not obvious what your bug is without seeing code

Well, this is in module's init:

int dfs_fs_init(void)
{
    printk("Dragon FileSystem alpha\n"); /* Pouzit definice jmena a verze */
    
    log_read_config(NULL); /* Takova missnamed inicializace */

    /* Inicializace subsystemu */

    DEBUG("",7,("retval cachep"));
    dfs_retval_cachep = kmem_cache_create("dfs_retval", sizeof(dfs_retval_t),
                                          0, DFS_KMEM_CACHE_FLAGS, NULL,
                                          NULL);
    DEBUG("",7,("identity"));
    dfs_identity_init(); /* FIXME upravit podle toho co vopravdu bude */
    DEBUG("",7,("handles"));
    dfs_handles_init();
    /* Spustime hlavni smycku */
    /* Ve drivers/scsi/hosts.c se povida neco o tom, ze se nesmi volat
     * kernel_thread z __initfunc; Jelikoz je kernel_thread externi, tak
     * nevidim rozdil mezi volanim pres funkci a primo. Toto je VAROVANI,
     * kdyby to tu spadlo. */
    DEBUG("",7,("kernel thread: we have mm %p (users %i), init_mm is at %p", current->mm, atomic_read(&current->mm->mm_users), &init_mm));
    loop_pid = kernel_thread(dfs_main_loop_thread, NULL,
                             CLONE_FS|CLONE_FILES|CLONE_VM);
    DEBUG("",7,("forked thread pid = %i", loop_pid));

    /* a nakonec zaregistrujeme filesystem */
    DEBUG("",7,("register filesystem"));
    register_filesystem(&dfs_fs_type);
    DEBUG("",7,("init done"));

    return 0; /* FIXME detekce chyby a vraceni chyby */
}

And this is in the thread:

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: we have mm %p (users %i), init_mm is at %p", current->mm, atomic_read(&current->mm->mm_users), &init_mm));
    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: we have mm %p (users %i), init_mm is at %p", current->mm, current->mm ? atomic_read(&current->mm->mm_users) : 0, &init_mm));
...

The mm is already broken at this time.
The DEBUG macros do some string copying and kmallocs and finally printk it out.
Firts time it prints mm (before kernel_thread is called), it has some mm different
from init_mm. Though there is CLONE_VM and the mm should be shared with parent,
it is not - instead init_mm is filled in thread's mm somewhere. But with wrong
ref-count. The last print shows mm being NULL as expected after daemonize.

--------------------------------------------------------------------------------
                  				- 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/


[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