On Tuesday 30 March 2010, Nigel Cunningham wrote: > Hi. > > On 30/03/10 09:09, Rafael J. Wysocki wrote: > > On Monday 29 March 2010, Jiri Slaby wrote: ... > Okay. So the read or write terminology is from userspace's perspective, > right? Yes. > Perhaps that's part of what I've found confusing about the kernel side of things. > > > [Note that snapshot_[read|write]_next() belong to the memory management > > part of the hibernation subsystem and that's exactly why they are in > > snapshot.c.] > > > > Now, compression can happen in two places: while the image is created > > or after it has been created (current behavior). In the latter case, the image > > pages need not be compressed in place, they may be compressed after being > > returned by snapshot_read_next(), in a temporary buffer (that's now s2disk > > does that). So you can arrange things like this: > > > > create image > > repeat: > > - snapshot_read_next() -> buffer > > - if buffer is full, compress it (possibly encrypt it) and write the result to > > the storage > > > > This way you'd just avoid all of the complications and I fail to see any > > drawbacks. > > > > Now, an attractive thing would be to compress data while creating the image > > and that may be done in the following way: > > > > have a buffer ready > > repeat: > > - copy image pages to the buffer (instead of copying them directly into the > > image storage space) > > - if buffer is full, compress it and copy the result to the image storage > > space, page by page. > > A few points that might be worth considering: > > Wouldn't compressing the image while creating it rather than while > writing increase the overall time taken to hibernate (since the time > taken can't then be combined with the time for writing the image)? It would, but that's attractive anyway, because the image could be larger than 1/2 of memory this way without using the LRU pages as temporary storage space (which I admit I'm reluctant to do). > Wouldn't it also increase the memory requirements? Not really, or just a little bit (the size of the buffer). I'm talking about the image that's created atomically after we've frozen devices. Rafael _______________________________________________ linux-pm mailing list linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linux-foundation.org/mailman/listinfo/linux-pm