From owner-freebsd-hackers@FreeBSD.ORG Sun Jul 30 20:47:49 2006 Return-Path: X-Original-To: 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 5C1FC16A4DA for ; Sun, 30 Jul 2006 20:47:49 +0000 (UTC) (envelope-from kip.macy@gmail.com) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.182]) by mx1.FreeBSD.org (Postfix) with ESMTP id E01BF43D49 for ; Sun, 30 Jul 2006 20:47:48 +0000 (GMT) (envelope-from kip.macy@gmail.com) Received: by py-out-1112.google.com with SMTP id b36so330493pyb for ; Sun, 30 Jul 2006 13:47:48 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=CWpJ5aXn9p2q2jy3ADe1AaskMaZ5McbRl0D116jpR9Af0eOYUK5ZTUyS9gcYgf+1KiR66oB7kTbEb+0uKssO6nzXeQBc8zP/X/CzGKiG1aOAMZq1xQfc/DrbY9E8GDtgYUSXBNJmqepOy62shdHVDuTNcoCWk6NaOKo3BS1DhLg= Received: by 10.35.41.14 with SMTP id t14mr2837298pyj; Sun, 30 Jul 2006 13:47:47 -0700 (PDT) Received: by 10.35.16.20 with HTTP; Sun, 30 Jul 2006 13:47:47 -0700 (PDT) Message-ID: Date: Sun, 30 Jul 2006 13:47:47 -0700 From: "Kip Macy" To: "Divacky Roman" In-Reply-To: <20060730200354.GA82547@stud.fit.vutbr.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20060730105731.GA64955@stud.fit.vutbr.cz> <20060730200354.GA82547@stud.fit.vutbr.cz> Cc: hackers@freebsd.org Subject: Re: VM question related to faults X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: kmacy@fsmware.com List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jul 2006 20:47:49 -0000 >From kern_umtx.c: static int _do_lock(struct thread *td, struct umtx *umtx, long id, int timo) { struct umtx_q *uq; intptr_t owner; intptr_t old; int error = 0; uq = td->td_umtxq; /* * Care must be exercised when dealing with umtx structure. It * can fault on any access. */ for (;;) { /* * Try the uncontested case. This should be done in userland. */ owner = casuptr((intptr_t *)&umtx->u_owner, UMTX_UNOWNED, id); /* The acquire succeeded. */ if (owner == UMTX_UNOWNED) return (0); /* The address was invalid. */ if (owner == -1) return (EFAULT); /* If no one owns it but it is contested try to acquire it. */ if (owner == UMTX_CONTESTED) { owner = casuptr((intptr_t *)&umtx->u_owner, UMTX_CONTESTED, id | UMTX_CONTESTED); if (owner == UMTX_CONTESTED) return (0); /* The address was invalid. */ if (owner == -1) return (EFAULT); On 7/30/06, 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" >