[lkml]   [2007]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: mm: how to check for kernel pages
On Sun, Feb 04, 2007 at 02:57:30PM +0100, Arjan van de Ven wrote:
> On Sun, 2007-02-04 at 12:02 +0100, Michal Hocko wrote:
> > Hi,
> > is there any effective and fast way how to find out whether page
> > given by its page frame number is currenly used by (mapped by) kernel?
> what do you want to use this for? The answer to your question greatly
> depends on that...

Sorry for not being more precise. As a part of my thesis work I need to
migrate pages. I greatly use mm/migrate.c code.
I assume that not all pages can be migrated - especially those used by
kernel (where direct virtual to physical mapping is used).
So I intended something like following code:

/* Returns 0 if page is suitable to be migration source */
int check_migrate_page(struct page * page)
return PageBuddy(page) || PageCompound(page) || ...

/* Steals pfn page from its current user(s) and replace it by newly
* allocated page. pfn page structure is returned if page was migrated
* to new location (can be reused by caller) or NULL otherwise.
struct page * steal_page(unsigned long pfn)
int ret;
struct page *page, *target_page;

page = pfn_to_page(pfn);
goto bad_page;

ret = check_migrate_page(page);
goto bad_page;

target_page = alloc_pages(flags, 0);
/* uses migrate_pages function internally */
ret = do_migration(page, target_page);
goto bad_page;

/* TODO clear page frame data. */
return page;
return NULL;

Please add me to Cc, because I am not the list member.
Best regards
Michal Hocko

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2007-02-04 16:15    [W:0.051 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site