jamal wrote: > On Tue, 2006-31-01 at 07:32 +1100, Herbert Xu wrote: > >>Unfortunately this is a bit too heavy weight. He needs it on the packet >>rx/tx path. Perhaps RCU would help? > > > yes, it is a little heavyweight for the fast path to check for netlink > listeners on every packet[1]. > RCU approach will be an improvement but not 100% cure for the fast path. > A couple of extensions i can think of: > > a) dont bother checking for listeners until event generation time; this > reduces the calls to check but may imply we end up doing unnecessary > work because the fast path will always keeps updating.
I'm not sure I understand you correctly. The updates are in relatively uncritical paths and netlink_has_listeners() should be used before event generation to avoid generating events that nobody will receive. But that's probably not what you meant .. BTW, there is a bug in the current patch, it only updates the subscribers mask if the group delta > 0, not if one group is left and another one if joined at the same time. > OR > b) a new netlink_event() callback which reports events like > "first_listener_joined" or "last_listener_left". In the case of the > first user one could set the variable (curently sysctl) that is checked > in the fast path and when the last user leaves one could unset it. > This way the fast path stays as is. That's possible, but implies using another global state variable. I'd prefer to just make netlink_has_listeners more lightweight by using RCU. > #b, for lacking locks in the fast path/synchronization, will result in > occasional sending an event with no listeners (when the last listener > leaves) or not sending an event or two (when the first listener joins) - > but this is acceptable imo and is not worse than current sysctl. That is totally acceptable, it will always be racy, but it doesn't matter because userspace can't know which will be the first event it will receive anyway. The only guarantee it should provide is that events generated after the bind() or setsockopt() call have returned will be delivered to the socket. The lock is only used to avoid accessing invalid memory, but that should be easy to achieve using RCU. - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html