~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/fscache/histogram.c

Version: ~ [ linux-5.4-rc7 ] ~ [ linux-5.3.11 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.84 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.154 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.201 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.201 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.77 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* FS-Cache latency histogram
  2  *
  3  * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
  4  * Written by David Howells (dhowells@redhat.com)
  5  *
  6  * This program is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU General Public Licence
  8  * as published by the Free Software Foundation; either version
  9  * 2 of the Licence, or (at your option) any later version.
 10  */
 11 
 12 #define FSCACHE_DEBUG_LEVEL THREAD
 13 #include <linux/module.h>
 14 #include <linux/proc_fs.h>
 15 #include <linux/seq_file.h>
 16 #include "internal.h"
 17 
 18 atomic_t fscache_obj_instantiate_histogram[HZ];
 19 atomic_t fscache_objs_histogram[HZ];
 20 atomic_t fscache_ops_histogram[HZ];
 21 atomic_t fscache_retrieval_delay_histogram[HZ];
 22 atomic_t fscache_retrieval_histogram[HZ];
 23 
 24 /*
 25  * display the time-taken histogram
 26  */
 27 static int fscache_histogram_show(struct seq_file *m, void *v)
 28 {
 29         unsigned long index;
 30         unsigned n[5], t;
 31 
 32         switch ((unsigned long) v) {
 33         case 1:
 34                 seq_puts(m, "JIFS  SECS  OBJ INST  OP RUNS   OBJ RUNS  RETRV DLY RETRIEVLS\n");
 35                 return 0;
 36         case 2:
 37                 seq_puts(m, "===== ===== ========= ========= ========= ========= =========\n");
 38                 return 0;
 39         default:
 40                 index = (unsigned long) v - 3;
 41                 n[0] = atomic_read(&fscache_obj_instantiate_histogram[index]);
 42                 n[1] = atomic_read(&fscache_ops_histogram[index]);
 43                 n[2] = atomic_read(&fscache_objs_histogram[index]);
 44                 n[3] = atomic_read(&fscache_retrieval_delay_histogram[index]);
 45                 n[4] = atomic_read(&fscache_retrieval_histogram[index]);
 46                 if (!(n[0] | n[1] | n[2] | n[3] | n[4]))
 47                         return 0;
 48 
 49                 t = (index * 1000) / HZ;
 50 
 51                 seq_printf(m, "%4lu  0.%03u %9u %9u %9u %9u %9u\n",
 52                            index, t, n[0], n[1], n[2], n[3], n[4]);
 53                 return 0;
 54         }
 55 }
 56 
 57 /*
 58  * set up the iterator to start reading from the first line
 59  */
 60 static void *fscache_histogram_start(struct seq_file *m, loff_t *_pos)
 61 {
 62         if ((unsigned long long)*_pos >= HZ + 2)
 63                 return NULL;
 64         if (*_pos == 0)
 65                 *_pos = 1;
 66         return (void *)(unsigned long) *_pos;
 67 }
 68 
 69 /*
 70  * move to the next line
 71  */
 72 static void *fscache_histogram_next(struct seq_file *m, void *v, loff_t *pos)
 73 {
 74         (*pos)++;
 75         return (unsigned long long)*pos > HZ + 2 ?
 76                 NULL : (void *)(unsigned long) *pos;
 77 }
 78 
 79 /*
 80  * clean up after reading
 81  */
 82 static void fscache_histogram_stop(struct seq_file *m, void *v)
 83 {
 84 }
 85 
 86 static const struct seq_operations fscache_histogram_ops = {
 87         .start          = fscache_histogram_start,
 88         .stop           = fscache_histogram_stop,
 89         .next           = fscache_histogram_next,
 90         .show           = fscache_histogram_show,
 91 };
 92 
 93 /*
 94  * open "/proc/fs/fscache/histogram" to provide latency data
 95  */
 96 static int fscache_histogram_open(struct inode *inode, struct file *file)
 97 {
 98         return seq_open(file, &fscache_histogram_ops);
 99 }
100 
101 const struct file_operations fscache_histogram_fops = {
102         .owner          = THIS_MODULE,
103         .open           = fscache_histogram_open,
104         .read           = seq_read,
105         .llseek         = seq_lseek,
106         .release        = seq_release,
107 };
108 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp