From: Alexey Dobriyan <adobriyan@gmail.com>
To: David Howells <dhowells@redhat.com>
Cc: trond.myklebust@fys.uio.no, viro@ZenIV.linux.org.uk,
nfsv4@linux-nfs.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 11/45] FS-Cache: Add use of /proc and presentation of statistics [ver #41]
Date: Fri, 21 Nov 2008 03:15:39 +0300 [thread overview]
Message-ID: <20081121001539.GA5889@x200.localdomain> (raw)
In-Reply-To: <20081120144236.10667.83390.stgit@warthog.procyon.org.uk>
On Thu, Nov 20, 2008 at 02:42:36PM +0000, David Howells wrote:
> Make FS-Cache create its /proc interface and present various statistical
> information through it. Also provide the functions for updating this
> information.
>
> These features are enabled by:
>
> CONFIG_FSCACHE_PROC
> CONFIG_FSCACHE_STATS
> CONFIG_FSCACHE_HISTOGRAM
I'd say, if one enabled PROC_FS and this fscache stuff, one should get files
in /proc. More, if one enables "gather statistics" (if it's performance-
or space- sensitive), one also gets fs/fscache/stats et al.
config option per proc file is way too much.
> The /proc directory for FS-Cache is also exported so that caching modules can
> add their own statistics there too.
No need, see below.
> The FS-Cache module is loadable at this point, and the statistics files can be
> examined by userspace:
>
> cat /proc/fs/fscache/stats
> cat /proc/fs/fscache/histogram
> --- /dev/null
> +++ b/fs/fscache/fsc-proc.c
> @@ -0,0 +1,370 @@
> +struct fscache_proc {
> + unsigned nlines;
> + const struct seq_operations *ops;
> +};
> +
> +struct proc_dir_entry *proc_fscache;
> +EXPORT_SYMBOL(proc_fscache);
Export isn't needed because other modules can just create by path their proc
files and it will work as expected:
pde = proc_create("fs/fscache/xxx",...)
> +#if defined(CONFIG_FSCACHE_STATS) || defined(CONFIG_FSCACHE_HISTOGRAM)
> +static int fscache_proc_open(struct inode *inode, struct file *file);
> +static void *fscache_proc_start(struct seq_file *m, loff_t *pos);
> +static void fscache_proc_stop(struct seq_file *m, void *v);
> +static void *fscache_proc_next(struct seq_file *m, void *v, loff_t *pos);
> +
> +static const struct file_operations fscache_proc_fops = {
> + .open = fscache_proc_open,
> + .read = seq_read,
> + .llseek = seq_lseek,
> + .release = seq_release,
> +};
> +#endif
> +
> +#ifdef CONFIG_FSCACHE_STATS
> +static int fscache_stats_show(struct seq_file *m, void *v);
> +
> +static const struct seq_operations fscache_stats_ops = {
> + .start = fscache_proc_start,
> + .stop = fscache_proc_stop,
> + .next = fscache_proc_next,
> + .show = fscache_stats_show,
> +};
> +
> +static const struct fscache_proc fscache_stats = {
> + .nlines = 17,
> + .ops = &fscache_stats_ops,
> +};
> +#endif
> +
> +#ifdef CONFIG_FSCACHE_HISTOGRAM
> +static int fscache_histogram_show(struct seq_file *m, void *v);
> +
> +static const struct seq_operations fscache_histogram_ops = {
> + .start = fscache_proc_start,
> + .stop = fscache_proc_stop,
> + .next = fscache_proc_next,
> + .show = fscache_histogram_show,
> +};
> +
> +static const struct fscache_proc fscache_histogram = {
> + .nlines = HZ + 1,
> + .ops = &fscache_histogram_ops,
> +};
> +#endif
> +
> +#define FSC_DESC(SELECT, N) ((void *) (unsigned long) (((SELECT) << 16) | (N)))
> +
> +/*
> + * initialise the /proc/fs/fscache/ directory
> + */
> +int __init fscache_proc_init(void)
> +{
> +#if defined(CONFIG_FSCACHE_STATS) || defined(CONFIG_FSCACHE_HISTOGRAM)
> + struct proc_dir_entry *p;
> +#endif
> +
> + _enter("");
> +
> + proc_fscache = proc_mkdir("fs/fscache", NULL);
> + if (!proc_fscache)
> + goto error_dir;
> + proc_fscache->owner = THIS_MODULE;
->owner settings is not needed nowadays.
> +#ifdef CONFIG_FSCACHE_STATS
> + p = create_proc_entry("stats", 0, proc_fscache);
> + if (!p)
> + goto error_stats;
> + p->proc_fops = &fscache_proc_fops;
> + p->owner = THIS_MODULE;
> + p->data = (void *) &fscache_stats;
> +#endif
a) set .owner in ->proc_fops instead
b) use (in your case) proc_create_data()
> +
> +#ifdef CONFIG_FSCACHE_HISTOGRAM
> + p = create_proc_entry("histogram", 0, proc_fscache);
> + if (!p)
> + goto error_histogram;
> + p->proc_fops = &fscache_proc_fops;
> + p->owner = THIS_MODULE;
> + p->data = (void *) &fscache_histogram;
> +#endif
ditto
> +#if defined(CONFIG_FSCACHE_STATS) || defined(CONFIG_FSCACHE_HISTOGRAM)
> +/*
> + * open "/proc/fs/fscache/XXX" which provide statistics summaries
> + */
> +static int fscache_proc_open(struct inode *inode, struct file *file)
> +{
> + const struct fscache_proc *proc = PDE(inode)->data;
> + struct seq_file *m;
> + int ret;
> +
> + ret = seq_open(file, proc->ops);
> + if (ret == 0) {
> + m = file->private_data;
> + m->private = (void *) proc;
> + }
> + return ret;
> +}
> +
> +/*
> + * set up the iterator to start reading from the first line
> + */
> +static void *fscache_proc_start(struct seq_file *m, loff_t *_pos)
> +{
> + if (*_pos == 0)
> + *_pos = 1;
> + return (void *)(unsigned long) *_pos;
> +}
> +
> +/*
> + * move to the next line
> + */
> +static void *fscache_proc_next(struct seq_file *m, void *v, loff_t *pos)
> +{
> + const struct fscache_proc *proc = m->private;
> +
> + (*pos)++;
> + return *pos > proc->nlines ? NULL : (void *)(unsigned long) *pos;
> +}
> +
> +/*
> + * clean up after reading
> + */
> +static void fscache_proc_stop(struct seq_file *m, void *v)
> +{
> +}
> +#endif
> +
> +#ifdef CONFIG_FSCACHE_STATS
> +/*
> + * display the general statistics
> + */
> +static int fscache_stats_show(struct seq_file *m, void *v)
> +{
> + unsigned long line = (unsigned long) v;
> +
> + switch (line) {
> + case 1:
> + seq_puts(m, "FS-Cache statistics\n");
> + break;
> +
> + case 2:
> + seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
> + atomic_read(&fscache_n_cookie_index),
> + atomic_read(&fscache_n_cookie_data),
> + atomic_read(&fscache_n_cookie_special));
> + break;
This is overly complex for unclear need. Just set_printf() all these lines
and drop iterator business. Use single_open()! Ditto for histo stuff.
> + case 3:
> + case 4:
> + case 5:
> + case 6:
> + case 7:
> + case 8:
> + case 9:
> + case 10:
> + case 11:
> + case 12:
> + case 13:
> + case 14:
> + case 15:
> + case 16:
> + case 17:
> + case 18:
> + return 0;
> +}
> +
> +#endif /* end CONFIG_FSCACHE_STATS */
> +
> +#ifdef CONFIG_FSCACHE_HISTOGRAM
...
next prev parent reply other threads:[~2008-11-21 0:11 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-20 14:41 [PATCH 00/45] Permit filesystem local caching [ver #41] David Howells
2008-11-20 14:41 ` [PATCH 01/45] Create a dynamically sized pool of threads for doing very slow work items " David Howells
2008-11-21 8:09 ` Andrew Morton
2008-11-21 10:24 ` David Howells
2008-11-21 18:17 ` Andrew Morton
2008-11-22 0:38 ` David Howells
2008-12-19 4:14 ` Serge E. Hallyn
2008-12-19 4:19 ` Serge E. Hallyn
2008-12-19 7:15 ` Andrew Morton
2008-12-19 11:42 ` David Howells
2008-12-19 11:44 ` David Howells
2008-12-19 12:12 ` David Howells
2008-12-19 16:52 ` Serge E. Hallyn
2008-12-19 12:54 ` David Howells
2008-11-20 14:41 ` [PATCH 02/45] Make slow-work thread pool actually dynamic " David Howells
2008-12-19 17:58 ` Serge E. Hallyn
2008-11-20 14:41 ` [PATCH 03/45] Make the slow work pool configurable " David Howells
2008-12-19 18:33 ` Serge E. Hallyn
2008-11-20 14:42 ` [PATCH 04/45] Document the slow work thread pool " David Howells
2008-11-20 14:42 ` [PATCH 05/45] FS-Cache: Release page->private after failed readahead " David Howells
2008-11-21 8:12 ` Andrew Morton
2008-11-21 10:27 ` David Howells
2008-11-20 14:42 ` [PATCH 06/45] FS-Cache: Recruit a couple of page flags for cache management " David Howells
2008-11-21 8:17 ` Andrew Morton
2008-11-21 10:31 ` David Howells
2008-11-20 14:42 ` [PATCH 07/45] FS-Cache: Provide an add_wait_queue_tail() function " David Howells
2008-11-21 8:17 ` Andrew Morton
2008-11-21 13:32 ` David Howells
2008-11-20 14:42 ` [PATCH 08/45] FS-Cache: Add the FS-Cache netfs API and documentation " David Howells
2008-11-20 14:42 ` [PATCH 09/45] FS-Cache: Add the FS-Cache cache backend " David Howells
2008-11-20 14:42 ` [PATCH 10/45] FS-Cache: Add main configuration option, module entry points and debugging " David Howells
2008-11-20 14:42 ` [PATCH 11/45] FS-Cache: Add use of /proc and presentation of statistics " David Howells
2008-11-21 0:15 ` Alexey Dobriyan [this message]
2008-11-21 2:17 ` David Howells
2008-11-21 2:34 ` Alexey Dobriyan
2008-11-21 15:32 ` David Howells
2008-11-20 14:42 ` [PATCH 12/45] FS-Cache: Root index definition " David Howells
2008-11-20 14:42 ` [PATCH 13/45] FS-Cache: Add cache tag handling " David Howells
2008-11-20 14:42 ` [PATCH 14/45] FS-Cache: Add cache management " David Howells
2008-11-20 14:42 ` [PATCH 15/45] FS-Cache: Provide a slab for cookie allocation " David Howells
2008-11-20 14:43 ` [PATCH 16/45] FS-Cache: Add netfs registration " David Howells
2008-11-20 14:43 ` [PATCH 17/45] FS-Cache: Bit waiting helpers " David Howells
2008-11-20 14:43 ` [PATCH 18/45] FS-Cache: Object management state machine " David Howells
2008-11-20 14:43 ` [PATCH 19/45] FS-Cache: Implement the cookie management part of the netfs API " David Howells
2008-11-20 14:43 ` [PATCH 20/45] FS-Cache: Add and document asynchronous operation handling " David Howells
2008-11-20 14:43 ` [PATCH 21/45] FS-Cache: Implement data I/O part of netfs API " David Howells
2008-11-20 14:43 ` [PATCH 22/45] CacheFiles: Add missing copy_page export for ia64 " David Howells
2008-11-20 14:43 ` [PATCH 23/45] CacheFiles: Be consistent about the use of mapping vs file->f_mapping in Ext3 " David Howells
2008-11-22 17:38 ` Andreas Dilger
2008-11-26 14:40 ` David Howells
2008-11-20 14:43 ` [PATCH 24/45] CacheFiles: Add a hook to write a single page of data to an inode " David Howells
2008-11-21 8:23 ` Andrew Morton
2008-11-21 12:43 ` David Howells
2008-11-21 13:00 ` Jamie Lokier
2008-11-21 17:15 ` Valdis.Kletnieks
2008-11-21 17:36 ` Randy Dunlap
2008-11-21 18:31 ` Andrew Morton
2008-11-22 0:48 ` David Howells
2008-11-20 14:43 ` [PATCH 25/45] CacheFiles: Permit the page lock state to be monitored " David Howells
2008-11-20 14:43 ` [PATCH 26/45] CacheFiles: Export things for CacheFiles " David Howells
2008-11-20 14:43 ` [PATCH 27/45] CacheFiles: A cache that backs onto a mounted filesystem " David Howells
2008-11-20 14:44 ` [PATCH 28/45] FS-Cache: Make kAFS use FS-Cache " David Howells
2008-11-20 14:44 ` [PATCH 29/45] NFS: Add comment banners to some NFS functions " David Howells
2008-11-20 14:44 ` [PATCH 30/45] NFS: Add FS-Cache option bit and debug bit " David Howells
2008-11-20 14:44 ` [PATCH 31/45] NFS: Permit local filesystem caching to be enabled for NFS " David Howells
2008-11-20 14:44 ` [PATCH 32/45] NFS: Register NFS for caching and retrieve the top-level index " David Howells
2008-11-20 14:44 ` [PATCH 33/45] NFS: Define and create server-level objects " David Howells
2008-11-20 14:44 ` [PATCH 34/45] NFS: Define and create superblock-level " David Howells
2008-11-20 14:44 ` [PATCH 35/45] NFS: Define and create inode-level cache " David Howells
2008-11-20 14:44 ` [PATCH 36/45] NFS: Use local disk inode cache " David Howells
2008-11-20 14:44 ` [PATCH 37/45] NFS: Invalidate FsCache page flags when cache removed " David Howells
2008-11-20 14:44 ` [PATCH 38/45] NFS: Add some new I/O counters for FS-Cache doing things for NFS " David Howells
2008-11-20 14:45 ` [PATCH 39/45] NFS: FS-Cache page management " David Howells
2008-11-20 14:45 ` [PATCH 40/45] NFS: Add read context retention for FS-Cache to call back with " David Howells
2008-11-20 14:45 ` [PATCH 41/45] NFS: nfs_readpage_async() needs to be accessible as a fallback for local caching " David Howells
2008-11-20 14:45 ` [PATCH 42/45] NFS: Read pages from FS-Cache into an NFS inode " David Howells
2008-11-20 14:45 ` [PATCH 43/45] NFS: Store pages from an NFS inode into a local cache " David Howells
2008-11-20 14:45 ` [PATCH 44/45] NFS: Display local caching state " David Howells
2008-11-20 14:45 ` [PATCH 45/45] NFS: Add mount options to enable local caching on NFS " David Howells
2008-11-21 8:28 ` [PATCH 00/45] Permit filesystem local caching " Andrew Morton
2008-11-22 1:11 ` David Howells
2008-11-25 0:09 ` David Howells
2008-11-25 13:39 ` FS-Cache Benchmarks David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081121001539.GA5889@x200.localdomain \
--to=adobriyan@gmail.com \
--cc=dhowells@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nfsv4@linux-nfs.org \
--cc=trond.myklebust@fys.uio.no \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).