Hi Andrew, Hi William, On Fri, Nov 15, 2002 at 01:08:38PM -0800, Andrew Morton wrote: > Ingo Oeser wrote: > > > > ... > > I envision the following usage: > > > > setup(&page_walk,...); /* currently done explicitly on stack */ > > walk_user_pages(&page_walk); > Good. The callers shouldn't have to know how to initialise the > state structure. The problem is: Sometimes they know it and duplicate the work. But I'll tackle that next time. > I'd say just keep it to "pull the user pagetable access code out of > memory.c". As much as you can, but not unrelated things. One > concept per file would be nice. Ok, so I created {mm/,include/linux/}page_walk.[ch] > > All improvements in that direction have only been with block devices > > in mind so far. I even don't see how I could improve the usage in > > fs/dio.c, because it might sleep very long, so I can't use a page > > walker for it (which needs the mmap_sem). > > Well I had plans there to reuse the page walker structure. So it > would become a big stateful thing which you just feed into the > walker engine and it spits out pages. With the callback page-processor > being able to return information such as "OK, that's enough pages > for now, let's start some IO". The walk_user_pages is actually made for this. Return values: 1 -> The walker was satisfied 0 -> No more pages there Negative -> some error occured, and we cleaned already up. So it should be quite simple to use and simplify all the error handling, too. The code got shorter by using a struct and stack usage looks smaller. Most of the page walking users got simpler and also the hugetlb code looks much better now. The diffstat shows 554 deletions and 224 additions, which is not too bad for a cleanup, which also adds a feature. BTW: make_pages_present needs a rewrite, because it duplicates work from its callers. The only non-trivial user is mm/mremap.c, the rest of it I could do. Comments are VERY welcome. bzip2ed patch attached. Regards Ingo Oeser -- Science is what we can tell a computer. Art is everything else. --- D.E.Knuth