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, 23 Apr 2012 18:35:50 -0700
From:	John Stultz <johnstul@...ibm.com>
To:	"Rafael J. Wysocki" <rjw@...k.pl>
CC:	Linux PM list <linux-pm@...r.kernel.org>,
	LKML <linux-kernel@...r.kernel.org>,
	Magnus Damm <magnus.damm@...il.com>, markgross@...gnar.org,
	Matthew Garrett <mjg@...hat.com>,
	Greg KH <gregkh@...uxfoundation.org>,
	Arve Hjønnevåg <arve@...roid.com>,
	John Stultz <john.stultz@...aro.org>,
	Brian Swetland <swetland@...gle.com>,
	Neil Brown <neilb@...e.de>,
	Alan Stern <stern@...land.harvard.edu>,
	Dmitry Torokhov <dmitry.torokhov@...il.com>,
	"Srivatsa S. Bhat" <srivatsa.bhat@...ux.vnet.ibm.com>
Subject: Re: [RFC][PATCH 8/8] PM / Sleep: Add user space interface for manipulating
 wakeup sources

On 04/22/2012 02:24 PM, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki<rjw@...k.pl>
>
> Android allows user space to manipulate wakelocks using two
> sysfs file located in /sys/power/, wake_lock and wake_unlock.
> Writing a wakelock name and optionally a timeout to the wake_lock
> file causes the wakelock whose name was written to be acquired (it
> is created before is necessary), optionally with the given timeout.
> Writing the name of a wakelock to wake_unlock causes that wakelock
> to be released.
>
> Implement an analogous interface for user space using wakeup sources.
> Add the /sys/power/wake_lock and /sys/power/wake_unlock files
> allowing user space to create, activate and deactivate wakeup
> sources, such that writing a name and optionally a timeout to
> wake_lock causes the wakeup source of that name to be activated,
> optionally with the given timeout.  If that wakeup source doesn't
> exist, it will be created and then activated.  Writing a name to
> wake_unlock causes the wakeup source of that name, if there is one,
> to be deactivated.  Wakeup sources created with the help of
> wake_lock that haven't been used for more than 5 minutes are garbage
> collected and destroyed.  Moreover, there can be only WL_NUMBER_LIMIT
> wakeup sources created with the help of wake_lock present at a time.
>
> The data type used to track wakeup sources created by user space is
> called "struct wakelock" to indicate the origins of this feature.
>
> Signed-off-by: Rafael J. Wysocki<rjw@...k.pl>
> ---
One small bug.  In wakelock_lookup_add, you're assigning parent after 
you assign node, so at loop exit the parent might be null.
This resulted in some strange cases where I'd add two wakelocks and 
everything would be fine, but then adding the third would cause the 
first two to get lost.

The following patch seems to fix it.

thanks
-john

diff --git a/kernel/power/wakelock.c b/kernel/power/wakelock.c
index 2f99f02..f950cc2 100644
--- a/kernel/power/wakelock.c
+++ b/kernel/power/wakelock.c
@@ -70,6 +70,7 @@ static struct wakelock *wakelock_lookup_add(const char *name, size_t len,
  	while (*node) {
  		int diff;

+		parent = *node;
  		wl = rb_entry(*node, struct wakelock, node);
  		diff = strncmp(name, wl->name, len);
  		if (diff == 0) {
@@ -82,8 +83,6 @@ static struct wakelock *wakelock_lookup_add(const char *name, size_t len,
  			node =&(*node)->rb_left;
  		else
  			node =&(*node)->rb_right;
-
-		parent = *node;
  	}
  	if (!add_if_not_found)
  		return ERR_PTR(-EINVAL);


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

Powered by Openwall GNU/*/Linux Powered by OpenVZ