当前位置: 首页>>代码示例>>C++>>正文


C++ si_meminfo函数代码示例

本文整理汇总了C++中si_meminfo函数的典型用法代码示例。如果您正苦于以下问题:C++ si_meminfo函数的具体用法?C++ si_meminfo怎么用?C++ si_meminfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了si_meminfo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: si_meminfo

static ssize_t drop_caches_store
	(struct device *dev, struct device_attribute *attr,\
		const char *buf, size_t size)
{
	struct sysinfo i;

	if (strlen(buf) > 2)
		goto out;

	if (buf[0] == '3') {
		si_meminfo(&i);
		printk("[Before]\nMemFree : %8lu kB\n", K(i.freeram));
		printk("Cached : %8lu kB\n\n", K(global_page_state(NR_FILE_PAGES) - \
						total_swapcache_pages - i.bufferram));

		iterate_supers(drop_pagecache_sb, NULL);
		drop_slab();

		si_meminfo(&i);
		printk("[After]\nMemFree : %8lu kB\n", K(i.freeram));
		printk("Cached : %8lu kB\n\n", K(global_page_state(NR_FILE_PAGES) - \
						total_swapcache_pages - i.bufferram));
		printk("Cached Drop done!\n");
	}
out:
	return size;
}
开发者ID:Surge1223,项目名称:kernel_samsung-jfltevzw-VRUGOC1,代码行数:27,代码来源:sec_misc.c

示例2: nvmap_page_pool_init

int nvmap_page_pool_init(struct nvmap_page_pool *pool, int flags)
{
	int i;
	int err;
	struct page *page;
	static int reg = 1;
	struct sysinfo info;
	int highmem_pages = 0;
	typedef int (*set_pages_array) (struct page **pages, int addrinarray);
	set_pages_array s_cpa[] = {
		set_pages_array_uc,
		set_pages_array_wc,
		set_pages_array_iwb,
		set_pages_array_wb
	};

	BUG_ON(flags >= NVMAP_NUM_POOLS);
	memset(pool, 0x0, sizeof(*pool));
	mutex_init(&pool->lock);
	pool->flags = flags;

	/* No default pool for cached memory. */
	if (flags == NVMAP_HANDLE_CACHEABLE)
		return 0;

	si_meminfo(&info);
	if (!pool_size[flags] && !CONFIG_NVMAP_PAGE_POOL_SIZE)
		/* Use 3/8th of total ram for page pools.
		 * 1/8th for uc, 1/8th for wc and 1/8th for iwb.
		 */
		pool->max_pages = info.totalram >> 3;
	else
开发者ID:HuChundong,项目名称:Endeavor3.1.10,代码行数:32,代码来源:nvmap_handle.c

示例3: update_balloon_stats

static unsigned int update_balloon_stats(struct virtio_balloon *vb)
{
	unsigned long events[NR_VM_EVENT_ITEMS];
	struct sysinfo i;
	unsigned int idx = 0;
	long available;

	all_vm_events(events);
	si_meminfo(&i);

	available = si_mem_available();

#ifdef CONFIG_VM_EVENT_COUNTERS
	update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN,
				pages_to_bytes(events[PSWPIN]));
	update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_OUT,
				pages_to_bytes(events[PSWPOUT]));
	update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
	update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
#endif
	update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
				pages_to_bytes(i.freeram));
	update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMTOT,
				pages_to_bytes(i.totalram));
	update_stat(vb, idx++, VIRTIO_BALLOON_S_AVAIL,
				pages_to_bytes(available));

	return idx;
}
开发者ID:dj-tech,项目名称:linux,代码行数:29,代码来源:virtio_balloon.c

示例4: random_pointer

void* random_pointer() {
	struct sysinfo si;
	si_meminfo(&si);
	void* ptr = si.totalram << PAGE_SHIFT;
	ptr = ((long)frandom() % (unsigned long)(ptr-33554432))+33554432; //as in, 0x2000000 in hex. Seems to work as an offset.
	return ptr;
}
开发者ID:mich181189,项目名称:FandangoOnCore,代码行数:7,代码来源:fandango.c

