mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] small fixes in brlock.h
@ 2003-03-09 23:44 Zwane Mwaikambo
  2003-03-10  0:00 ` Robert Love
  2003-03-10  0:15 ` Robert Love
  0 siblings, 2 replies; 34+ messages in thread
From: Zwane Mwaikambo @ 2003-03-09 23:44 UTC (permalink / raw)
  To: Linux Kernel; +Cc: Linus Torvalds

Index: linux-2.5.64-unwashed/include/linux/brlock.h
===================================================================
RCS file: /build/cvsroot/linux-2.5.64/include/linux/brlock.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 brlock.h
--- linux-2.5.64-unwashed/include/linux/brlock.h	5 Mar 2003 05:07:54 -0000	1.1.1.1
+++ linux-2.5.64-unwashed/include/linux/brlock.h	9 Mar 2003 23:42:26 -0000
@@ -85,8 +85,7 @@
 	if (idx >= __BR_END)
 		__br_lock_usage_bug();
 
-	preempt_disable();
-	_raw_read_lock(&__brlock_array[smp_processor_id()][idx]);
+	read_lock(&__brlock_array[smp_processor_id()][idx]);
 }
 
 static inline void br_read_unlock (enum brlock_indices idx)
@@ -202,7 +201,7 @@
 	do { local_bh_disable(); br_write_lock(idx); } while (0)
 
 #define br_read_unlock_irqrestore(idx, flags) \
-	do { br_read_unlock(irx); local_irq_restore(flags); } while (0)
+	do { br_read_unlock(idx); local_irq_restore(flags); } while (0)
 
 #define br_read_unlock_irq(idx) \
 	do { br_read_unlock(idx); local_irq_enable(); } while (0)
@@ -211,7 +210,7 @@
 	do { br_read_unlock(idx); local_bh_enable(); } while (0)
 
 #define br_write_unlock_irqrestore(idx, flags) \
-	do { br_write_unlock(irx); local_irq_restore(flags); } while (0)
+	do { br_write_unlock(idx); local_irq_restore(flags); } while (0)
 
 #define br_write_unlock_irq(idx) \
 	do { br_write_unlock(idx); local_irq_enable(); } while (0)

-- 
function.linuxpower.ca

^ permalink raw reply	[flat|nested] 34+ messages in thread
* 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; 34+ 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] 34+ messages in thread
* Re: [PATCH] (1/8) Eliminate brlock in psnap
@ 2003-03-13 21:54 Paul McKenney
  0 siblings, 0 replies; 34+ 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] 34+ messages in thread

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

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-09 23:44 [PATCH] small fixes in brlock.h Zwane Mwaikambo
2003-03-10  0:00 ` Robert Love
2003-03-10  0:03   ` Zwane Mwaikambo
2003-03-10  0:10     ` Robert Love
2003-03-10  1:11       ` Zwane Mwaikambo
2003-03-10  0:15 ` Robert Love
2003-03-10  2:33   ` Linus Torvalds
2003-03-10 21:54     ` Roman Zippel
2003-03-12  0:13     ` [PATCH] (0/8) replace brlock with RCU Stephen Hemminger
2003-03-12  0:23       ` Linus Torvalds
2003-03-12  0:28         ` David S. Miller
2003-03-12  1:36           ` Roman Zippel
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
2003-03-12  0:14     ` [PATCH] (2/8) Eliminate brlock for packet_type Stephen Hemminger
2003-03-12  0:20       ` David S. Miller
2003-03-12  0:25         ` Stephen Hemminger
2003-03-12  0:14     ` [PATCH] (3/8) Eliminate brlock from vlan Stephen Hemminger
2003-03-12  0:14     ` [PATCH] (4/8) Eliminate brlock in net/bridge Stephen Hemminger
2003-03-12  0:14     ` [PATCH] (5/8) Eliminate brlock from netfilter Stephen Hemminger
2003-03-12  1:25       ` Zwane Mwaikambo
2003-03-12  0:15     ` [PATCH] (6/8) Eliminate brlock from ipv4 Stephen Hemminger
2003-03-12  0:15     ` [PATCH] (7/8) Eliminate brlock from IPV6 Stephen Hemminger
2003-03-12  0:15     ` [PATCH] (8/8) Kill brlock Stephen Hemminger
2003-03-12  0:23       ` David S. Miller
2003-03-12  0:31         ` Stephen Hemminger
2003-03-12  0:34           ` David S. Miller
2003-03-12  0:44             ` Linus Torvalds
2003-03-12  0:48               ` Stephen Hemminger
2003-03-12  2:31               ` Alan Cox
2003-03-12 20:28 [PATCH] (1/8) Eliminate brlock in psnap Paul McKenney
2003-03-13  0:54 ` Zwane Mwaikambo
2003-03-13 21:54 Paul McKenney

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®