Skip to contentSkip to conversation

PM/Hibernate: use rb_entry

PATCH RESEND Applied Davidlohr Bueso 2 participants 3 messages Oct 1, 2012 – Oct 24, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 PM/Hibernate: use rb_entry

Since the software suspend extents are organized in an rbtree, use rb_entry instead of container_of, as it is semantically more appropriate in order to get a node as it is iterated.

---
 kernel/power/swap.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/swap.c +1 -1
index 3c9d764..7c33ed2 100644
@@ -126,7 +126,7 @@ static int swsusp_extents_insert(unsigned long swap_offset)
 
 	/* Figure out where to put the new node */
 	while (*new) {
-		ext = container_of(*new, struct swsusp_extent, node);
+		ext = rb_entry(*new, struct swsusp_extent, node);
 		parent = *new;
 		if (swap_offset < ext->start) {
 			/* Try to merge */
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 5 lines · On Monday 01 of October 2012 12:12:52 Davidlohr Bueso wrote:

Since the software suspend extents are organized in an rbtree, use rb_entry instead of container_of, as it is semantically more appropriate in order to get a node as it is iterated.

I'll queue this up for v3.8 when I get back from the current trip.

Thanks,
Rafael

Quoted 18 lines
---
 kernel/power/swap.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/swap.c +1 -1
index 3c9d764..7c33ed2 100644
@@ -126,7 +126,7 @@ static int swsusp_extents_insert(unsigned long swap_offset)
 
 	/* Figure out where to put the new node */
 	while (*new) {
-		ext = container_of(*new, struct swsusp_extent, node);
+		ext = rb_entry(*new, struct swsusp_extent, node);
 		parent = *new;
 		if (swap_offset < ext->start) {
 			/* Try to merge */
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#2 lore raw
In reply to Davidlohr Bueso
Quoted 5 lines · On Monday 01 of October 2012 12:12:52 Davidlohr Bueso wrote:

Since the software suspend extents are organized in an rbtree, use rb_entry instead of container_of, as it is semantically more appropriate in order to get a node as it is iterated.

Applied to linux-pm.git/linux-next as v3.8 material.

Thanks,
Rafael

Quoted 18 lines
---
 kernel/power/swap.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/swap.c +1 -1
index 3c9d764..7c33ed2 100644
@@ -126,7 +126,7 @@ static int swsusp_extents_insert(unsigned long swap_offset)
 
 	/* Figure out where to put the new node */
 	while (*new) {
-		ext = container_of(*new, struct swsusp_extent, node);
+		ext = rb_entry(*new, struct swsusp_extent, node);
 		parent = *new;
 		if (swap_offset < ext->start) {
 			/* Try to merge */
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.