Received: by oss.sgi.com id ; Sat, 24 Jun 2000 08:38:08 -0700 Received: from puffin.external.hp.com ([192.25.206.4]:25610 "EHLO puffin.external.hp.com") by oss.sgi.com with ESMTP id ; Sat, 24 Jun 2000 08:37:51 -0700 Received: (from prumpf@localhost) by puffin.external.hp.com (8.9.3/8.9.3) id JAA31745; Sat, 24 Jun 2000 09:35:48 -0600 Message-ID: <20000624093548.A31621@puffin.external.hp.com> Date: Sat, 24 Jun 2000 09:35:48 -0600 From: Philipp Rumpf To: Andrew Morton , Philipp Rumpf Cc: Rusty Russell , Keith Owens , Alan Cox , "netdev@oss.sgi.com" Subject: Re: modular net drivers References: <20000623164805.AA5BB8154@halfway> <3954262D.60BDEF41@uow.edu.au>, <3954262D.60BDEF41@uow.edu.au> <20000624080106.A25102@fruits.uzix.org> <3954D42A.938A724B@uow.edu.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.93.2 In-Reply-To: <3954D42A.938A724B@uow.edu.au>; from Andrew Morton on Sun, Jun 25, 2000 at 01:30:50AM +1000 Sender: owner-netdev@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;netdev-outgoing On Sun, Jun 25, 2000 at 01:30:50AM +1000, Andrew Morton wrote: > +static volatile int ice_block; > +static spinlock_t freeze_lock = SPIN_LOCK_UNLOCKED; > + > +static int > +antarctica(void *dummy) > +{ > + printk("start antarctica on %d\n", smp_processor_id()); > + while (ice_block) > + ; > + printk("stop antarctica on %d\n", smp_processor_id()); > + return 0; > +} > + > +static int > +freeze_other_cpus(void) > +{ > + int cpu, retval; > + > + if (!spin_trylock(&freeze_lock)) > + return -EAGAIN; > + > + printk("start freeze_other_cpus()\n"); > + ice_block = 1; > + for (cpu = 0; cpu < smp_num_cpus - 1; cpu++) { > + retval = kernel_thread(antarctica, (void *)0, 0); > + if (retval < 0) > + goto out_melt; > + } > + printk("continue freeze_other_cpus()\n"); > + return 0; > +out_melt: > + ice_block = 0; > + spin_unlock(&freeze_lock); > + return retval; > +} You don't guarantee all the other kernel_threads have started executing. Basically you need either an atomic_inc or a per-CPU flag somewhere. Philipp Rumpf