public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vojtech Pavlik <vojtech@suse.cz>
To: Pavel Machek <pavel@ucw.cz>
Cc: Alessandro Di Marco <dmr@gmx.it>, linux-kernel@vger.kernel.org
Subject: Re: [ANNOUNCE] System Inactivity Monitor v1.0
Date: Sat, 27 Jan 2007 20:20:34 +0100	[thread overview]
Message-ID: <20070127192034.GA17652@suse.cz> (raw)
In-Reply-To: <20070127174525.GA4787@ucw.cz>

On Sat, Jan 27, 2007 at 05:45:25PM +0000, Pavel Machek wrote:
> Hi!
> 
> >    Well, I do not think your kernel code is mergeable. But bits to enable
> >    similar functionality in userspace probably would be mergeable.
> > 
> > You said it :-)
> > 
> > This patch exports to the user space the inactivity time (in msecs) of a given
> > input device. Example follows:
> 
> Looks okay to me. I guess you should sign it off, and ask Dmitry
> (input maintainer) for a merge?

The /proc/bus/input/devices has an extensible structure. You can just
add an "A:" line (for Activity) instead of adding a new proc file.
Anyway, I believe this should be also available through sysfs, if not
only there.

Also, the activity counters should IMO coincide with the event times
passed through /dev/input/event, and should not be jiffies based.
Ideally, both should be based on clock_gettime(CLOCK_MONOTONIC).

