Received: by oss.sgi.com id ; Sat, 24 Jun 2000 08:29:58 -0700 Received: from [203.126.247.144] ([203.126.247.144]:42629 "EHLO zsngs001") by oss.sgi.com with ESMTP id ; Sat, 24 Jun 2000 08:29:32 -0700 Received: from zsngd101.asiapac.nortel.com (actually znsgd101) by zsngs001; Sat, 24 Jun 2000 23:28:32 +0800 Received: from zctwb003.asiapac.nortel.com ([47.152.32.111]) by zsngd101.asiapac.nortel.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id NQ12PTT9; Sat, 24 Jun 2000 23:28:35 +0800 Received: from pwold011.asiapac.nortel.com ([47.181.193.45]) by zctwb003.asiapac.nortel.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id NCLF8NQ6; Sun, 25 Jun 2000 01:28:37 +1000 Received: from uow.edu.au (IDENT:akpm@[47.181.194.190]) by pwold011.asiapac.nortel.com (8.9.3/8.9.3) with ESMTP id BAA31811; Sun, 25 Jun 2000 01:26:12 +1000 Message-ID: <3954D42A.938A724B@uow.edu.au> Date: Sun, 25 Jun 2000 01:30:50 +1000 X-Sybari-Space: 00000000 00000000 00000000 From: Andrew Morton X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.14-15mdk i586) X-Accept-Language: en MIME-Version: 1.0 To: 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> Content-Type: multipart/mixed; boundary="------------CBB127BDC2B6A2C0991803E8" X-Orig: Sender: owner-netdev@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;netdev-outgoing This is a multi-part message in MIME format. --------------CBB127BDC2B6A2C0991803E8 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit OK. I've flung together a prototype. It doesn't immediately crash.... --------------CBB127BDC2B6A2C0991803E8 Content-Type: text/plain; charset=us-ascii; name="freeze.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="freeze.patch" --- linux-official/kernel/module.c Fri Jun 9 23:00:28 2000 +++ linux-akpm/kernel/module.c Sun Jun 25 01:15:57 2000 @@ -365,17 +365,14 @@ return res; } -asmlinkage long -sys_delete_module(const char *name_user) +static long +do_sys_delete_module(const char *name_user) { struct module *mod, *next; char *name; long error; int something_changed; - if (!capable(CAP_SYS_MODULE)) - return -EPERM; - lock_kernel(); if (name_user) { if ((error = get_mod_name(name_user, &name)) < 0) @@ -442,6 +439,75 @@ unlock_kernel(); return error; } + +#ifdef CONFIG_SMP +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; +} + +static void +melt_other_cpus(void) +{ + printk("melt_other_cpus() starts\n"); + ice_block = 0; + spin_unlock(&freeze_lock); + printk("melt_other_cpus() stops\n"); +} + +#else /* CONFIG_SMP */ + +#define freeze_other_cpus() 0 +#define melt_other_cpus() do { } while (0) +#endif + +asmlinkage long +sys_delete_module(const char *name_user) +{ + long ret; + + if (!capable(CAP_SYS_MODULE)) + return -EPERM; + + if ((ret = freeze_other_cpus())) + return ret; + + ret = do_sys_delete_module(name_user); + melt_other_cpus(); + return ret; +} + /* Query various bits about modules. */ --------------CBB127BDC2B6A2C0991803E8--