Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Nov 2003 15:38:47 -0800
From:      Sean McNeil <sean@mcneil.com>
To:        Jeff Roberson <jroberson@chesapeake.net>
Cc:        freebsd-threads@freebsd.org
Subject:   Re: Losing pages from a mmap in threaded app vs. non-threaded
Message-ID:  <1069285127.4781.2.camel@blue.mcneil.com>
In-Reply-To: <20031119165234.D10222-100000@mail.chesapeake.net>
References:  <20031119165234.D10222-100000@mail.chesapeake.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Actually, what I'm doing is looking through the process map.  What I'm
seeing is that the first 8 pages are always missing.  Here is the
routine that I'm using:

static vm_map_entry_t find_entry (vm_map_t map, vm_paddr_t addr)
{
    vm_map_entry_t entry = &map->header;

    while (1)
    {
	vm_page_t page;
	vm_paddr_t paddr;
	vm_object_t object;

	if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
	{
	    vm_map_entry_t sub_entry =
		find_entry (entry->object.sub_map, addr);

	    if (sub_entry) return sub_entry;
	    goto next_entry;
	}

	object = entry->object.vm_object;

	if (object == NULL || object->type != OBJT_DEVICE) goto next_entry;

	VM_OBJECT_LOCK (object);
	TAILQ_FOREACH (page, &object->un_pager.devp.devp_pglist, pageq)
	    {
		if (VM_PAGE_TO_PHYS (page) == addr)
		{
		    VM_OBJECT_UNLOCK (object);
		    return entry;
		}
	    }
	VM_OBJECT_UNLOCK (object);

      next_entry:
	entry = entry->next;
	if (entry == &map->header) break;
    }

    return NULL;
}

I've actually tested now with memory mmap'd with an offset of both

0x40000000 and
0x04000000

same results with both.  The result being entry returned by the above
routine is NULL.

Sean

On Wed, 2003-11-19 at 13:54, Jeff Roberson wrote:
> On Wed, 19 Nov 2003, Sean McNeil wrote:
> 
> > Yes, I mentioned this in my original post.  They all have the same
> > problem.
> 
> If you mount procfs you can look through the vm map for the process.  You
> want /proc/<pid>/map I believe.  Please note that the address returned by
> your driver routine is a physical address that will be mapped by the
> kernel at a new virtual address.  User-space can pass you only the offset
> into your memory range, and not a real address.
> 
> Cheers,
> Jeff
> 
> >
> > On Wed, 2003-11-19 at 13:38, Jeff Roberson wrote:
> > > On Wed, 19 Nov 2003, Daniel Eischen wrote:
> > >
> > > > On Wed, 19 Nov 2003, Sean McNeil wrote:
> > > >
> > > > > OK, would this happen to be 8 pages typically?
> > > >
> > > > It depends; see the comment and ascii art in
> > > > src/lib/libpthread/thread/thr_alloc.c.
> > >
> > > Have you tried with libc_r, libthr, and libkse?
> > >
> > > >
> > > > --
> > > > Dan Eischen
> > > >
> > > > _______________________________________________
> > > > freebsd-threads@freebsd.org mailing list
> > > > http://lists.freebsd.org/mailman/listinfo/freebsd-threads
> > > > To unsubscribe, send any mail to "freebsd-threads-unsubscribe@freebsd.org"
> > > >
> > >
> >
> 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1069285127.4781.2.camel>