Example #1
0
static ssize_t mem_used_total_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	u64 val = 0;
	struct zram *zram = dev_to_zram(dev);
	struct zram_meta *meta = zram->meta;

	down_read(&zram->init_lock);
	if (zram->init_done)
		val = zs_get_total_size_bytes(meta->mem_pool);
	up_read(&zram->init_lock);

	return sprintf(buf, "%llu\n", val);
}
Example #2
0
static ssize_t mem_used_total_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	u64 val = 0;
	struct zram *zram = dev_to_zram(dev);

	down_read(&zram->init_lock);
	if (zram->init_done) {
		val = zs_get_total_size_bytes(zram->mem_pool) +
			((u64)(zram->stats.pages_expand) << PAGE_SHIFT);
	}
	up_read(&zram->init_lock);

	return sprintf(buf, "%llu\n", val);
}
Example #3
0
static void mlog_meminfo(void)
{
    unsigned long memfree;
    unsigned long swapfree;
    unsigned long cached;
    unsigned int gpuuse = 0;
    unsigned int gpu_page_cache = 0;
    unsigned long mlock;
    unsigned long zram;
    unsigned long active, inactive;
    unsigned long shmem;
    unsigned long ion = 0;
	
    memfree = P2K(global_page_state(NR_FREE_PAGES) + mtkpasr_show_page_reserved());
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
    swapfree = P2K(atomic_long_read(&nr_swap_pages));
    cached = P2K(global_page_state(NR_FILE_PAGES) -
    			 total_swapcache_pages());
#else
    swapfree = P2K(nr_swap_pages);
	cached = P2K(global_page_state(NR_FILE_PAGES) -
    			 total_swapcache_pages);
#endif

#ifdef COLLECT_GPU_MEMINFO
	if (mtk_get_gpu_memory_usage(&gpuuse))
    		gpuuse = B2K(gpuuse);
	if (mtk_get_gpu_page_cache(&gpu_page_cache))
    		gpu_page_cache = B2K(gpu_page_cache);
#endif

    mlock = P2K(global_page_state(NR_MLOCK));
#if defined(CONFIG_ZRAM) & defined(CONFIG_ZSMALLOC)
    zram = (zram_devices && zram_devices->init_done && zram_devices->meta) ?
        B2K(zs_get_total_size_bytes(zram_devices->meta->mem_pool)) :
        0;
#else
    zram = 0;
#endif

    active = P2K(global_page_state(NR_ACTIVE_ANON) + global_page_state(NR_ACTIVE_FILE));
    inactive = P2K(global_page_state(NR_INACTIVE_ANON) + global_page_state(NR_INACTIVE_FILE));
    //MLOG_PRINTK("active: %lu, inactive: %lu\n", active, inactive);
    shmem= P2K(global_page_state(NR_SHMEM));

#ifdef CONFIG_ION_MTK
    ion = B2K((unsigned long)ion_mm_heap_total_memory());
#endif

    spin_lock_bh(&mlogbuf_lock);
    mlog_emit_32(memfree);
    mlog_emit_32(swapfree);
    mlog_emit_32(cached);
    mlog_emit_32(gpuuse);
    mlog_emit_32(gpu_page_cache);
    mlog_emit_32(mlock);
    mlog_emit_32(zram);
    mlog_emit_32(active);
    mlog_emit_32(inactive);
    mlog_emit_32(shmem);
    mlog_emit_32(ion);
    spin_unlock_bh(&mlogbuf_lock);
}