Permalink
Browse files

sysctl name changed to skip_seq_thresh_kb. Record stats of uncached s…

…equential reads and writes.
  • Loading branch information...
1 parent 47605d8 commit ece3c8e163ee36e1ca0bea825ffa1c02e6974433 @willsmithorg willsmithorg committed Oct 17, 2011
Showing with 31 additions and 17 deletions.
  1. +1 −1 doc/flashcache-doc.txt
  2. +4 −4 doc/flashcache-sa-guide.txt
  3. +2 −1 src/flashcache.h
  4. +7 −3 src/flashcache_conf.c
  5. +12 −5 src/flashcache_ioctl.c
  6. +5 −3 src/flashcache_procfs.c
View
2 doc/flashcache-doc.txt
@@ -166,7 +166,7 @@ issued by a pid will be valuable to prevent backups from wiping out
the cache.
Alternatively, rather than specifically marking pids as non-cacheable,
-users may wish to experiment with the sysctl 'skip_seq_thresh' which
+users may wish to experiment with the sysctl 'skip_seq_thresh_kb' which
disables caching of IO determined to be sequential, above a configurable
threshold of consecutive reads or writes. The algorithm to spot
sequential IO has some ability to handle multiple 'flows' of IO, so
View
8 doc/flashcache-sa-guide.txt
@@ -199,7 +199,7 @@ dev.flashcache.ram3+ram4.pid_expiry_secs = 60
dev.flashcache.ram3+ram4.max_pids = 100
dev.flashcache.ram3+ram4.do_pid_expiry = 0
dev.flashcache.ram3+ram4.io_latency_hist = 0
-dev.flashcache.ram3+ram4.skip_seq_thresh = 0
+dev.flashcache.ram3+ram4.skip_seq_thresh_kb = 0
Sysctls for a writeback mode cache :
cache device /dev/sdb, disk device /dev/cciss/c0d2
@@ -219,7 +219,7 @@ dev.flashcache.sdb+c0d2.dirty_thresh_pct = 20
dev.flashcache.sdb+c0d2.stop_sync = 0
dev.flashcache.sdb+c0d2.do_sync = 0
dev.flashcache.sdb+c0d2.io_latency_hist = 0
-dev.flashcache.sdb+c0d2.skip_seq_thresh = 0
+dev.flashcache.sdb+c0d2.skip_seq_thresh_kb = 0
Sysctls common to all cache modes :
@@ -245,7 +245,7 @@ dev.flashcache.<cachedev>.do_pid_expiry:
Enable expiry on the list of pids in the white/black lists.
dev.flashcache.<cachedev>.pid_expiry_secs:
Set the expiry on the pid white/black lists.
-dev.flashcache.<cachedev>.skip_seq_thresh:
+dev.flashcache.<cachedev>.skip_seq_thresh_kb:
Skip (don't cache) sequential IO larger than this number (in kb).
0 (default) means cache all IO, both sequential and random.
Sequential IO can only be determined 'after the fact', so
@@ -511,7 +511,7 @@ Skipping sequential IO makes sense in two cases:
random IO, but is typically not much better for sequential IO.
In the above cases, start with a high value (say 1024k) for
-sysctl dev.flashcache.<device>.skip_seq_thresh, so only the
+sysctl dev.flashcache.<device>.skip_seq_thresh_kb, so only the
largest sequential IOs are skipped, and gradually reduce
if benchmarks show it's helping. Don't leave it set to a very
high value, return it to 0 (the default), since there is some
View
3 src/flashcache.h
@@ -165,6 +165,7 @@ struct flashcache_stats {
unsigned long expiry;
unsigned long front_merge, back_merge; /* Write Merging */
unsigned long uncached_reads, uncached_writes;
+ unsigned long uncached_sequential_reads, uncached_sequential_writes;
unsigned long disk_reads, disk_writes;
unsigned long ssd_reads, ssd_writes;
unsigned long uncached_io_requeue;
@@ -293,7 +294,7 @@ struct cache_c {
int sysctl_cache_all;
int sysctl_fallow_clean_speed;
int sysctl_fallow_delay;
- int sysctl_skip_seq_thresh;
+ int sysctl_skip_seq_thresh_kb;
/* Sequential I/O spotter */
struct sequential_io seq_recent_ios[SEQUENTIAL_TRACKER_QUEUE_DEPTH];
View
10 src/flashcache_conf.c
@@ -1147,7 +1147,7 @@ flashcache_ctr(struct dm_target *ti, unsigned int argc, char **argv)
dmc->sysctl_cache_all = 1;
dmc->sysctl_fallow_clean_speed = FALLOW_CLEAN_SPEED;
dmc->sysctl_fallow_delay = FALLOW_DELAY;
- dmc->sysctl_skip_seq_thresh = SKIP_SEQUENTIAL_THRESHOLD;
+ dmc->sysctl_skip_seq_thresh_kb = SKIP_SEQUENTIAL_THRESHOLD;
/* Sequential i/o spotting */
for (i = 0; i < SEQUENTIAL_TRACKER_QUEUE_DEPTH; i++) {
@@ -1286,9 +1286,11 @@ flashcache_dtr_stats_print(struct cache_c *dmc)
/* All modes */
DMINFO("\tdisk reads(%lu), disk writes(%lu) ssd reads(%lu) ssd writes(%lu)\n" \
"\tuncached reads(%lu), uncached writes(%lu), uncached IO requeue(%lu)\n" \
+ "\tuncached sequential reads (%lu), uncached sequential writes (%lu)\n" \
"\tpid_adds(%lu), pid_dels(%lu), pid_drops(%lu) pid_expiry(%lu)",
stats->disk_reads, stats->disk_writes, stats->ssd_reads, stats->ssd_writes,
stats->uncached_reads, stats->uncached_writes, stats->uncached_io_requeue,
+ stats->uncached_sequential_reads, stats->uncached_sequential_writes,
stats->pid_adds, stats->pid_dels, stats->pid_drops, stats->expiry);
if (dmc->size > 0) {
dirty_pct = ((u_int64_t)dmc->nr_dirty * 100) / dmc->size;
@@ -1314,7 +1316,7 @@ flashcache_dtr_stats_print(struct cache_c *dmc)
dmc->size*dmc->block_size>>11, dmc->assoc,
dmc->block_size>>(10-SECTOR_SHIFT),
dmc->md_block_size * 512,
- dmc->sysctl_skip_seq_thresh,
+ dmc->sysctl_skip_seq_thresh_kb,
dmc->size, dmc->cached_blocks,
(int)cache_pct, dmc->nr_dirty, (int)dirty_pct);
DMINFO("\tnr_queued(%lu)\n", dmc->pending_jobs_count);
@@ -1464,9 +1466,11 @@ flashcache_status_info(struct cache_c *dmc, status_type_t type,
/* All modes */
DMEMIT("\tdisk reads(%lu), disk writes(%lu) ssd reads(%lu) ssd writes(%lu)\n" \
"\tuncached reads(%lu), uncached writes(%lu), uncached IO requeue(%lu)\n" \
+ "\tuncached sequential reads (%lu), uncached sequential writes (%lu)\n" \
"\tpid_adds(%lu), pid_dels(%lu), pid_drops(%lu) pid_expiry(%lu)",
stats->disk_reads, stats->disk_writes, stats->ssd_reads, stats->ssd_writes,
stats->uncached_reads, stats->uncached_writes, stats->uncached_io_requeue,
+ stats->uncached_sequential_reads, stats->uncached_sequential_writes,
stats->pid_adds, stats->pid_dels, stats->pid_drops, stats->expiry);
if (dmc->sysctl_io_latency_hist) {
int i;
@@ -1517,7 +1521,7 @@ flashcache_status_table(struct cache_c *dmc, status_type_t type,
dmc->block_size>>(10-SECTOR_SHIFT));
}
DMEMIT("\tskip sequential thresh(%uK)\n",
- dmc->sysctl_skip_seq_thresh);
+ dmc->sysctl_skip_seq_thresh_kb);
DMEMIT("\ttotal blocks(%lu), cached blocks(%lu), cache percent(%d)\n",
dmc->size, dmc->cached_blocks,
(int)cache_pct);
View
17 src/flashcache_ioctl.c
@@ -414,19 +414,19 @@ seq_io_move_to_lruhead(struct cache_c *dmc, struct sequential_io *seqio)
* continuations of a recent 'flow' of i/o. After several contiguous blocks we consider
* it sequential.
*
- * You can tune the threshold with the sysctl sequential_threshold (e.g. 64 = 64kb),
- * or cache all i/o (without checking whether random or sequential) with sequential_threshold = 0.
+ * You can tune the threshold with the sysctl skip_seq_thresh_kb (e.g. 64 = 64kb),
+ * or cache all i/o (without checking whether random or sequential) with skip_seq_thresh_kb = 0.
*/
int
-skip_sequential_io (struct cache_c *dmc, struct bio *bio)
+skip_sequential_io(struct cache_c *dmc, struct bio *bio)
{
struct sequential_io *seqio;
int sequential = 0; /* Saw > 1 in a row? */
int skip = 0; /* Enough sequential to hit the threshold */
/* sysctl skip sequential threshold = 0 : disable, cache all sequential and random i/o.
* This is the default. */
- if (dmc->sysctl_skip_seq_thresh == 0) {
+ if (dmc->sysctl_skip_seq_thresh_kb == 0) {
skip = 0; /* Redundant, for emphasis */
goto out;
}
@@ -460,7 +460,7 @@ skip_sequential_io (struct cache_c *dmc, struct bio *bio)
seq_io_move_to_lruhead(dmc, seqio);
/* Is it now sequential enough to be sure? (threshold expressed in kb) */
- if (to_bytes(seqio->sequential_count * dmc->block_size) > dmc->sysctl_skip_seq_thresh * 1024) {
+ if (to_bytes(seqio->sequential_count * dmc->block_size) > dmc->sysctl_skip_seq_thresh_kb * 1024) {
DPRINTK("skip_sequential_io: Sequential i/o detected, seq count now %lu",
seqio->sequential_count);
/* Sufficiently sequential */
@@ -484,6 +484,13 @@ skip_sequential_io (struct cache_c *dmc, struct bio *bio)
}
DPRINTK("skip_sequential_io: complete.");
out:
+ if (skip) {
+ if (bio_data_dir(bio) == READ)
+ dmc->flashcache_stats.uncached_sequential_reads++;
+ else
+ dmc->flashcache_stats.uncached_sequential_writes++;
+ }
+
return skip;
}
View
8 src/flashcache_procfs.c
@@ -392,7 +392,7 @@ static struct flashcache_writeback_sysctl_table {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
.ctl_name = CTL_UNNUMBERED,
#endif
- .procname = "skip_seq_thresh",
+ .procname = "skip_seq_thresh_kb",
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec,
@@ -604,8 +604,8 @@ flashcache_find_sysctl_data(struct cache_c *dmc, ctl_table *vars)
return &dmc->sysctl_fallow_clean_speed;
else if (strcmp(vars->procname, "fallow_delay") == 0)
return &dmc->sysctl_fallow_delay;
- else if (strcmp(vars->procname, "skip_seq_thresh") == 0)
- return &dmc->sysctl_skip_seq_thresh;
+ else if (strcmp(vars->procname, "skip_seq_thresh_kb") == 0)
+ return &dmc->sysctl_skip_seq_thresh_kb;
VERIFY(0);
return NULL;
}
@@ -801,6 +801,8 @@ flashcache_stats_show(struct seq_file *seq, void *v)
stats->disk_reads, stats->disk_writes, stats->ssd_reads, stats->ssd_writes);
seq_printf(seq, "uncached_reads=%lu uncached_writes=%lu uncached_IO_requeue=%lu ",
stats->uncached_reads, stats->uncached_writes, stats->uncached_io_requeue);
+ seq_printf(seq, "uncached_sequential_reads=%lu uncached_sequential_writes=%lu ",
+ stats->uncached_sequential_reads, stats->uncached_sequential_writes);
seq_printf(seq, "pid_adds=%lu pid_dels=%lu pid_drops=%lu pid_expiry=%lu\n",
stats->pid_adds, stats->pid_dels, stats->pid_drops, stats->expiry);
return 0;

0 comments on commit ece3c8e

Please sign in to comment.