Re: CVS commit: [uebayasi-xip] src/sys/miscfs/genfs

2010-11-21 Thread Masao Uebayashi
On Sun, Nov 21, 2010 at 05:07:39PM +, Masao Uebayashi wrote:
> Module Name:  src
> Committed By: uebayasi
> Date: Sun Nov 21 17:07:38 UTC 2010
> 
> Modified Files:
>   src/sys/miscfs/genfs [uebayasi-xip]: genfs_io.c
> 
> Log Message:
> Put back XIP putpages, but slightly modifed to be called from the
> generic putpages, and to call pgo_get() than a specific function.
> Without this, UVM went mad after unmount (vinval, etc.).

This might become simpler if uobj had a set of back-pointers to
vm_map_entries...


Re: CVS commit: [uebayasi-xip] src/sys/miscfs/genfs

2010-11-21 Thread Masao Uebayashi
On Sun, Nov 21, 2010 at 07:41:49AM +, Masao Uebayashi wrote:
> Module Name:  src
> Committed By: uebayasi
> Date: Sun Nov 21 07:41:49 UTC 2010
> 
> Modified Files:
>   src/sys/miscfs/genfs [uebayasi-xip]: genfs_io.c
> 
> Log Message:
> Revert XIP putpages totally.
> 
> XIP'ed uobj owns no pages; uvm_object::uo_npages is always 0,
> nothing happens.
> 
> Upper layer is responsible to unmap pmap-level mappings.

This assumption seems wrong.  More thought is needed here...

> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.36.2.58 -r1.36.2.59 src/sys/miscfs/genfs/genfs_io.c
> 
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
> 

