All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chandra Seetharaman <sekharan@us.ibm.com>
To: akpm@osdl.org, linux-kernel@vger.kernel.org,
	ckrm-tech@lists.sourceforge.net
Cc: Chandra Seetharaman <sekharan@us.ibm.com>
Subject: [PATCH 1/6] numtasks - Initialization routines
Date: Thu, 27 Apr 2006 18:35:24 -0700	[thread overview]
Message-ID: <20060428013524.27212.37711.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20060428013518.27212.954.sendpatchset@localhost.localdomain>

1/6: numtasks_init

Hooks up with Resource Groups core by defining the basic alloc/free
functions and registering the controller with the core.
--

Signed-Off-By: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-Off-By: Matt Helsley <matthltc@us.ibm.com>

 init/Kconfig                |   10 ++++
 kernel/res_group/Makefile   |    1 
 kernel/res_group/numtasks.c |   90 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 101 insertions(+)

Index: linux-2617-rc3/kernel/res_group/Makefile
===================================================================
--- linux-2617-rc3.orig/kernel/res_group/Makefile	2006-04-27 10:14:38.000000000 -0700
+++ linux-2617-rc3/kernel/res_group/Makefile	2006-04-27 10:18:49.000000000 -0700
@@ -1,2 +1,3 @@
 obj-y = res_group.o shares.o task.o
+obj-$(CONFIG_RES_GROUPS_NUMTASKS) += numtasks.o
 obj-$(CONFIG_RGCS) += rgcs.o
Index: linux-2617-rc3/kernel/res_group/numtasks.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2617-rc3/kernel/res_group/numtasks.c	2006-04-27 10:18:49.000000000 -0700
@@ -0,0 +1,90 @@
+/* numtasks.c - "Number of tasks" resource controller for Resource Groups
+ *
+ * Copyright (C) Chandra Seetharaman,  IBM Corp. 2003-2006
+ *	      (C) Matt Helsley, IBM Corp. 2006
+ *
+ * Latest version, more details at http://ckrm.sf.net
+ *
+ * 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.
+ *
+ */
+
+/*
+ * Resource controller for tracking number of tasks in a resource group.
+ */
+#include <linux/module.h>
+#include <linux/res_group_rc.h>
+
+static const char res_ctlr_name[] = "numtasks";
+
+struct numtasks {
+	struct res_shares shares;
+};
+
+struct res_controller numtasks_ctlr;
+
+static struct numtasks *get_shares_numtasks(struct res_shares *shares)
+{
+	if (shares)
+		return container_of(shares, struct numtasks, shares);
+	return NULL;
+}
+
+/* Initialize share struct values */
+static void numtasks_res_init_one(struct numtasks *numtasks_res)
+{
+	numtasks_res->shares.min_shares = SHARE_DONT_CARE;
+	numtasks_res->shares.max_shares = SHARE_DONT_CARE;
+	numtasks_res->shares.child_shares_divisor = SHARE_DEFAULT_DIVISOR;
+	numtasks_res->shares.unused_min_shares = SHARE_DEFAULT_DIVISOR;
+}
+
+static struct res_shares *numtasks_alloc_shares_struct(
+					struct resource_group *rgroup)
+{
+	struct numtasks *res;
+
+	res = kzalloc(sizeof(struct numtasks), GFP_KERNEL);
+	if (!res)
+		return NULL;
+	numtasks_res_init_one(res);
+	return &res->shares;
+}
+
+/*
+ * No locking of this resource group object necessary as we are not
+ * supposed to be assigned (or used) when/after this function is called.
+ */
+static void numtasks_free_shares_struct(struct res_shares *my_res)
+{
+	kfree(get_shares_numtasks(my_res));
+}
+
+struct res_controller numtasks_ctlr = {
+	.name = res_ctlr_name,
+	.depth_supported = 3,
+	.ctlr_id = NO_RES_ID,
+	.alloc_shares_struct = numtasks_alloc_shares_struct,
+	.free_shares_struct = numtasks_free_shares_struct,
+};
+
+int __init init_numtasks_res(void)
+{
+	if (numtasks_ctlr.ctlr_id != NO_RES_ID)
+		return -EBUSY; /* already registered */
+	return register_controller(&numtasks_ctlr);
+}
+
+void __exit exit_numtasks_res(void)
+{
+	int rc;
+	do {
+		rc = unregister_controller(&numtasks_ctlr);
+	} while (rc == -EBUSY);
+	BUG_ON(rc != 0);
+}
+module_init(init_numtasks_res)
+module_exit(exit_numtasks_res)
Index: linux-2617-rc3/init/Kconfig
===================================================================
--- linux-2617-rc3.orig/init/Kconfig	2006-04-27 10:17:11.000000000 -0700
+++ linux-2617-rc3/init/Kconfig	2006-04-27 10:18:49.000000000 -0700
@@ -175,6 +175,16 @@ config RGCS
 	  Say M if unsure, Y to save on module loading. N doesn't make sense
 	  when Resource Groups has been configured.
 
+config RES_GROUPS_NUMTASKS
+	bool "Number of Tasks Resource Controller"
+	depends on RES_GROUPS
+	default y
+	help
+	  Provides a Resource Controller for Resource Groups that allows
+	  limiting number of tasks a resource group can have.
+
+	  Say N if unsure, Y to use the feature.
+
 endmenu
 config SYSCTL
 	bool "Sysctl support"

-- 

----------------------------------------------------------------------
    Chandra Seetharaman               | Be careful what you choose....
              - sekharan@us.ibm.com   |      .......you may get it.
----------------------------------------------------------------------

  reply	other threads:[~2006-04-28  1:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-28  1:35 [PATCH 0/6] Number of Tasks Resource controller Chandra Seetharaman
2006-04-28  1:35 ` Chandra Seetharaman [this message]
2006-04-28  1:35 ` [PATCH 2/6] numtasks - Add task control support Chandra Seetharaman
2006-04-28  1:35 ` [PATCH 3/6] numtasks - Add shares and stats support Chandra Seetharaman
2006-04-28  1:35 ` [PATCH 4/6] numtasks - Add configuration support Chandra Seetharaman
2006-04-28  1:35 ` [PATCH 5/6] numtasks - Add fork rate control support Chandra Seetharaman
2006-04-28  1:35 ` [PATCH 6/6] numtasks - Documentation for Numtasks controller Chandra Seetharaman

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=20060428013524.27212.37711.sendpatchset@localhost.localdomain \
    --to=sekharan@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=ckrm-tech@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.