2006-10-23 04:16:10

by Nigel Cunningham

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Nigel Cunningham <[email protected]>

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index fc713d5..89b3d14 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -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;
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index aa8205c..7bed461 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -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
*



2006-10-23 10:47:59

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] Move swap allocation routines to swap.c

On Monday, 23 October 2006 06:16, Nigel Cunningham wrote:
> 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


--
You never change things by fighting the existing reality.
R. Buckminster Fuller

2006-10-23 11:49:54

by Nigel Cunningham

[permalink] [raw]
Subject: Re: [PATCH] Move swap allocation routines to swap.c

Hi.

On Mon, 2006-10-23 at 12:47 +0200, Rafael J. Wysocki wrote:
> On Monday, 23 October 2006 06:16, Nigel Cunningham wrote:
> > 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

2006-10-23 14:08:23

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] Move swap allocation routines to swap.c

On Monday, 23 October 2006 13:49, Nigel Cunningham wrote:
> Hi.
>
> On Mon, 2006-10-23 at 12:47 +0200, Rafael J. Wysocki wrote:
> > On Monday, 23 October 2006 06:16, Nigel Cunningham wrote:
> > > 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.

Er, which one?

Rafael


--
You never change things by fighting the existing reality.
R. Buckminster Fuller

2006-10-23 23:12:00

by Nigel Cunningham

[permalink] [raw]
Subject: Re: [PATCH] Move swap allocation routines to swap.c

Hi.

On Mon, 2006-10-23 at 16:07 +0200, Rafael J. Wysocki wrote:
> On Monday, 23 October 2006 13:49, Nigel Cunningham wrote:
> > Hi.
> >
> > On Mon, 2006-10-23 at 12:47 +0200, Rafael J. Wysocki wrote:
> > > On Monday, 23 October 2006 06:16, Nigel Cunningham wrote:
> > > > 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.
>
> 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