public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* per cpun+ spin locks coexistence?
@ 2008-03-12 16:17 Peter Teoh
  2008-03-14 17:54 ` Jeremy Fitzhardinge
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Teoh @ 2008-03-12 16:17 UTC (permalink / raw)
  To: LKML

Help me out this one - in fs/file.c, there is a function free_fdtable_rcu():

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);
               spin_lock(&fddef->lock);
               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);
       }
}

Notice above that get_cpu_var() is followed by spin_lock().   Does this
make sense?   get_cpu_var() will return a variable that is only
accessible by the current CPU - guaranteed it will not be touch (read or
write) by another CPU, right?   so why do we need to spin_lock() it?

Thanks.

-- 
Regards,
Peter Teoh

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-03-20  9:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-12 16:17 per cpun+ spin locks coexistence? Peter Teoh
2008-03-14 17:54 ` Jeremy Fitzhardinge
2008-03-16 16:30   ` Peter Teoh
2008-03-16 20:20     ` Johannes Weiner
2008-03-17 17:06       ` Peter Teoh
2008-03-17 17:51         ` Johannes Weiner
2008-03-17 19:22         ` Eric Dumazet
2008-03-18 17:00           ` Peter Teoh
2008-03-18 17:34             ` Dipankar Sarma
2008-03-18 18:00             ` Eric Dumazet
2008-03-19 16:25               ` Peter Teoh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox