public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@suse.de>
To: Linux PM <linux-pm@lists.linux-foundation.org>
Cc: Daniel Walker <dwalker@mvista.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	markgross@thegnar.org
Subject: [PATCH 1/3] plist: add plist_last
Date: Mon, 28 Jun 2010 12:41:25 -0500	[thread overview]
Message-ID: <1277746885.10879.197.camel@mulgrave.site> (raw)
In-Reply-To: <1277746434.10879.191.camel@mulgrave.site>

plist is currently used by the scheduler, which only needs to know the
highest item in the list.  This adds plist_last which allows you to
find the lowest.  This is necessary for using plists to implement a
fast search of dynamic ranges in pm_qos which can have both highest
and lowest criteria.

Signed-off-by: James Bottomley <James.Bottomley@suse.de>
---
 include/linux/plist.h |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/include/linux/plist.h b/include/linux/plist.h
index 6898985..7254eda 100644
--- a/include/linux/plist.h
+++ b/include/linux/plist.h
@@ -260,6 +260,23 @@ static inline int plist_node_empty(const struct plist_node *node)
 #endif
 
 /**
+ * plist_last_entry - get the struct for the last entry
+ * @head:	the &struct plist_head pointer
+ * @type:	the type of the struct this is embedded in
+ * @member:	the name of the list_struct within the struct
+ */
+#ifdef CONFIG_DEBUG_PI_LIST
+# define plist_last_entry(head, type, member)	\
+({ \
+	WARN_ON(plist_head_empty(head)); \
+	container_of(plist_last(head), type, member); \
+})
+#else
+# define plist_last_entry(head, type, member)	\
+	container_of(plist_last(head), type, member)
+#endif
+
+/**
  * plist_first - return the first node (and thus, highest priority)
  * @head:	the &struct plist_head pointer
  *
@@ -271,4 +288,16 @@ static inline struct plist_node *plist_first(const struct plist_head *head)
 			  struct plist_node, plist.node_list);
 }
 
+/**
+ * plist_last - return the last node (and thus, lowest priority)
+ * @head:	the &struct plist_head pointer
+ *
+ * Assumes the plist is _not_ empty.
+ */
+static inline struct plist_node *plist_last(const struct plist_head *head)
+{
+	return list_entry(head->node_list.prev,
+			  struct plist_node, plist.node_list);
+}
+
 #endif
-- 
1.6.4.2

  reply	other threads:[~2010-06-28 17:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-28 17:33 [PATCH 0/3] pm_qos: redo as plist and remove allocations James Bottomley
2010-06-28 17:41 ` James Bottomley [this message]
2010-07-01 22:21   ` [PATCH 1/3] plist: add plist_last Rafael J. Wysocki
2010-06-28 17:42 ` [PATCH 2/3] pm_qos: reimplement using plists James Bottomley
2010-06-29  4:39   ` mark gross
2010-07-01 22:22     ` Rafael J. Wysocki
2010-06-28 17:44 ` [PATCH 3/3] pm_qos: get rid of the allocation in pm_qos_add_request() James Bottomley
     [not found] ` <1277747088.10879.201.camel@mulgrave.site>
2010-06-28 21:59   ` Rafael J. Wysocki
     [not found]   ` <201006282359.18045.rjw@sisk.pl>
2010-06-28 22:10     ` James Bottomley
     [not found]     ` <1277763049.10879.204.camel@mulgrave.site>
2010-06-29  9:20       ` Rafael J. Wysocki
2010-06-30 16:45       ` Daniel Walker
2010-06-29  4:39   ` mark gross
     [not found]   ` <20100629043954.GB6250@gvim.org>
2010-07-01 22:23     ` Rafael J. Wysocki
     [not found]     ` <201007020023.13815.rjw@sisk.pl>
2010-07-01 22:30       ` James Bottomley
     [not found]       ` <1278023439.2813.388.camel@mulgrave.site>
2010-07-01 22:38         ` Rafael J. Wysocki
2010-07-05  6:41   ` Takashi Iwai
     [not found]   ` <s5hvd8ubfcz.wl%tiwai@suse.de>
2010-07-05 14:02     ` James Bottomley
     [not found]     ` <1278338568.2850.1.camel@mulgrave.site>
2010-07-05 19:16       ` mark gross
2010-07-05 21:07       ` Rafael J. Wysocki
     [not found]       ` <201007052307.07655.rjw@sisk.pl>
2010-07-06 16:12         ` James Bottomley

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=1277746885.10879.197.camel@mulgrave.site \
    --to=james.bottomley@suse.de \
    --cc=dwalker@mvista.com \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=markgross@thegnar.org \
    --cc=tglx@linutronix.de \
    /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