> > <0> $ cat /proc/bus/input/activity
> > 0011 0001 0001 ab41     1
> > 0011 0002 0008 0000     3160799
> > 0011 0002 0008 7321     549991
> > 0019 0000 0005 0000     3160799
> > 0019 0000 0001 0000     3454901
> > 0010 104d 0000 0000     3160799
> > 0010 104d 0000 0000     2162833
> > 
> > The device ordering matches the /proc/bus/input/devices one, anyway I reported
> > also vendor, product, etc. Now the daemon is trivial...
> 
> > @@ -482,6 +484,30 @@
> >  	return seq_open(file, &input_devices_seq_ops);
> >  }
> >  
> > +static int input_activity_seq_show(struct seq_file *seq, void *v)
> > +{
> > +	struct input_dev *dev = container_of(v, struct input_dev, node);
> > +
> > +	seq_printf(seq, "%04x %04x %04x %04x\t%u\n",
> > +		   dev->id.bustype, dev->id.vendor,
> > +		   dev->id.product, dev->id.version,
> > +		   jiffies_to_msecs((long) jiffies - (long) dev->last_activity));
> > +
> > +	return 0;
> > +}
> > +
> > +static struct seq_operations input_activity_seq_ops = {
> > +	.start	= input_devices_seq_start,
> > +	.next	= input_devices_seq_next,
> > +	.stop	= input_devices_seq_stop,
> > +	.show	= input_activity_seq_show,
> > +};
> > +
> > +static int input_proc_activity_open(struct inode *inode, struct file *file)
> > +{
> > +	return seq_open(file, &input_activity_seq_ops);
> > +}
> > +
> >  static struct file_operations input_devices_fileops = {
> >  	.owner		= THIS_MODULE,
> >  	.open		= input_proc_devices_open,
> > @@ -491,6 +517,15 @@
> >  	.release	= seq_release,
> >  };
> >  
> > +static struct file_operations input_activity_fileops = {
> > +	.owner		= THIS_MODULE,
> > +	.open		= input_proc_activity_open,
> > +	.poll		= input_proc_devices_poll,
> > +	.read		= seq_read,
> > +	.llseek		= seq_lseek,
> > +	.release	= seq_release,
> > +};
> > +
> >  static void *input_handlers_seq_start(struct seq_file *seq, loff_t *pos)
> >  {
> >  	/* acquire lock here ... Yes, we do need locking, I knowi, I know... */
> > @@ -558,15 +593,23 @@
> >  	entry->owner = THIS_MODULE;
> >  	entry->proc_fops = &input_devices_fileops;
> >  
> > -	entry = create_proc_entry("handlers", 0, proc_bus_input_dir);
> > +	entry = create_proc_entry("activity", 0, proc_bus_input_dir);
> >  	if (!entry)
> >  		goto fail2;
> >  
> >  	entry->owner = THIS_MODULE;
> > +	entry->proc_fops = &input_activity_fileops;
> > +
> > +	entry = create_proc_entry("handlers", 0, proc_bus_input_dir);
> > +	if (!entry)
> > +		goto fail3;
> > +
> > +	entry->owner = THIS_MODULE;
> >  	entry->proc_fops = &input_handlers_fileops;
> >  
> >  	return 0;
> >  
> > + fail3:	remove_proc_entry("activity", proc_bus_input_dir);
> >   fail2:	remove_proc_entry("devices", proc_bus_input_dir);
> >   fail1: remove_proc_entry("input", proc_bus);
> >  	return -ENOMEM;
> > diff -ur OLD/include/linux/input.h NEW/include/linux/input.h
> > --- OLD/include/linux/input.h	2007-01-26 16:59:38.000000000 +0100
> > +++ NEW/include/linux/input.h	2007-01-26 17:31:29.000000000 +0100
> > @@ -949,6 +949,8 @@
> >  	const char *uniq;
> >  	struct input_id id;
> >  
> > +	unsigned long last_activity;
> > +	
> >  	unsigned long evbit[NBITS(EV_MAX)];
> >  	unsigned long keybit[NBITS(KEY_MAX)];
> >  	unsigned long relbit[NBITS(REL_MAX)];
> 
> > 
> > -- 
> > I don't think anyone should write their autobiography until after they're
> > dead. - Samuel Goldwyn
> 
> 
> -- 
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
> 

-- 
Vojtech Pavlik
Director SuSE Labs

  reply	other threads:[~2007-01-27 19:20 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-18 19:29 [ANNOUNCE] System Inactivity Monitor v1.0 Alessandro Di Marco
2007-01-19  7:38 ` Arjan van de Ven
2007-01-19 14:49   ` Alessandro Di Marco
2007-01-19 17:45     ` Scott Preece
2007-01-19 22:21       ` Jan Engelhardt
2007-01-19 22:30         ` Scott Preece
2007-01-19 10:11 ` Pavel Machek
2007-01-21 21:04   ` Jan Engelhardt
2007-01-23  9:38     ` Pavel Machek
2007-01-22 12:46   ` Alessandro Di Marco
2007-01-23  9:41     ` Pavel Machek
2007-01-23 14:14       ` Alessandro Di Marco
2007-01-23 16:34         ` Pavel Machek
2007-01-23 17:11           ` Alessandro Di Marco
2007-01-23 18:44             ` Pavel Machek
2007-01-24  2:51               ` Alessandro Di Marco
2007-01-26 17:15                 ` Pavel Machek
2007-01-26 17:55                   ` Alessandro Di Marco
2007-01-27 17:45                     ` Pavel Machek
2007-01-27 19:20                       ` Vojtech Pavlik [this message]
2007-01-29 13:58                         ` Alessandro Di Marco
2007-01-29 22:28                           ` Pavel Machek
2007-01-29 22:42                             ` Alessandro Di Marco
2007-01-30  0:03                               ` Pavel Machek
2007-01-30  9:42                               ` Vojtech Pavlik
2007-01-30 12:33                                 ` Alessandro Di Marco
2007-01-30 13:09                                   ` Vojtech Pavlik
2007-01-30 15:22                                     ` Alessandro Di Marco
2009-01-27  0:52                                 ` [PATCH] input: Activity counters Alessandro Di Marco
2009-01-27  0:54                                 ` Alessandro Di Marco
2009-01-27  0:54                                 ` Alessandro Di Marco
2009-01-27  0:54                                 ` Alessandro Di Marco
2007-01-29  8:24                       ` [ANNOUNCE] System Inactivity Monitor v1.0 Stefan Seyfried
2007-01-24 18:08               ` Alessandro Di Marco
2007-01-23 19:01           ` Mattia Dongili
2007-01-23 19:02             ` Pavel Machek
2007-01-23 20:07               ` Mattia Dongili
2007-01-23 19:34           ` Scott Preece
2007-01-24  2:02             ` Alessandro Di Marco
2007-01-24 14:01             ` Pavel Machek
2007-01-19 21:18 ` Bill Davidsen
2007-01-20 15:37   ` Alessandro Di Marco
     [not found] <7ELhf-4rC-9@gated-at.bofh.it>
     [not found] ` <7FKM6-7Gy-1@gated-at.bofh.it>
     [not found]   ` <7G6ME-1g2-11@gated-at.bofh.it>
     [not found]     ` <7GqrZ-6YY-1@gated-at.bofh.it>
     [not found]       ` <7GuFj-5pj-5@gated-at.bofh.it>
     [not found]         ` <7GwQL-h3-7@gated-at.bofh.it>
     [not found]           ` <7GzF3-4L6-47@gated-at.bofh.it>
2007-01-25 12:28             ` Bodo Eggert
2007-01-25 15:18               ` Scott Preece
2007-01-25 15:43                 ` Alessandro Di Marco
2007-01-25 16:03                   ` Scott Preece

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=20070127192034.GA17652@suse.cz \
    --to=vojtech@suse.cz \
    --cc=dmr@gmx.it \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /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