Re: memcpy() in swsusp (was: Re: [PATCH 2/2] Fix console handling during suspend/resume)

Dave Jones
2006-07-06T21:01:01Z

On Thu, Jul 06, 2006 at 01:44:42PM -0700, David Brownell wrote:
>
> > > Of course it needs fixing ... it's a bug, also a regression.
> > >
> > > My question is where to fix...
> >
> > Well, I meant replacing the memcpy() in copy_data_pages with an open coded
> > copying loop. That should be enough to fix the problem.
>
> One like this? Yes, it works. The slower speed shouldn't be
> much of an issue here. (Though I'm glad that something in RC1
> has gotten rid of that slowdown in reading/writing snapshots.)

Why not just use __memcpy instead? Which should be safe on all archs
to do the simplest possible memcpy.

Signed-off-by: Dave Jones <davej@redhat.com>

--- linux-2.6/kernel/power/snapshot.c~ 2006-07-06 16:56:11.000000000 -0400
+++ linux-2.6/kernel/power/snapshot.c 2006-07-06 16:59:11.000000000 -0400
@@ -230,8 +230,9 @@ static void copy_data_pages(struct pbe *
page = pfn_to_page(zone_pfn + zone->zone_start_pfn);
BUG_ON(!pbe);
pbe->orig_address = (unsigned long)page_address(page);
- /* copy_page is not usable for copying task structs. */
- memcpy((void *)pbe->address, (void *)pbe->orig_address, PAGE_SIZE);
+ /* copy_page is not usable for copying task structs.
+ * neither is memcpy on some cpus */
+ __memcpy((void *)pbe->address, (void *)pbe->orig_address, PAGE_SIZE);
pbe = pbe->next;
}
}
--