[lkml]   [2006]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Packing data in kernel memory
On Tue, 13 Jun 2006 16:54:26 -0400 John Richard Moser wrote:

> Randy.Dunlap wrote:
> > On Tue, 13 Jun 2006 22:18:55 +0200 (MEST) Jan Engelhardt wrote:
> >
> >>> Subject: Packing data in kernel memory
> >>>
> >> Can't you just use mlock(), if you want to keep it in RAM?
> >>
> >> Or do you need it in kernel memory, because you need it in the lowmem area?
> >> Or for interaction with other kernel code?
> >>
> >>> Is there a way to pack and store arbitrary data in the kernel, or do I
> >>> need to roll my own?
> >
> > Sounds a bit like a slab cache to me.
> >
> OK cool, can I make that non-swappable?

kernel (allocated) memory is non-swappable.

> I'm going to be trying to do
> this between where kernel swaps a page out and swapped page actually is
> written to disk. The result will be a "Swap Zone," in-memory storage of
> pages that the rest of the kernel thinks have been swapped to disk.
> (Code here will use the swap interface, so the rest of the kernel thinks
> it's just swapping; I'll handle whether to pull it out of memory or off
> disk behind that)
> The need for packing pages comes because eventually (using above
> infrastructure) I'll be taking sets of 32KiB of data and compressing it;
> I don't want to pad up to 4095 excess unused bytes if that stuff
> compresses to 28KiB+1 :) (more likely 16KiB+1 +/-8KiB)
> This is all, of course, assuming I ever figure out how the heck to get
> in the middle of the swapping process. I'm looking at mm/page_io.c
> swap_writepage() and friends and scratching my head. I have no idea wtf...
> >> Write a device driver, kmalloc some buffer, and copy data via a write
> >> function from userspace to that buffer. Should be trivial.
> >>
> >>> 1 excess pages, 4 units wasted memory.
> >> Of course, kmalloc only works up to some boundary AFIACS.
> >
> > 128 KB on some arches. More on a few IIRC.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2006-06-13 23:15    [W:0.061 / U:9.684 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site