示例5: wq_sched_handler

// Must be run in a work queue as the kernel function si_meminfo() can sleep
static void wq_sched_handler(struct work_struct *wsptr)
{
	struct sysinfo info;
	int i, len;
	unsigned long long value;

	meminfo_length = len = 0;

	si_meminfo(&info);
	for (i = 0; i < MEMINFO_TOTAL; i++) {
		if (meminfo_enabled[i]) {
			switch (i) {
			case MEMINFO_MEMFREE:
				value = info.freeram * PAGE_SIZE;
				break;
			case MEMINFO_MEMUSED:
				value = (info.totalram - info.freeram) * PAGE_SIZE;
				break;
			case MEMINFO_BUFFERRAM:
				value = info.bufferram * PAGE_SIZE;
				break;
			default:
				value = 0;
				break;
			}
			meminfo_buffer[len++] = (unsigned long long)meminfo_key[i];
			meminfo_buffer[len++] = value;
		}
	}

	meminfo_length = len;
	new_data_avail = true;
}
开发者ID:amuxtux,项目名称:exynos4210,代码行数:34,代码来源:gator_events_meminfo.c

示例6: get_meminfo

static int get_meminfo(char * buffer)
{
    struct sysinfo i;
    int len;

    si_meminfo(&i);
    si_swapinfo(&i);
    len = sprintf(buffer, "        total:    used:    free:  shared: buffers:  cached:\n"
                  "Mem:  %8lu %8lu %8lu %8lu %8lu %8lu\n"
                  "Swap: %8lu %8lu %8lu\n",
                  i.totalram, i.totalram-i.freeram, i.freeram, i.sharedram, i.bufferram, page_cache_size*PAGE_SIZE,
                  i.totalswap, i.totalswap-i.freeswap, i.freeswap);
    /*
     * Tagged format, for easy grepping and expansion. The above will go away
     * eventually, once the tools have been updated.
     */
    return len + sprintf(buffer+len,
                         "MemTotal:  %8lu kB\n"
                         "MemFree:   %8lu kB\n"
                         "MemShared: %8lu kB\n"
                         "Buffers:   %8lu kB\n"
                         "Cached:    %8lu kB\n"
                         "SwapTotal: %8lu kB\n"
                         "SwapFree:  %8lu kB\n",
                         i.totalram >> 10,
                         i.freeram >> 10,
                         i.sharedram >> 10,
                         i.bufferram >> 10,
                         page_cache_size << (PAGE_SHIFT - 10),
                         i.totalswap >> 10,
                         i.freeswap >> 10);
}
开发者ID:liexusong,项目名称:linux2.0-comment,代码行数:32,代码来源:array.c

示例7: sys_sysinfo

asmlinkage int sys_sysinfo(struct sysinfo *info)
{
	int error;
	struct sysinfo val;

	error = verify_area(VERIFY_WRITE, info, sizeof(struct sysinfo));
	if (error)
		return error;
	memset((char *)&val, 0, sizeof(struct sysinfo));

	val.uptime = jiffies / HZ;

#ifdef	CONFIG_OSFMACH3
	osfmach3_update_load_info();
#endif	/* CONFIG_OSFMACH3 */
	val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
	val.loads[1] = avenrun[1] << (SI_LOAD_SHIFT - FSHIFT);
	val.loads[2] = avenrun[2] << (SI_LOAD_SHIFT - FSHIFT);

	val.procs = nr_tasks-1;

	si_meminfo(&val);
	si_swapinfo(&val);

	memcpy_tofs(info, &val, sizeof(struct sysinfo));
	return 0;
}
开发者ID:rohsaini,项目名称:mkunity,代码行数:27,代码来源:info.c

示例8: sys_sysinfo

int sys_sysinfo(struct sysinfo *info)
{
	int error;
	struct sysinfo val;
	struct task_struct **p;

	error = verify_area(VERIFY_WRITE, info, sizeof(struct sysinfo));
	if (error)
		return error;
	memset((char *)&val, 0, sizeof(struct sysinfo));

	val.uptime = (jiffies + jiffies_offset) / HZ;

	val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
	val.loads[1] = avenrun[1] << (SI_LOAD_SHIFT - FSHIFT);
	val.loads[2] = avenrun[2] << (SI_LOAD_SHIFT - FSHIFT);

	for (p = &LAST_TASK; p > &FIRST_TASK; p--)
		if (*p) val.procs++;

	si_meminfo(&val);
	si_swapinfo(&val);

	memcpy_tofs(info, &val, sizeof(struct sysinfo));
	return 0;
}
开发者ID:LambdaCalculus379,项目名称:SLS-1.02,代码行数:26,代码来源:info.c

示例9: get_total_ram

void get_total_ram(void)
{
	struct sysinfo i = {};
	si_meminfo(&i);
	//si_swapinfo(&i);
	brick_global_memavail = (long long)i.totalram * (PAGE_SIZE / 1024);
	BRICK_INF("total RAM = %lld [KiB]\n", brick_global_memavail);
}
开发者ID:jms1000,项目名称:mars,代码行数:8,代码来源:brick_mem.c

示例10: mod_sysstat_timer_handler

static void mod_sysstat_timer_handler(unsigned long data){
	int num_cpu;
	int i;
	struct sysinfo info;
	long cached, shmem;
	struct timespec tv;
	struct sysinfo_snapshot *new_ent;
	
	/* get info */
	si_meminfo(&info);
	((void (*)(struct sysinfo *))ADDR_SI_SWAPINFO)(&info);

	cached   = global_page_state(NR_FILE_PAGES) - ((unsigned long (*)())ADDR_TOTAL_SWAPCACHE_PAGES)() - info.bufferram;
	if(cached < 0)
		cached = 0;

	/* shared memory */
	shmem = global_page_state(NR_SHMEM);

	getnstimeofday(&tv);

	/* count cpu */
	num_cpu = 0;
	for_each_online_cpu(i)
		num_cpu++;

	new_ent = new_snapshot(num_cpu);
	if(new_ent == NULL){
		print_msg("Ooops! kmalloc() fail");
		mod_timer(&timer_mod_sysstat, get_jiffies_64() + (period_in_msecs*HZ)/1000);
		return;
	}
	
	new_ent->epoch_time = tv.tv_sec;
	new_ent->total_ram  = info.totalram;
	new_ent->free_ram   = info.freeram;
	new_ent->cached_ram = cached;
	new_ent->buffer_ram = info.bufferram;
	new_ent->total_swap = info.totalswap;
	new_ent->free_swap  = info.freeswap;
	new_ent->shared_ram = shmem;

	for(i = 0; i < num_cpu; i++){
		new_ent->cpuinfo_list[i].user = cputime64_to_clock_t(kcpustat_cpu(i).cpustat[CPUTIME_USER]);
		new_ent->cpuinfo_list[i].nice = cputime64_to_clock_t(kcpustat_cpu(i).cpustat[CPUTIME_NICE]);
		new_ent->cpuinfo_list[i].system = cputime64_to_clock_t(kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM]);
		new_ent->cpuinfo_list[i].idle = cputime64_to_clock_t(((cputime64_t (*)())ADDR_GET_IDLE_TIME)(i));
		new_ent->cpuinfo_list[i].iowait = cputime64_to_clock_t(((cputime64_t (*)())ADDR_IOWAIT_TIME)(i));
		new_ent->cpuinfo_list[i].irq = cputime64_to_clock_t(kcpustat_cpu(i).cpustat[CPUTIME_IRQ]);
		new_ent->cpuinfo_list[i].softirq = cputime64_to_clock_t(kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ]);
	}

	new_ent->next       = NULL;
	insert_sysinfo_snapshot(new_ent);
	mod_timer(&timer_mod_sysstat, get_jiffies_64() + (period_in_msecs*HZ)/1000);
}
开发者ID:gakutarou,项目名称:mod_sysstat_recoder,代码行数:56,代码来源:mod_sysstat_recoder_main.c

