All of lore.kernel.org
 help / color / mirror / Atom feed
* [1/3] Domgrps/SchedGrps Merge RFC: domgrps-vmm
@ 2008-02-04 19:14 Chris
  2008-02-06 12:00 ` Akio Takebe
  2008-02-11 22:07 ` Mike D. Day
  0 siblings, 2 replies; 6+ messages in thread
From: Chris @ 2008-02-04 19:14 UTC (permalink / raw)
  To: Mike D. Day; +Cc: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1101 bytes --]

diffstat domgrps-vmm.patch
  arch/ia64/xen/xensetup.c                 |    7
  arch/powerpc/powerpc64/hypercall_table.S |    1
  arch/powerpc/setup.c                     |    7
  arch/x86/setup.c                         |    8
  arch/x86/x86_32/entry.S                  |    2
  arch/x86/x86_64/entry.S                  |    3
  common/Makefile                          |    2
  common/domain.c                          |    8
  common/domctl.c                          |   13 +
  common/domgrp.c                          |  320 ++++++++++++++++++++ 
+++++++++++
  common/domgrpctl.c                       |  134 ++++++++++++
  common/sysctl.c                          |    1
  include/public/domctl.h                  |    2
  include/public/domgrpctl.h               |   86 ++++++++
  include/public/xen.h                     |    5
  include/xen/compile.h                    |   39 +++
  include/xen/domgrp.h                     |   36 +++
  include/xen/hypercall.h                  |    5
  include/xen/sched.h                      |   21 ++
  19 files changed, 697 insertions(+), 3 deletions(-)


[-- Attachment #2: domgrps-vmm.patch --]
[-- Type: application/octet-stream, Size: 30354 bytes --]

diff -urN xen-unstable/xen/arch/ia64/xen/xensetup.c xen-unstable-domgrps/xen/arch/ia64/xen/xensetup.c
--- xen-unstable/xen/arch/ia64/xen/xensetup.c	2008-01-29 12:44:24.000000000 -0500
+++ xen-unstable-domgrps/xen/arch/ia64/xen/xensetup.c	2008-01-29 12:52:40.000000000 -0500
@@ -15,6 +15,7 @@
 #include <xen/version.h>
 #include <xen/console.h>
 #include <xen/domain.h>
+#include <xen/domgrp.h>
 #include <xen/serial.h>
 #include <xen/trace.h>
 #include <xen/keyhandler.h>
@@ -632,6 +633,10 @@
 
     expose_p2m_init();
 
+    /* initialize domain groups */
+    if (init_domain_groups())
+        panic("Error creating default groups\n");
+
     /* Create initial domain 0. */
     dom0 = domain_create(0, 0, DOM0_SSIDREF);
     if (dom0 == NULL)
@@ -642,6 +647,8 @@
         panic("Cannot allocate dom0 vcpu 0\n");
 
     dom0->is_privileged = 1;
+    if (add_dom_to_grp(dom0, 0))
+        panic("Error adding dom0 to grp0\n");
     dom0->target = NULL;
 
     /*
diff -urN xen-unstable/xen/arch/powerpc/powerpc64/hypercall_table.S xen-unstable-domgrps/xen/arch/powerpc/powerpc64/hypercall_table.S
--- xen-unstable/xen/arch/powerpc/powerpc64/hypercall_table.S	2007-08-06 17:59:54.000000000 -0400
+++ xen-unstable-domgrps/xen/arch/powerpc/powerpc64/hypercall_table.S	2007-11-19 18:42:00.000000000 -0500
@@ -41,6 +41,7 @@
         .quad 0 /* do_hvm_op */
         .quad do_sysctl             /* 35 */
         .quad do_domctl
+        .quad do_domgrpctl
         .rept NR_hypercalls-((.-__hypercall_table)/8)
         .quad do_ni_hypercall
         .endr
diff -urN xen-unstable/xen/arch/powerpc/setup.c xen-unstable-domgrps/xen/arch/powerpc/setup.c
--- xen-unstable/xen/arch/powerpc/setup.c	2008-01-29 12:44:24.000000000 -0500
+++ xen-unstable-domgrps/xen/arch/powerpc/setup.c	2008-01-29 12:53:06.000000000 -0500
@@ -32,6 +32,7 @@
 #include <xen/trace.h>
 #include <xen/mm.h>
 #include <xen/domain.h>
+#include <xen/domgrp.h>
 #include <xen/gdbstub.h>
 #include <xen/symbols.h>
 #include <xen/keyhandler.h>
@@ -365,6 +366,10 @@
     /* This cannot be called before secondary cpus are marked online.  */
     percpu_free_unused_areas();
 
+    /* initialize domain groups */
+    if (init_domain_groups())
+        panic("Error creating default groups\n");
+
     /* Create initial domain 0. */
     dom0 = domain_create(0, 0, DOM0_SSIDREF);
     if (dom0 == NULL)
@@ -375,6 +380,8 @@
     dom0->vcpu[0]->cpu_affinity = cpumask_of_cpu(0);
 
     dom0->is_privileged = 1;
+    if (add_dom_to_grp(dom0, 0))
+        panic("Error adding dom0 to grp0\n");
     dom0->target = NULL;
 
     /* scrub_heap_pages() requires IRQs enabled, and we're post IRQ setup... */
diff -urN xen-unstable/xen/arch/x86/setup.c xen-unstable-domgrps/xen/arch/x86/setup.c
--- xen-unstable/xen/arch/x86/setup.c	2008-01-29 12:44:24.000000000 -0500
+++ xen-unstable-domgrps/xen/arch/x86/setup.c	2008-01-29 12:53:23.000000000 -0500
@@ -3,6 +3,7 @@
 #include <xen/lib.h>
 #include <xen/sched.h>
 #include <xen/domain.h>
+#include <xen/domgrp.h>
 #include <xen/serial.h>
 #include <xen/softirq.h>
 #include <xen/acpi.h>
@@ -969,6 +970,10 @@
     if ( opt_watchdog ) 
         watchdog_enable();
 
+    /* initialize domain groups */
+    if (init_domain_groups())
+        panic("Error creating default groups\n");
+
     /* Create initial domain 0. */
     dom0 = domain_create(0, 0, DOM0_SSIDREF);
     if ( (dom0 == NULL) || (alloc_vcpu(dom0, 0, 0) == NULL) )
@@ -977,6 +982,9 @@
     dom0->is_privileged = 1;
     dom0->target = NULL;
 
+    if (add_dom_to_grp(dom0, 0))
+        panic("Error adding dom0 to grp0\n");
+
     /* Grab the DOM0 command line. */
     cmdline = (char *)(mod[0].string ? __va(mod[0].string) : NULL);
     if ( (cmdline != NULL) || (kextra != NULL) )
diff -urN xen-unstable/xen/arch/x86/x86_32/entry.S xen-unstable-domgrps/xen/arch/x86/x86_32/entry.S
--- xen-unstable/xen/arch/x86/x86_32/entry.S	2007-11-19 10:38:08.000000000 -0500
+++ xen-unstable-domgrps/xen/arch/x86/x86_32/entry.S	2007-11-19 18:42:00.000000000 -0500
@@ -682,6 +682,7 @@
         .long do_sysctl             /* 35 */
         .long do_domctl
         .long do_kexec_op
+        .long do_domgrpctl
         .rept NR_hypercalls-((.-hypercall_table)/4)
         .long do_ni_hypercall
         .endr
@@ -725,6 +726,7 @@
         .byte 1 /* do_sysctl            */  /* 35 */
         .byte 1 /* do_domctl            */
         .byte 2 /* do_kexec_op          */
+        .byte 1 /* do_domgrpctl         */
         .rept NR_hypercalls-(.-hypercall_args_table)
         .byte 0 /* do_ni_hypercall      */
         .endr
diff -urN xen-unstable/xen/arch/x86/x86_64/entry.S xen-unstable-domgrps/xen/arch/x86/x86_64/entry.S
--- xen-unstable/xen/arch/x86/x86_64/entry.S	2007-11-19 10:38:08.000000000 -0500
+++ xen-unstable-domgrps/xen/arch/x86/x86_64/entry.S	2007-11-19 18:43:06.000000000 -0500
@@ -672,6 +672,7 @@
         .quad do_sysctl             /* 35 */
         .quad do_domctl
         .quad do_kexec_op
+        .quad do_domgrpctl
         .rept NR_hypercalls-((.-hypercall_table)/8)
         .quad do_ni_hypercall
         .endr
@@ -715,7 +716,7 @@
         .byte 1 /* do_sysctl            */  /* 35 */
         .byte 1 /* do_domctl            */
         .byte 2 /* do_kexec             */
-        .byte 1 /* do_xsm_op            */
+        .byte 1 /* do_domgrpctl         */
         .rept NR_hypercalls-(.-hypercall_args_table)
         .byte 0 /* do_ni_hypercall      */
         .endr
diff -urN xen-unstable/xen/common/domain.c xen-unstable-domgrps/xen/common/domain.c
--- xen-unstable/xen/common/domain.c	2008-01-29 12:44:24.000000000 -0500
+++ xen-unstable-domgrps/xen/common/domain.c	2008-01-29 12:53:23.000000000 -0500
@@ -11,6 +11,7 @@
 #include <xen/errno.h>
 #include <xen/sched.h>
 #include <xen/domain.h>
+#include <xen/domgrp.h>
 #include <xen/mm.h>
 #include <xen/event.h>
 #include <xen/time.h>
@@ -57,6 +58,7 @@
 
     memset(d, 0, sizeof(*d));
     d->domain_id = domid;
+    d->group = NULL;
 
     if ( xsm_alloc_security_domain(d) != 0 )
     {
@@ -241,6 +243,8 @@
         rcu_assign_pointer(*pd, d);
         rcu_assign_pointer(domain_hash[DOMAIN_HASH(domid)], d);
         spin_unlock(&domlist_update_lock);
+
+        add_dom_to_grp(d, NULL_GROUP_ID);
     }
 
     return d;
@@ -388,6 +392,8 @@
 {
     struct vcpu *v;
 
+    del_dom_from_grp(d);
+
     if ( d->domain_id == 0 )
         dom0_shutdown(reason);
 
@@ -525,6 +531,8 @@
     if ( _atomic_read(old) != 0 )
         return;
 
+    del_dom_from_grp(d);
+
     /* Delete from task list and task hashtable. */
     spin_lock(&domlist_update_lock);
     pd = &domain_list;
diff -urN xen-unstable/xen/common/domctl.c xen-unstable-domgrps/xen/common/domctl.c
--- xen-unstable/xen/common/domctl.c	2008-01-29 12:44:24.000000000 -0500
+++ xen-unstable-domgrps/xen/common/domctl.c	2008-01-29 12:53:23.000000000 -0500
@@ -12,6 +12,7 @@
 #include <xen/mm.h>
 #include <xen/sched.h>
 #include <xen/domain.h>
+#include <xen/domgrp.h>
 #include <xen/event.h>
 #include <xen/domain_page.h>
 #include <xen/trace.h>
@@ -94,8 +95,16 @@
     u64 cpu_time = 0;
     int flags = XEN_DOMINF_blocked;
     struct vcpu_runstate_info runstate;
-    
+    struct domain_group *grp;
+
     info->domain = d->domain_id;
+
+    if (d->group)
+        grp = d->group;
+    else
+        grp = find_grp_by_id(NULL_GROUP_ID);
+
+    info->group = grp->group_id;
     info->nr_online_vcpus = 0;
     
     /* 
@@ -136,6 +145,7 @@
     info->shared_info_frame = mfn_to_gmfn(d, __pa(d->shared_info)>>PAGE_SHIFT);
 
     memcpy(info->handle, d->handle, sizeof(xen_domain_handle_t));
+    memcpy(info->dg_handle, grp->handle, sizeof(xen_domain_group_handle_t));
 }
 
 static unsigned int default_vcpu0_location(void)
@@ -546,7 +556,6 @@
         ret = xsm_getdomaininfo(d);
         if ( ret )
             goto getdomaininfo_out;
-
         getdomaininfo(d, &op->u.getdomaininfo);
 
         op->domain = op->u.getdomaininfo.domain;
diff -urN xen-unstable/xen/common/domgrp.c xen-unstable-domgrps/xen/common/domgrp.c
--- xen-unstable/xen/common/domgrp.c	1969-12-31 19:00:00.000000000 -0500
+++ xen-unstable-domgrps/xen/common/domgrp.c	2008-01-30 09:51:52.000000000 -0500
@@ -0,0 +1,320 @@
+/******************************************************************************
+ * domgrp.c
+ *
+ * Generic domain group-handling functions.
+ *
+ * Author: Chris Bookholt (hap10@tycho.ncsc.mil)
+ */
+
+#include <xen/sched.h>
+#include <xen/list.h>
+#include <xen/xmalloc.h>
+#include <public/domgrpctl.h>
+
+DEFINE_SPINLOCK(domgrplist_update_lock);
+DEFINE_RCU_READ_LOCK(domgrplist_read_lock);
+
+struct list_head domgrplist;
+
+#define SERIALIZE_LINKED_LIST(op_name, list_name)		\
+    rcu_read_lock(&grp->op_name##_read_lock);			\
+    memset(&info->op_name, 0, sizeof(domid_t)*MAX_GROUP_SIZE);	\
+    if (!list_empty(&grp->op_name)) {				\
+        i = 0;							\
+        list_for_each_entry(dom, &grp->op_name, list_name) {	\
+            info->op_name[i] = dom->domain_id;			\
+       	    i++;						\
+	}							\
+    } else 							\
+	info->op_name[i] = NULL_GROUP_ID;			\
+    rcu_read_unlock(&grp->op_name##_read_lock);
+
+void get_grp_info(struct domain_group *grp, xen_domgrpctl_getgrpinfo_t * info)
+{
+	struct domain *dom;
+	uint16_t i = 0;
+
+	info->dgid = grp->group_id;
+	info->size = grp->size;
+
+	SERIALIZE_LINKED_LIST(member_list, member);
+
+	memcpy(info->handle, grp->handle, sizeof(xen_domain_group_handle_t));
+}
+
+struct domain_group *alloc_domain_group(void)
+{
+	struct domain_group *grp = NULL;
+
+	if ((grp = xmalloc(struct domain_group)) != NULL)
+		 memset(grp, 0, sizeof(*grp));
+
+	return grp;
+}
+
+struct domain_group *find_grp_by_id(dgid_t dgid)
+{
+	struct domain_group *grp;
+
+	rcu_read_lock(&domgrplist_read_lock);
+	list_for_each_entry(grp, &domgrplist, groups) {
+	    BUG_ON(grp == NULL);
+	    if (grp->group_id == dgid) 
+		goto out;
+	}
+	grp = NULL;
+      out:
+	rcu_read_unlock(&domgrplist_read_lock);
+	return grp;
+}
+
+uint16_t get_new_group_id(void)
+{
+	static DEFINE_SPINLOCK(domgrpcnt_lock);
+	static dgid_t group_counter = 1;
+	dgid_t ret;
+	
+	if (group_counter < NULL_GROUP_ID - 1) {
+		spin_lock(&domgrpcnt_lock);
+	        ret = group_counter++;
+		spin_unlock(&domgrpcnt_lock);
+	} else
+		ret = NULL_GROUP_ID;
+	return ret;
+}
+
+struct domain_group *domain_group_create(dgid_t dgid)
+{
+	struct domain_group *grp = NULL, *tail;
+
+	grp = alloc_domain_group();
+	if (!grp)
+		goto out;
+
+	grp->group_id = dgid;
+	grp->size = 0;
+	if (dgid == 0)
+		memset(grp->handle, 0, sizeof(xen_domain_group_handle_t));
+	else if (dgid == NULL_GROUP_ID)
+		memset(grp->handle, 0xFF, sizeof(xen_domain_group_handle_t));
+
+	/* init group's lists */
+	INIT_LIST_HEAD(&grp->member_list);
+
+	/* init group's locks */
+	spin_lock_init(&grp->grp_big_lock);
+	spin_lock_init(&grp->member_list_update_lock);
+
+	/* add new group to domgrplist *
+	 * TODO: This is a candidate for optimization. Could 
+	 * be optimized by maintaining a ptr to the tail, but 
+	 * list size is small, so search isn't expensive */
+	if (dgid != 0 && dgid != NULL_GROUP_ID) {
+		tail = find_grp_by_id(NULL_GROUP_ID);
+		spin_lock(&domgrplist_update_lock);
+		list_add_tail(&grp->groups, &tail->groups);
+		spin_unlock(&domgrplist_update_lock);
+	} else {
+		spin_lock(&domgrplist_update_lock);
+		list_add_tail(&grp->groups, &domgrplist);
+		spin_unlock(&domgrplist_update_lock);
+	}
+
+      out:
+	return grp;
+}
+
+int dom_in_member_list(domid_t domid, struct domain_group *grp)
+{
+	struct domain *dom;
+	int ret = 0;
+
+	if (grp == NULL) {
+		ret = -EINVAL;
+		goto out;
+	}
+
+	rcu_read_lock(&grp->member_list_read_lock);
+	list_for_each_entry(dom, &grp->member_list, member) {
+		if (dom->domain_id == domid) {
+			ret = 1;
+			break;
+		}
+	}
+	rcu_read_unlock(&grp->member_list_read_lock);
+      out:
+	return ret;
+}
+
+#define RM_DOM_FROM_LIST(list_name, entry)	\
+    spin_lock(&grp->list_name##_update_lock);	\
+    if (!list_empty(&grp->list_name)) 		\
+        list_del(&dom->entry);		    	\
+    spin_unlock(&grp->list_name##_update_lock);
+
+void del_dom_from_grp(struct domain *dom)
+{
+	struct domain_group *grp;
+
+	if (dom == NULL)
+		goto out;
+
+	grp = dom->group;
+	if (grp == NULL)
+		goto out;
+
+	/* skip it if dom is not a member */
+	if (dom_in_member_list(dom->domain_id, grp) <= 0)
+		goto out;
+
+	RM_DOM_FROM_LIST(member_list, member);
+	dom->group = NULL;
+	grp->size--;
+
+      out:
+	return;
+}
+
+int add_dom_to_grp(struct domain *dom, dgid_t dgid)
+{
+	struct domain_group *grp = NULL;
+	int ret = 0;
+
+	if (dom == NULL)
+		goto out;
+
+	grp = find_grp_by_id(dgid);
+	if (grp == NULL) {
+		printk("DEBUG: add_dom_to_grp(): *grp was null\n");
+		ret = -ESRCH;
+		goto out;
+	} 
+
+	if (grp->size >= MAX_GROUP_SIZE) {
+		ret = -EPERM;
+		goto out;
+	} 
+
+	/* skip it if dom is already a member */
+	if (dom_in_member_list(dom->domain_id, grp))
+		goto out;
+	
+	/* remove dom from old group */
+	if (dom->group != NULL)
+		del_dom_from_grp(dom);
+
+	/* add dom to end of new group list */
+	spin_lock(&grp->member_list_update_lock);
+	list_add_tail(&dom->member, &grp->member_list);
+	spin_unlock(&grp->member_list_update_lock);
+
+        dom->group = grp;
+	grp->size++;
+      out: 
+	return ret;
+}
+
+int pause_grp(dgid_t dgid)
+{
+	int ret = 0;
+	struct domain *member;
+	struct domain_group *grp;
+
+	if (dgid == 0) {
+		ret = -EPERM;
+		goto out;
+	}
+
+	grp = find_grp_by_id(dgid);
+
+	if (grp == NULL) {
+		ret = -ESRCH;
+		goto out;
+	}
+
+	spin_lock_recursive(&grp->grp_big_lock);
+	rcu_read_lock(&grp->member_list_read_lock);
+	/* could ignore interupts during this loop to increase atomicity */
+	list_for_each_entry(member, &grp->member_list, member) {
+		if (member != current->domain && member->domain_id != 0)
+			domain_pause_by_systemcontroller(member);
+	}
+	rcu_read_unlock(&grp->member_list_read_lock);
+	spin_unlock_recursive(&grp->grp_big_lock);
+      out:
+	return ret;
+}
+
+int unpause_grp(dgid_t dgid)
+{
+	int ret = 0;
+	struct domain *member;
+	struct domain_group *grp;
+
+	if (dgid == 0) {
+		ret = -EPERM;
+		goto out;
+	}
+
+	grp = find_grp_by_id(dgid);
+
+	if (grp == NULL) {
+		ret = -ESRCH;
+		goto out;
+	}
+
+	spin_lock_recursive(&grp->grp_big_lock);
+	rcu_read_lock(&grp->member_list_read_lock);
+	/* could ignore interupts during this loop to increase atomicity */
+	list_for_each_entry(member, &grp->member_list, member) {
+		if (member != current->domain && member->domain_id != 0)
+			domain_unpause_by_systemcontroller(member);
+	}
+	rcu_read_unlock(&grp->member_list_read_lock);
+	spin_unlock_recursive(&grp->grp_big_lock);
+      out:
+	return ret;
+}
+
+int domain_group_destroy(dgid_t dgid)
+{
+	int ret = 0;
+	struct domain_group *grp;
+
+	grp = find_grp_by_id(dgid);
+	if (grp == NULL) {
+		ret = -ESRCH;
+		goto out;
+	}
+
+	if (grp->size != 0) {
+		ret = -EPERM;
+		printk(KERN_INFO "refusing to destroy non-emtpry group %d\n", grp->group_id);
+		goto out;
+	}
+
+	spin_lock(&domgrplist_update_lock);
+	list_del(&grp->groups);
+	spin_unlock(&domgrplist_update_lock);
+
+	xfree(grp);
+      out:
+	return ret;
+}
+
+int init_domain_groups(void)
+{
+	struct domain_group *grp0, *nullgrp;
+	int ret = 0;
+	INIT_LIST_HEAD(&domgrplist);
+
+	/* order matters for creation of default groups: 
+	 * create default groups in order of ascending dgid so they 
+	 * are added to the group list in the expected order */
+	grp0 = domain_group_create(0);
+	nullgrp = domain_group_create(NULL_GROUP_ID);
+
+	if (!grp0 || !nullgrp)
+	    ret = -ENOMEM;
+	return ret;
+}
diff -urN xen-unstable/xen/common/domgrpctl.c xen-unstable-domgrps/xen/common/domgrpctl.c
--- xen-unstable/xen/common/domgrpctl.c	1969-12-31 19:00:00.000000000 -0500
+++ xen-unstable-domgrps/xen/common/domgrpctl.c	2007-11-19 18:42:00.000000000 -0500
@@ -0,0 +1,134 @@
+/******************************************************************************
+ * domgrpctl.c
+ *
+ * Domain group management operations. For use by node control stack.
+ *
+ * Author: Chris Bookholt (hap10@tycho.ncsc.mil)
+ */
+
+#include <xen/sched.h>
+#include <xen/domgrp.h>
+#include <xen/guest_access.h>
+#include <public/domgrpctl.h>
+#include <asm/current.h>
+
+long do_domgrpctl(XEN_GUEST_HANDLE(xen_domgrpctl_t) u_domgrpctl)
+{
+	long ret = 0;
+	struct xen_domgrpctl curop, *op = &curop;
+	static DEFINE_SPINLOCK(domgrpctl_lock);
+	struct domain_group *grp;
+	dgid_t dgid;
+
+	if (!IS_PRIV(current->domain)) {
+		ret = -EPERM;
+		goto out;
+	}
+
+	if (copy_from_guest(op, u_domgrpctl, 1)) {
+		ret = -EFAULT;
+		goto out;
+	}
+
+	if (op->interface_version != XEN_DOMGRPCTL_INTERFACE_VERSION) {
+		ret = -EINVAL;
+		goto out;
+	}
+
+	spin_lock(&domgrpctl_lock);
+
+	switch (op->cmd) {
+
+	case XEN_DOMGRPCTL_getgrpinfo:
+		{
+			rcu_read_lock(&domgrplist_read_lock);
+			ret = -ESRCH;
+			dgid = op->u.get_grp_info.dgid;
+
+			list_for_each_entry(grp, &domgrplist, groups) {
+				if (grp->group_id >= dgid) {
+					ret = 0;
+					break;
+				}
+			}
+			if (ret)
+				goto getgrpinfo_out;
+
+			get_grp_info(grp, &op->u.get_grp_info);
+
+			if (copy_to_guest(u_domgrpctl, op, 1))
+				ret = -EFAULT;
+
+		      getgrpinfo_out:
+			rcu_read_unlock(&domgrplist_read_lock);
+			break;
+		}
+
+	case XEN_DOMGRPCTL_creategrp:
+		{
+			dgid = get_new_group_id();
+			if (dgid == NULL_GROUP_ID) {
+				ret = -EINVAL;
+				break;
+			}
+
+			grp = domain_group_create(dgid);
+			if (grp == NULL) {
+				ret = -ENOMEM;
+				break;
+			}
+
+			memcpy(grp->handle, op->u.create_grp.handle,
+			       sizeof(xen_domain_group_handle_t));
+
+			op->u.create_grp.dgid = grp->group_id;
+			if (copy_to_guest(u_domgrpctl, op, 1))
+				ret = -EFAULT;
+
+			break;
+		}
+
+	case XEN_DOMGRPCTL_joingrp:
+		{
+			domid_t domid;
+			struct domain *dom;
+
+			domid = op->u.join_grp.domid;
+			dgid = op->u.join_grp.dgid;
+
+			dom = get_domain_by_id(domid);
+			if (dom == NULL)
+				ret = -ESRCH;
+			else
+				ret = add_dom_to_grp(dom, dgid);
+			put_domain(dom);
+
+			break;
+		}
+
+	case XEN_DOMGRPCTL_pausegrp:
+		{
+			ret = pause_grp(op->u.pause_grp.dgid);
+			break;
+		}
+
+	case XEN_DOMGRPCTL_unpausegrp:
+		{
+			ret = unpause_grp(op->u.unpause_grp.dgid);
+			break;
+		}
+
+	case XEN_DOMGRPCTL_destroygrp:
+		{
+			ret = domain_group_destroy(op->u.destroy_grp.dgid);
+			break;
+		}
+
+	default:
+		ret = -EINVAL;
+	}
+
+	spin_unlock(&domgrpctl_lock);
+      out:
+	return ret;
+}
diff -urN xen-unstable/xen/common/Makefile xen-unstable-domgrps/xen/common/Makefile
--- xen-unstable/xen/common/Makefile	2007-11-19 10:38:08.000000000 -0500
+++ xen-unstable-domgrps/xen/common/Makefile	2007-11-19 18:42:00.000000000 -0500
@@ -1,6 +1,8 @@
 obj-y += bitmap.o
 obj-y += domctl.o
+obj-y += domgrpctl.o
 obj-y += domain.o
+obj-y += domgrp.o
 obj-y += event_channel.o
 obj-y += grant_table.o
 obj-y += kernel.o
diff -urN xen-unstable/xen/common/sysctl.c xen-unstable-domgrps/xen/common/sysctl.c
--- xen-unstable/xen/common/sysctl.c	2007-11-19 10:38:08.000000000 -0500
+++ xen-unstable-domgrps/xen/common/sysctl.c	2008-01-22 14:40:02.000000000 -0500
@@ -104,6 +104,7 @@
             if ( ret )
                 continue;
 
+            printk("DEBUG: XEN_SYSCTL_getdomaininfolist\n");
             getdomaininfo(d, &info);
 
             if ( copy_to_guest_offset(op->u.getdomaininfolist.buffer,
diff -urN xen-unstable/xen/include/public/domctl.h xen-unstable-domgrps/xen/include/public/domctl.h
--- xen-unstable/xen/include/public/domctl.h	2008-01-29 12:44:24.000000000 -0500
+++ xen-unstable-domgrps/xen/include/public/domctl.h	2008-01-29 12:53:23.000000000 -0500
@@ -70,6 +70,7 @@
 struct xen_domctl_getdomaininfo {
     /* OUT variables. */
     domid_t  domain;              /* Also echoed in domctl.domain */
+    dgid_t   group;
  /* Domain is scheduled to die. */
 #define _XEN_DOMINF_dying     0
 #define XEN_DOMINF_dying      (1U<<_XEN_DOMINF_dying)
@@ -106,6 +107,7 @@
     uint32_t max_vcpu_id;        /* Maximum VCPUID in use by this domain. */
     uint32_t ssidref;
     xen_domain_handle_t handle;
+    xen_domain_group_handle_t dg_handle;
 };
 typedef struct xen_domctl_getdomaininfo xen_domctl_getdomaininfo_t;
 DEFINE_XEN_GUEST_HANDLE(xen_domctl_getdomaininfo_t);
diff -urN xen-unstable/xen/include/public/domgrpctl.h xen-unstable-domgrps/xen/include/public/domgrpctl.h
--- xen-unstable/xen/include/public/domgrpctl.h	1969-12-31 19:00:00.000000000 -0500
+++ xen-unstable-domgrps/xen/include/public/domgrpctl.h	2007-11-19 18:42:00.000000000 -0500
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * domgrpctl.h
+ *
+ * Domain group management operations. For use by node control stack.
+ *
+ * Author: Chris Bookholt (hap10@tycho.ncsc.mil)
+ */
+
+#ifndef __XEN_PUBLIC_DOMGRPCTL_H__
+#define __XEN_PUBLIC_DOMGRPCTL_H__
+
+#if !defined(__XEN__) && !defined(__XEN_TOOLS__)
+#error "domgrpctl operations are intended for use by node control tools only"
+#endif
+
+#include "xen.h"
+
+#define XEN_DOMGRPCTL_INTERFACE_VERSION 0x00000001
+
+#define MAX_GROUP_SIZE			24
+#define NULL_GROUP_ID			(0x7FFFU)
+#define INVAL_GROUP_ID			(0xFFFFU)
+
+#define XEN_DOMGRPCTL_creategrp		1
+struct xen_domgrpctl_creategrp {
+	dgid_t dgid;
+	xen_domain_group_handle_t handle;
+};
+typedef struct xen_domgrpctl_creategrp xen_domgrpctl_creategrp_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domgrpctl_creategrp_t);
+
+#define XEN_DOMGRPCTL_joingrp		2
+struct xen_domgrpctl_joingrp {
+	domid_t domid;
+	dgid_t dgid;
+};
+typedef struct xen_domgrpctl_joingrp xen_domgrpctl_joingrp_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domgrpctl_joingrp_t);
+
+#define XEN_DOMGRPCTL_pausegrp		3
+struct xen_domgrpctl_pausegrp {
+	dgid_t dgid;
+};
+typedef struct xen_domgrpctl_pausegrp xen_domgrpctl_pausegrp_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domgrpctl_pausegrp_t);
+
+#define XEN_DOMGRPCTL_unpausegrp	4
+struct xen_domgrpctl_unpausegrp {
+	dgid_t dgid;
+};
+typedef struct xen_domgrpctl_unpausegrp xen_domgrpctl_unpausegrp_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domgrpctl_unpausegrp_t);
+
+#define XEN_DOMGRPCTL_destroygrp	5
+struct xen_domgrpctl_destroygrp {
+	dgid_t dgid;
+};
+typedef struct xen_domgrpctl_destroygrp xen_domgrpctl_destroygrp_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domgrpctl_destroygrp_t);
+
+#define XEN_DOMGRPCTL_getgrpinfo	6
+struct xen_domgrpctl_getgrpinfo {
+	dgid_t dgid;
+	uint16_t size;
+	domid_t member_list[MAX_GROUP_SIZE];
+	xen_domain_group_handle_t handle;
+};
+typedef struct xen_domgrpctl_getgrpinfo xen_domgrpctl_getgrpinfo_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domgrpctl_getgrpinfo_t);
+
+struct xen_domgrpctl {
+	uint32_t cmd;
+	uint32_t interface_version;
+	union {
+		struct xen_domgrpctl_creategrp create_grp;
+		struct xen_domgrpctl_joingrp join_grp;
+		struct xen_domgrpctl_pausegrp pause_grp;
+		struct xen_domgrpctl_unpausegrp unpause_grp;
+		struct xen_domgrpctl_destroygrp destroy_grp;
+		struct xen_domgrpctl_getgrpinfo get_grp_info;
+	} u;
+};
+typedef struct xen_domgrpctl xen_domgrpctl_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domgrpctl_t);
+
+#endif				/* __XEN_PUBLIC_DOMGRPCTL_H__ */
diff -urN xen-unstable/xen/include/public/xen.h xen-unstable-domgrps/xen/include/public/xen.h
--- xen-unstable/xen/include/public/xen.h	2008-01-29 12:44:24.000000000 -0500
+++ xen-unstable-domgrps/xen/include/public/xen.h	2008-01-29 12:53:23.000000000 -0500
@@ -93,6 +93,7 @@
 #define __HYPERVISOR_sysctl               35
 #define __HYPERVISOR_domctl               36
 #define __HYPERVISOR_kexec_op             37
+#define __HYPERVISOR_domgrpctl            38
 
 /* Architecture-specific hypercall definitions. */
 #define __HYPERVISOR_arch_0               48
@@ -319,6 +320,8 @@
 
 typedef uint16_t domid_t;
 
+typedef uint16_t dgid_t;
+
 /* Domain ids >= DOMID_FIRST_RESERVED cannot be used for ordinary domains. */
 #define DOMID_FIRST_RESERVED (0x7FF0U)
 
@@ -601,6 +604,8 @@
 
 typedef uint8_t xen_domain_handle_t[16];
 
+typedef uint8_t xen_domain_group_handle_t[16];
+
 /* Turn a plain number into a C unsigned long constant. */
 #define __mk_unsigned_long(x) x ## UL
 #define mk_unsigned_long(x) __mk_unsigned_long(x)
diff -urN xen-unstable/xen/include/xen/compile.h xen-unstable-domgrps/xen/include/xen/compile.h
--- xen-unstable/xen/include/xen/compile.h	1969-12-31 19:00:00.000000000 -0500
+++ xen-unstable-domgrps/xen/include/xen/compile.h	2008-01-23 14:58:34.000000000 -0500
@@ -0,0 +1,39 @@
+#define XEN_COMPILE_DATE	"Wed Jan 23 14:58:34 EST 2008"
+#define XEN_COMPILE_TIME	"14:58:34"
+#define XEN_COMPILE_BY		"cgbook2"
+#define XEN_COMPILE_DOMAIN	"epoch.ncsc.mil"
+#define XEN_COMPILE_HOST	"moss-zuul.epoch.ncsc.mil"
+#define XEN_COMPILER		"gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)"
+
+#define XEN_VERSION		3
+#define XEN_SUBVERSION		2
+#define XEN_EXTRAVERSION	".0-rc2-pre"
+
+#define XEN_CHANGESET		"Wed Jan 23 14:48:12 2008 -0500 16715:c3db21b13433"
+#define XEN_BANNER		\
+"\040\137\137\040\040\137\137\040\040\040\040\040\040\040\040\040\040\040" \
+"\040\137\137\137\137\137\040\040\137\137\137\137\040\040\040\040\137\137" \
+"\137\040\040\040\040\040\040\040\040\040\040\040\040\040\040\137\137\137" \
+"\137\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040" \
+"\040\040\040\012\040\134\040\134\057\040\057\137\137\137\040\137\040\137" \
+"\137\040\040\040\174\137\137\137\040\057\040\174\137\137\137\040\134\040" \
+"\040\057\040\137\040\134\040\040\040\040\137\040\137\137\040\137\137\137" \
+"\174\137\137\137\040\134\040\040\040\040\137\040\137\137\040\040\137\040" \
+"\137\137\040\137\137\137\040\012\040\040\134\040\040\057\057\040\137\040" \
+"\134\040\047\137\040\134\040\040\040\040\174\137\040\134\040\040\040\137" \
+"\137\051\040\174\174\040\174\040\174\040\174\137\137\174\040\047\137\137" \
+"\057\040\137\137\174\040\137\137\051\040\174\137\137\174\040\047\137\040" \
+"\134\174\040\047\137\137\057\040\137\040\134\012\040\040\057\040\040\134" \
+"\040\040\137\137\057\040\174\040\174\040\174\040\040\137\137\137\051\040" \
+"\174\040\057\040\137\137\057\040\174\040\174\137\174\040\174\137\137\174" \
+"\040\174\040\174\040\050\137\137\040\057\040\137\137\057\174\137\137\174" \
+"\040\174\137\051\040\174\040\174\040\174\040\040\137\137\057\012\040\057" \
+"\137\057\134\137\134\137\137\137\174\137\174\040\174\137\174\040\174\137" \
+"\137\137\137\050\137\051\137\137\137\137\137\050\137\051\137\137\137\057" \
+"\040\040\040\174\137\174\040\040\134\137\137\137\174\137\137\137\137\137" \
+"\174\040\040\174\040\056\137\137\057\174\137\174\040\040\134\137\137\137" \
+"\174\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040" \
+"\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040" \
+"\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040" \
+"\040\040\040\040\040\040\040\174\137\174\040\040\040\040\040\040\040\040" \
+"\040\040\040\040\040\012"
diff -urN xen-unstable/xen/include/xen/domgrp.h xen-unstable-domgrps/xen/include/xen/domgrp.h
--- xen-unstable/xen/include/xen/domgrp.h	1969-12-31 19:00:00.000000000 -0500
+++ xen-unstable-domgrps/xen/include/xen/domgrp.h	2007-11-19 18:42:00.000000000 -0500
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * domgrp.h
+ *
+ * Generic domain group-handling functions.
+ *
+ * Author: Chris Bookholt (hap10@tycho.ncsc.mil)
+ */
+
+#ifndef __XEN_DOM_GROUP_H__
+#define __XEN_DOM_GROUP_H__
+
+#include <public/domgrpctl.h>
+
+extern struct list_head domgrplist;
+
+void get_grp_info(struct domain_group *grp, xen_domgrpctl_getgrpinfo_t * info);
+
+struct domain_group *find_grp_by_id(dgid_t dgid);
+
+uint16_t get_new_group_id(void);
+
+struct domain_group *domain_group_create(dgid_t dgid);
+
+int del_dom_from_grp(struct domain *old_dom);
+
+int add_dom_to_grp(struct domain *dom, dgid_t dgid);
+
+int pause_grp(dgid_t dgid);
+
+int unpause_grp(dgid_t dgid);
+
+int domain_group_destroy(dgid_t dgid);
+
+int init_domain_groups(void);
+
+#endif				/* __XEN_DOM_GROUP_H__ */
diff -urN xen-unstable/xen/include/xen/hypercall.h xen-unstable-domgrps/xen/include/xen/hypercall.h
--- xen-unstable/xen/include/xen/hypercall.h	2007-09-13 14:40:12.000000000 -0400
+++ xen-unstable-domgrps/xen/include/xen/hypercall.h	2007-11-19 18:42:00.000000000 -0500
@@ -10,6 +10,7 @@
 #include <xen/time.h>
 #include <public/xen.h>
 #include <public/domctl.h>
+#include <public/domgrpctl.h>
 #include <public/sysctl.h>
 #include <public/platform.h>
 #include <public/event_channel.h>
@@ -35,6 +36,10 @@
     XEN_GUEST_HANDLE(xen_domctl_t) u_domctl);
 
 extern long
