Received: by oss.sgi.com id ; Fri, 23 Jun 2000 09:48:29 -0700 Received: from dialup326.canberra.net.au ([203.33.188.198]:1035 "HELO halfway") by oss.sgi.com with SMTP id ; Fri, 23 Jun 2000 09:48:12 -0700 Received: from linuxcare.com.au (localhost [127.0.0.1]) by halfway (Postfix) with ESMTP id AA5BB8154; Sat, 24 Jun 2000 02:48:05 +1000 (EST) From: Rusty Russell To: Keith Owens , Philipp Rumpf , Andrew Morton , Alan Cox , "netdev@oss.sgi.com" Subject: Re: modular net drivers Date: Sat, 24 Jun 2000 02:48:05 +1000 Message-Id: <20000623164805.AA5BB8154@halfway> Sender: owner-netdev@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;netdev-outgoing In message <20000622174858.304CE8154@halfway> I wrote: > OK. Here is how it would work: Alternate solution to avoid module problems: Phil Rumpf and I came up with basically identical answers. It assumes that MOD_INC_USE_COUNT is always called in user context, and involves no changes to module code. 1) static volatile int freeze[NR_CPUS]; 2) sys_delete_module fires off a RT kernel thread for every other CPU: ... /* Fire off #CPUs - 1 threads */ retry: for (i = 0; i < smp_num_cpus(); i++) if (!freeze[i] && i != smp_processor_id()) goto retry; if (atomic_read(&mod->uc.use) == 0) mod->cleanup(); else err = -EBUSY; memset(freeze, 0, sizeof(freeze)); 3) Threads do: freeze[smp_processor_id()] = 1; while (freeze[smp_processor_id()]); exit That effectively freezes the other cpus, and cleanup() can sleep et al. No more races. Problems? Rusty. -- Hacking time. ------- End of Forwarded Message