Re: [PATCH 2/7] CAN: Add PF_CAN core module

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Patrick McHardy <kaber@...>
Cc: <netdev@...>, David Miller <davem@...>, Thomas Gleixner <tglx@...>, Oliver Hartkopp <oliver@...>, Oliver Hartkopp <oliver.hartkopp@...>, Urs Thuermann <urs@...>
Date: Thursday, September 20, 2007 - 4:53 am

Hi Patrick,

I have done allmost all changes to the code as you suggested.  The
changes to use the return value of can_rx_register() also fixed a
minor flax with failing bind() and setsockopt() on raw sockets.

But there are two things left I would like to ask/understand:

Patrick McHardy <kaber@trash.net> writes:


How would I use the module reference counter?  Somehow with
try_module_get()?  I have thought something like

        cp = proto_tab[protocol];
        if (!cp ...)
                return ...;

        if (!try_module_get(cp->prot->owner))
                return ...;

        sk = sk_alloc(...)

        module_put(...);
        return ret;

But here I see two problems:

1. Between the check !cp...  and referencing cp->prot->owner the
   module could get unloaded and the reference be invalid.  Is there
   some lock I can hold that prevents module unloading?  I haven't
   found something like this in include/linux/module.h

2. If the module gets unloaded after the first check and
   request_module() but before the call to try_module_get() the
   socket() syscall will return with error, although module auto
   loading would normally be successful.  How can I prevent that?


I have no objections to add the _rcu suffix for the code changing the
receive lists, but I don't see why it's necessary.  When I do a
spin_lock_bh() before writing, can't I be sure that there is no
interrupt routine running in parallel while I hold this spinlock?  If
so, there is no reader in parallel because the can_rcv() function runs
in a softirq.  I'd really like to understand why you think the writers
should also use the _rcu variant.  I'm sorry if I miss something
obvious here, but could you try to explain it to me?

urs
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 2/7] CAN: Add PF_CAN core module, Urs Thuermann, (Mon Sep 17, 6:03 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Patrick McHardy, (Tue Sep 18, 9:31 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Urs Thuermann, (Tue Sep 18, 5:20 pm)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Patrick McHardy, (Wed Sep 19, 4:27 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Urs Thuermann, (Thu Sep 20, 4:53 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Patrick McHardy, (Thu Sep 20, 6:33 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Urs Thuermann, (Thu Sep 20, 7:30 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Patrick McHardy, (Thu Sep 20, 7:43 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Urs Thuermann, (Tue Sep 18, 10:54 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Patrick McHardy, (Tue Sep 18, 11:07 am)
Re: [PATCH 2/7] CAN: Add PF_CAN core module, Paul E. McKenney, (Mon Sep 17, 11:50 am)