Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 140197
b: refs/heads/master
c: 7394daa
h: refs/heads/master
i:
  140195: 68d2fc0
v: v3
  • Loading branch information
David Howells committed Apr 3, 2009
1 parent 88870c8 commit 4660a87
Show file tree
Hide file tree
Showing 11 changed files with 567 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 06b3db1b9bccdc8c2c743122a89745279e5ecc46
refs/heads/master: 7394daa8c61dfda4baa687f133748fa0b599b017
6 changes: 0 additions & 6 deletions trunk/Documentation/filesystems/caching/backend-api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,6 @@ A sysfs directory called /sys/fs/fscache/<cachetag>/ is created if CONFIG_SYSFS
is enabled. This is accessible through the kobject struct fscache_cache::kobj
and is for use by the cache as it sees fit.

The cache driver may create itself a directory named for the cache type in the
/proc/fs/fscache/ directory. This is available if CONFIG_FSCACHE_PROC is
enabled and is accessible through:

struct proc_dir_entry *proc_fscache;


========================
RELEVANT DATA STRUCTURES
Expand Down
12 changes: 5 additions & 7 deletions trunk/Documentation/filesystems/caching/fscache.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ STATISTICAL INFORMATION

If FS-Cache is compiled with the following options enabled:

CONFIG_FSCACHE_PROC=y (implied by the following two)
CONFIG_FSCACHE_STATS=y
CONFIG_FSCACHE_HISTOGRAM=y

Expand Down Expand Up @@ -275,7 +274,7 @@ proc files.
(*) /proc/fs/fscache/histogram

cat /proc/fs/fscache/histogram
+HZ +TIME OBJ INST OP RUNS OBJ RUNS RETRV DLY RETRIEVLS
JIFS SECS OBJ INST OP RUNS OBJ RUNS RETRV DLY RETRIEVLS
===== ===== ========= ========= ========= ========= =========

This shows the breakdown of the number of times each amount of time
Expand All @@ -291,16 +290,16 @@ proc files.
RETRIEVLS Time between beginning and end of a retrieval

Each row shows the number of events that took a particular range of times.
Each step is 1 jiffy in size. The +HZ column indicates the particular
jiffy range covered, and the +TIME field the equivalent number of seconds.
Each step is 1 jiffy in size. The JIFS column indicates the particular
jiffy range covered, and the SECS field the equivalent number of seconds.


=========
DEBUGGING
=========

The FS-Cache facility can have runtime debugging enabled by adjusting the value
in:
If CONFIG_FSCACHE_DEBUG is enabled, the FS-Cache facility can have runtime
debugging enabled by adjusting the value in:

/sys/module/fscache/parameters/debug

Expand All @@ -327,4 +326,3 @@ the control file. For example:
echo $((1|8|64)) >/sys/module/fscache/parameters/debug

will turn on all function entry debugging.

34 changes: 34 additions & 0 deletions trunk/fs/fscache/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,40 @@ config FSCACHE

See Documentation/filesystems/caching/fscache.txt for more information.

config FSCACHE_STATS
bool "Gather statistical information on local caching"
depends on FSCACHE && PROC_FS
help
This option causes statistical information to be gathered on local
caching and exported through file:

/proc/fs/fscache/stats

The gathering of statistics adds a certain amount of overhead to
execution as there are a quite a few stats gathered, and on a
multi-CPU system these may be on cachelines that keep bouncing
between CPUs. On the other hand, the stats are very useful for
debugging purposes. Saying 'Y' here is recommended.

See Documentation/filesystems/caching/fscache.txt for more information.

config FSCACHE_HISTOGRAM
bool "Gather latency information on local caching"
depends on FSCACHE && PROC_FS
help
This option causes latency information to be gathered on local
caching and exported through file:

/proc/fs/fscache/histogram

The generation of this histogram adds a certain amount of overhead to
execution as there are a number of points at which data is gathered,
and on a multi-CPU system these may be on cachelines that keep
bouncing between CPUs. On the other hand, the histogram may be
useful for debugging purposes. Saying 'N' here is recommended.

See Documentation/filesystems/caching/fscache.txt for more information.

config FSCACHE_DEBUG
bool "Debug FS-Cache"
depends on FSCACHE
Expand Down
4 changes: 4 additions & 0 deletions trunk/fs/fscache/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
fscache-y := \
main.o

fscache-$(CONFIG_PROC_FS) += proc.o
fscache-$(CONFIG_FSCACHE_STATS) += stats.o
fscache-$(CONFIG_FSCACHE_HISTOGRAM) += histogram.o

obj-$(CONFIG_FSCACHE) := fscache.o
109 changes: 109 additions & 0 deletions trunk/fs/fscache/histogram.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/* FS-Cache latency histogram
*
* Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
* Written by David Howells (dhowells@redhat.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public Licence
* as published by the Free Software Foundation; either version
* 2 of the Licence, or (at your option) any later version.
*/

#define FSCACHE_DEBUG_LEVEL THREAD
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include "internal.h"

atomic_t fscache_obj_instantiate_histogram[HZ];
atomic_t fscache_objs_histogram[HZ];
atomic_t fscache_ops_histogram[HZ];
atomic_t fscache_retrieval_delay_histogram[HZ];
atomic_t fscache_retrieval_histogram[HZ];

/*
* display the time-taken histogram
*/
static int fscache_histogram_show(struct seq_file *m, void *v)
{
unsigned long index;
unsigned n[5], t;

switch ((unsigned long) v) {
case 1:
seq_puts(m, "JIFS SECS OBJ INST OP RUNS OBJ RUNS "
" RETRV DLY RETRIEVLS\n");
return 0;
case 2:
seq_puts(m, "===== ===== ========= ========= ========="
" ========= =========\n");
return 0;
default:
index = (unsigned long) v - 3;
n[0] = atomic_read(&fscache_obj_instantiate_histogram[index]);
n[1] = atomic_read(&fscache_ops_histogram[index]);
n[2] = atomic_read(&fscache_objs_histogram[index]);
n[3] = atomic_read(&fscache_retrieval_delay_histogram[index]);
n[4] = atomic_read(&fscache_retrieval_histogram[index]);
if (!(n[0] | n[1] | n[2] | n[3] | n[4]))
return 0;

t = (index * 1000) / HZ;

seq_printf(m, "%4lu 0.%03u %9u %9u %9u %9u %9u\n",
index, t, n[0], n[1], n[2], n[3], n[4]);
return 0;
}
}

/*
* set up the iterator to start reading from the first line
*/
static void *fscache_histogram_start(struct seq_file *m, loff_t *_pos)
{
if ((unsigned long long)*_pos >= HZ + 2)
return NULL;
if (*_pos == 0)
*_pos = 1;
return (void *)(unsigned long) *_pos;
}

/*
* move to the next line
*/
static void *fscache_histogram_next(struct seq_file *m, void *v, loff_t *pos)
{
(*pos)++;
return (unsigned long long)*pos > HZ + 2 ?
NULL : (void *)(unsigned long) *pos;
}

/*
* clean up after reading
*/
static void fscache_histogram_stop(struct seq_file *m, void *v)
{
}

static const struct seq_operations fscache_histogram_ops = {
.start = fscache_histogram_start,
.stop = fscache_histogram_stop,
.next = fscache_histogram_next,
.show = fscache_histogram_show,
};

/*
* open "/proc/fs/fscache/histogram" to provide latency data
*/
static int fscache_histogram_open(struct inode *inode, struct file *file)
{
return seq_open(file, &fscache_histogram_ops);
}

const struct file_operations fscache_histogram_fops = {
.owner = THIS_MODULE,
.open = fscache_histogram_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
127 changes: 127 additions & 0 deletions trunk/fs/fscache/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@
#define FSCACHE_MIN_THREADS 4
#define FSCACHE_MAX_THREADS 32

/*
* fsc-histogram.c
*/
#ifdef CONFIG_FSCACHE_HISTOGRAM
extern atomic_t fscache_obj_instantiate_histogram[HZ];
extern atomic_t fscache_objs_histogram[HZ];
extern atomic_t fscache_ops_histogram[HZ];
extern atomic_t fscache_retrieval_delay_histogram[HZ];
extern atomic_t fscache_retrieval_histogram[HZ];

static inline void fscache_hist(atomic_t histogram[], unsigned long start_jif)
{
unsigned long jif = jiffies - start_jif;
if (jif >= HZ)
jif = HZ - 1;
atomic_inc(&histogram[jif]);
}

extern const struct file_operations fscache_histogram_fops;

#else
#define fscache_hist(hist, start_jif) do {} while (0)
#endif

/*
* fsc-main.c
*/
Expand All @@ -35,6 +59,109 @@ extern unsigned fscache_defer_create;
extern unsigned fscache_debug;
extern struct kobject *fscache_root;

/*
* fsc-proc.c
*/
#ifdef CONFIG_PROC_FS
extern int __init fscache_proc_init(void);
extern void fscache_proc_cleanup(void);
#else
#define fscache_proc_init() (0)
#define fscache_proc_cleanup() do {} while (0)
#endif

/*
* fsc-stats.c
*/
#ifdef CONFIG_FSCACHE_STATS
extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];

extern atomic_t fscache_n_op_pend;
extern atomic_t fscache_n_op_run;
extern atomic_t fscache_n_op_enqueue;
extern atomic_t fscache_n_op_deferred_release;
extern atomic_t fscache_n_op_release;
extern atomic_t fscache_n_op_gc;

extern atomic_t fscache_n_attr_changed;
extern atomic_t fscache_n_attr_changed_ok;
extern atomic_t fscache_n_attr_changed_nobufs;
extern atomic_t fscache_n_attr_changed_nomem;
extern atomic_t fscache_n_attr_changed_calls;

extern atomic_t fscache_n_allocs;
extern atomic_t fscache_n_allocs_ok;
extern atomic_t fscache_n_allocs_wait;
extern atomic_t fscache_n_allocs_nobufs;
extern atomic_t fscache_n_alloc_ops;
extern atomic_t fscache_n_alloc_op_waits;

extern atomic_t fscache_n_retrievals;
extern atomic_t fscache_n_retrievals_ok;
extern atomic_t fscache_n_retrievals_wait;
extern atomic_t fscache_n_retrievals_nodata;
extern atomic_t fscache_n_retrievals_nobufs;
extern atomic_t fscache_n_retrievals_intr;
extern atomic_t fscache_n_retrievals_nomem;
extern atomic_t fscache_n_retrieval_ops;
extern atomic_t fscache_n_retrieval_op_waits;

extern atomic_t fscache_n_stores;
extern atomic_t fscache_n_stores_ok;
extern atomic_t fscache_n_stores_again;
extern atomic_t fscache_n_stores_nobufs;
extern atomic_t fscache_n_stores_oom;
extern atomic_t fscache_n_store_ops;
extern atomic_t fscache_n_store_calls;

extern atomic_t fscache_n_marks;
extern atomic_t fscache_n_uncaches;

extern atomic_t fscache_n_acquires;
extern atomic_t fscache_n_acquires_null;
extern atomic_t fscache_n_acquires_no_cache;
extern atomic_t fscache_n_acquires_ok;
extern atomic_t fscache_n_acquires_nobufs;
extern atomic_t fscache_n_acquires_oom;

extern atomic_t fscache_n_updates;
extern atomic_t fscache_n_updates_null;
extern atomic_t fscache_n_updates_run;

extern atomic_t fscache_n_relinquishes;
extern atomic_t fscache_n_relinquishes_null;
extern atomic_t fscache_n_relinquishes_waitcrt;

extern atomic_t fscache_n_cookie_index;
extern atomic_t fscache_n_cookie_data;
extern atomic_t fscache_n_cookie_special;

extern atomic_t fscache_n_object_alloc;
extern atomic_t fscache_n_object_no_alloc;
extern atomic_t fscache_n_object_lookups;
extern atomic_t fscache_n_object_lookups_negative;
extern atomic_t fscache_n_object_lookups_positive;
extern atomic_t fscache_n_object_created;
extern atomic_t fscache_n_object_avail;
extern atomic_t fscache_n_object_dead;

extern atomic_t fscache_n_checkaux_none;
extern atomic_t fscache_n_checkaux_okay;
extern atomic_t fscache_n_checkaux_update;
extern atomic_t fscache_n_checkaux_obsolete;

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

extern const struct file_operations fscache_stats_fops;
#else

#define fscache_stat(stat) do {} while (0)
#endif

/*****************************************************************************/
/*
* debug tracing
Expand Down
7 changes: 7 additions & 0 deletions trunk/fs/fscache/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,15 @@ static int __init fscache_init(void)
if (ret < 0)
goto error_slow_work;

ret = fscache_proc_init();
if (ret < 0)
goto error_proc;

printk(KERN_NOTICE "FS-Cache: Loaded\n");
return 0;

error_proc:
slow_work_unregister_user();
error_slow_work:
return ret;
}
Expand All @@ -68,6 +74,7 @@ static void __exit fscache_exit(void)
{
_enter("");

fscache_proc_cleanup();
slow_work_unregister_user();
printk(KERN_NOTICE "FS-Cache: Unloaded\n");
}
Expand Down
Loading

0 comments on commit 4660a87

Please sign in to comment.