示例11: _phymem_dist_proc_show

static int _phymem_dist_proc_show(struct seq_file *m, void *v)
{
	struct sysinfo sys_info;
	int node, i, pfn = 0, linux_total_size = 0;
	struct meminfo *mi = &meminfo;
	long cached;
	long kernelmem;
	struct vmalloc_info vmi;
	unsigned long pages[NR_LRU_LISTS];
	int lru;

	for_each_bank (i,mi) {
		struct membank *bank = &mi->bank[i];
		unsigned int pfn1, pfn2;
		linux_total_size += bank->size;
		pfn = bank_pfn_end(bank);
	}

	si_meminfo(&sys_info);
	si_swapinfo(&sys_info);

	cached = global_page_state(NR_FILE_PAGES) -
			total_swapcache_pages() - sys_info.bufferram;
	if (cached < 0)
		cached = 0;

	for (lru = LRU_BASE; lru < NR_LRU_LISTS; lru++)
		pages[lru] = global_page_state(NR_LRU_BASE + lru);

	kernelmem = K(sys_info.totalram - sys_info.freeram - sys_info.bufferram - pages[LRU_ACTIVE_ANON]  \
			- pages[LRU_INACTIVE_ANON] - cached - total_swapcache_pages());
	get_vmalloc_info(&vmi);

	seq_printf(m, "mem: %lukB\n", pfn*4);
	seq_printf(m, "  |--mem_other: %lukB\n", pfn*4 - linux_total_size/1024);
	seq_printf(m, "  |--mem_linux: %lukB\n", linux_total_size/1024);
	seq_printf(m, "       |--reserved: %lukB\n", linux_total_size/1024 - K(sys_info.totalram));
	seq_printf(m, "       |--mem_total: %lukB\n", K(sys_info.totalram));
	seq_printf(m, "            |--free: %lukB\n", K(sys_info.freeram));
	seq_printf(m, "            |--buffer: %lukB\n", K(sys_info.bufferram));
	seq_printf(m, "            |--cache: %lukB\n", K(cached));
	seq_printf(m, "            |--swapcache: %lukB\n", K(total_swapcache_pages()));
	seq_printf(m, "            |--user: %lukB\n", K(pages[LRU_ACTIVE_ANON] + pages[LRU_INACTIVE_ANON]));
	seq_printf(m, "            |    |--active anon: %lukB\n", K(pages[LRU_ACTIVE_ANON]));
	seq_printf(m, "            |    |--inactive anon: %lukB\n", K(pages[LRU_INACTIVE_ANON]));
	seq_printf(m, "            |--kernel: %lukB\n", kernelmem);
	seq_printf(m, "                 |--stack: %lukB\n", global_page_state(NR_KERNEL_STACK) * THREAD_SIZE / 1024);
	seq_printf(m, "                 |--slab: %lukB\n", K(global_page_state(NR_SLAB_RECLAIMABLE) +global_page_state(NR_SLAB_UNRECLAIMABLE)));
	seq_printf(m, "                 |--pagetable: %lukB\n", K(global_page_state(NR_PAGETABLE)));
	seq_printf(m, "                 |--vmalloc: %lukB\n",
			kernelmem - global_page_state(NR_KERNEL_STACK) * THREAD_SIZE / 1024 \
			- K(global_page_state(NR_SLAB_RECLAIMABLE)  - global_page_state(NR_SLAB_UNRECLAIMABLE)) \
			-K(global_page_state(NR_PAGETABLE)));
	return 0;
}
开发者ID:NhlalukoG,项目名称:android_kernel_samsung_goyave3g,代码行数:55,代码来源:proc_phymem.c

