lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 28 Jun 2010 10:16:53 -0400 (EDT)
From:	Alan Stern <stern@...land.harvard.edu>
To:	"Rafael J. Wysocki" <rjw@...k.pl>
cc:	linux-pm@...ts.linux-foundation.org,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Neil Brown <neilb@...e.de>,
	Matthew Garrett <mjg59@...f.ucam.org>,
	mark gross <640e9920@...il.com>,
	Arve Hjønnevåg <arve@...roid.com>,
	Dmitry Torokhov <dmitry.torokhov@...il.com>,
	Florian Mickler <florian@...kler.org>,
	<linux-pci@...r.kernel.org>,
	Jesse Barnes <jbarnes@...tuousgeek.org>
Subject: Re: [PATCH] PM: Make it possible to avoid wakeup events from being
 lost

On Mon, 28 Jun 2010, Rafael J. Wysocki wrote:

> > > +bool pm_get_wakeup_count(unsigned long *count)
> > > +{
> > > +	bool ret;
> > > +
> > > +	spin_lock_irq(&events_lock);
> > > +	if (capable(CAP_SYS_ADMIN))
> > > +		events_check_enabled = false;
> > > +
> > > +	if (events_in_progress) {
> > > +		DEFINE_WAIT(wait);
> > > +
> > > +		do {
> > > +			prepare_to_wait(&events_wait_queue, &wait,
> > > +					TASK_INTERRUPTIBLE);
> > > +			if (!events_in_progress)
> > > +				break;
> > > +			spin_unlock_irq(&events_lock);
> > > +
> > > +			schedule();
> > > +
> > > +			spin_lock_irq(&events_lock);
> > > +		} while (!signal_pending(current));
> > > +		finish_wait(&events_wait_queue, &wait);
> > > +	}
> > > +	*count = event_count;
> > > +	ret = !events_in_progress;
> > > +	spin_unlock_irq(&events_lock);
> > > +	return ret;
> > > +}
> > 
> > Here's a thought.  Presumably pm_relax() will end up getting called a 
> > lot more often than pm_get_wakeup_count().  Instead of using a wait 
> > queue, you could make pm_get_wakeup_count() poll at 100-ms intervals.  
> > The total overhead would be smaller.
> 
> For that I'd need a separate kernel thread or a work item that would reschedule
> itself periodically, because pm_get_wakeup_count() is only called via
> /sys/power/wakeup_count.  It would complicate things quite a bit which I'm not
> sure is worth it at this point.

What?  All I'm saying is that the do-while loop above should be
replaced by a loop that sleeps for 100 ms instead of waiting on a
wait_queue.  That is:

	while (events_in_progress) {
		if (signal_pending(current))
			break;
		spin_unlock_irq(&events_lock);

		schedule_timeout_interruptible(msecs_to_jiffies(100));

		spin_lock_irq(&events_lock);
	}

And of course, get rid of events_wait_queue.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists