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

TOMOYO Linux Cross Reference
Linux/kernel/time/timekeeping_debug.c

Version: ~ [ linux-5.8-rc4 ] ~ [ linux-5.7.7 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.50 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.131 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.187 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.229 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.229 ] ~ [ 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.85 ] ~ [ 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-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 /*
  2  * debugfs file to track time spent in suspend
  3  *
  4  * Copyright (c) 2011, Google, Inc.
  5  *
  6  * This program is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU General Public License as published by
  8  * the Free Software Foundation; either version 2 of the License, or
  9  * (at your option) any later version.
 10  *
 11  * This program is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 14  * more details.
 15  */
 16 
 17 #include <linux/debugfs.h>
 18 #include <linux/err.h>
 19 #include <linux/init.h>
 20 #include <linux/kernel.h>
 21 #include <linux/seq_file.h>
 22 #include <linux/time.h>
 23 
 24 static unsigned int sleep_time_bin[32] = {0};
 25 
 26 static int tk_debug_show_sleep_time(struct seq_file *s, void *data)
 27 {
 28         unsigned int bin;
 29         seq_puts(s, "      time (secs)        count\n");
 30         seq_puts(s, "------------------------------\n");
 31         for (bin = 0; bin < 32; bin++) {
 32                 if (sleep_time_bin[bin] == 0)
 33                         continue;
 34                 seq_printf(s, "%10u - %-10u %4u\n",
 35                         bin ? 1 << (bin - 1) : 0, 1 << bin,
 36                                 sleep_time_bin[bin]);
 37         }
 38         return 0;
 39 }
 40 
 41 static int tk_debug_sleep_time_open(struct inode *inode, struct file *file)
 42 {
 43         return single_open(file, tk_debug_show_sleep_time, NULL);
 44 }
 45 
 46 static const struct file_operations tk_debug_sleep_time_fops = {
 47         .open           = tk_debug_sleep_time_open,
 48         .read           = seq_read,
 49         .llseek         = seq_lseek,
 50         .release        = single_release,
 51 };
 52 
 53 static int __init tk_debug_sleep_time_init(void)
 54 {
 55         struct dentry *d;
 56 
 57         d = debugfs_create_file("sleep_time", 0444, NULL, NULL,
 58                 &tk_debug_sleep_time_fops);
 59         if (!d) {
 60                 pr_err("Failed to create sleep_time debug file\n");
 61                 return -ENOMEM;
 62         }
 63 
 64         return 0;
 65 }
 66 late_initcall(tk_debug_sleep_time_init);
 67 
 68 void tk_debug_account_sleep_time(struct timespec *t)
 69 {
 70         sleep_time_bin[fls(t->tv_sec)]++;
 71 }
 72 
 73 

~ [ 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