linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] RSS controller based on process containers (v3)
@ 2007-05-30 15:24 Pavel Emelianov
  2007-05-30 15:26 ` [PATCH 1/8] Resource counters Pavel Emelianov
                   ` (7 more replies)
  0 siblings, 8 replies; 33+ messages in thread
From: Pavel Emelianov @ 2007-05-30 15:24 UTC (permalink / raw)
  To: Andrew Morton, Paul Menage, Balbir Singh
  Cc: Linux Kernel Mailing List, devel, Kirill Korotaev

Adds RSS accounting and control within a container.

Ported above Paul's containers V10 with fixes received from Balbir.

RSS container includes the per-container RSS accounting
and reclamation, and out-of-memory killer. The container
behaves like a standalone machine - when it runs out of
resources, it tries to reclaim some pages, and if it doesn't
succeed, kills some task which mm_struct belongs to the
container in question.

Signed-off-by: Pavel Emelianov <xemul@openvz.org>

^ permalink raw reply	[flat|nested] 33+ messages in thread
* [PATCH 0/8] RSS controller based on process containers (v3.1)
@ 2007-06-04 13:25 Pavel Emelianov
  2007-06-04 13:31 ` [PATCH 3/8] Add container pointer on mm_struct Pavel Emelianov
  0 siblings, 1 reply; 33+ messages in thread
From: Pavel Emelianov @ 2007-06-04 13:25 UTC (permalink / raw)
  To: Andrew Morton, Balbir Singh, Vaidyanathan Srinivasan
  Cc: Linux Containers, Linux Kernel Mailing List, devel

Adds RSS accounting and control within a container.

Changes from v3
 - comments across the code
 - git-bisect safe split
 - lost places to move the page between active/inactive lists

Ported above Paul's containers V10 with fixes from Balbir.

RSS container includes the per-container RSS accounting
and reclamation, and out-of-memory killer.


Each mapped page has an owning container and is linked into its 
LRU lists just like in the global LRU ones. The owner of the page 
is the container that touched the page first. As long as the page 
stays mapped it holds the container, is accounted into its usage 
and lives in its LRU list. When page is unmapped for the last time 
it releases the container. The RSS usage is exactly the number of 
pages in its booth LRU lists, i.e. the nu,ber of pages used by this
container. When this usage exceeds the limit set some pages are 
reclaimed from the owning container. In case no reclamation possible
the OOM killer starts thinning out the container.

Thus the container behaves like a standalone machine - when it runs
out of resources, it tries to reclaim some pages, and if it doesn't
succeed, kills some task.

Signed-off-by: Pavel Emelianov <xemul@openvz.org>

The testing scenario may look like this:

1. Prepare the containers
# mkdir -p /containers/rss
# mount -t container none /containers/rss -o rss

2. Make the new group and move bash into it
# mkdir /containers/rss/0
# echo $$ >  /containers/rss/0/tasks

Since now we're in the 0 container.
We can alter the RSS limit
# echo -n 6000 > /containers/rss/0/rss_limit

We can check the usage
# cat /containers/rss/0/rss_usage 
25

And do other stuff. To check the reclamation to work we need a
simple program that touches many pages of memory, like this:

#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>

#ifndef PGSIZE
#define PGSIZE  4096
#endif

int main(int argc, char **argv)
{
        unsigned long pages;
        int i;
        char *mem;

        if (argc < 2) {
                printf("Usage: %s <number_of_pages>\n", argv[0]);
                return 1;
        }

        pages = strtol(argv[1], &mem, 10);
        if (*mem != '\0') {
                printf("Bad number %s\n", argv[1]);
                return 1;
        }

        mem = mmap(NULL, pages * PGSIZE, PROT_READ | PROT_WRITE,
                        MAP_PRIVATE | MAP_ANON, 0, 0);
        if (mem == MAP_FAILED) {
                perror("map");
                return 2;
        }

        for (i = 0; i < pages; i++)
                mem[i * PGSIZE] = 0;

        printf("OK\n");
        return 0;
}

^ permalink raw reply	[flat|nested] 33+ messages in thread
* [PATCH 0/8] RSS controller based on process containers (v2)
@ 2007-04-09 12:22 Pavel Emelianov
  2007-04-09 12:46 ` [PATCH 3/8] Add container pointer on mm_struct Pavel Emelianov
  0 siblings, 1 reply; 33+ messages in thread