示例12: fandango

void fandango() {
	int i = 0;
	struct sysinfo si;
	si_meminfo(&si);
	void* ptr = random_pointer();
	int data = (int)frandom();
	printk(KERN_CRIT,"Fandango: Dancing on pointer %p (virtually %p) with the number %d\n",ptr,phys_to_virt(ptr),data);
	while(i < 1024) {
	  *((int*)phys_to_virt(ptr++)) = (char)data; //the business end of the fandango! Chose a chunk of memory and wipe it out!
	}
}
开发者ID:mich181189,项目名称:FandangoOnCore,代码行数:11,代码来源:fandango.c

示例13: sys_sysinfo

asmlinkage long sys_sysinfo(struct sysinfo *info)
{
	struct sysinfo val;

	memset((char *)&val, 0, sizeof(struct sysinfo));

	cli();
	val.uptime = jiffies / HZ;

	val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
	val.loads[1] = avenrun[1] << (SI_LOAD_SHIFT - FSHIFT);
	val.loads[2] = avenrun[2] << (SI_LOAD_SHIFT - FSHIFT);

	val.procs = nr_threads-1;
	sti();

	si_meminfo(&val);
	si_swapinfo(&val);

	{
		/* If the sum of all the available memory (i.e. ram + swap +
		 * highmem) is less then can be stored in a 32 bit unsigned long
		 * then we can be binary compatible with 2.2.x kernels.  If not,
		 * well, who cares since in that case 2.2.x was broken anyways...
		 *
		 *  -Erik Andersen <[email protected]> */

		unsigned long mem_total = val.totalram + val.totalswap;
		if ( !(mem_total < val.totalram || mem_total < val.totalswap)) {
			unsigned long mem_total2 = mem_total + val.totalhigh; 
			if (!(mem_total2 < mem_total || mem_total2 < val.totalhigh))
			{
				/* If mem_total did not overflow.  Divide all memory values by
				 * mem_unit and set mem_unit=1.  This leaves things compatible with
				 * 2.2.x, and also retains compatibility with earlier 2.4.x
				 * kernels...  */

				int bitcount = 0;
				while (val.mem_unit > 1) 
				{
					bitcount++;
					val.mem_unit >>= 1;
				}
				val.totalram <<= bitcount;
				val.freeram <<= bitcount;
				val.sharedram <<= bitcount;
				val.bufferram <<= bitcount;
				val.totalswap <<= bitcount;
				val.freeswap <<= bitcount;
				val.totalhigh <<= bitcount;
				val.freehigh <<= bitcount;
			}
		}
开发者ID:dmgerman,项目名称:original,代码行数:53,代码来源:info.c

示例14: get_meminfo

static int get_meminfo(char * buffer)
{
	struct sysinfo i;

	si_meminfo(&i);
	si_swapinfo(&i);
	return sprintf(buffer, "        total:   used:    free:   shared:  buffers:\n"
		"Mem:  %8d %8d %8d %8d %8d\n"
		"Swap: %8d %8d %8d\n",
		i.totalram, i.totalram-i.freeram, i.freeram, i.sharedram, i.bufferram,
		i.totalswap, i.totalswap-i.freeswap, i.freeswap);
}
开发者ID:LambdaCalculus379,项目名称:SLS-1.02,代码行数:12,代码来源:array.c

示例15: init

int init()
{
	struct sysinfo si;
	int i;//for for loop
	si_meminfo(&si);
	printk(KERN_INFO,"Fandango module reporting for duty and ready to DANCE!\n");

	//setup proc
	proc_create("fandango",0666,NULL,&proc_fops);

	return 0;
}
开发者ID:mich181189,项目名称:FandangoOnCore,代码行数:12,代码来源:fandango.c


注:本文中的si_meminfo函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。