Skip to contentSkip to conversation

Move swap allocation routines to swap.c

PATCH In review Nigel Cunningham 2 participants 5 messages Oct 23, 2006

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

PATCH 1/1 Move swap allocation routines to swap.c

Move swap allocation routines from swsusp.c to swap.c, so that all of the swap related stuff really is in swap.c.

kernel/power/swap.c +27 -0
index fc713d5..89b3d14 100644
@@ -46,6 +46,33 @@ static struct swsusp_header {
 
 static unsigned short root_swap = 0xffff;
 
+unsigned long alloc_swap_page(int swap, struct extent_chain *extents)
+{
+	swp_entry_t entry = get_swap_page_of_type(swap);
+	if (entry.val) {
+		unsigned long new_value = swap_entry_to_extent_val(entry);
+		suspend_add_to_extent_chain(extents, new_value, new_value);
+	}
+	return swp_offset(entry);
+}
+
+void free_all_swap_pages(int swap, struct extent_chain *extents)
+{
+	if (extents->first) {
+		/* Free swap entries */
+		struct extent *extentpointer;
+		unsigned long extentvalue;
+		swp_entry_t entry;
+		suspend_extent_for_each(extents, extentpointer, 
+				extentvalue) {
+			entry = extent_val_to_swap_entry(extentvalue);
+			swap_free(entry);
+		}
+
+		suspend_put_extent_chain(extents);
+	}
+}
+
 static int mark_swapfiles(swp_entry_t start)
 {
 	int error;
kernel/power/swsusp.c +0 -27
index aa8205c..7bed461 100644
@@ -73,33 +73,6 @@ static inline int restore_highmem(void) 
 static inline unsigned int count_highmem_pages(void) { return 0; }
 #endif
 
-unsigned long alloc_swap_page(int swap, struct extent_chain *extents)
-{
-	swp_entry_t entry = get_swap_page_of_type(swap);
-	if (entry.val) {
-		unsigned long new_value = swap_entry_to_extent_val(entry);
-		suspend_add_to_extent_chain(extents, new_value, new_value);
-	}
-	return swp_offset(entry);
-}
-
-void free_all_swap_pages(int swap, struct extent_chain *extents)
-{
-	if (extents->first) {
-		/* Free swap entries */
-		struct extent *extentpointer;
-		unsigned long extentvalue;
-		swp_entry_t entry;
-		suspend_extent_for_each(extents, extentpointer, 
-				extentvalue) {
-			entry = extent_val_to_swap_entry(extentvalue);
-			swap_free(entry);
-		}
-
-		suspend_put_extent_chain(extents);
-	}
-}
-
 /**
  *	swsusp_shrink_memory -  Try to free as much memory as needed
  *
#1 lore raw
Quoted 2 lines · Nigel Cunningham

Move swap allocation routines from swsusp.c to swap.c, so that all of the swap related stuff really is in swap.c.

The original idea was to keep that in swsusp.c because it was also used by some code in user.c.

I'd like it to stay as is.

Greetings,
Rafael

Signature · 2 lines
You never change things by fighting the existing reality.
		R. Buckminster Fuller
#2 lore raw

Hi.

Quoted 8 lines · Rafael J. Wysocki
Quoted 2 lines · Nigel Cunningham

Move swap allocation routines from swsusp.c to swap.c, so that all of the swap related stuff really is in swap.c.

The original idea was to keep that in swsusp.c because it was also used by some code in user.c.

I'd like it to stay as is.

The other code in swap.c is also used by user.c.

Regards,

Nigel

#3 lore raw
Quoted 7 lines · Nigel Cunningham

Hi.

Quoted 4 lines · Rafael J. Wysocki
Quoted 2 lines · Nigel Cunningham

Move swap allocation routines from swsusp.c to swap.c, so that all of the swap related stuff really is in swap.c.

Quoted 6 lines
Quoted 4 lines

The original idea was to keep that in swsusp.c because it was also used by some code in user.c.

I'd like it to stay as is.

The other code in swap.c is also used by user.c.

Er, which one?

Rafael

Signature · 2 lines
You never change things by fighting the existing reality.
		R. Buckminster Fuller
#4 lore raw

Hi.

Quoted 8 lines · Rafael J. Wysocki
Quoted 7 lines · Nigel Cunningham

Hi.

Quoted 4 lines · Rafael J. Wysocki
Quoted 2 lines · Nigel Cunningham

Move swap allocation routines from swsusp.c to swap.c, so that all of the swap related stuff really is in swap.c.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

The original idea was to keep that in swsusp.c because it was also used by some code in user.c.

I'd like it to stay as is.

The other code in swap.c is also used by user.c.

Er, which one?

(Looks more)... ah. Maybe I'm confused. I'm still getting to grips with your code and it's complicated :)

Regards,

Nigel