From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 31 06:12:24 2006 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 6C84C16A4DD for ; Mon, 31 Jul 2006 06:12:24 +0000 (UTC) (envelope-from admin@intron.ac) Received: from intron.ac (unknown [210.51.165.237]) by mx1.FreeBSD.org (Postfix) with ESMTP id 65A0243D66 for ; Mon, 31 Jul 2006 06:12:22 +0000 (GMT) (envelope-from admin@intron.ac) Received: from localhost (localhost [127.0.0.1]) (uid 1003) by intron.ac with local; Mon, 31 Jul 2006 14:12:20 +0800 id 00102DF1.44CD9F44.00017212 References: <20060730105731.GA64955@stud.fit.vutbr.cz> <20060730200354.GA82547@stud.fit.vutbr.cz> In-Reply-To: <20060730200354.GA82547@stud.fit.vutbr.cz> From: "Intron" To: freebsd-hackers@freebsd.org Date: Mon, 31 Jul 2006 14:12:20 +0800 Mime-Version: 1.0 Content-Type: text/plain; charset="gb2312"; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Subject: Re: VM question related to faults 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: Mon, 31 Jul 2006 06:12:24 -0000 Divacky Roman wrote: > On Sun, Jul 30, 2006 at 12:57:32PM +0200, Divacky Roman wrote: >> hi, >> >> while working on SoC linuxolator project I am in a need of this: >> >> I need to do some operation on memory like mem1 = mem1 + mem2 etc. >> where the mem1/mem2 access can trigger fault. (memory not mapped or something) > > to make it clear.. I am trying to access user-space memory from kernel. > This needs to be atomic (its an implementation of linux futexes) > > I need to check from kernel if some memory is accessible and then perform an > operation on this memory. All atomically. > > hence I need two things - function which checks wheter the memory is accessible > and something which makes it atomic (some mutex/something which prevents other > process to enter VM to unmap/etc. the memory in question) > > hope its a bit more clear now > > roman > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" The manual page mutex(9) says, No mutexes should be held (except for Giant) across functions which access memory in userspace, such as copyin(9), copyout(9), uiomove(9), fuword(9), etc. No locks are needed when calling these functions. Actually, any contents in user space should be copied into kernel space before reading them. They should also be mirrored in kernel space if necessary. Mutex(9) is sometimes too heavy, and has many limitations, while sx(9) is somewhat enough. ------------------------------------------------------------------------ From Beijing, China