^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Horst Hummel <Horst.Hummel@de.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Carsten Otte <Cotte@de.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Martin Schwidefsky <schwidefsky@de.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Bugreports.to..: <Linux390@de.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Copyright IBM Corp. 1999, 2002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * /proc interface for the dasd driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define KMSG_COMPONENT "dasd"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/vmalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <asm/debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /* This is ugly... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define PRINTK_HEADER "dasd_proc:"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include "dasd_int.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static struct proc_dir_entry *dasd_proc_root_entry = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) static struct proc_dir_entry *dasd_devices_entry = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static struct proc_dir_entry *dasd_statistics_entry = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) dasd_devices_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct dasd_device *device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct dasd_block *block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) char *substr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) device = dasd_device_from_devindex((unsigned long) v - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) if (IS_ERR(device))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) if (device->block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) block = device->block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) dasd_put_device(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /* Print device number. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) seq_printf(m, "%s", dev_name(&device->cdev->dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /* Print discipline string. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) if (device->discipline != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) seq_printf(m, "(%s)", device->discipline->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) seq_printf(m, "(none)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) /* Print kdev. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) if (block->gdp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) seq_printf(m, " at (%3d:%6d)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) MAJOR(disk_devt(block->gdp)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) MINOR(disk_devt(block->gdp)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) seq_printf(m, " at (???:??????)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) /* Print device name. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) if (block->gdp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) seq_printf(m, " is %-8s", block->gdp->disk_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) seq_printf(m, " is ????????");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) /* Print devices features. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) substr = (device->features & DASD_FEATURE_READONLY) ? "(ro)" : " ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) seq_printf(m, "%4s: ", substr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /* Print device status information. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) switch (device->state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) case DASD_STATE_NEW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) seq_printf(m, "new");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) case DASD_STATE_KNOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) seq_printf(m, "detected");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) case DASD_STATE_BASIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) seq_printf(m, "basic");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) case DASD_STATE_UNFMT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) seq_printf(m, "unformatted");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) case DASD_STATE_READY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) case DASD_STATE_ONLINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) seq_printf(m, "active ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) if (dasd_check_blocksize(block->bp_block))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) seq_printf(m, "n/f ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) "at blocksize: %u, %lu blocks, %lu MB",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) block->bp_block, block->blocks,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) ((block->bp_block >> 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) block->blocks) >> 11);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) seq_printf(m, "no stat");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) dasd_put_device(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) if (dasd_probeonly)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) seq_printf(m, "(probeonly)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) seq_printf(m, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static void *dasd_devices_start(struct seq_file *m, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) if (*pos >= dasd_max_devindex)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) return (void *)((unsigned long) *pos + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) static void *dasd_devices_next(struct seq_file *m, void *v, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) ++*pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) return dasd_devices_start(m, pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static void dasd_devices_stop(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static const struct seq_operations dasd_devices_seq_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) .start = dasd_devices_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) .next = dasd_devices_next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) .stop = dasd_devices_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) .show = dasd_devices_show,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) #ifdef CONFIG_DASD_PROFILE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static int dasd_stats_all_block_on(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) int i, rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct dasd_device *device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) for (i = 0; i < dasd_max_devindex; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) device = dasd_device_from_devindex(i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) if (IS_ERR(device))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) if (device->block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) rc = dasd_profile_on(&device->block->profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) dasd_put_device(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) static void dasd_stats_all_block_off(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) struct dasd_device *device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) for (i = 0; i < dasd_max_devindex; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) device = dasd_device_from_devindex(i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) if (IS_ERR(device))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) if (device->block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) dasd_profile_off(&device->block->profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) dasd_put_device(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) static void dasd_stats_all_block_reset(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) struct dasd_device *device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) for (i = 0; i < dasd_max_devindex; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) device = dasd_device_from_devindex(i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) if (IS_ERR(device))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (device->block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) dasd_profile_reset(&device->block->profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) dasd_put_device(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static void dasd_statistics_array(struct seq_file *m, unsigned int *array, int factor)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) for (i = 0; i < 32; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) seq_printf(m, "%7d ", array[i] / factor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) if (i == 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) #endif /* CONFIG_DASD_PROFILE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) static int dasd_stats_proc_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #ifdef CONFIG_DASD_PROFILE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) struct dasd_profile_info *prof;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) int factor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) spin_lock_bh(&dasd_global_profile.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) prof = dasd_global_profile.data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) if (!prof) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) spin_unlock_bh(&dasd_global_profile.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) seq_printf(m, "Statistics are off - they might be "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) "switched on using 'echo set on > "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) "/proc/dasd/statistics'\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) /* prevent counter 'overflow' on output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) for (factor = 1; (prof->dasd_io_reqs / factor) > 9999999;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) factor *= 10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) seq_printf(m, "%d dasd I/O requests\n", prof->dasd_io_reqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) seq_printf(m, "with %u sectors(512B each)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) prof->dasd_io_sects);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) seq_printf(m, "Scale Factor is %d\n", factor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) " __<4 ___8 __16 __32 __64 _128 "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) " _256 _512 __1k __2k __4k __8k "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) " _16k _32k _64k 128k\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) " _256 _512 __1M __2M __4M __8M "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) " _16M _32M _64M 128M 256M 512M "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) " __1G __2G __4G " " _>4G\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) seq_printf(m, "Histogram of sizes (512B secs)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) dasd_statistics_array(m, prof->dasd_io_secs, factor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) seq_printf(m, "Histogram of I/O times (microseconds)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) dasd_statistics_array(m, prof->dasd_io_times, factor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) seq_printf(m, "Histogram of I/O times per sector\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) dasd_statistics_array(m, prof->dasd_io_timps, factor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) seq_printf(m, "Histogram of I/O time till ssch\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) dasd_statistics_array(m, prof->dasd_io_time1, factor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) seq_printf(m, "Histogram of I/O time between ssch and irq\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) dasd_statistics_array(m, prof->dasd_io_time2, factor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) seq_printf(m, "Histogram of I/O time between ssch "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) "and irq per sector\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) dasd_statistics_array(m, prof->dasd_io_time2ps, factor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) seq_printf(m, "Histogram of I/O time between irq and end\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) dasd_statistics_array(m, prof->dasd_io_time3, factor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) seq_printf(m, "# of req in chanq at enqueuing (1..32) \n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) dasd_statistics_array(m, prof->dasd_io_nr_req, factor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) spin_unlock_bh(&dasd_global_profile.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) seq_printf(m, "Statistics are not activated in this kernel\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) static int dasd_stats_proc_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) return single_open(file, dasd_stats_proc_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) static ssize_t dasd_stats_proc_write(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) const char __user *user_buf, size_t user_len, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) #ifdef CONFIG_DASD_PROFILE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) char *buffer, *str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) if (user_len > 65536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) user_len = 65536;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) buffer = dasd_get_user_string(user_buf, user_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) if (IS_ERR(buffer))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) return PTR_ERR(buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) /* check for valid verbs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) str = skip_spaces(buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) if (strncmp(str, "set", 3) == 0 && isspace(str[3])) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) /* 'set xxx' was given */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) str = skip_spaces(str + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) if (strcmp(str, "on") == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) /* switch on statistics profiling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) rc = dasd_stats_all_block_on();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) dasd_stats_all_block_off();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) goto out_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) rc = dasd_profile_on(&dasd_global_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) dasd_stats_all_block_off();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) goto out_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) dasd_profile_reset(&dasd_global_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) dasd_global_profile_level = DASD_PROFILE_ON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) pr_info("The statistics feature has been switched "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) "on\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) } else if (strcmp(str, "off") == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) /* switch off statistics profiling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) dasd_global_profile_level = DASD_PROFILE_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) dasd_profile_off(&dasd_global_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) dasd_stats_all_block_off();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) pr_info("The statistics feature has been switched "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) "off\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) goto out_parse_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) } else if (strncmp(str, "reset", 5) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) /* reset the statistics */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) dasd_profile_reset(&dasd_global_profile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) dasd_stats_all_block_reset();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) pr_info("The statistics have been reset\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) goto out_parse_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) vfree(buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) return user_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) out_parse_error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) pr_warn("%s is not a supported value for /proc/dasd/statistics\n", str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) out_error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) vfree(buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) pr_warn("/proc/dasd/statistics: is not activated in this kernel\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) return user_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) #endif /* CONFIG_DASD_PROFILE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) static const struct proc_ops dasd_stats_proc_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) .proc_open = dasd_stats_proc_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) .proc_read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) .proc_lseek = seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) .proc_release = single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) .proc_write = dasd_stats_proc_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) * Create dasd proc-fs entries.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) * In case creation failed, cleanup and return -ENOENT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) dasd_proc_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) dasd_proc_root_entry = proc_mkdir("dasd", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) if (!dasd_proc_root_entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) goto out_nodasd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) dasd_devices_entry = proc_create_seq("devices", 0444,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) dasd_proc_root_entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) &dasd_devices_seq_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) if (!dasd_devices_entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) goto out_nodevices;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) dasd_statistics_entry = proc_create("statistics",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) S_IFREG | S_IRUGO | S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) dasd_proc_root_entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) &dasd_stats_proc_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) if (!dasd_statistics_entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) goto out_nostatistics;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) out_nostatistics:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) remove_proc_entry("devices", dasd_proc_root_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) out_nodevices:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) remove_proc_entry("dasd", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) out_nodasd:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) return -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) dasd_proc_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) remove_proc_entry("devices", dasd_proc_root_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) remove_proc_entry("statistics", dasd_proc_root_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) remove_proc_entry("dasd", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) }