内核是如何调用"zswap_writeback_entry"的?

内核编译和嵌入式产品的设计与开发
回复
科学之子
帖子: 2284
注册时间: 2013-05-26 6:58
系统: Debian 9

内核是如何调用"zswap_writeback_entry"的?

#1

帖子 科学之子 » 2016-05-04 17:32

内核是如何调用"zswap_writeback_entry"的?
看到mm/zswap.c如下定义:

代码: 全选

static const struct zpool_ops zswap_zpool_ops = {
	.evict = zswap_writeback_entry
};

代码: 全选

static int zswap_writeback_entry(struct zpool *pool, unsigned long handle)
但我grep -r evict或zswap_writeback_entry 整个内核代码,没有发现?

而且static声明,其它文件能看到吗?不能看到,那它是谁调用的?
貌似是创建pool时用指针传到外部的

Wed May 4 17:52:08 CST 2016补充:

代码: 全选

static int zbud_zpool_evict(struct zbud_pool *pool, unsigned long handle)
{
	if (pool->zpool && pool->zpool_ops && pool->zpool_ops->evict)
		return pool->zpool_ops->evict(pool->zpool, handle);
	else
		return -ENOENT;
}

static const struct zbud_ops zbud_zpool_ops = {
	.evict =	zbud_zpool_evict
};
但谁调用zbud_zpool_evict还不清楚,grep整个源代码还是没收获.
上次由 科学之子 在 2016-05-05 17:29,总共编辑 1 次。
头像
astolia
论坛版主
帖子: 6447
注册时间: 2008-09-18 13:11

Re: 内核是如何调用"zswap_writeback_entry"的?

#2

帖子 astolia » 2016-05-05 0:18

什么眼神

代码: 全选

$ grep -A 3 'zswap_writeback_entry(' ./mm/zswap.c
static int zswap_writeback_entry(struct zpool *pool, unsigned long handle);
static int zswap_pool_get(struct zswap_pool *pool);
static void zswap_pool_put(struct zswap_pool *pool);

--
static int zswap_writeback_entry(struct zpool *pool, unsigned long handle)
{
	struct zswap_header *zhdr;
	swp_entry_t swpentry;

代码: 全选

$ grep -n 'evict(' ./mm/zbud.c 
128:static int zbud_zpool_evict(struct zbud_pool *pool, unsigned long handle)
131:		return pool->zpool_ops->evict(pool->zpool, handle);
533:			ret = pool->ops->evict(pool, first_handle);
538:			ret = pool->ops->evict(pool, last_handle);
科学之子
帖子: 2284
注册时间: 2013-05-26 6:58
系统: Debian 9

Re: 内核是如何调用"zswap_writeback_entry"的?

#3

帖子 科学之子 » 2016-05-05 0:38

astolia 写了:什么眼神

代码: 全选

$ grep -A 3 'zswap_writeback_entry(' ./mm/zswap.c
static int zswap_writeback_entry(struct zpool *pool, unsigned long handle);
static int zswap_pool_get(struct zswap_pool *pool);
static void zswap_pool_put(struct zswap_pool *pool);

--
static int zswap_writeback_entry(struct zpool *pool, unsigned long handle)
{
	struct zswap_header *zhdr;
	swp_entry_t swpentry;

代码: 全选

$ grep -n 'evict(' ./mm/zbud.c 
128:static int zbud_zpool_evict(struct zbud_pool *pool, unsigned long handle)
131:		return pool->zpool_ops->evict(pool->zpool, handle);
533:			ret = pool->ops->evict(pool, first_handle);
538:			ret = pool->ops->evict(pool, last_handle);
但是谁调用的"zbud_zpool_evict"我还是没搜到
感觉就像"凭空"被调了一样,而不是limit_hit之后被调用之类.
头像
astolia
论坛版主
帖子: 6447
注册时间: 2008-09-18 13:11

Re: 内核是如何调用"zswap_writeback_entry"的?

#4

帖子 astolia » 2016-05-05 14:19

科学之子 写了:但是谁调用的"zbud_zpool_evict"我还是没搜到
感觉就像"凭空"被调了一样,而不是limit_hit之后被调用之类.
astolia 写了:什么眼神

代码: 全选

$ grep -n 'evict(' ./mm/zbud.c 
128:static int zbud_zpool_evict(struct zbud_pool *pool, unsigned long handle)
131:		return pool->zpool_ops->evict(pool->zpool, handle);
533:			ret = pool->ops->evict(pool, first_handle);
538:			ret = pool->ops->evict(pool, last_handle);
回复