From owner-freebsd-current Tue Oct 6 07:09:11 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA21002 for freebsd-current-outgoing; Tue, 6 Oct 1998 07:09:11 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from tim.xenologics.com (tim.xenologics.com [194.77.5.24]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA20987 for ; Tue, 6 Oct 1998 07:09:06 -0700 (PDT) (envelope-from seggers@semyam.dinoco.de) Received: (from uucp@localhost) by tim.xenologics.com (8.8.5/8.8.8) with UUCP id QAA05838 for freebsd-current@FreeBSD.ORG; Tue, 6 Oct 1998 16:05:11 +0200 (MET DST) Received: from semyam.dinoco.de (semyam.dinoco.de [127.0.0.1]) by semyam.dinoco.de (8.9.1/8.8.8) with ESMTP id PAA05872; Tue, 6 Oct 1998 15:00:22 +0200 (CEST) (envelope-from seggers@semyam.dinoco.de) Message-Id: <199810061300.PAA05872@semyam.dinoco.de> To: freebsd-current@FreeBSD.ORG cc: seggers@semyam.dinoco.de Subject: Text: Locking in the kernel's VM subsystem Date: Tue, 06 Oct 1998 15:00:21 +0200 From: Stefan Eggers Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Surely someone knows more than I do about this but noone seems to have written a few bits about locking in the VM subsystem, yet. ;-) So this is a first and surely in many places incorrect description of how it is supposed to work. Comments and corrections welcome. Stefan. ---------------------------------------------------------------------- Locking in the VM subsystem In the following text o denotes a VM object, p is a VM page. splvm()/splx() Similar to the other spl...() calls. o->paging_in_progress Indicator for paging going on on pages within this object. p->busy/vm_page_io_start()/vm_page_io_finish() vm_page_io_start() marks a page as busy for I/O use - usually this is happening due to filesystem accesses. The reverse operation is vm_page_io_finish() which also does the wakeup of processes waiting for the page. NOTE: This is different from setting the busy flag! You have to check both if you want to make sure a page is really non-busy. p->flags & PG_BUSY/vm_page_busy()/vm_page_wakeup() This marks a page as busy for some operation. Using the functions ensures the operation of setting/clearing the flags is atomar and also does a wakeup of processes waiting for this page to become non-busy when necessary. NOTE: This is different from setting the busy counter! You have to check both if you want to make sure a page is really non-busy. p->hold_count/vm_page_hold()/vm_page_unhold() Used (if non-zero) to indicate someone has a reference to this page. One better doesn't make this reference invalid in any way. p->wire_count Wired pages are those which don't get paged anymore. The are also fixed at their position. Useful for making something unmoveable during I/O for example. vm_page_flag_set()/vm_page_flag_clear() Generic flag set/clear operation used for example by vm_page_busy()/ vm_page_wakeup(). Ensures that the operation is atomic. ---------------------------------------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message