From: Pavel Emelianov @ 2007-04-09 12:22 UTC (permalink / raw)
  To: Andrew Morton, Paul Menage, Srivatsa Vaddagiri, Balbir Singh
  Cc: devel, Linux Kernel Mailing List, Kirill Korotaev,
	Chandra Seetharaman, Cedric Le Goater, Eric W. Biederman,
	Rohit Seth, Linux Containers

Adds RSS accounting and control within a container.

Major change: current scanner code reuse.

Tasks and files accounting is not included as these containers
are simple enough to be implemented later.

Based on top of Paul Menage's container subsystem v8.
Note, that only first three patches from Paul's patchset should
be used as BeanCounters, CPU accounting etc are not needed for
RSS container.

RSS container includes the per-container RSS accounting and
reclamation, and out-of-memory killer. The container behaves like
a standalone machine - when it runs out of resources, it tries to
reclaim some pages, and if it doesn't succeed, kills some task
which mm_struct belongs to the container in question.

Changes from previous version:
* reclamation code reuse. I.e. the scanner code used to reclaim
  pages on global memory shortage is used as-is in per-container
  page reclamation;
* active/inactive per-container lists (a bit reworked patch
  from Balbir);
* more elegant top container creation (thanks Paul for clarifying).

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2007-06-04 13:27 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-30 15:24 [PATCH 0/8] RSS controller based on process containers (v3) Pavel Emelianov
2007-05-30 15:26 ` [PATCH 1/8] Resource counters Pavel Emelianov
2007-05-30 21:44   ` Andrew Morton
2007-05-30 15:28 ` [PATCH 2/8] Add container pointer on struct page Pavel Emelianov
2007-05-30 21:45   ` Andrew Morton
2007-05-30 15:29 ` [PATCH 3/8] Add container pointer on mm_struct Pavel Emelianov
2007-05-30 21:45   ` Andrew Morton
2007-05-30 15:32 ` [PATCH 4/8] RSS container core Pavel Emelianov
2007-05-30 21:46   ` Andrew Morton
2007-05-31  9:00     ` Pavel Emelianov
2007-05-30 15:34 ` [PATCH 5/8] RSS accounting hooks over the code Pavel Emelianov
2007-05-30 21:46   ` Andrew Morton
2007-06-01  6:48     ` Balbir Singh
2007-05-30 15:35 ` [PATCH 6/8] Per container OOM killer Pavel Emelianov
2007-05-30 15:39 ` [PATCH 7/8] Scanner changes needed to implement per-container scanner Pavel Emelianov
2007-05-30 21:46   ` Andrew Morton
2007-06-01  6:50     ` Balbir Singh
2007-06-01  7:40       ` Pavel Emelianov
2007-06-01  7:38         ` Balbir Singh
2007-05-30 15:42 ` [PATCH 8/8] Per-container pages reclamation Pavel Emelianov
2007-05-30 21:47   ` Andrew Morton
2007-05-31  8:22     ` Vaidyanathan Srinivasan
2007-05-31  9:22       ` Balbir Singh
2007-06-01  9:27         ` Pavel Emelianov
2007-06-01  9:23           ` Balbir Singh
2007-05-31 10:35     ` Pavel Emelianov
2007-05-31 17:58       ` Andrew Morton
2007-06-01  7:44         ` Pavel Emelianov
2007-06-01  7:49           ` Andrew Morton
2007-06-01  7:02     ` Balbir Singh
2007-06-01  7:50       ` Pavel Emelianov
  -- strict thread matches above, loose matches on Subject: below --
2007-06-04 13:25 [PATCH 0/8] RSS controller based on process containers (v3.1) Pavel Emelianov
2007-06-04 13:31 ` [PATCH 3/8] Add container pointer on mm_struct Pavel Emelianov
2007-04-09 12:22 [PATCH 0/8] RSS controller based on process containers (v2) Pavel Emelianov
2007-04-09 12:46 ` [PATCH 3/8] Add container pointer on mm_struct Pavel Emelianov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).