spin_lock after get_cpu_var()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Peter Teoh
Date: Sunday, March 16, 2008 - 1:24 am

I find it quite puzzling (no where else in kernel source is this
found) that you would want to apply spin_lock() after get_cpu_var().
The fddef is already percpu, so there is no need to lock it, right?

I submitted this patch before, but got no response, just trying my
luck this time :-).

void free_fdtable_rcu(struct rcu_head *rcu)
{
        struct fdtable *fdt = container_of(rcu, struct fdtable, rcu);
        struct fdtable_defer *fddef;

        BUG_ON(!fdt);

        if (fdt->max_fds <= NR_OPEN_DEFAULT) {
                /*
                 * This fdtable is embedded in the files structure and that
                 * structure itself is getting destroyed.
                 */
                kmem_cache_free(files_cachep,
                                container_of(fdt, struct files_struct, fdtab));
                return;
        }
        if (fdt->max_fds <= (PAGE_SIZE / sizeof(struct file *))) {
                kfree(fdt->fd);
                kfree(fdt->open_fds);
                kfree(fdt);
        } else {
                fddef = &get_cpu_var(fdtable_defer_list);=============> here
                spin_lock(&fddef->lock);==========================>here
                fdt->next = fddef->next;
                fddef->next = fdt;
                /* vmallocs are handled from the workqueue context */
                schedule_work(&fddef->wq);
                spin_unlock(&fddef->lock);
                put_cpu_var(fdtable_defer_list);
        }
}
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
spin_lock after get_cpu_var(), Peter Teoh, (Sun Mar 16, 1:24 am)
Re: spin_lock after get_cpu_var(), Johannes Weiner, (Sun Mar 16, 3:12 am)