Received: by oss.sgi.com id ; Tue, 20 Jun 2000 19:39:03 -0700 Received: from [203.126.247.144] ([203.126.247.144]:11680 "EHLO zsngs001") by oss.sgi.com with ESMTP id ; Tue, 20 Jun 2000 19:38:42 -0700 Received: from zsngd101.asiapac.nortel.com (actually znsgd101) by zsngs001; Wed, 21 Jun 2000 10:37:58 +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 NBKHBWW7; Wed, 21 Jun 2000 10:38:01 +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 NCLF8DJD; Wed, 21 Jun 2000 12:38:05 +1000 Received: from uow.edu.au (IDENT:akpm@localhost [127.0.0.1]) by pwold011.asiapac.nortel.com (8.9.3/8.9.3) with ESMTP id MAA27669; Wed, 21 Jun 2000 12:37:59 +1000 Message-ID: <39502A86.6C8C6FC2@uow.edu.au> Date: Wed, 21 Jun 2000 02:37:58 +0000 X-Sybari-Space: 00000000 00000000 00000000 From: Andrew Morton X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.4.0-test1-ac10 i686) X-Accept-Language: en MIME-Version: 1.0 To: Keith Owens CC: "netdev@oss.sgi.com" Subject: Re: modular net drivers, take 2 References: Your message of "Wed, 21 Jun 2000 01:18:43 GMT." <395017F3.516165AD@uow.edu.au> <6062.961552095@kao2.melbourne.sgi.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Orig: Sender: owner-netdev@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;netdev-outgoing Keith Owens wrote: > > Change every module that registers anything to make sure that they > replace the register data with stubs on exit? And make sure that all > of them do so before they sleep anywhere in module cleanup? It would > work but is it the best solution? Not when you put it that way. > The existing method of avoiding module races is beginning to look like > a dead dog. Look at the constraints we have to run under :- > > * All code that can ever call any module functions must either have a > reference count on that module or must run under the same lock as the > module unload (big kernel lock). Yes. > * Every module must be checked to see that it never sleeps before doing > MOD_INC_USE_COUNT. > * Every module must be checked to see that it never sleeps after doing > MOD_DEC_USE_COUNT. These two can be avoided by hoisting the inc/dec up into the netdevice layer. But we need to wrap dev->get_stats(), dev->ioctl(), etc with inc/dec as well.. > * Every module that registers anything must change the registered > functions in module cleanup and must do so before sleeping (new). > > That is an awful lot of opportunities to make mistakes. And forcing > lots of code to run under the big kernel lock does not scale well. I am now remembering Alexey's disparaging comments about "self-modifying code". It sucks and I'm still seeking a single, centralised fix. How about plan J (warning: inelegance approaching): Module unload is a very rare occurence, so let's penalise that and that alone. We grab the ENTIRE machine within sys_delete_module. Like, grab the big kernel lock, then wait until ALL other CPUs are spinning on the kernel lock, and then allow sys_delete_module to proceed.