+do_domgrpctl(
+    XEN_GUEST_HANDLE(xen_domgrpctl_t) u_domgrpctl);
+
+extern long
 do_sysctl(
     XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl);
 
diff -urN xen-unstable/xen/include/xen/sched.h xen-unstable-domgrps/xen/include/xen/sched.h
--- xen-unstable/xen/include/xen/sched.h	2008-01-29 12:44:24.000000000 -0500
+++ xen-unstable-domgrps/xen/include/xen/sched.h	2008-01-29 12:53:24.000000000 -0500
@@ -9,6 +9,7 @@
 #include <xen/shared.h>
 #include <public/xen.h>
 #include <public/domctl.h>
+#include <public/domgrpctl.h>
 #include <public/vcpu.h>
 #include <public/xsm/acm.h>
 #include <xen/time.h>
@@ -19,6 +20,7 @@
 #include <xen/xenoprof.h>
 #include <xen/rcupdate.h>
 #include <xen/irq.h>
+#include <xen/init.h>
 
 #ifdef CONFIG_COMPAT
 #include <compat/vcpu.h>
@@ -27,6 +29,9 @@
 
 extern unsigned long volatile jiffies;
 
+extern spinlock_t domgrplist_update_lock;
+extern rcu_read_lock_t domgrplist_read_lock;
+
 /* A global pointer to the initial domain (DOM0). */
 extern struct domain *dom0;
 
