From owner-p4-projects@FreeBSD.ORG  Wed Jul 14 12:32:35 2010
Return-Path: <owner-p4-projects@FreeBSD.ORG>
Delivered-To: p4-projects@freebsd.org
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id 8557C1065676; Wed, 14 Jul 2010 12:32:35 +0000 (UTC)
Delivered-To: perforce@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 495E1106566B;
	Wed, 14 Jul 2010 12:32:35 +0000 (UTC)
	(envelope-from pebu3op@googlemail.com)
Received: from mail.net.t-labs.tu-berlin.de (mail.net.t-labs.tu-berlin.de
	[130.149.220.252])
	by mx1.freebsd.org (Postfix) with ESMTP id 0A6CB8FC17;
	Wed, 14 Jul 2010 12:32:34 +0000 (UTC)
Received: from tomtit.net.t-labs.tu-berlin.de (tomtit.net.t-labs.tu-berlin.de
	[130.149.220.28])
	by mail.net.t-labs.tu-berlin.de (Postfix) with ESMTP id 0B8DE700C81B;
	Wed, 14 Jul 2010 14:32:34 +0200 (CEST)
From: Alexander Fiveg <pebu3op@googlemail.com>
Organization: Google
To: John Baldwin <jhb@freebsd.org>
Date: Wed, 14 Jul 2010 14:32:32 +0200
User-Agent: KMail/1.9.10
References: <201007110309.o6B39Lr2057896@repoman.freebsd.org>
	<201007121013.30769.jhb@freebsd.org>
In-Reply-To: <201007121013.30769.jhb@freebsd.org>
MIME-Version: 1.0
Content-Type: text/plain;
  charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <201007141432.33140.pebu3op@googlemail.com>
Cc: Perforce Change Reviews <perforce@freebsd.org>
Subject: Re: PERFORCE change 180741 for review
X-BeenThere: p4-projects@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
Reply-To: pebu3op@googlemail.com
List-Id: p4 projects tree changes <p4-projects.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/p4-projects>,
	<mailto:p4-projects-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/p4-projects>
List-Post: <mailto:p4-projects@freebsd.org>
List-Help: <mailto:p4-projects-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/p4-projects>,
	<mailto:p4-projects-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 14 Jul 2010 12:32:35 -0000

On Monday 12 July 2010 16:13:30 you wrote:
> On Saturday, July 10, 2010 11:09:21 pm Alexandre Fiveg wrote:
> > http://p4web.freebsd.org/@@180741?ac=10
> >
> > Change 180741 by afiveg@cottonmouth on 2010/07/11 03:08:49
> >
> > 	d_mmap is eliminated from ringmap because of very strange behavior. Now:
>
> user-space process calls read(/dev/ringmap ... ) in order get physical
> addres of ring. Then by calling mmap(/dev/mem, .... ,
> offset=ring_phys_addr) the ring will be mapped into user-space.
>
> Oof, this is not appropriate.  You should use d_mmap.  Can you provide more
> details on the problems you see with d_mmap?


yes, it was a lot of problems. The first one: 
- after calling mmap(2) (in user-space) the d_mmap() (in kernel) will be 
called TWO times! In the first run of d_mmap() the current-thread can access 
the private data that was previously set by devfs_set_cdevpriv(9) in the 
d_open(). But after the first run the  d_mmap() will somehow (unexpected) 
called again. In the second run it can NOT access private data and returns 
with error in the user-space. The call of devfs_get_cdevpriv() in the second 
run of d_mmap() returned error.

It was not really a big problem for me. The data needed in the d_mmap() is 
stored in the SLIST which head is accessible through ringmap structure. But 
traverse the SLIST in order to search our data... boring :) if we can use 
devfs_* functions.


The ringmaps kernel code is in:
//depot/projects/soc2010/ringmap/current/sys/net/ringmap.c

The ringmaps user-space code:
 //depot/projects/soc2010/ringmap/current/contrib/libpcap/ringmap_pcap.c

Please tell me if you need more information from me. Probably some code 
examples ? 


Thanx for review,
Alex