mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH] (1/8) Eliminate brlock in psnap
@ 2003-03-12 20:28 Paul McKenney
  2003-03-13  0:54 ` Zwane Mwaikambo
  0 siblings, 1 reply; 6+ messages in thread
From: Paul McKenney @ 2003-03-12 20:28 UTC (permalink / raw)
  To: Zwane Mwaikambo
  Cc: David Miller, Linux Kernel Mailing List, linux-kernel-owner,
	linux-net, Stephen Hemminger, Linus Torvalds





> On Tue, 11 Mar 2003, Stephen Hemminger wrote:
>
> >  void unregister_snap_client(struct datalink_proto *proto)
> >  {
> > -        br_write_lock_bh(BR_NETPROTO_LOCK);
> > +        static RCU_HEAD(snap_rcu);
> >
> > -        list_del(&proto->node);
> > -        kfree(proto);
> > +        spin_lock_bh(&snap_lock);
> > +        list_del_rcu(&proto->node);
> > +        spin_unlock_bh(&snap_lock);
> >
> > -        br_write_unlock_bh(BR_NETPROTO_LOCK);
> > +        call_rcu(&snap_rcu, (void (*)(void *)) kfree, proto);
> >  }
>
> Do we need the spin_lock_bh around the list_del_rcu? But also How
> about. This way we don't change the previous characteristic of block till
> done unregistering
>
> struct datalink_proto {
> ...
>            struct completion registration;
> };
>
> void __unregister_snap_client(void *__proto)
> {
>            struct datalink_proto *proto = __proto;
>            complete(&proto->registration);
> }
>
> unregister_snap_client(struct datalink_proto *proto)
> {
>            list_del_rcu(&proto->node);
>            call_rcu(&snap_rcu, __unregister_snap_client, proto);
>            wait_for_completion(&proto->registration);
>            kfree(proto);
> }

You are saying that we can omit locking because this is
called only from a module-exit function, and thus protected
by the module_mutex semaphore?  (I must defer to
others who have a better handle on modules...)

If in fact only one module-exit function can be
executing at a given time, then we should be able to
use the following approach:

void unregister_snap_client(struct datalink_proto *proto)
{
      list_del_rcu(&proto->node); /* protected by module_mutex. */
      synchronize_kernel();
      kfree(proto);
}

If multiple module-exit functions can somehow execute
concurrently, then something like the following would
be needed:

void unregister_snap_client(struct datalink_proto *proto)
{
      spin_lock_bh(&snap_lock);
      list_del_rcu(&proto->node);
      spin_unlock_bh(&snap_lock);
      synchronize_kernel();
      kfree(proto);
}

Module unloading should be rare enough to tolerate
the grace period under the module_mutex, right?

Thoughts?

                        Thanx, Paul


^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [PATCH] (1/8) Eliminate brlock in psnap
@ 2003-03-13 21:54 Paul McKenney
  0 siblings, 0 replies; 6+ messages in thread
From: Paul McKenney @ 2003-03-13 21:54 UTC (permalink / raw)
  To: Zwane Mwaikambo
  Cc: David Miller, Linux Kernel Mailing List, linux-kernel-owner,
	linux-net, Stephen Hemminger, Linus Torvalds





> > Module unloading should be rare enough to tolerate
> > the grace period under the module_mutex, right?
> >
> > Thoughts?
>
> I would agree. However can't unregister_snap_client be used in other
paths
> apart from module_unload? I wouldn't worry too much since if
> register_snap_client and unregister_snap_client for the same protocol
> races it's a bug in the caller's code. The safe RCU list removal and
> synchronize_kernel should protect us from sane usage.
>
>            Zwane

It is not called from elsewhere right now, but if there
is a possibility that it might be, Steve of course should
keep the locking in these functions.

                              Thanx, Paul


^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [PATCH] small fixes in brlock.h
@ 2003-03-10  2:33 Linus Torvalds
  2003-03-12  0:14 ` [PATCH] (1/8) Eliminate brlock in psnap Stephen Hemminger
  0 siblings, 1 reply; 6+ messages in thread
From: Linus Torvalds @ 2003-03-10  2:33 UTC (permalink / raw)
  To: Robert Love; +Cc: Zwane Mwaikambo, Linux Kernel


On 9 Mar 2003, Robert Love wrote:
> 
> I guess nothing uses these irq variants.  In fact, grepping the
> source... wow, not much uses brlocks at all.  Only registered lock is
> BR_NETPROTO_LOCK.  A read lock on it is called only 7 times and a write
> lock is used 31 times.
> 
> Everything must of moved over to using RCU or something.  It makes me
> question the future of these things.

No, I don't think there are even "moved to RCU" users. It's just never 
been used very much, since the writes are _so_ expensive (in fact, there 
have been various live-locks on the writer side, the whole brlock thing is 
really questionable).

It's entirely possible that the current user could be replaced by RCU 
and/or seqlocks, and we could get rid of brlocks entirely.

		Linus


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

end of thread, other threads:[~2003-03-13 22:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-12 20:28 [PATCH] (1/8) Eliminate brlock in psnap Paul McKenney
2003-03-13  0:54 ` Zwane Mwaikambo
  -- strict thread matches above, loose matches on Subject: below --
2003-03-13 21:54 Paul McKenney
2003-03-10  2:33 [PATCH] small fixes in brlock.h Linus Torvalds
2003-03-12  0:14 ` [PATCH] (1/8) Eliminate brlock in psnap Stephen Hemminger
2003-03-12  1:03   ` Roman Zippel
2003-03-12  1:13   ` Zwane Mwaikambo

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

all inboxes | Powered by JetHome®