> Modified files:
> 
> Index: src/sys/miscfs/genfs/genfs_io.c
> diff -u src/sys/miscfs/genfs/genfs_io.c:1.36.2.58 
> src/sys/miscfs/genfs/genfs_io.c:1.36.2.59
> --- src/sys/miscfs/genfs/genfs_io.c:1.36.2.58 Sun Nov 21 06:46:15 2010
> +++ src/sys/miscfs/genfs/genfs_io.c   Sun Nov 21 07:41:49 2010
> @@ -1,4 +1,4 @@
> -/*   $NetBSD: genfs_io.c,v 1.36.2.58 2010/11/21 06:46:15 uebayasi Exp $  
> */
> +/*   $NetBSD: genfs_io.c,v 1.36.2.59 2010/11/21 07:41:49 uebayasi Exp $  
> */
>  
>  /*
>   * Copyright (c) 1982, 1986, 1989, 1993
> @@ -31,7 +31,7 @@
>   */
>  
>  #include 
> -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.36.2.58 2010/11/21 06:46:15 
> uebayasi Exp $");
> +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.36.2.59 2010/11/21 07:41:49 
> uebayasi Exp $");
>  
>  #include "opt_xip.h"
>  
> @@ -58,12 +58,6 @@
>  #include 
>  #include 
>  
> -#ifdef XIP
> -static int genfs_do_getpages_xip_io(struct vnode *, voff_t, struct vm_page 
> **,
> -int *, int, vm_prot_t, int, int, const int);
> -static int genfs_do_putpages_xip(struct vnode *, off_t, off_t, int,
> -struct vm_page **);
> -#endif
>  static int genfs_do_directio(struct vmspace *, vaddr_t, size_t, struct vnode 
> *,
>  off_t, enum uio_rw);
>  static void genfs_dio_iodone(struct buf *);
> @@ -940,100 +934,6 @@
>   return error;
>  }
>  
> -#ifdef XIP
> -/*
> - * genfs_do_getpages_xip_io
> - *  Return "direct pages" of XIP vnode.  The block addresses of XIP
> - *  vnode pages are returned back to the VM fault handler as the
> - *   actually mapped physical addresses.
> - */
> -static int
> -genfs_do_getpages_xip_io(
> - struct vnode *vp,
> - voff_t origoffset,
> - struct vm_page **pps,
> - int *npagesp,
> - int centeridx,
> - vm_prot_t access_type,
> - int advice,
> - int flags,
> - const int orignmempages)
> -{
> - const int fs_bshift = vp2fs_bshift(vp);
> - const int dev_bshift = vp2dev_bshift(vp);
> - const int fs_bsize = 1 << fs_bshift;
> -
> - int error;
> - off_t off;
> - int i;
> -
> - UVMHIST_FUNC("genfs_do_getpages_xip_io"); UVMHIST_CALLED(ubchist);
> -
> - KASSERT(((flags & PGO_GLOCKHELD) != 0) || genfs_node_rdlocked(vp));
> -
> -#ifdef UVMHIST
> - const off_t startoffset = trunc_blk(origoffset);
> - const off_t endoffset = round_blk(origoffset + PAGE_SIZE * 
> orignmempages);
> -#endif
> -
> - const int ridx = (origoffset - startoffset) >> PAGE_SHIFT;
> -
> - UVMHIST_LOG(ubchist,
> - "ridx=%d xip npages=%d startoff=0x%lx endoff=0x%lx",
> - ridx, orignmempages, (long)startoffset, (long)endoffset);
> -
> - off = origoffset;
> - for (i = ridx; i < ridx + orignmempages; i++) {
> - daddr_t blkno;
> - int run;
> - struct vnode *devvp;
> -
> - KASSERT((off - origoffset) >> PAGE_SHIFT == i - ridx);
> -
> - const daddr_t lbn = trunc_blk(off) >> fs_bshift;
> -
> - error = VOP_BMAP(vp, lbn, &devvp, &blkno, &run);
> - KASSERT(error == 0);
> - UVMHIST_LOG(ubchist, "xip VOP_BMAP: lbn=%ld blkno=%ld run=%d",
> - (long)lbn, (long)blkno, run, 0);
> -
> - const daddr_t blk_off = blkno << dev_bshift;
> - const daddr_t fs_off = origoffset - (lbn << fs_bshift);
> -
> - /*
> -  * XIP page metadata assignment
> -  * - Unallocated block is redirected to the dedicated zero'ed
> -  *   page.
> -  */
> - if (blkno < 0) {
> - panic("XIP hole is not supported yet!");
> - } else {
> - KASSERT(off - origoffset == (i - ridx) << PAGE_SHIFT);
> -
> - const daddr_t pg_off = (i - ridx) << PAGE_SHIFT;
> -
> - struct vm_page *pg;
> -
> - UVMHIST_LOG(ubchist,
> - "xip blk_off=%lx fs_off=%lx pg_off=%lx",
> - (long)blk_off, (long)fs_off, (long)pg_off, 0);
> -
> - pg = uvn_findpage_xip(devvp, &vp->v_uobj,
> - blk_off + fs_off + pg_off);
> - KASSERT(pg != NULL);
> - UVMHIST_LOG(ubchist,
> - 

Re: CVS commit: [uebayasi-xip] src/sys/miscfs/genfs

2010-03-25 Thread Masao Uebayashi
On Thu, Mar 18, 2010 at 1:12 AM, Masao Uebayashi  wrote:
> On Tue, Mar 16, 2010 at 03:52:26AM +, YAMAMOTO Takashi wrote:
>> > Why not adding VOP_GETPAGES_XIP - because XIP is almost transparent to
>> > filesystems.  The difference between XIP or not is only where to get pages,
>> > which is beyond filesystem's task.
>>
>> it doesn't sound convincing to me, given that you have a separate copy
>> of genfs_getpages for xip.
>
> My intent is to merge it into genfs_getpages().  But that'll involve changes
> to genfs_getpages(), and it's beyond my scope at the moment.  I put comments
> to reflect my intent that I want to merge two copies.
>
> I hope this answers your questions.

I'd also point out that genfs_io.c already has two copies of
genfs_do_io() (itself and in genfs_getpages()).  I'd want to merge
these two first, but this is beyond the XIP branch.  Merging these two
+ _getpages_xip() will be done very slowly in the future...

Masao


Re: CVS commit: [uebayasi-xip] src/sys/miscfs/genfs

2010-03-17 Thread Masao Uebayashi
On Tue, Mar 16, 2010 at 03:52:26AM +, YAMAMOTO Takashi wrote:
> > Why not adding VOP_GETPAGES_XIP - because XIP is almost transparent to
> > filesystems.  The difference between XIP or not is only where to get pages,
> > which is beyond filesystem's task.
> 
> it doesn't sound convincing to me, given that you have a separate copy
> of genfs_getpages for xip.

My intent is to merge it into genfs_getpages().  But that'll involve changes
to genfs_getpages(), and it's beyond my scope at the moment.  I put comments
to reflect my intent that I want to merge two copies.

I hope this answers your questions.

Masao

-- 
Masao Uebayashi / Tombi Inc. / Tel: +81-90-9141-4635


Re: CVS commit: [uebayasi-xip] src/sys/miscfs/genfs

2010-03-15 Thread YAMAMOTO Takashi
[add cc:tech-kern]

hi,

>> what's the point of implementing it in the single VOP?
>> ie. how is it better than having VOP_GETPAGES_XIP and pgo_get_xip?
> 
> Why not adding VOP_GETPAGES_XIP - because XIP is almost transparent to
> filesystems.  The difference between XIP or not is only where to get pages,
> which is beyond filesystem's task.

it doesn't sound convincing to me, given that you have a separate copy
of genfs_getpages for xip.

YAMAMOTO Takashi

> 
> Why not adding pgo_get_xip - because I didn't think it's worth adding it.
> XIP is transparent to other UVM pagers.  (And only used by vnode anyway.)
> 
> Why not done in pgo_get (uvn_get) - it's possible.  My 1st implementation
> did the task in uvn_get().  I've changed it because what it does is close to
> (generic) genfs_getpages().
> 
>> is it allowed to return both of "device pages" and normal pages mixed
>> for a request?
> 
> That should work.  Once vm_page *[] are filled and passed back to UVM, they're
> deal with one-by-one.
> 
> Masao
> 
> -- 
> Masao Uebayashi / Tombi Inc. / Tel: +81-90-9141-4635


Re: CVS commit: [uebayasi-xip] src/sys/miscfs/genfs

2010-02-23 Thread Masao Uebayashi
> what's the point of implementing it in the single VOP?
> ie. how is it better than having VOP_GETPAGES_XIP and pgo_get_xip?

Why not adding VOP_GETPAGES_XIP - because XIP is almost transparent to
filesystems.  The difference between XIP or not is only where to get pages,
which is beyond filesystem's task.

Why not adding pgo_get_xip - because I didn't think it's worth adding it.
XIP is transparent to other UVM pagers.  (And only used by vnode anyway.)

Why not done in pgo_get (uvn_get) - it's possible.  My 1st implementation
did the task in uvn_get().  I've changed it because what it does is close to
(generic) genfs_getpages().

> is it allowed to return both of "device pages" and normal pages mixed
> for a request?

That should work.  Once vm_page *[] are filled and passed back to UVM, they're
deal with one-by-one.

Masao

-- 
Masao Uebayashi / Tombi Inc. / Tel: +81-90-9141-4635


Re: CVS commit: [uebayasi-xip] src/sys/miscfs/genfs

2010-02-23 Thread YAMAMOTO Takashi
hi,

> Module Name:  src
> Committed By: uebayasi
> Date: Thu Feb 11 06:23:04 UTC 2010
> 
> Modified Files:
>   src/sys/miscfs/genfs [uebayasi-xip]: genfs_io.c
> 
> Log Message:
> genfs_getpages() for XIP.
> 
> Pages are directly mappable, and always there.  What we need to do here is
> to address filesystem blocks and tell those addresses back to the fault
> handler by encoding the physical addresses in struct vm_page * pointers.
> 
> (I hate code duplication.  What can I do?)

what's the point of implementing it in the single VOP?
ie. how is it better than having VOP_GETPAGES_XIP and pgo_get_xip?
is it allowed to return both of "device pages" and normal pages mixed
for a request?

YAMAMOTO Takashi

> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.36 -r1.36.2.1 src/sys/miscfs/genfs/genfs_io.c
> 
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.


CVS commit: [uebayasi-xip] src/sys/miscfs/genfs

2010-02-22 Thread Masao Uebayashi
Module Name:src
Committed By:   uebayasi
Date:   Tue Feb 23 07:46:28 UTC 2010

Modified Files:
src/sys/miscfs/genfs [uebayasi-xip]: genfs_io.c

Log Message:
genfs_do_getpages_xip: Drop vmobjlock before calling VOP_BMAP, otherwise
deadlock.  No idea how this worked for me before.

Directly call uvm_phys_to_vm_page_device() to make a device page cookie.


To generate a diff of this commit:
cvs rdiff -u -r1.36.2.1 -r1.36.2.2 src/sys/miscfs/genfs/genfs_io.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [uebayasi-xip] src/sys/miscfs/genfs

2010-02-10 Thread Masao Uebayashi
Module Name:src
Committed By:   uebayasi
Date:   Thu Feb 11 06:23:04 UTC 2010

Modified Files:
src/sys/miscfs/genfs [uebayasi-xip]: genfs_io.c

Log Message:
genfs_getpages() for XIP.

Pages are directly mappable, and always there.  What we need to do here is
to address filesystem blocks and tell those addresses back to the fault
handler by encoding the physical addresses in struct vm_page * pointers.

(I hate code duplication.  What can I do?)


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.36.2.1 src/sys/miscfs/genfs/genfs_io.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.