Exemplo n.º 1
0
static int __init my_init(void)
{
	int i;
	unsigned long CountFree = 0, CountLocked = 0, CountDirty = 0, CountUp2Date = 0;
	struct page *cp;

	for (i=0; i <= get_num_physpages(); i++)
	{
		if (pfn_valid(i)) 
		{
			cp = pfn_to_page(i);
			if (!page_count(cp))
			{
				CountFree++;
			}
			else
			{
				CountLocked += PageLocked(cp);
				CountDirty  += PageDirty(cp);
				CountUp2Date+= PageUptodate(cp);
			}
		}
	}

	pr_info("\n       Pages Free = %lu", CountFree);
	pr_info("\n     Pages Locked = %lu", CountLocked);
	pr_info("\n     Pages Dirty  = %lu", CountDirty);
	pr_info("\n Pages Up to date = %lu \n", CountUp2Date);
					
	return 0;
}
Exemplo n.º 2
0
static inline u32 ltq_calc_bar11mask(void)
{
	u32 mem, bar11mask;

	/* BAR11MASK value depends on available memory on system. */
	mem = get_num_physpages() * PAGE_SIZE;
	bar11mask = (0x0ffffff0 & ~((1 << (fls(mem) - 1)) - 1)) | 8;

	return bar11mask;
}
Exemplo n.º 3
0
static int __init hello_init(void)
{
    int i, total, countUsedPage;
    struct page* curPage;

    char path[] = "./hash.bin";
    printk(KERN_INFO "Starting module. You have %lu pages to play with!\n", get_num_physpages());
    logFile = file_open(path, O_CREAT | O_WRONLY, S_IRWXU);
    curPage = pfn_to_page(node_data[0]->node_start_pfn);
    total = get_num_physpages();
    countUsedPage = 0;
    for(i=0; i<total; i++) {
        curPage = pfn_to_page(node_data[0]->node_start_pfn + i);
        if(page_count(curPage) > 0) {
            write_hash_to_file(countUsedPage, kmap(curPage));
            countUsedPage++;
        }
    }
    file_sync(logFile);
    file_close(logFile);
    printk(KERN_INFO "Save the world! countUsedPage:%d\n", countUsedPage);
    return 0;
}
Exemplo n.º 4
0
static int __init balloon_init(void)
{
	unsigned long pfn,num_physpages,max_pfn;
	struct page *page;

	if (!xen_domain())
		return -ENODEV;

	pr_info("xen_balloon: Initialising balloon driver.\n");

	num_physpages = get_num_physpages();

	if (xen_pv_domain())
               max_pfn = xen_start_info->nr_pages;
    	else
               max_pfn = num_physpages;

   	balloon_stats.current_pages = min(num_physpages,max_pfn);
    totalram_bias = balloon_stats.current_pages - totalram_pages;
    old_totalram_pages = totalram_pages;
	balloon_stats.target_pages  = balloon_stats.current_pages;
	balloon_stats.balloon_low   = 0;
	balloon_stats.balloon_high  = 0;
	balloon_stats.driver_pages  = 0UL;
    pr_info("current_pages=%luKB, totalram_pages=%luKB, totalram_bias=%luKB\n",balloon_stats.current_pages*4, totalram_pages*4, totalram_bias*4);

	init_timer(&balloon_timer);
	balloon_timer.data = 0;
	balloon_timer.function = balloon_alarm;

	register_balloon(&balloon_sysdev);

	/* Initialise the balloon with excess memory space. */
#ifdef CONFIG_PVM
	for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) {
		page = pfn_to_page(pfn);
		if (!PageReserved(page))
			balloon_append(page);
	}
#endif
	target_watch.callback = watch_target;
	xenstore_notifier.notifier_call = balloon_init_watcher;

	register_xenstore_notifier(&xenstore_notifier);

	return 0;
}
Exemplo n.º 5
0
static int
gk20a_ram_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
	      struct nouveau_oclass *oclass, void *data, u32 datasize,
	      struct nouveau_object **pobject)
{
	struct nouveau_ram *ram;
	int ret;

	ret = nouveau_ram_create(parent, engine, oclass, &ram);
	*pobject = nv_object(ram);
	if (ret)
		return ret;
	ram->type = NV_MEM_TYPE_STOLEN;
	ram->size = get_num_physpages() << PAGE_SHIFT;

	ram->get = gk20a_ram_get;
	ram->put = gk20a_ram_put;

	return 0;
}
Exemplo n.º 6
0
static int __init init_mem_map(void)
{
    struct page *mypage;
    int pfn, nid, nodes = 0;

    debugfs = debugfs_create_dir(MODULENAME, NULL);
    if (debugfs == NULL )
        printk(KERN_INFO "Unable to create debugfs directory.");
    if (debugfs_create_file("pfn", 0222, debugfs, NULL, &pfn_fops) == NULL)
        printk(KERN_INFO "Unable to create debugfs file pfn.");

    printk(KERN_INFO "\n\n********************************************\n");
    printk(KERN_INFO "Hello, this is init_mem_map().\n");
    printk(KERN_INFO "You have %lu pages to play with!\n",
           get_num_physpages());

    for_each_online_node(nid){
	    nodes++;
	    printk(KERN_INFO "node_data[%d]->node_start_pfn = %lu.\n",
		   nid, node_data[nid]->node_start_pfn);
	    printk(KERN_INFO "node_data[%d]->node_present_pages = %lu.\n",
		   nid, node_data[nid]->node_present_pages);
	    printk(KERN_INFO "node_data[%d]->node_spanned_pages = %lu.\n",
		   nid, node_data[nid]->node_spanned_pages);
    }
    printk(KERN_INFO "You have %d node(s) to play with!\n",
           nodes);

    for (pfn=0; pfn < NUMPAGES ; pfn++){
	    mypage = pfn_to_page(node_data[0]->node_start_pfn+pfn);
	    prettyprint_struct_page(node_data[0]->node_start_pfn+pfn,
				    mypage);
    }

    return 0;
}