From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Nick Piggin <npiggin@suse.de>
Cc: keith.packard@intel.com, eric@anholt.net, hugh@veritas.com,
hch@infradead.org, airlied@linux.ie, jbarnes@virtuousgeek.org,
thomas@tungstengraphics.com, dri-devel@lists.sourceforge.net,
Linux Memory Management List <linux-mm@kvack.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [patch] mm: pageable memory allocator (for DRM-GEM?)
Date: Thu, 25 Sep 2008 17:45:13 +0900 [thread overview]
Message-ID: <20080925174513.fd44bc08.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20080923091017.GB29718@wotan.suse.de>
On Tue, 23 Sep 2008 11:10:17 +0200
Nick Piggin <npiggin@suse.de> wrote:
> +void *pageable_vmap_object(pgobj_t *object, unsigned long start, unsigned long end)
> +{
> + struct file *filp = (struct file *)object;
> + struct address_space *mapping = filp->f_dentry->d_inode->i_mapping;
> + unsigned int offset = start & ~PAGE_CACHE_MASK;
> + pgoff_t first, last, i;
> + struct page **pages;
> + int nr;
> + void *ret;
> +
> + BUG_ON(start >= end);
> +
> + first = start / PAGE_SIZE;
> + last = DIV_ROUND_UP(end, PAGE_SIZE);
> + nr = last - first;
> +
> +#ifndef CONFIG_HIGHMEM
> + if (nr == 1) {
> + struct page *page;
> +
> + rcu_read_lock();
> + page = radix_tree_lookup(&mapping->page_tree, first);
> + rcu_read_unlock();
> + BUG_ON(!page);
> + BUG_ON(page_count(page) < 2);
> +
> + ret = page_address(page);
> +
> + goto out;
> + }
> +#endif
> +
> + pages = kmalloc(sizeof(struct page *) * nr, GFP_KERNEL);
> + if (!pages)
> + return NULL;
> +
> + for (i = first; i < last; i++) {
> + struct page *page;
> +
> + rcu_read_lock();
> + page = radix_tree_lookup(&mapping->page_tree, i);
> + rcu_read_unlock();
> + BUG_ON(!page);
> + BUG_ON(page_count(page) < 2);
> +
> + pages[i] = page;
> + }
> +
> + ret = vmap(pages, nr, VM_MAP, PAGE_KERNEL);
> + kfree(pages);
> + if (!ret)
> + return NULL;
> +
> +out:
> + return ret + offset;
> +}
> +
> +void pageable_vunmap_object(pgobj_t *object, void *ptr, unsigned long start, unsigned long end)
> +{
> +#ifndef CONFIG_HIGHMEM
> + pgoff_t first, last;
> + int nr;
> +
> + BUG_ON(start >= end);
> +
> + first = start / PAGE_SIZE;
> + last = DIV_ROUND_UP(end, PAGE_SIZE);
> + nr = last - first;
> + if (nr == 1)
> + return;
> +#endif
> +
> + vunmap((void *)((unsigned long)ptr & PAGE_CACHE_MASK));
> +}
> +
Some questions..
- could you use GFP_HIGHUSER rather than GFP_HIGHUSER_MOVABLE ?
I think setting mapping_gfp_mask() (address_space->flags) to appropriate
value is enough.
- Can we mlock pages while it's vmapped ? (or Reserve and remove from LRU)
Then, new split-lru can ignore these pages while there are mapped. over-killing ?
- Doesn't we need to increase page->mapcount ?
- memory resource contorller should account these pages ?
(Maybe this is question to myself....)
Thanks,
-Kame
next prev parent reply other threads:[~2008-09-25 8:45 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-23 9:10 Nick Piggin
2008-09-23 10:21 ` Thomas Hellström
2008-09-23 11:31 ` Jerome Glisse
2008-09-23 13:18 ` Christoph Lameter
2008-09-25 0:18 ` Nick Piggin
2008-09-25 7:19 ` Thomas Hellström
2008-09-25 14:38 ` Keith Packard
2008-09-25 15:39 ` Thomas Hellström
2008-09-25 22:41 ` Dave Airlie
2008-09-23 15:50 ` Keith Packard
2008-09-23 18:29 ` Jerome Glisse
2008-09-25 0:30 ` Nick Piggin
2008-09-25 1:20 ` Keith Packard
2008-09-25 2:30 ` Nick Piggin
2008-09-25 2:43 ` Keith Packard
2008-09-25 3:07 ` Nick Piggin
2008-09-25 6:16 ` Keith Packard
2008-09-25 8:45 ` KAMEZAWA Hiroyuki [this message]
2008-09-30 1:10 ` Eric Anholt
2008-10-02 17:15 ` Jesse Barnes
2008-10-03 5:17 ` Keith Packard
2008-10-03 6:40 ` Nick Piggin
2008-09-23 9:10 Nick Piggin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080925174513.fd44bc08.kamezawa.hiroyu@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.sourceforge.net \
--cc=eric@anholt.net \
--cc=hch@infradead.org \
--cc=hugh@veritas.com \
--cc=jbarnes@virtuousgeek.org \
--cc=keith.packard@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=npiggin@suse.de \
--cc=thomas@tungstengraphics.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox