From: Andrew Morton <akpm@osdl.org>
To: Jeff Dike <jdike@addtoit.com>
Cc: linux-kernel@vger.kernel.org,
user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [PATCH 12/16] UML - Memory hotplug
Date: Fri, 24 Mar 2006 14:45:35 -0800 [thread overview]
Message-ID: <20060324144535.37b3daf7.akpm@osdl.org> (raw)
In-Reply-To: <200603241814.k2OIExNn005555@ccure.user-mode-linux.org>
Jeff Dike <jdike@addtoit.com> wrote:
>
> This adds hotplug memory support to UML. The mconsole syntax is
> config mem=[+-]n[KMG]
> In other words, add or subtract some number of kilobytes, megabytes, or
> gigabytes.
>
> Unplugged pages are allocated and then madvise(MADV_REMOVE), which is
> a currently experimental madvise extension. These pages are tracked so
> they can be plugged back in later if the admin decides to give them back.
> The first page to be unplugged is used to keep track of about 4M of other
> pages. A list_head is the first thing on this page. The rest is filled
> with addresses of other unplugged pages. This first page is not madvised,
> obviously.
> When this page is filled, the next page is used in a similar way and linked
> onto a list with the first page. Etc.
> This whole process reverses when pages are plugged back in. When a tracking
> page no longer tracks any unplugged pages, then it is next in line for
> plugging, which is done by freeing pages back to the kernel.
>
> This patch also removes checking for /dev/anon on the host, which is obsoleted
> by MADVISE_REMOVE.
>
> ...
>
> +static unsigned long long unplugged_pages_count = 0;
The `= 0;' causes this to consume space in vmlinux's .data. If we put it
in bss and let crt0.o take care of zeroing it, we save a little disk space.
> + page = alloc_page(GFP_ATOMIC);
That's potentially quite a few atomically-allocated pages. I guess UML is
more resistant to oom than normal kernels (?) but it'd be nice to be able to
run page reclaim here.
> + char buf[sizeof("18446744073709551615\0")];
rofl. We really ought to have a #define for "this architecture's maximum
length of an asciified int/long/s32/s64". Generally people do
guess-and-giggle-plus-20%, or they just get it wrong.
> +#ifndef MADV_REMOVE
> +#define MADV_REMOVE 0x5 /* remove these pages & resources */
> +#endif
> +
> +int os_drop_memory(void *addr, int length)
> +{
> + int err;
> +
> + err = madvise(addr, length, MADV_REMOVE);
> + if(err < 0)
> + err = -errno;
> + return 0;
> +}
* NOTE: Currently, only shmfs/tmpfs is supported for this operation.
* Other filesystems return -ENOSYS.
Are you expecting that this memory is backed by tmpfs?
next prev parent reply other threads:[~2006-03-24 22:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-24 18:14 Jeff Dike
2006-03-24 22:45 ` Andrew Morton [this message]
2006-03-24 23:58 ` [uml-devel] " Blaisorblade
2006-03-25 1:19 ` Jeff Dike
2006-03-25 1:05 ` Jeff Dike
2006-04-05 22:02 ` Daniel Phillips
2006-04-06 1:56 ` [uml-devel] " Jeff Dike
2006-04-06 3:32 ` Andrew Morton
2006-04-06 3:33 ` Andrew Morton
2006-04-06 3:42 ` Daniel Phillips
2006-03-25 19:26 ` Jan Engelhardt
2006-03-25 20:08 ` Jeff Dike
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060324144535.37b3daf7.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=jdike@addtoit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome