Re: [robust-futex-4] futex: robust futex support

From: Todd Kneisel
Date: Mon Jan 23 2006 - 13:19:17 EST


On 1/18/06, Andrew Morton <akpm@xxxxxxxx> wrote:
> > +/**
> > + * futex_free_robust_list - release the list of registered futexes.
> > + * @inode: inode that may be a memory mapped file
> > + *
> > + * Called from dput() when a dentry reference count reaches zero.
> > + * If the dentry is associated with a memory mapped file, then
> > + * release the list of registered robust futexes that are contained
> > + * in that mapping.
> > + */
> > +void futex_free_robust_list(struct inode *inode)
> > +{
> > + struct address_space *mapping;
> > + struct list_head *head;
> > + struct futex_robust *this, *next;
> > + struct futex_head *futex_head = NULL;
> > +
> > + if (inode == NULL)
> > + return;
>
> Is this test needed?
>
> This function is called when a dentry's refcount falls to zero. But there
> could be other refs to this inode which might get upset at having their
> robust futexes thrown away. Shouldn't this be based on inode destruction
> rather than dentry?
>

In an early version, it was based on inode destruction. But inodes are
not destroyed
at process termination. If I understand the code, they're cached so that another
process that opens the same file will not have to build the inode from scratch.

So I based it on the dentry's refcount falling to zero, which occurs at process
termination. I did consider the problem of other references to the
inode. The only
scenario I could come up with was mapping the file using hard links. Then there
would be multiple dentrys referencing the same inode. This could be fixed by
adding a refcount to the futex_robust structure, but I never got around to doing
this.

Todd.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/