@@ -147,6 +152,9 @@
 {
     domid_t          domain_id;
 
+    struct domain_group *group;
+    struct list_head member;
+
     shared_info_t   *shared_info;     /* shared data area */
 
     spinlock_t       big_lock;
@@ -237,6 +245,19 @@
     spinlock_t hypercall_deadlock_mutex;
 };
 
+struct domain_group
+{
+    dgid_t                       group_id;
+    uint16_t                     size;
+    struct list_head             groups;
+    struct list_head             member_list;
+    spinlock_t                   grp_big_lock;
+    spinlock_t                   member_list_update_lock;
+    rcu_read_lock_t              member_list_read_lock;
+    xen_domain_group_handle_t    handle;
+    void 			*sched_priv; /* scheduler-specific data */ 
+};
+
 struct domain_setup_info
 {
     /* Initialised by caller. */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

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

* Re: [1/3] Domgrps/SchedGrps Merge RFC: domgrps-vmm
  2008-02-04 19:14 [1/3] Domgrps/SchedGrps Merge RFC: domgrps-vmm Chris
@ 2008-02-06 12:00 ` Akio Takebe
  2008-02-06 13:59   ` Chris
  2008-02-11 22:07 ` Mike D. Day
  1 sibling, 1 reply; 6+ messages in thread
From: Akio Takebe @ 2008-02-06 12:00 UTC (permalink / raw)
  To: Chris, Mike D. Day; +Cc: xen-devel

Hi, Chris

Please write summaries of each patches.
And can you wirte usage of domgrps/schedgrps?
My comments are below.

+long do_domgrpctl(XEN_GUEST_HANDLE(xen_domgrpctl_t) u_domgrpctl)
+{
+	long ret = 0;
+	struct xen_domgrpctl curop, *op = &curop;
+	static DEFINE_SPINLOCK(domgrpctl_lock);
+	struct domain_group *grp;
+	dgid_t dgid;
+
+	if (!IS_PRIV(current->domain)) {
+		ret = -EPERM;
+		goto out;
+	}
+
+	if (copy_from_guest(op, u_domgrpctl, 1)) {
+		ret = -EFAULT;
+		goto out;
+	}
+
+	if (op->interface_version != XEN_DOMGRPCTL_INTERFACE_VERSION) {
+		ret = -EINVAL;
I think "ret = -EACESS" is right.

diff -urN xen-unstable/xen/arch/x86/setup.c xen-unstable-domgrps/xen/arch/x86/setup.c
--- xen-unstable/xen/arch/x86/setup.c	2008-01-29 12:44:24.000000000 -0500
+++ xen-unstable-domgrps/xen/arch/x86/setup.c	2008-01-29 12:53:23.000000000 -0500
@@ -3,6 +3,7 @@
 #include <xen/lib.h>
 #include <xen/sched.h>
 #include <xen/domain.h>
+#include <xen/domgrp.h>
 #include <xen/serial.h>
 #include <xen/softirq.h>
 #include <xen/acpi.h>
@@ -969,6 +970,10 @@
     if ( opt_watchdog ) 
         watchdog_enable();
 
+    /* initialize domain groups */
+    if (init_domain_groups())
+        panic("Error creating default groups\n");
+
     /* Create initial domain 0. */
     dom0 = domain_create(0, 0, DOM0_SSIDREF);
     if ( (dom0 == NULL) || (alloc_vcpu(dom0, 0, 0) == NULL) )
@@ -977,6 +982,9 @@
     dom0->is_privileged = 1;
     dom0->target = NULL;
 
+    if (add_dom_to_grp(dom0, 0))
+        panic("Error adding dom0 to grp0\n");
+
     /* Grab the DOM0 command line. */
     cmdline = (char *)(mod[0].string ? __va(mod[0].string) : NULL);
     if ( (cmdline != NULL) || (kextra != NULL) )
You change this part in the second patch.

diff -urN xen-unstable/xen/arch/x86/x86_64/entry.S xen-unstable-domgrps/xen/arch/x86/x86_64/entry.S
--- xen-unstable/xen/arch/x86/x86_64/entry.S	2007-11-19 10:38:08.000000000 -0500
+++ xen-unstable-domgrps/xen/arch/x86/x86_64/entry.S	2007-11-19 18:43:06.000000000 -0500
@@ -672,6 +672,7 @@
         .quad do_sysctl             /* 35 */
         .quad do_domctl
         .quad do_kexec_op
+        .quad do_domgrpctl
         .rept NR_hypercalls-((.-hypercall_table)/8)
         .quad do_ni_hypercall
         .endr
@@ -715,7 +716,7 @@
         .byte 1 /* do_sysctl            */  /* 35 */
         .byte 1 /* do_domctl            */
         .byte 2 /* do_kexec             */
-        .byte 1 /* do_xsm_op            */
+        .byte 1 /* do_domgrpctl         */
         .rept NR_hypercalls-(.-hypercall_args_table)
         .byte 0 /* do_ni_hypercall      */
         .endr
Why do you remove do_xsm_op?

diff -urN xen-unstable/xen/include/xen/compile.h xen-unstable-domgrps/xen/include/xen/compile.h
--- xen-unstable/xen/include/xen/compile.h	1969-12-31 19:00:00.000000000 -0500
+++ xen-unstable-domgrps/xen/include/xen/compile.h	2008-01-23 14:58:34.000000000 -0500
Please don't inlcude this file.

Best Regards,

Akio Takebe

>diffstat domgrps-vmm.patch
>  arch/ia64/xen/xensetup.c                 |    7
>  arch/powerpc/powerpc64/hypercall_table.S |    1
>  arch/powerpc/setup.c                     |    7
>  arch/x86/setup.c                         |    8
>  arch/x86/x86_32/entry.S                  |    2
>  arch/x86/x86_64/entry.S                  |    3
>  common/Makefile                          |    2
>  common/domain.c                          |    8
>  common/domctl.c                          |   13 +
>  common/domgrp.c                          |  320 ++++++++++++++++++++++++++
>+++++
>  common/domgrpctl.c                       |  134 ++++++++++++
>  common/sysctl.c                          |    1
>  include/public/domctl.h                  |    2
>  include/public/domgrpctl.h               |   86 ++++++++
>  include/public/xen.h                     |    5
>  include/xen/compile.h                    |   39 +++
>  include/xen/domgrp.h                     |   36 +++
>  include/xen/hypercall.h                  |    5
>  include/xen/sched.h                      |   21 ++
>  19 files changed, 697 insertions(+), 3 deletions(-)
>
>
>-------------------------------text/plain-------------------------------
>_______________________________________________
>Xen-devel mailing list
>Xen-devel@lists.xensource.com
>http://lists.xensource.com/xen-devel

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

* Re: [1/3] Domgrps/SchedGrps Merge RFC: domgrps-vmm
  2008-02-06 12:00 ` Akio Takebe
@ 2008-02-06 13:59   ` Chris
  0 siblings, 0 replies; 6+ messages in thread
From: Chris @ 2008-02-06 13:59 UTC (permalink / raw)
  To: Akio Takebe; +Cc: xen-devel

On Feb 6, 2008, at 7:00 AM, Akio Takebe wrote:
> +long do_domgrpctl(XEN_GUEST_HANDLE(xen_domgrpctl_t) u_domgrpctl)
> +{
> +	long ret = 0;
> +	struct xen_domgrpctl curop, *op = &curop;
> +	static DEFINE_SPINLOCK(domgrpctl_lock);
> +	struct domain_group *grp;
> +	dgid_t dgid;
> +
> +	if (!IS_PRIV(current->domain)) {
> +		ret = -EPERM;
> +		goto out;
> +	}
> +
> +	if (copy_from_guest(op, u_domgrpctl, 1)) {
> +		ret = -EFAULT;
> +		goto out;
> +	}
> +
> +	if (op->interface_version != XEN_DOMGRPCTL_INTERFACE_VERSION) {
> +		ret = -EINVAL;
> I think "ret = -EACESS" is right.

Ack

> diff -urN xen-unstable/xen/arch/x86/setup.c xen-unstable-domgrps/ 
> xen/arch/x86/setup.c
> --- xen-unstable/xen/arch/x86/setup.c	2008-01-29 12:44:24.000000000  
> -0500
> +++ xen-unstable-domgrps/xen/arch/x86/setup.c	2008-01-29  
> 12:53:23.000000000 -0500
> @@ -3,6 +3,7 @@
>  #include <xen/lib.h>
>  #include <xen/sched.h>
>  #include <xen/domain.h>
> +#include <xen/domgrp.h>
>  #include <xen/serial.h>
>  #include <xen/softirq.h>
>  #include <xen/acpi.h>
> @@ -969,6 +970,10 @@
>      if ( opt_watchdog )
>          watchdog_enable();
>
> +    /* initialize domain groups */
> +    if (init_domain_groups())
> +        panic("Error creating default groups\n");
> +
>      /* Create initial domain 0. */
>      dom0 = domain_create(0, 0, DOM0_SSIDREF);
>      if ( (dom0 == NULL) || (alloc_vcpu(dom0, 0, 0) == NULL) )
> @@ -977,6 +982,9 @@
>      dom0->is_privileged = 1;
>      dom0->target = NULL;
>
> +    if (add_dom_to_grp(dom0, 0))
> +        panic("Error adding dom0 to grp0\n");
> +
>      /* Grab the DOM0 command line. */
>      cmdline = (char *)(mod[0].string ? __va(mod[0].string) : NULL);
>      if ( (cmdline != NULL) || (kextra != NULL) )
> You change this part in the second patch

You're right.  There are in fact several places where the second  
(schedgrps) patch goes back and changes the first (domgrps), which is  
confusing.  It got that way b/c merging with schedgrps identified  
areas where changes to domgrps where needed.  I'll try to separate  
patches more cleanly in the future.

> diff -urN xen-unstable/xen/arch/x86/x86_64/entry.S xen-unstable- 
> domgrps/xen/arch/x86/x86_64/entry.S
> --- xen-unstable/xen/arch/x86/x86_64/entry.S	2007-11-19  
> 10:38:08.000000000 -0500
> +++ xen-unstable-domgrps/xen/arch/x86/x86_64/entry.S	2007-11-19  
> 18:43:06.000000000 -0500
> @@ -672,6 +672,7 @@
>          .quad do_sysctl             /* 35 */
>          .quad do_domctl
>          .quad do_kexec_op
> +        .quad do_domgrpctl
>          .rept NR_hypercalls-((.-hypercall_table)/8)
>          .quad do_ni_hypercall
>          .endr
> @@ -715,7 +716,7 @@
>          .byte 1 /* do_sysctl            */  /* 35 */
>          .byte 1 /* do_domctl            */
>          .byte 2 /* do_kexec             */
> -        .byte 1 /* do_xsm_op            */
> +        .byte 1 /* do_domgrpctl         */
>          .rept NR_hypercalls-(.-hypercall_args_table)
>          .byte 0 /* do_ni_hypercall      */
>          .endr
> Why do you remove do_xsm_op?

It's actually not removing xsm_op.  There's a redundant op  
declaration in the x86_64 hyercall table.  A bit higher in the file  
(it's op 27 for x86_64), xsm_op is declared where it replaced  
acm_op.  The latter declaration was unused, so I swapped it out for  
domgrpctl.  This fix probably should've been submitted as a separate  
patch to avoid confusion.

> diff -urN xen-unstable/xen/include/xen/compile.h xen-unstable- 
> domgrps/xen/include/xen/compile.h
> --- xen-unstable/xen/include/xen/compile.h	1969-12-31  
> 19:00:00.000000000 -0500
> +++ xen-unstable-domgrps/xen/include/xen/compile.h	2008-01-23  
> 14:58:34.000000000 -0500
> Please don't inlcude this file.

Thanks for catching my mistake, that file shouldn't be included. 

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

* Re: Domgrps/SchedGrps Merge RFC: domgrps-vmm
  2008-02-04 19:14 [1/3] Domgrps/SchedGrps Merge RFC: domgrps-vmm Chris
  2008-02-06 12:00 ` Akio Takebe
@ 2008-02-11 22:07 ` Mike D. Day
  2008-02-12  0:05   ` Samuel Thibault
  2008-02-27 18:45   ` Chris
  1 sibling, 2 replies; 6+ messages in thread
From: Mike D. Day @ 2008-02-11 22:07 UTC (permalink / raw)
  To: Chris; +Cc: xen-devel

Sorry for the lateness of this review. My opinion is that sched groups
should (as implemented for credit sharing to support stub domains)
should go upstream for 3.3 without being merged with domain groups. 

I think domain groups are more powerful and will eventually assimilate
the focused scheduling group patchset. At the same time, more thought
needs to go into domain groups. To that end, here are a few of my
belated thoughts and questions.



On 04/02/08 14:14 -0500, Chris wrote:
>diff -urN xen-unstable/xen/arch/powerpc/powerpc64/hypercall_table.S xen-unstable-domgrps/xen/arch/powerpc/powerpc64/hypercall_table.S
>--- xen-unstable/xen/arch/powerpc/powerpc64/hypercall_table.S	2007-08-06 17:59:54.000000000 -0400
>+++ xen-unstable-domgrps/xen/arch/powerpc/powerpc64/hypercall_table.S	2007-11-19 18:42:00.000000000 -0500
>@@ -41,6 +41,7 @@
>         .quad 0 /* do_hvm_op */
>         .quad do_sysctl             /* 35 */
>         .quad do_domctl
>+        .quad do_domgrpctl
>         .rept NR_hypercalls-((.-__hypercall_table)/8)
>         .quad do_ni_hypercall
>         .endr

Rather than creating a new hypercall, it may be best to implement all
the grouping and grouping control as part of a sub-command of the
domctrl hypercall. Then we don't need to add this extra hypercall into
the table of every platform.



>+
>+    if (d->group)
>+        grp = d->group;
>+    else
>+        grp = find_grp_by_id(NULL_GROUP_ID);
>+

Wondering why we have to search for the null group. Why can't the null
group be statically initialized and then always referred to by a
pointer? In fact, what is the role of the null group? I see that it is
a real domain group and it is created automatically. Also it can't be
created by a hypercall.

All domains that do not belong to a group actually belong to the null
group. Could it also be just as easy for each domain to have an
identity group (itself), to which it belongs in the absence of any
other group membership? Or is there a specific purpose to the null
group?


>+#define SERIALIZE_LINKED_LIST(op_name, list_name)		\
>+    rcu_read_lock(&grp->op_name##_read_lock);			\
>+    memset(&info->op_name, 0, sizeof(domid_t)*MAX_GROUP_SIZE);	\
>+    if (!list_empty(&grp->op_name)) {				\
>+        i = 0;							\
>+        list_for_each_entry(dom, &grp->op_name, list_name) {	\
>+            info->op_name[i] = dom->domain_id;			\
>+       	    i++;						\
>+	}							\
>+    } else 							\
>+	info->op_name[i] = NULL_GROUP_ID;			\
>+    rcu_read_unlock(&grp->op_name##_read_lock);


This should really be cleaned up and made into an inline function. It
also refers to a variable declared outside of the macro and parameters
(info). It's not clear what's happening inside the macro.


>+#define RM_DOM_FROM_LIST(list_name, entry)	\
>+    spin_lock(&grp->list_name##_update_lock);	\
>+    if (!list_empty(&grp->list_name)) 		\
>+        list_del(&dom->entry);		    	\
>+    spin_unlock(&grp->list_name##_update_lock);
>+

Another good candidate for inlining.

>+int add_dom_to_grp(struct domain *dom, dgid_t dgid)
>+{

...

>+
>+	/* skip it if dom is already a member */
>+	if (dom_in_member_list(dom->domain_id, grp))
>+		goto out;
>+	
>+	/* remove dom from old group */
>+	if (dom->group != NULL)
>+		del_dom_from_grp(dom);


So a domain can only belong to one group at a time. Would it ever be
useful for a domain to belong to more than one group? This type of
restriction seems to work against the idea of a general grouping
concept. For example, all domains that belong to a scheduling group
(assuming we eventually merge domgrp and schedgrp) would automatically
be removed from a scheduling group if added to any other type of
group.

This argues for keeping different types of groups under different
grouping infrastructures unless we can figure out a way for a domain
to have multiple group memberships. It may be too complicated to do so.


>+int pause_grp(dgid_t dgid)
>+{
>+	int ret = 0;
>+	struct domain *member;
>+	struct domain_group *grp;
>+
>+	if (dgid == 0) {
>+		ret = -EPERM;
>+		goto out;
>+	}
>+
>+	grp = find_grp_by_id(dgid);
>+
>+	if (grp == NULL) {
>+		ret = -ESRCH;
>+		goto out;
>+	}
>+
>+	spin_lock_recursive(&grp->grp_big_lock);
>+	rcu_read_lock(&grp->member_list_read_lock);
>+	/* could ignore interupts during this loop to increase atomicity */
>+	list_for_each_entry(member, &grp->member_list, member) {
>+		if (member != current->domain && member->domain_id != 0)
>+			domain_pause_by_systemcontroller(member);
>+	}
>+	rcu_read_unlock(&grp->member_list_read_lock);
>+	spin_unlock_recursive(&grp->grp_big_lock);
>+      out:
>+	return ret;
>+}
>+


Groups are paused in the order in which they are added to the group,
right? (FIFO). What do we do when we have groups which are dependant
upon each other in certain ways. 

For example, the stub domain and HVM domain. At first glance, it seems
that you would want to pause the hvm domain before pausing its stub
domain. And then the reverse on resume: unpause the stub domain, then
unpause the hvm domain. (I could have it backward). But the point is,
group operations may have inter-domain dependencies that are not
accounted for simply by the order in which the domains are added to a
group.  This is true for pause, unpause, start, migrate, etc., on down
the line of possible group operations.

Mike

-- 
Mike D. Day
IBM LTC
Cell: 919 412-3900
Sametime: ncmike@us.ibm.com AIM: ncmikeday  Yahoo: ultra.runner
PGP key: http://www.ncultra.org/ncmike/pubkey.asc

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

* Re: Re: Domgrps/SchedGrps Merge RFC: domgrps-vmm
  2008-02-11 22:07 ` Mike D. Day
@ 2008-02-12  0:05   ` Samuel Thibault
  2008-02-27 18:45   ` Chris
  1 sibling, 0 replies; 6+ messages in thread
From: Samuel Thibault @ 2008-02-12  0:05 UTC (permalink / raw)
  To: Mike D. Day; +Cc: Chris, xen-devel

Mike D. Day, le Mon 11 Feb 2008 17:07:38 -0500, a écrit :
> So a domain can only belong to one group at a time. Would it ever be
> useful for a domain to belong to more than one group? This type of
> restriction seems to work against the idea of a general grouping
> concept.

Right.

> For example, all domains that belong to a scheduling group
> (assuming we eventually merge domgrp and schedgrp) would automatically
> be removed from a scheduling group if added to any other type of
> group.

Which makes sense, doesn't it?

> This argues for keeping different types of groups under different
> grouping infrastructures unless we can figure out a way for a domain
> to have multiple group memberships. It may be too complicated to do so.

Yes, usually group mecanisms are just hierarchical rather than being so
generic as to permit several membership.  I guess the common pitfall is
when enumerating groups, you may see a domain several times, and such
strange effects.

Samuel

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

* Re: Domgrps/SchedGrps Merge RFC: domgrps-vmm
  2008-02-11 22:07 ` Mike D. Day
  2008-02-12  0:05   ` Samuel Thibault
@ 2008-02-27 18:45   ` Chris
  1 sibling, 0 replies; 6+ messages in thread
From: Chris @ 2008-02-27 18:45 UTC (permalink / raw)
  To: ncmike; +Cc: xen-devel, Samuel Thibault

On Feb 11, 2008, at 5:07 PM, Mike D. Day wrote:
>> diff -urN xen-unstable/xen/arch/powerpc/powerpc64/ 
>> hypercall_table.S xen-unstable-domgrps/xen/arch/powerpc/powerpc64/ 
>> hypercall_table.S
>> --- xen-unstable/xen/arch/powerpc/powerpc64/hypercall_table.S	 
>> 2007-08-06 17:59:54.000000000 -0400
>> +++ xen-unstable-domgrps/xen/arch/powerpc/powerpc64/ 
>> hypercall_table.S	2007-11-19 18:42:00.000000000 -0500
>> @@ -41,6 +41,7 @@
>>         .quad 0 /* do_hvm_op */
>>         .quad do_sysctl             /* 35 */
>>         .quad do_domctl
>> +        .quad do_domgrpctl
>>         .rept NR_hypercalls-((.-__hypercall_table)/8)
>>         .quad do_ni_hypercall
>>         .endr
>
> Rather than creating a new hypercall, it may be best to implement all
> the grouping and grouping control as part of a sub-command of the
> domctrl hypercall. Then we don't need to add this extra hypercall into
> the table of every platform.

Ack.  There would be no functionality or flexibility lost by making  
group operations part of the domctl hypercall and doing so would also  
shave off a few LOC.  The reasons I had for make domgrpctl operations  
a separate hypercall are now moot.

>> +
>> +    if (d->group)
>> +        grp = d->group;
>> +    else
>> +        grp = find_grp_by_id(NULL_GROUP_ID);
>> +
>
> Wondering why we have to search for the null group. Why can't the null
> group be statically initialized and then always referred to by a
> pointer?

Ack.  The searching for the null group is an artifact of an older  
design.

> In fact, what is the role of the null group? I see that it is
> a real domain group and it is created automatically. Also it can't be
> created by a hypercall.

The purpose of the null group is to provide a means of efficiently  
addressing all domains that aren't explicitly in a group.  Although  
it's a real group, it isn't intended to be used as one from a user  
perspective.  Perhaps it would be useful for xm to display domains in  
the null group as "ungrouped."

> All domains that do not belong to a group actually belong to the null
> group. Could it also be just as easy for each domain to have an
> identity group (itself), to which it belongs in the absence of any
> other group membership? Or is there a specific purpose to the null
> group?

The current null group implementation isn't the only way to provide  
an efficient means to identify ungrouped domains, so I'm open to  
alternatives.  That said, is there a win to automatically creating a  
group for each domain?  When needed, a group can be created for an  
existing domain.

The null group should not provide any privileges or otherwise induce  
relationships between members.  The null group was intended primarily  
as a convenient tool for security policy analysis where it's useful  
to ensure the same property(ies) apply to all ungrouped domains.

>> +#define SERIALIZE_LINKED_LIST(op_name, list_name)		\
>> +    rcu_read_lock(&grp->op_name##_read_lock);			\
>> +    memset(&info->op_name, 0, sizeof(domid_t)*MAX_GROUP_SIZE);	\
>> +    if (!list_empty(&grp->op_name)) {				\
>> +        i = 0;							\
>> +        list_for_each_entry(dom, &grp->op_name, list_name) {	\
>> +            info->op_name[i] = dom->domain_id;			\
>> +       	    i++;						\
>> +	}							\
>> +    } else 							\
>> +	info->op_name[i] = NULL_GROUP_ID;			\
>> +    rcu_read_unlock(&grp->op_name##_read_lock);
>
> This should really be cleaned up and made into an inline function. It
> also refers to a variable declared outside of the macro and parameters
> (info). It's not clear what's happening inside the macro.

Ack.

>> +#define RM_DOM_FROM_LIST(list_name, entry)	\
>> +    spin_lock(&grp->list_name##_update_lock);	\
>> +    if (!list_empty(&grp->list_name)) 		\
>> +        list_del(&dom->entry);		    	\
>> +    spin_unlock(&grp->list_name##_update_lock);
>> +
>
> Another good candidate for inlining.

Ack.

>> +
>> +	/* skip it if dom is already a member */
>> +	if (dom_in_member_list(dom->domain_id, grp))
>> +		goto out;
>> +	
>> +	/* remove dom from old group */
>> +	if (dom->group != NULL)
>> +		del_dom_from_grp(dom);
>
> So a domain can only belong to one group at a time. Would it ever be
> useful for a domain to belong to more than one group? This type of
> restriction seems to work against the idea of a general grouping
> concept. For example, all domains that belong to a scheduling group
> (assuming we eventually merge domgrp and schedgrp) would automatically
> be removed from a scheduling group if added to any other type of
> group.

I agree with Samuel; it makes sense that a domain would be removed  
from its schedgrp when changing its domgrp.

In addition to the aesthetic issues Samuel mentioned (domains  
appearing in multiple listings), domgrps intentionally disallows  
membership in multiple groups because of the complications it would  
create.  Consider the following example with 3 domains and 2 groups.   
DomA and domB are in grpX; domB and domC are in grpY.  In this  
scenario XSM security policy expresses two properties: (1) group  
members can communicate with each other and (2) there is no cross- 
group communication.  However, from an information flow perspective  
grpX and grpY are effectively a single group because domB is a member  
of both and can be used to pass information between groups.  While it  
is possible to detect this policy conflict, doing so loses the  
simplicity gains of integrating groups with security policy.

In short, allowing domains to join multiple groups creates many more  
problems than it solves and there are extremely few good use cases  
(if any) where it's a win.  Contrary to popular belief, my goal is to  
add as little code to Xen as possible.  :)

> This argues for keeping different types of groups under different
> grouping infrastructures unless we can figure out a way for a domain
> to have multiple group memberships. It may be too complicated to do  
> so.

To increase flexibility, I propose allowing domains to opt in to/out  
of schedgrps (or any other feature that is integrated with the domgrp  
mechanism).  Can you describe a likely scenario where this extra  
ability doesn't meet your needs?

>> +int pause_grp(dgid_t dgid)
>> +{
>> +	int ret = 0;
>> +	struct domain *member;
>> +	struct domain_group *grp;
>> +
>> +	if (dgid == 0) {
>> +		ret = -EPERM;
>> +		goto out;
>> +	}
>> +
>> +	grp = find_grp_by_id(dgid);
>> +
>> +	if (grp == NULL) {
>> +		ret = -ESRCH;
>> +		goto out;
>> +	}
>> +
>> +	spin_lock_recursive(&grp->grp_big_lock);
>> +	rcu_read_lock(&grp->member_list_read_lock);
>> +	/* could ignore interupts during this loop to increase atomicity */
>> +	list_for_each_entry(member, &grp->member_list, member) {
>> +		if (member != current->domain && member->domain_id != 0)
>> +			domain_pause_by_systemcontroller(member);
>> +	}
>> +	rcu_read_unlock(&grp->member_list_read_lock);
>> +	spin_unlock_recursive(&grp->grp_big_lock);
>> +      out:
>> +	return ret;
>> +}
>> +
>
> Groups are paused in the order in which they are added to the group,
> right? (FIFO). What do we do when we have groups which are dependant
> upon each other in certain ways.

In an earlier domgrps prototype I had a means for expressing  
dependencies that was read in from a group configuration file and was  
propagated into the VMM.  This allowed fine-grained dependencies to  
be expressed and handled at the VMM level.  However, I decided to  
remove it from the VMM because of the complexity it added.  Although  
there are certainly advantages to having that information in the VMM,  
my opinion today is that that functionality belongs in the control  
plane.

> For example, the stub domain and HVM domain. At first glance, it seems
> that you would want to pause the hvm domain before pausing its stub
> domain. And then the reverse on resume: unpause the stub domain, then
> unpause the hvm domain. (I could have it backward). But the point is,
> group operations may have inter-domain dependencies that are not
> accounted for simply by the order in which the domains are added to a
> group.  This is true for pause, unpause, start, migrate, etc., on down
> the line of possible group operations.

I agree.  The configuration-file based approach I mentioned earlier  
allowed users to specify reactions to various events and error  
conditions to include the events you listed above.  That  
functionality is not submitted as part of this patch, but it  
certainly has a place in future work.

I greatly appreciate the feedback.

-Chris

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

end of thread, other threads:[~2008-02-27 18:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-04 19:14 [1/3] Domgrps/SchedGrps Merge RFC: domgrps-vmm Chris
2008-02-06 12:00 ` Akio Takebe
2008-02-06 13:59   ` Chris
2008-02-11 22:07 ` Mike D. Day
2008-02-12  0:05   ` Samuel Thibault
2008-02-27 18:45   ` Chris

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.