本文整理汇总了C++中PageReserved函数的典型用法代码示例。如果您正苦于以下问题:C++ PageReserved函数的具体用法?C++ PageReserved怎么用?C++ PageReserved使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PageReserved函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: remap_pte_range
/*
* maps a range of physical memory into the requested pages. the old
* mappings are removed. any references to nonexistent pages results
* in null mappings (currently treated as "copy-on-access")
*/
static inline void remap_pte_range(pte_t * pte, unsigned long address, unsigned long size,
unsigned long offset, pgprot_t prot)
{
unsigned long end;
address &= ~PMD_MASK;
end = address + size;
if (end > PMD_SIZE)
end = PMD_SIZE;
do {
pte_t oldpage = *pte;
pte_clear(pte);
if (offset >= high_memory || PageReserved(mem_map+MAP_NR(offset)))
set_pte(pte, mk_pte(offset, prot));
forget_pte(oldpage);
address += PAGE_SIZE;
offset += PAGE_SIZE;
pte++;
} while (address < end);
}
开发者ID:shattered,项目名称:linux-m68k,代码行数:25,代码来源:memory.c
示例2: mem_init
/*
* transfer all the memory from the bootmem allocator to the runtime allocator
*/
void __init mem_init(void)
{
int codesize, reservedpages, datasize, initsize;
int tmp;
if (!mem_map)
BUG();
#define START_PFN (contig_page_data.bdata->node_min_pfn)
#define MAX_LOW_PFN (contig_page_data.bdata->node_low_pfn)
max_mapnr = num_physpages = MAX_LOW_PFN - START_PFN;
high_memory = (void *) __va(MAX_LOW_PFN * PAGE_SIZE);
/* clear the zero-page */
memset(empty_zero_page, 0, PAGE_SIZE);
/* this will put all low memory onto the freelists */
totalram_pages += free_all_bootmem();
reservedpages = 0;
for (tmp = 0; tmp < num_physpages; tmp++)
if (PageReserved(&mem_map[tmp]))
reservedpages++;
codesize = (unsigned long) &_etext - (unsigned long) &_stext;
datasize = (unsigned long) &_edata - (unsigned long) &_etext;
initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
printk(KERN_INFO
"Memory: %luk/%luk available"
" (%dk kernel code, %dk reserved, %dk data, %dk init,"
" %ldk highmem)\n",
nr_free_pages() << (PAGE_SHIFT - 10),
max_mapnr << (PAGE_SHIFT - 10),
codesize >> 10,
reservedpages << (PAGE_SHIFT - 10),
datasize >> 10,
initsize >> 10,
totalhigh_pages << (PAGE_SHIFT - 10));
}
开发者ID:12019,项目名称:linux-2.6.34-ts471x,代码行数:44,代码来源:init.c
示例3: _phymem_pages_proc_show
static int _phymem_pages_proc_show(struct seq_file *m, void *v)
{
int free = 0, total = 0, reserved = 0;
int other = 0, shared = 0, cached = 0, slab = 0, node, i;
struct meminfo * mi = &meminfo;
for_each_bank (i,mi) {
struct membank *bank = &mi->bank[i];
unsigned int pfn1, pfn2;
struct page *page, *end;
pfn1 = bank_pfn_start(bank);
pfn2 = bank_pfn_end(bank);
page = pfn_to_page(pfn1);
end = pfn_to_page(pfn2 - 1) + 1;
do {
total++;
if (PageReserved(page))
reserved++;
else if (PageSwapCache(page))
cached++;
else if (PageSlab(page))
slab++;
else if (page_count(page) > 1)
shared++;
else if (!page_count(page))
free++;
else
other++;
page++;
}while (page < end);
}
seq_printf(m, "pages of RAM %d\n", total);
seq_printf(m, "free pages %d\n", free);
seq_printf(m, "reserved pages %d\n", reserved);
seq_printf(m, "slab pages %d\n", slab);
seq_printf(m, "pages shared %d\n", shared);
seq_printf(m, "pages swap cached %d\n", cached);
seq_printf(m, "other pages %d\n", other);
return 0;
}
开发者ID:NhlalukoG,项目名称:android_kernel_samsung_goyave3g,代码行数:41,代码来源:proc_phymem.c
示例4: si_meminfo
void si_meminfo(struct sysinfo *val)
{
int i;
i = MAP_NR(high_memory);
val->totalram = 0;
val->sharedram = 0;
val->freeram = nr_free_pages << PAGE_SHIFT;
val->bufferram = buffermem;
while (i-- > 0) {
if (PageReserved(mem_map+i))
continue;
val->totalram++;
if (!atomic_read(&mem_map[i].count))
continue;
val->sharedram += atomic_read(&mem_map[i].count) - 1;
}
val->totalram <<= PAGE_SHIFT;
val->sharedram <<= PAGE_SHIFT;
return;
}
开发者ID:chinnyannieb,项目名称:empeg-hijack,代码行数:21,代码来源:init.c
示例5: default_init_memmap
static void
default_init_memmap(struct Page *base, size_t n) {
assert(n > 0);
// n是页数
struct Page *p = base;
for (; p != base + n; p ++) {
assert(PageReserved(p));
p->flags = p->property = 0;
SetPageProperty(p);
set_page_ref(p, 0); // 引用计数设置为0
// 也就是在free_list的前面插入,不过考虑到这是一个双向链表,所以实际的意思是,插到链表的尾部
list_add_before(&free_list, &(p->page_link));
}
// 因为base是头表
// property这个玩意只有在free block首地址对应的Page有用,其余都被设置为了0
// 用于指示这个free block一共有多少个free page
base->property = n; // 可用的页面数是n
SetPageProperty(base); // base所在的页面为头表
nr_free += n; // 空闲的页面数目增加了n
//list_add(&free_list, &(base->page_link)); // 添加到free_list的头部
}
开发者ID:lishuhuakai,项目名称:CS,代码行数:21,代码来源:default_pmm.c
示例6: si_meminfo
void si_meminfo(struct sysinfo *val)
{
unsigned long i;
i = (high_memory - PAGE_OFFSET) >> PAGE_SHIFT;
val->totalram = 0;
val->sharedram = 0;
val->freeram = nr_free_pages << PAGE_SHIFT;
val->bufferram = buffermem;
while (i-- > 0) {
if (PageReserved(mem_map+i))
continue;
val->totalram++;
if (!mem_map[i].count)
continue;
val->sharedram += mem_map[i].count-1;
}
val->totalram <<= PAGE_SHIFT;
val->sharedram <<= PAGE_SHIFT;
return;
}
开发者ID:robacklin,项目名称:uclinux-linux,代码行数:21,代码来源:init.c
示例7: default_free_pages
static void default_free_pages(struct Page *base, size_t n) {
assert(n > 0);
struct Page *p = base;
for (; p != base + n; p ++) {
assert(!PageReserved(p) && !PageProperty(p));
p->flags = 0;
set_page_ref(p, 0);
}
base->property = n;
SetPageProperty(base);
list_entry_t *le = list_next(&free_list);
while (le != &free_list) {
p = le2page(le, page_link);
le = list_next(le);
if (base + base->property == p) {
base->property += p->property;
ClearPageProperty(p);
list_del(&(p->page_link));
}
else if (p + p->property == base) {
p->property += base->property;
ClearPageProperty(base);
base = p;
list_del(&(p->page_link));
}
}
nr_free += n;
//list_add(&free_list, &(base->page_link));
list_entry_t *curr=&free_list;
while((curr=list_next(curr))!=&free_list){
struct Page *currp=le2page(curr,page_link);
if(p<currp){
list_add_before(curr,&(base->page_link));
break;
}
}
if(curr==&free_list){
list_add_before(curr,&(base->page_link));
}
}
开发者ID:Renkai,项目名称:ucore_lab,代码行数:40,代码来源:default_pmm.c
示例8: default_free_pages
static void
default_free_pages(struct Page *base, size_t n) {
assert(n > 0);
struct Page *p = base;
for (; p != base + n; p ++) {
assert(PageReserved(p) && !PageProperty(p));
p->flags = 0;
set_page_ref(p, 0);
}
base->property = n;
SetPageProperty(base);
struct Page* tempPG = base;
for (; tempPG != base + n; tempPG++) {
ClearPageReserved(tempPG);
SetPageProperty(tempPG);
}
list_entry_t *le = list_next(&free_list);
while (le != &free_list) {
p = le2page(le, page_link);
le = list_next(le);
if (base + base->property == p) {
base->property += p->property;
p->property = 0;
list_del(&(p->page_link));
}
else if (p + p->property == base) {
p->property += base->property;
base->property = 0;
list_del(&(p->page_link));
base = p;
}
}
nr_free += n;
list_entry_t* rank = &free_list;
while((rank=list_next(rank)) != &free_list) {
if(le2page(rank, page_link) > base)
break;
}
list_add_before(rank, &(base->page_link));
}
开发者ID:dpatrickx,项目名称:course-ucore-lab,代码行数:40,代码来源:default_pmm.c
示例9: show_mem
void show_mem(void)
{
int free = 0, total = 0, reserved = 0;
int shared = 0, cached = 0, slab = 0, node, i;
struct meminfo * mi = &meminfo;
printk("Mem-info:\n");
show_free_areas();
printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
for_each_online_node(node) {
pg_data_t *n = NODE_DATA(node);
struct page *map = n->node_mem_map - n->node_start_pfn;
for_each_nodebank (i,mi,node) {
unsigned int pfn1, pfn2;
struct page *page, *end;
pfn1 = __phys_to_pfn(mi->bank[i].start);
pfn2 = __phys_to_pfn(mi->bank[i].size + mi->bank[i].start);
page = map + pfn1;
end = map + pfn2;
do {
total++;
if (PageReserved(page))
reserved++;
else if (PageSwapCache(page))
cached++;
else if (PageSlab(page))
slab++;
else if (!page_count(page))
free++;
else
shared += page_count(page) - 1;
page++;
} while (page < end);
}
}
开发者ID:cilynx,项目名称:dd-wrt,代码行数:40,代码来源:init.c
示例10: mark_dirty_kiobuf
void mark_dirty_kiobuf(struct kiobuf *iobuf, int bytes)
{
int index, offset, remaining;
struct page *page;
index = iobuf->offset >> PAGE_SHIFT;
offset = iobuf->offset & ~PAGE_MASK;
remaining = bytes;
if (remaining > iobuf->length)
remaining = iobuf->length;
while (remaining > 0 && index < iobuf->nr_pages) {
page = iobuf->maplist[index];
if (!PageReserved(page))
set_page_dirty(page);
remaining -= (PAGE_SIZE - offset);
offset = 0;
index++;
}
}
开发者ID:ProjectZeroSlackr,项目名称:linux-2.4.32-ipod,代码行数:22,代码来源:memory.c
示例11: default_free_pages
static void default_free_pages(struct Page* base, size_t n) {
assert(0 < n);
struct Page* p = base;
for (; p != base + n; ++p) {
assert(!PageReserved(p) && !PageProperty(p));
p->flags = 0;
set_page_ref(p, 0);
}
base->property = n;
SetPageProperty(base);
list_entry_t* le = list_next(&free_list);
// Find insertion position
while (le2page(le, page_link) < base && le != &free_list) {
le = list_next(le);
}
le = list_prev(le);
// Insert into list
list_add(le, &(base->page_link));
// Merge previous one
p = le2page(le, page_link);
if (p + p->property == base) {
p->property += base->property;
ClearPageProperty(base);
base->property = 0;
list_del(&(base->page_link));
base = p;
}
// Merge next one
if (list_next(&(base->page_link)) != &free_list) {
p = le2page(list_next(&(base->page_link)), page_link);
if (base + base->property == p) {
base->property += p->property;
ClearPageProperty(p);
p->property = 0;
list_del(&(p->page_link));
}
}
nr_free += n;
}
开发者ID:hotpxl,项目名称:ucore-code,代码行数:39,代码来源:default_pmm.c
示例12: Jcmd_mem
/*
* Show free area list (used inside shift_scroll-lock stuff)
* We also calculate the percentage fragmentation. We do this by counting the
* memory on each free list with the exception of the first item on the list.
*/
int Jcmd_mem(char *arg1, char *arg2) {
unsigned long order, flags;
unsigned long total = 0;
spin_lock_irqsave(&free_area_lock, flags);
for (order = 0; order < NR_MEM_LISTS; order++) {
struct page * tmp;
unsigned long nr = 0;
for (tmp = free_mem_area[order].next;
tmp != memory_head(free_mem_area+order); tmp = tmp->next) {
nr++;
}
total += nr << order;
ut_printf("%d(%d): count:%d static count:%d total:%d (%dM)\n", order,1<<order, nr,
free_mem_area[order].stat_count, (nr << order), ((nr << order)*PAGE_SIZE)/(1024*1024));
}
spin_unlock_irqrestore(&free_area_lock, flags);
ut_printf("total Free pages = %d (%dM) Actual pages: %d (%dM) pagecachesize: %dM , freepages:%d\n", total, (total * 4) / 1024,g_stat_mem_size/PAGE_SIZE,g_stat_mem_size/(1024*1024),g_pagecache_size/(1024*1024),g_nr_free_pages);
int slab=0;
int referenced=0;
int reserved=0;
int dma=0;
unsigned long va_end=(unsigned long)__va(g_phy_mem_size);
page_struct_t *p;
p = g_mem_map + MAP_NR(va_end);
do {
--p;
if (PageReserved(p)) reserved++;
if (PageDMA(p)) dma++;
if (PageReferenced(p))referenced++;
if (PageSlab(p)) slab++;
} while (p > g_mem_map);
ut_printf(" reserved :%d(%dM) referenced:%d dma:%d slab:%d stat_allocs:%d stat_frees: %d\n\n",reserved,(reserved*PAGE_SIZE)/(1024*1024),referenced,dma,slab,stat_allocs,stat_frees);
if ((arg1 != 0) && (ut_strcmp(arg1,"all")==0))
Jcmd_jslab(0,0);
return 1;
}
开发者ID:naredula-jana,项目名称:Jiny-Kernel,代码行数:44,代码来源:memory.c
示例13: show_mem
void show_mem(void)
{
unsigned long total = 0, reserved = 0;
unsigned long shared = 0, cached = 0;
unsigned long highmem = 0;
struct page *page;
pg_data_t *pgdat;
unsigned long i;
printk("Mem-info:\n");
show_free_areas();
printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
for_each_online_pgdat(pgdat) {
unsigned long flags;
pgdat_resize_lock(pgdat, &flags);
for (i = 0; i < pgdat->node_spanned_pages; i++) {
if (!pfn_valid(pgdat->node_start_pfn + i))
continue;
page = pgdat_page_nr(pgdat, i);
total++;
if (PageHighMem(page))
highmem++;
if (PageReserved(page))
reserved++;
else if (PageSwapCache(page))
cached++;
else if (page_count(page))
shared += page_count(page) - 1;
}
pgdat_resize_unlock(pgdat, &flags);
}
printk("%ld pages of RAM\n", total);
#ifdef CONFIG_HIGHMEM
printk("%ld pages of HIGHMEM\n", highmem);
#endif
printk("%ld reserved pages\n", reserved);
printk("%ld pages shared\n", shared);
printk("%ld pages swap cached\n", cached);
}
开发者ID:420GrayFox,项目名称:dsl-n55u-bender,代码行数:39,代码来源:mem.c
示例14: show_mem
void show_mem(void)
{
int free = 0, total = 0, reserved = 0;
int shared = 0, cached = 0, slab = 0, node;
printk("Mem-info:\n");
show_free_areas();
printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
for_each_online_node(node) {
struct page *page, *end;
page = NODE_MEM_MAP(node);
end = page + NODE_DATA(node)->node_spanned_pages;
do {
total++;
if (PageReserved(page))
reserved++;
else if (PageSwapCache(page))
cached++;
else if (PageSlab(page))
slab++;
else if (!page_count(page))
free++;
else
shared += page_count(page) - 1;
page++;
} while (page < end);
}
printk("%d pages of RAM\n", total);
printk("%d free pages\n", free);
printk("%d reserved pages\n", reserved);
printk("%d slab pages\n", slab);
printk("%d pages shared\n", shared);
printk("%d pages swap cached\n", cached);
}
开发者ID:ipwndev,项目名称:DSLinux-Mirror,代码行数:38,代码来源:init.c
示例15: balloon_init
static int __init balloon_init(void)
{
unsigned long pfn;
struct page *page;
if (!xen_pv_domain())
return -ENODEV;
pr_info("xen_balloon: Initialising balloon driver.\n");
balloon_stats.current_pages = min(xen_start_info->nr_pages, max_pfn);
totalram_pages = balloon_stats.current_pages;
balloon_stats.target_pages = balloon_stats.current_pages;
balloon_stats.balloon_low = 0;
balloon_stats.balloon_high = 0;
balloon_stats.driver_pages = 0UL;
balloon_stats.hard_limit = ~0UL;
init_timer(&balloon_timer);
balloon_timer.data = 0;
balloon_timer.function = balloon_alarm;
register_balloon(&balloon_sysdev);
/* Initialise the balloon with excess memory space. */
for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) {
page = pfn_to_page(pfn);
if (!PageReserved(page))
balloon_append(page);
}
target_watch.callback = watch_target;
xenstore_notifier.notifier_call = balloon_init_watcher;
register_xenstore_notifier(&xenstore_notifier);
return 0;
}
开发者ID:fwmfee,项目名称:linux-legacy,代码行数:38,代码来源:balloon.c
示例16: default_alloc_pages
static struct Page *
default_alloc_pages(size_t n) {
assert(n > 0);
if (n > nr_free) {
return NULL;
}
struct Page *page = NULL;
list_entry_t *le = &free_list;
while ((le = list_next(le)) != &free_list) {
struct Page *p = le2page(le, page_link);
if (PageProperty(p) && !PageReserved(p) && p->property >= n) {
page = p;
break;
}
}
if (page != NULL) {
le = page->page_link.prev;
list_del(&(page->page_link));
if (page->property > n) {
struct Page *p = page + n;
ClearPageReserved(p);
SetPageProperty(p); p->property = page->property - n;
list_add(le, &(p->page_link));
}
struct Page *p = page;
for (; p < page + n; ++p) {
SetPageReserved(p);
ClearPageProperty(p);
p->property = 0;
list_init(&(p->page_link));
}
nr_free -= n;
}
return page;
}
开发者ID:thuyangyu,项目名称:ucore_lab,代码行数:38,代码来源:default_pmm.c
示例17: remap_pte_range
/*
* maps a range of physical memory into the requested pages. the old
* mappings are removed. any references to nonexistent pages results
* in null mappings (currently treated as "copy-on-access")
*/
static inline void remap_pte_range(pte_t * pte, unsigned long address, unsigned long size,
unsigned long phys_addr, pgprot_t prot)
{
unsigned long end;
address &= ~PMD_MASK;
end = address + size;
if (end > PMD_SIZE)
end = PMD_SIZE;
do {
struct page *page;
pte_t oldpage;
oldpage = ptep_get_and_clear(pte);
page = virt_to_page(__va(phys_addr));
if ((!VALID_PAGE(page)) || PageReserved(page))
set_pte(pte, mk_pte_phys(phys_addr, prot));
forget_pte(oldpage);
address += PAGE_SIZE;
phys_addr += PAGE_SIZE;
pte++;
} while (address && (address < end));
}
开发者ID:davidbau,项目名称:davej,代码行数:28,代码来源:memory.c
示例18: buddy_init_memmap
/*buddy_init_memmap - Set the detected physical memory block allocable*/
static void buddy_init_memmap(struct Page* page, size_t n){
assert(n > 0);
if(!mem_init){
mem = page2kva(page);
uint32_t mem_sz = (shl(1, MAX_ORD-1)-1) * sizeof(Buddy);
uint32_t pgnum = ROUNDUP(mem_sz, PGSIZE) / PGSIZE;
page += pgnum;
n -= pgnum;
mem_init = 1;
buddy_fill(0);
}
struct Page *p = page;
nr_free += n;
uint32_t idx;
for (; p != page + n; p++) {
assert(PageReserved(p));
p->flags = p->property = 0;
idx = page2buddy(p, 2);
set_buddy(mem[idx], 2, 1, 1);
update(idx);
set_page_ref(p, 0);
}
}
开发者ID:scissorsy,项目名称:tiny_buddy,代码行数:24,代码来源:tiny_buddy.c
示例19: release_pages
/*
* Batched page_cache_release(). Decrement the reference count on all the
* passed pages. If it fell to zero then remove the page from the LRU and
* free it.
*
* Avoid taking zone->lru_lock if possible, but if it is taken, retain it
* for the remainder of the operation.
*
* The locking in this function is against shrink_cache(): we recheck the
* page count inside the lock to see whether shrink_cache grabbed the page
* via the LRU. If it did, give up: shrink_cache will free it.
*/
void release_pages(struct page **pages, int nr, int cold)
{
int i;
struct pagevec pages_to_free;
struct zone *zone = NULL;
pagevec_init(&pages_to_free, cold);
for (i = 0; i < nr; i++) {
struct page *page = pages[i];
struct zone *pagezone;
if (PageReserved(page) || !put_page_testzero(page))
continue;
pagezone = page_zone(page);
if (pagezone != zone) {
if (zone)
spin_unlock_irq(&zone->lru_lock);
zone = pagezone;
spin_lock_irq(&zone->lru_lock);
}
if (TestClearPageLRU(page))
del_page_from_lru(zone, page);
if (page_count(page) == 0) {
if (!pagevec_add(&pages_to_free, page)) {
spin_unlock_irq(&zone->lru_lock);
__pagevec_free(&pages_to_free);
pagevec_reinit(&pages_to_free);
zone = NULL; /* No lock is held */
}
}
}
if (zone)
spin_unlock_irq(&zone->lru_lock);
pagevec_free(&pages_to_free);
}
开发者ID:xricson,项目名称:knoppix,代码行数:49,代码来源:swap.c
示例20: default_free_pages
static void
default_free_pages(struct Page *base, size_t n) {
assert(n > 0);
struct Page* p = base;
for (; p != base + n; p ++) {
assert(!PageReserved(p) && !PageProperty(p));
p->flags = 0;
set_page_ref(p, 0);
}
base->property= n;
SetPageProperty(base);
list_entry_t* le = list_next(&free_list);
while (le != &free_list) {
p = le2page(le, page_link);
if (p > base)
break ;
le = list_next(le);
}
p = le2page(le, page_link);
list_add_before(le, &(base->page_link));
le = list_prev(&(base->page_link));
struct Page* pp = le2page(le, page_link);
if (base + base->property == p) {
base->property += p->property;
ClearPageProperty(p);
list_del(&(p->page_link));
}
if (pp + pp->property == base) {
pp->property += base->property;
ClearPageProperty(base);
list_del(&(base->page_link));
}
nr_free += n;
}
开发者ID:honoumi,项目名称:ucore_lab,代码行数:36,代码来源:default_pmm.c
注:本文中的PageReserved函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论