From: Balbir Singh <balbir@in.ibm.com>
To: Linux MM <linux-mm@kvack.org>
Cc: dev@openvz.org, ckrm-tech@lists.sourceforge.net,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
haveblue@us.ibm.com, rohitseth@google.com,
Balbir Singh <balbir@in.ibm.com>
Subject: [RFC][PATCH 2/8] RSS controller setup
Date: Fri, 10 Nov 2006 01:05:41 +0530 [thread overview]
Message-ID: <20061109193541.21437.8046.sendpatchset@balbir.in.ibm.com> (raw)
In-Reply-To: <20061109193523.21437.86224.sendpatchset@balbir.in.ibm.com>
Basic setup for a controller written for resource groups. This patch
registers a dummy controller.
Signed-off-by: Balbir Singh <balbir@in.ibm.com>
---
include/linux/memctlr.h | 31 ++++++++++++++
init/Kconfig | 11 +++++
kernel/res_group/Makefile | 1
kernel/res_group/memctlr.c | 94 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 137 insertions(+)
diff -puN /dev/null include/linux/memctlr.h
--- /dev/null 2006-05-31 06:45:07.000000000 +0530
+++ linux-2.6.19-rc2-balbir/include/linux/memctlr.h 2006-11-09 23:56:03.000000000 +0530
@@ -0,0 +1,31 @@
+/*
+ * Memory controller - "Account and Control Memory Usage"
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) IBM Corporation, 2006
+ *
+ * Author: Balbir Singh <balbir@in.ibm.com>
+ *
+ */
+
+#ifndef _LINUX_MEMCTRL_H
+#define _LINUX_MEMCTRL_H
+
+#ifdef CONFIG_RES_GROUPS_MEMORY
+#include <linux/res_group_rc.h>
+#endif /* CONFIG_RES_GROUPS_MEMORY */
+
+#endif /* _LINUX_MEMCTRL_H */
diff -puN init/Kconfig~container-memctlr-setup init/Kconfig
--- linux-2.6.19-rc2/init/Kconfig~container-memctlr-setup 2006-11-09 23:09:03.000000000 +0530
+++ linux-2.6.19-rc2-balbir/init/Kconfig 2006-11-09 23:56:47.000000000 +0530
@@ -325,6 +325,17 @@ config RES_GROUPS_NUMTASKS
Say N if unsure, Y to use the feature.
+config RES_GROUPS_MEMORY
+ bool "Memory Controller for RSS"
+ depends on RES_GROUPS
+ default y
+ help
+ Provides a Resource Controller for Resource Groups.
+ It limits the resident pages of the tasks belonging to the resource
+ group.
+
+ Say N if unsure, Y to use the feature.
+
endmenu
config SYSCTL
bool
diff -puN kernel/res_group/Makefile~container-memctlr-setup kernel/res_group/Makefile
--- linux-2.6.19-rc2/kernel/res_group/Makefile~container-memctlr-setup 2006-11-09 23:09:03.000000000 +0530
+++ linux-2.6.19-rc2-balbir/kernel/res_group/Makefile 2006-11-09 23:09:03.000000000 +0530
@@ -1,2 +1,3 @@
obj-y = res_group.o shares.o rgcs.o
obj-$(CONFIG_RES_GROUPS_NUMTASKS) += numtasks.o
+obj-$(CONFIG_RES_GROUPS_MEMORY) += memctlr.o
diff -puN /dev/null kernel/res_group/memctlr.c
--- /dev/null 2006-05-31 06:45:07.000000000 +0530
+++ linux-2.6.19-rc2-balbir/kernel/res_group/memctlr.c 2006-11-09 23:56:03.000000000 +0530
@@ -0,0 +1,94 @@
+/*
+ * Memory controller - "Account and Control Memory Usage"
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) IBM Corporation, 2006
+ *
+ * Author: Balbir Singh <balbir@in.ibm.com>
+ *
+ */
+
+/*
+ * Simple memory controller.
+ * Supports limits, guarantees not supported right now
+ *
+ * Tasks are group'ed virtually by thread groups - Add more details
+ */
+
+#include <linux/module.h>
+#include <linux/res_group_rc.h>
+#include <linux/memctlr.h>
+
+static const char res_ctlr_name[] = "memctlr";
+static struct resource_group *root_rgroup;
+
+struct mem_counter {
+ atomic_long_t rss;
+};
+
+struct memctlr {
+ struct resource_group *rgroup; /* My resource group */
+ struct res_shares shares; /* My shares */
+
+ struct mem_counter counter; /* Accounting information */
+ /* Statistics */
+ int successes;
+ int failures;
+};
+
+struct res_controller memctlr_rg;
+
+static struct memctlr *get_memctlr_from_shares(struct res_shares *shares)
+{
+ if (shares)
+ return container_of(shares, struct memctlr, shares);
+ return NULL;
+}
+
+static struct memctlr *get_memctlr(struct resource_group *rgroup)
+{
+ return get_memctlr_from_shares(get_controller_shares(rgroup,
+ &memctlr_rg));
+}
+
+struct res_controller memctlr_rg = {
+ .name = res_ctlr_name,
+ .ctlr_id = NO_RES_ID,
+ .alloc_shares_struct = NULL,
+ .free_shares_struct = NULL,
+ .move_task = NULL,
+ .shares_changed = NULL,
+ .show_stats = NULL,
+};
+
+int __init memctlr_init(void)
+{
+ if (memctlr_rg.ctlr_id != NO_RES_ID)
+ return -EBUSY; /* already registered */
+ return register_controller(&memctlr_rg);
+}
+
+void __exit memctlr_exit(void)
+{
+ int rc;
+ do {
+ rc = unregister_controller(&memctlr_rg);
+ } while (rc == -EBUSY);
+ BUG_ON(rc != 0);
+}
+
+module_init(memctlr_init);
+module_exit(memctlr_exit);
_
--
Balbir Singh,
Linux Technology Center,
IBM Software Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2006-11-09 19:46 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-09 19:35 [RFC][PATCH 0/8] RSS controller for containers Balbir Singh
2006-11-09 19:35 ` [RFC][PATCH 1/8] Fix resource groups parsing, while assigning shares Balbir Singh
2006-11-09 19:35 ` Balbir Singh [this message]
2006-11-09 19:35 ` [RFC][PATCH 3/8] RSS controller add callbacks Balbir Singh
2006-11-09 19:36 ` [RFC][PATCH 4/8] RSS controller accounting Balbir Singh
2006-11-10 9:06 ` Pavel Emelianov
2006-11-10 9:29 ` Balbir Singh
2006-11-09 19:36 ` [RFC][PATCH 5/8] RSS controller task migration support Balbir Singh
2006-11-09 19:36 ` [RFC][PATCH 6/8] RSS controller shares allocation Balbir Singh
2006-11-10 9:11 ` Pavel Emelianov
2006-11-10 10:27 ` [ckrm-tech] " Balbir Singh
2006-11-10 10:32 ` Pavel Emelianov
2006-11-10 12:55 ` Balbir Singh
2006-11-09 19:36 ` [RFC][PATCH 7/8] RSS controller fix resource groups parsing Balbir Singh
2006-11-10 9:13 ` Pavel Emelianov
2006-11-10 9:32 ` Balbir Singh
2006-11-09 19:36 ` [RFC][PATCH 8/8] RSS controller support reclamation Balbir Singh
2006-11-09 19:45 ` Arjan van de Ven
2006-11-10 1:56 ` [ckrm-tech] " Balbir Singh
2006-11-10 8:54 ` Pavel Emelianov
2006-11-10 9:16 ` Balbir Singh
2006-11-10 9:29 ` Pavel Emelianov
2006-11-10 12:42 ` Balbir Singh
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=20061109193541.21437.8046.sendpatchset@balbir.in.ibm.com \
--to=balbir@in.ibm.com \
--cc=ckrm-tech@lists.sourceforge.net \
--cc=dev@openvz.org \
--cc=haveblue@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rohitseth@google.com \
/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