From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 23 09:41:50 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 51C7616A41C for ; Thu, 23 Jun 2005 09:41:50 +0000 (GMT) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from comsys.ntu-kpi.kiev.ua (comsys.ntu-kpi.kiev.ua [195.245.194.142]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4781B43D48 for ; Thu, 23 Jun 2005 09:41:25 +0000 (GMT) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from pm514-9.comsys.ntu-kpi.kiev.ua (pm514-9.comsys.ntu-kpi.kiev.ua [10.18.54.109]) (authenticated bits=0) by comsys.ntu-kpi.kiev.ua (8.12.10/8.12.10) with ESMTP id j5N9lDFl050916 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 23 Jun 2005 12:47:16 +0300 (EEST) Received: by pm514-9.comsys.ntu-kpi.kiev.ua (Postfix, from userid 1000) id EC3C083; Thu, 23 Jun 2005 12:39:40 +0300 (EEST) Date: Thu, 23 Jun 2005 12:39:40 +0300 From: Andrey Simonenko To: freebsd-hackers@freebsd.org Message-ID: <20050623093940.GA338@pm514-9.comsys.ntu-kpi.kiev.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.1i X-Spam-Status: No, score=-4.5 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.0.1 X-Spam-Checker-Version: SpamAssassin 3.0.1 (2004-10-22) on comsys.ntu-kpi.kiev.ua X-Virus-Scanned: ClamAV 0.82/950/Wed Jun 22 03:48:34 2005 on comsys.ntu-kpi.kiev.ua X-Virus-Status: Clean Subject: Question about synchronization in socow_setup() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jun 2005 09:41:50 -0000 Hello, Can somebody explain how socow_setup() synchronizes access to the page it wants to COW: 99 s = splvm(); 100 /* 101 * verify page is mapped & not already wired for i/o 102 */ 103 socow_stats.attempted++; 104 pa=pmap_extract(map->pmap, uva); 105 if(!pa) { 106 socow_stats.fail_not_mapped++; 107 splx(s); 108 return(0); 109 } 110 pp = PHYS_TO_VM_PAGE(pa); 111 /* 112 * set up COW 113 */ 114 vm_page_lock_queues(); 115 vm_page_cowsetup(pp); How socow_setup() is sure, that pp is valid after pmap_extract() (line 104) and before vm_page_lock_queues() (line 114) ? Another question, why socow_setup() uses vm_page_wire() instead of pmap_extract_and_hold() ? When a page should be held and when it should be wired? According the comment for vm_page_hold(), a page should be held only for "*very* temporary holding", so when one decides what to use (vm_page_hold() or vm_page_wire()), he should decide what will be more effective: simply increment m->hold_count or increment m->wire_count and remove m from the page queue (so this page will be invisible for vm_pageout_scan()). Am I right?