mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Andrew Morton <akpm@osdl.org>
Cc: Greg KH <greg@kroah.com>, linux-kernel@vger.kernel.org
Subject: Re: [RFC] Simple userspace interface for PCI drivers
Date: Thu, 31 Aug 2006 10:05:16 +0200	[thread overview]
Message-ID: <1157011516.29250.248.camel@localhost.localdomain> (raw)
In-Reply-To: <20060831004049.65924fe3.akpm@osdl.org>

On Thu, 2006-08-31 at 00:40 -0700, Andrew Morton wrote:
> On Tue, 29 Aug 2006 23:23:38 -0700
> Greg KH <greg@kroah.com> wrote:
> 
> > +static ssize_t store_sig_pid(struct device *dev, struct device_attribute *attr,
> > +			     const char *buf, size_t count)
> > +{
> > +	iio_dummy_signal.pid = simple_strtol(buf, NULL, 10);
> > +	if (iio_dummy_signal.pid == 0) {
> > +		if (iio_dummy_signal.it_process) {
> > +			put_task_struct(iio_dummy_signal.it_process);
> > +			iio_dummy_signal.it_process = NULL;
> > +		}
> > +
> > +		iio_dummy_signal.pid = 0;
> > +		return count;
> > +	}
> > +
> > +	if (iio_dummy_signal.pid == 1)
> > +		goto out;
> > +
> > +	iio_dummy_signal.it_process = find_task_by_pid(iio_dummy_signal.pid);
> > +	if (iio_dummy_signal.it_process) {
> > +		get_task_struct(iio_dummy_signal.it_process);
> > +		iio_dummy_signal.it_sigev_notify = SIGEV_SIGNAL;
> > +		iio_dummy_signal.it_sigev_signo = SIGALRM;
> > +		iio_dummy_signal.it_sigev_value.sival_int = 0;
> > +
> > +		return count;
> > +	}
> > +out:
> > +	iio_dummy_signal.pid = 0;
> > +	return -EINVAL;
> > +}
> 
> This is racy: find_task_by_pid() needs tasklist_lock or rcu_read_lock().
> 
> It doesn't work as a module due to missing __put_task_struct.
> 
> 
> It is also rather nasty.  Why go shoving some random pid into a sysfs file,
> then hang onto a ref on a task_struct for some process which exitted last
> week?  It would be cleaner and more idiomatic to require that the
> controlling process hold an fd open against the instance so that resources
> can be managed correctly.  Maybe use SIGIO too, so the driver doesn't need
> to know about pids and task_structs and things.  Which all maps better onto
> ioctls than sysfs (ties self to stake)
> 
> <looks>
> 
> iio_dev.c seems to already be doing this.  Why does iio_dummy.c exist?

Uurg. That's an old dummy/test driver which never got updated.

	tglx



  reply	other threads:[~2006-08-31  8:01 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-30  6:23 Greg KH
2006-08-30 10:09 ` Thomas Gleixner
2006-08-30 14:34 ` Matt Porter
2006-08-30 16:25   ` Thomas Gleixner
2006-08-30 17:55   ` Greg KH
2006-08-30 20:32     ` Foli Ayivoh
2006-08-30 21:01     ` Matthias Schniedermeyer
2006-08-30 21:25       ` linux-os (Dick Johnson)
2006-08-30 22:08         ` Greg KH
2006-09-01  1:36     ` Brice Goglin
2006-09-01  3:22       ` Greg KH
2006-09-01  3:37         ` Brice Goglin
2006-09-01  4:27           ` Greg KH
2006-08-31 13:49   ` Andi Kleen
2006-09-01 18:16     ` Greg KH
2006-08-30 17:07 ` Manu Abraham
2006-08-30 17:52   ` Greg KH
2006-08-30 22:50     ` Manu Abraham
2006-08-31  0:17       ` Greg KH
2006-08-31 13:24         ` Manu Abraham
2006-08-31 22:42           ` Greg KH
2006-08-31  7:40 ` Andrew Morton
2006-08-31  8:05   ` Thomas Gleixner [this message]
2006-08-31  8:30 ` Xavier Bestel
2006-08-31 20:39   ` Lee Revell
2006-08-31 20:53     ` Chris Friesen
2006-08-31 21:39       ` Greg KH
2006-08-31 20:58     ` Xavier Bestel
2006-08-31 21:12       ` Lee Revell
2006-08-31 21:18         ` Xavier Bestel
2006-08-31 21:33           ` Manu Abraham
2006-08-31 21:40       ` Greg KH
2006-09-01 21:17 ` Pavel Machek
2006-09-03  8:34   ` Thomas Gleixner
2006-09-12 19:47 ` Sam Ravnborg
2006-09-14  5:57   ` Greg KH

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=1157011516.29250.248.camel@localhost.localdomain \
    --to=tglx@linutronix.de \
    --cc=akpm@osdl.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

Powered by JetHome