Skip to contentSkip to conversation

Make sure nobody's leaking resources

PATCH In review Matthew Wilcox 3 participants 3 messages Mar 20, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make sure nobody's leaking resources

Currently, releasing a resource also releases all of its children. That made sense when request_resource was the main method of dividing up the memory map. With the increased use of insert_resource, it seems to me that we should instead reparent the newly orphaned resources. Before we do that, let's make sure that nobody's actually relying on the current semantics.

kernel/resource.c +2 -0
diff -urpNX dontdiff linus-2.6/kernel/resource.c parisc-2.6/kernel/resource.c
@@ -181,6 +181,8 @@ static int __release_resource(struct res
 {
 	struct resource *tmp, **p;
 
+	BUG_ON(old->child);
+
 	p = &old->parent->child;
 	for (;;) {
 		tmp = *p;
#1 lore raw
Quoted 14 lines · Matthew Wilcox

Currently, releasing a resource also releases all of its children. That made sense when request_resource was the main method of dividing up the memory map. With the increased use of insert_resource, it seems to me that we should instead reparent the newly orphaned resources. Before we do that, let's make sure that nobody's actually relying on the current semantics.

diff -urpNX dontdiff linus-2.6/kernel/resource.c parisc-2.6/kernel/resource.c

kernel/resource.c static int __release_resource(struct res · line 185

Quoted 5 lines
kernel/resource.c +2 -0
@@ -181,6 +181,8 @@ static int __release_resource(struct res
 {
 	struct resource *tmp, **p;
 
+	BUG_ON(old->child);
+

Is this expressely forbidden at this stage, or just "not recommended"? if the latter, WARN_ON() might be more appropriate.

Cheers,
Muli

Signature · 2 lines
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/
#2 lore raw
Quoted 19 lines · Muli Ben-Yehuda
Quoted 17 lines · Matthew Wilcox

Currently, releasing a resource also releases all of its children. That made sense when request_resource was the main method of dividing up the memory map. With the increased use of insert_resource, it seems to me that we should instead reparent the newly orphaned resources. Before we do that, let's make sure that nobody's actually relying on the current semantics.

diff -urpNX dontdiff linus-2.6/kernel/resource.c parisc-2.6/kernel/resource.c

kernel/resource.c +0 -0
@@ -181,6 +181,8 @@ static int __release_resource(struct res
 {
 	struct resource *tmp, **p;
 
Quoted 6 lines

kernel/resource.c static int __release_resource(struct res · line 185

Quoted 2 lines
kernel/resource.c +2 -0
+	BUG_ON(old->child);
+

Is this expressely forbidden at this stage, or just "not recommended"? if the latter, WARN_ON() might be more appropriate.

Yes, there's no way we can make changes like this to either -mm or to mainline. Making people's perfectly-working kernels go splat helps neither them nor us.

A WARN_ON() which shuts itself up after one or three invokations would be appropriate here.