Re: dev_base_lock and ->get_stats()?

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

 



"David S. Miller" wrote:
> 
> David Dillow writes:
>  > F.e. anything that calls rtmsg_ifinfo() almost always calls it without
>  > the dev_base_lock held. This includes the dev_ioctl(), dev_ifsioc(),
>  > dev_change_flags(), dev_open() call chain, among others. And anything
>  > that notfies using the netdev_chain notifier list.
> 
> Holding the rtnl_sem semaphore makes holding the dev_base_lock()
> unnecessary in most cases.
> 
> Actually, let's go over the cases in detail:
> 
> net/core/rtnetlink.c:rtnetlink_fill_ifinfo()
> 
>         Called from:
> 
>         1) rtnetlink_dump_ifinfo, holds dev_base_lock
>         2) rtmsg_ifinfo, all callers paths hold rtnl_sem
> 
> net/core/dev.c:sprintf_stats()
> 
>         Caller dev_get_info() holds dev_base_lock
> 
> And that's it.

I agree that that looks like all of the cases. My parse tree was larger,
but I also wasn't taking the rntl_{lock,sem} into account. But, I'm
still getting multiple callers into get_stats() at the same time, unless
my detect code is buggy:

static atomic_t mylock = ATOMIC_INIT(1);
int printed = 0;

while(!atomic_dec_and_test(&mylock))
{
    atomic_inc(&mylock);
    if(!printed) {
        printk("%s: reentered get_stats\n", dev->name);
        printed = 1;
    }
}

... rest of get_stats ...

atomic_inc(&mylock);


Maybe I'm missing something, but there seems to be a problem somewhere.
I'll keep looking.

Thanks,
David Dillow
dillowd@y12.doe.gov
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux