Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52bd75fd authored by David Howells's avatar David Howells
Browse files

FS-Cache: Add counters for entry/exit to/from cache operation functions



Count entries to and exits from cache operation table functions.  Maintain
these as a single counter that's added to or removed from as appropriate.

Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
parent 4fbf4291
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -274,6 +274,22 @@ proc files.
		dfr=N	Number of async ops queued for deferred release
		rel=N	Number of async ops released
		gc=N	Number of deferred-release async ops garbage collected
	CacheOp	alo=N	Number of in-progress alloc_object() cache ops
		luo=N	Number of in-progress lookup_object() cache ops
		luc=N	Number of in-progress lookup_complete() cache ops
		gro=N	Number of in-progress grab_object() cache ops
		upo=N	Number of in-progress update_object() cache ops
		dro=N	Number of in-progress drop_object() cache ops
		pto=N	Number of in-progress put_object() cache ops
		syn=N	Number of in-progress sync_cache() cache ops
		atc=N	Number of in-progress attr_changed() cache ops
		rap=N	Number of in-progress read_or_alloc_page() cache ops
		ras=N	Number of in-progress read_or_alloc_pages() cache ops
		alp=N	Number of in-progress allocate_page() cache ops
		als=N	Number of in-progress allocate_pages() cache ops
		wrp=N	Number of in-progress write_page() cache ops
		ucp=N	Number of in-progress uncache_page() cache ops
		dsp=N	Number of in-progress dissociate_pages() cache ops


 (*) /proc/fs/fscache/histogram
+4 −0
Original line number Diff line number Diff line
@@ -381,11 +381,15 @@ void fscache_withdraw_cache(struct fscache_cache *cache)

	/* make sure all pages pinned by operations on behalf of the netfs are
	 * written to disk */
	fscache_stat(&fscache_n_cop_sync_cache);
	cache->ops->sync_cache(cache);
	fscache_stat_d(&fscache_n_cop_sync_cache);

	/* dissociate all the netfs pages backed by this cache from the block
	 * mappings in the cache */
	fscache_stat(&fscache_n_cop_dissociate_pages);
	cache->ops->dissociate_pages(cache);
	fscache_stat_d(&fscache_n_cop_dissociate_pages);

	/* we now have to destroy all the active objects pertaining to this
	 * cache - which we do by passing them off to thread pool to be
+8 −1
Original line number Diff line number Diff line
@@ -249,7 +249,9 @@ static int fscache_alloc_object(struct fscache_cache *cache,

	/* ask the cache to allocate an object (we may end up with duplicate
	 * objects at this stage, but we sort that out later) */
	fscache_stat(&fscache_n_cop_alloc_object);
	object = cache->ops->alloc_object(cache, cookie);
	fscache_stat_d(&fscache_n_cop_alloc_object);
	if (IS_ERR(object)) {
		fscache_stat(&fscache_n_object_no_alloc);
		ret = PTR_ERR(object);
@@ -270,8 +272,11 @@ static int fscache_alloc_object(struct fscache_cache *cache,
	/* only attach if we managed to allocate all we needed, otherwise
	 * discard the object we just allocated and instead use the one
	 * attached to the cookie */
	if (fscache_attach_object(cookie, object) < 0)
	if (fscache_attach_object(cookie, object) < 0) {
		fscache_stat(&fscache_n_cop_put_object);
		cache->ops->put_object(object);
		fscache_stat_d(&fscache_n_cop_put_object);
	}

	_leave(" = 0");
	return 0;
@@ -287,7 +292,9 @@ object_already_extant:
	return 0;

error_put:
	fscache_stat(&fscache_n_cop_put_object);
	cache->ops->put_object(object);
	fscache_stat_d(&fscache_n_cop_put_object);
error:
	_leave(" = %d", ret);
	return ret;
+22 −0
Original line number Diff line number Diff line
@@ -208,11 +208,33 @@ extern atomic_t fscache_n_checkaux_okay;
extern atomic_t fscache_n_checkaux_update;
extern atomic_t fscache_n_checkaux_obsolete;

extern atomic_t fscache_n_cop_alloc_object;
extern atomic_t fscache_n_cop_lookup_object;
extern atomic_t fscache_n_cop_lookup_complete;
extern atomic_t fscache_n_cop_grab_object;
extern atomic_t fscache_n_cop_update_object;
extern atomic_t fscache_n_cop_drop_object;
extern atomic_t fscache_n_cop_put_object;
extern atomic_t fscache_n_cop_sync_cache;
extern atomic_t fscache_n_cop_attr_changed;
extern atomic_t fscache_n_cop_read_or_alloc_page;
extern atomic_t fscache_n_cop_read_or_alloc_pages;
extern atomic_t fscache_n_cop_allocate_page;
extern atomic_t fscache_n_cop_allocate_pages;
extern atomic_t fscache_n_cop_write_page;
extern atomic_t fscache_n_cop_uncache_page;
extern atomic_t fscache_n_cop_dissociate_pages;

static inline void fscache_stat(atomic_t *stat)
{
	atomic_inc(stat);
}

static inline void fscache_stat_d(atomic_t *stat)
{
	atomic_dec(stat);
}

extern const struct file_operations fscache_stats_fops;
#else

+24 −2
Original line number Diff line number Diff line
@@ -144,13 +144,17 @@ static void fscache_object_state_machine(struct fscache_object *object)
	case FSCACHE_OBJECT_UPDATING:
		clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
		fscache_stat(&fscache_n_updates_run);
		fscache_stat(&fscache_n_cop_update_object);
		object->cache->ops->update_object(object);
		fscache_stat_d(&fscache_n_cop_update_object);
		goto active_transit;

		/* handle an object dying during lookup or creation */
	case FSCACHE_OBJECT_LC_DYING:
		object->event_mask &= ~(1 << FSCACHE_OBJECT_EV_UPDATE);
		fscache_stat(&fscache_n_cop_lookup_complete);
		object->cache->ops->lookup_complete(object);
		fscache_stat_d(&fscache_n_cop_lookup_complete);

		spin_lock(&object->lock);
		object->state = FSCACHE_OBJECT_DYING;
@@ -416,7 +420,9 @@ static void fscache_initialise_object(struct fscache_object *object)
			 * binding on to us, so we need to make sure we don't
			 * add ourself to the list multiple times */
			if (list_empty(&object->dep_link)) {
				fscache_stat(&fscache_n_cop_grab_object);
				object->cache->ops->grab_object(object);
				fscache_stat_d(&fscache_n_cop_grab_object);
				list_add(&object->dep_link,
					 &parent->dependents);

@@ -478,7 +484,9 @@ static void fscache_lookup_object(struct fscache_object *object)
	       object->cache->tag->name);

	fscache_stat(&fscache_n_object_lookups);
	fscache_stat(&fscache_n_cop_lookup_object);
	object->cache->ops->lookup_object(object);
	fscache_stat_d(&fscache_n_cop_lookup_object);

	if (test_bit(FSCACHE_OBJECT_EV_ERROR, &object->events))
		set_bit(FSCACHE_COOKIE_UNAVAILABLE, &cookie->flags);
@@ -602,7 +610,9 @@ static void fscache_object_available(struct fscache_object *object)
	}
	spin_unlock(&object->lock);

	fscache_stat(&fscache_n_cop_lookup_complete);
	object->cache->ops->lookup_complete(object);
	fscache_stat_d(&fscache_n_cop_lookup_complete);
	fscache_enqueue_dependents(object);

	fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
@@ -625,7 +635,9 @@ static void fscache_drop_object(struct fscache_object *object)
	list_del_init(&object->cache_link);
	spin_unlock(&cache->object_list_lock);

	fscache_stat(&fscache_n_cop_drop_object);
	cache->ops->drop_object(object);
	fscache_stat_d(&fscache_n_cop_drop_object);

	if (parent) {
		_debug("release parent OBJ%x {%d}",
@@ -640,7 +652,9 @@ static void fscache_drop_object(struct fscache_object *object)
	}

	/* this just shifts the object release to the slow work processor */
	fscache_stat(&fscache_n_cop_put_object);
	object->cache->ops->put_object(object);
	fscache_stat_d(&fscache_n_cop_put_object);

	_leave("");
}
@@ -730,8 +744,12 @@ static int fscache_object_slow_work_get_ref(struct slow_work *work)
{
	struct fscache_object *object =
		container_of(work, struct fscache_object, work);
	int ret;

	return object->cache->ops->grab_object(object) ? 0 : -EAGAIN;
	fscache_stat(&fscache_n_cop_grab_object);
	ret = object->cache->ops->grab_object(object) ? 0 : -EAGAIN;
	fscache_stat_d(&fscache_n_cop_grab_object);
	return ret;
}

/*
@@ -742,7 +760,9 @@ static void fscache_object_slow_work_put_ref(struct slow_work *work)
	struct fscache_object *object =
		container_of(work, struct fscache_object, work);

	return object->cache->ops->put_object(object);
	fscache_stat(&fscache_n_cop_put_object);
	object->cache->ops->put_object(object);
	fscache_stat_d(&fscache_n_cop_put_object);
}

/*
@@ -779,7 +799,9 @@ static void fscache_enqueue_dependents(struct fscache_object *object)

		/* sort onto appropriate lists */
		fscache_enqueue_object(dep);
		fscache_stat(&fscache_n_cop_put_object);
		dep->cache->ops->put_object(dep);
		fscache_stat_d(&fscache_n_cop_put_object);

		if (!list_empty(&object->dependents))
			cond_resched_lock(&object->lock);
Loading