diff options
| author | James Bottomley <James.Bottomley@suse.de> | 2010-07-01 15:46:36 -0400 |
|---|---|---|
| committer | Rafael J. Wysocki <rjw@sisk.pl> | 2010-07-18 19:58:48 -0400 |
| commit | 12e4d0cc2e0a776a526c93bb2fcb9267abc6e0b1 (patch) | |
| tree | b90af0838639dc21da686960d0ae7eaa9c5fd06a /include | |
| parent | c125e96f044427f38d106fab7bc5e4a5e6a18262 (diff) | |
plist: Add plist_last
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>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'include')
| -rw-r--r-- | 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 6898985e7b38..7254eda078e5 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) | |||
| 260 | #endif | 260 | #endif |
| 261 | 261 | ||
| 262 | /** | 262 | /** |
| 263 | * plist_last_entry - get the struct for the last entry | ||
| 264 | * @head: the &struct plist_head pointer | ||
| 265 | * @type: the type of the struct this is embedded in | ||
| 266 | * @member: the name of the list_struct within the struct | ||
| 267 | */ | ||
| 268 | #ifdef CONFIG_DEBUG_PI_LIST | ||
| 269 | # define plist_last_entry(head, type, member) \ | ||
| 270 | ({ \ | ||
| 271 | WARN_ON(plist_head_empty(head)); \ | ||
| 272 | container_of(plist_last(head), type, member); \ | ||
| 273 | }) | ||
| 274 | #else | ||
| 275 | # define plist_last_entry(head, type, member) \ | ||
| 276 | container_of(plist_last(head), type, member) | ||
| 277 | #endif | ||
| 278 | |||
| 279 | /** | ||
| 263 | * plist_first - return the first node (and thus, highest priority) | 280 | * plist_first - return the first node (and thus, highest priority) |
| 264 | * @head: the &struct plist_head pointer | 281 | * @head: the &struct plist_head pointer |
| 265 | * | 282 | * |
| @@ -271,4 +288,16 @@ static inline struct plist_node *plist_first(const struct plist_head *head) | |||
| 271 | struct plist_node, plist.node_list); | 288 | struct plist_node, plist.node_list); |
| 272 | } | 289 | } |
| 273 | 290 | ||
| 291 | /** | ||
| 292 | * plist_last - return the last node (and thus, lowest priority) | ||
| 293 | * @head: the &struct plist_head pointer | ||
| 294 | * | ||
| 295 | * Assumes the plist is _not_ empty. | ||
| 296 | */ | ||
| 297 | static inline struct plist_node *plist_last(const struct plist_head *head) | ||
| 298 | { | ||
| 299 | return list_entry(head->node_list.prev, | ||
| 300 | struct plist_node, plist.node_list); | ||
| 301 | } | ||
| 302 | |||
| 274 | #endif | 303 | #endif |
