git://git.onelab.eu
/
util-vserver-pl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
66033b3
)
Allow independent setting of CPU reservation and CPU share
author
Andy Bavier
<acb@cs.princeton.edu>
Wed, 16 Jan 2008 22:07:46 +0000
(22:07 +0000)
committer
Andy Bavier
<acb@cs.princeton.edu>
Wed, 16 Jan 2008 22:07:46 +0000
(22:07 +0000)
python/vserver.py
patch
|
blob
|
history
python/vserverimpl.c
patch
|
blob
|
history
scripts/vuseradd
patch
|
blob
|
history
src/planetlab.c
patch
|
blob
|
history
src/planetlab.h
patch
|
blob
|
history
util-vserver-pl.spec
patch
|
blob
|
history
diff --git
a/python/vserver.py
b/python/vserver.py
index
65d9c62
..
7937022
100644
(file)
--- a/
python/vserver.py
+++ b/
python/vserver.py
@@
-17,7
+17,6
@@
import resource
import vserverimpl
import cpulimit, bwlimit
import vserverimpl
import cpulimit, bwlimit
-from vserverimpl import VS_SCHED_CPU_GUARANTEED as SCHED_CPU_GUARANTEED
from vserverimpl import DLIMIT_INF
from vserverimpl import VC_LIM_KEEP
from vserverimpl import VLIMIT_NSOCK
from vserverimpl import DLIMIT_INF
from vserverimpl import VC_LIM_KEEP
from vserverimpl import VLIMIT_NSOCK
@@
-325,25
+324,23
@@
class VServer:
return block_limit
return block_limit
- def set_sched_config(self, cpu_
share, sched_flags
):
+ def set_sched_config(self, cpu_
min, cpu_share
):
""" Write current CPU scheduler parameters to the vserver
configuration file. This method does not modify the kernel CPU
scheduling parameters for this context. """
""" Write current CPU scheduler parameters to the vserver
configuration file. This method does not modify the kernel CPU
scheduling parameters for this context. """
- if sched_flags & SCHED_CPU_GUARANTEED:
- cpu_guaranteed = cpu_share
- else:
- cpu_guaranteed = 0
+ self.config.update('sched/fill-rate', cpu_min)
self.config.update('sched/fill-rate2', cpu_share)
self.config.update('sched/fill-rate2', cpu_share)
- self.config.update('sched/fill-rate', cpu_guaranteed)
-
+ if cpu_share == 0:
+ self.config.unset('sched/idle-time')
+
if self.vm_running:
if self.vm_running:
- self.set_sched(cpu_
share, sched_flags
)
+ self.set_sched(cpu_
min, cpu_share
)
- def set_sched(self, cpu_
share, sched_flags = 0
):
+ def set_sched(self, cpu_
min, cpu_share
):
""" Update kernel CPU scheduling parameters for this context. """
""" Update kernel CPU scheduling parameters for this context. """
- vserverimpl.setsched(self.ctx, cpu_
share, sched_flags
)
+ vserverimpl.setsched(self.ctx, cpu_
min, cpu_share
)
def get_sched(self):
# have no way of querying scheduler right now on a per vserver basis
def get_sched(self):
# have no way of querying scheduler right now on a per vserver basis
diff --git
a/python/vserverimpl.c
b/python/vserverimpl.c
index
b20725c
..
eef6f8e
100644
(file)
--- a/
python/vserverimpl.c
+++ b/
python/vserverimpl.c
@@
-192,14
+192,14
@@
static PyObject *
vserver_setsched(PyObject *self, PyObject *args)
{
xid_t ctx;
vserver_setsched(PyObject *self, PyObject *args)
{
xid_t ctx;
+ uint32_t cpu_min;
uint32_t cpu_share;
uint32_t cpu_share;
- uint32_t cpu_sched_flags = VC_VXF_SCHED_FLAGS;
- if (!PyArg_ParseTuple(args, "II|I", &ctx, &cpu_
share, &cpu_sched_flags
))
+ if (!PyArg_ParseTuple(args, "II|I", &ctx, &cpu_
min, &cpu_share
))
return NULL;
/* ESRCH indicates that there are no processes in the context */
return NULL;
/* ESRCH indicates that there are no processes in the context */
- if (pl_setsched(ctx, cpu_
share, cpu_sched_flags
) &&
+ if (pl_setsched(ctx, cpu_
min, cpu_share
) &&
errno != ESRCH)
return PyErr_SetFromErrno(PyExc_OSError);
errno != ESRCH)
return PyErr_SetFromErrno(PyExc_OSError);
@@
-740,8
+740,4
@@
initvserverimpl(void)
PyModule_AddIntConstant(mod, "VLIMIT_ANON", (int)VC_VLIMIT_ANON);
PyModule_AddIntConstant(mod, "VLIMIT_SHMEM", (int)VC_VLIMIT_SHMEM);
PyModule_AddIntConstant(mod, "VLIMIT_ANON", (int)VC_VLIMIT_ANON);
PyModule_AddIntConstant(mod, "VLIMIT_SHMEM", (int)VC_VLIMIT_SHMEM);
- /* scheduler flags */
- PyModule_AddIntConstant(mod,
- "VS_SCHED_CPU_GUARANTEED",
- VS_SCHED_CPU_GUARANTEED);
}
}
diff --git
a/scripts/vuseradd
b/scripts/vuseradd
index
80b00f2
..
0e2c8a0
100755
(executable)
--- a/
scripts/vuseradd
+++ b/
scripts/vuseradd
@@
-94,10
+94,10
@@
if [ ! -d $__CONFDIR/$NAME ] ; then
echo persistent > $DIR/nflags
# Set up the scheduler
echo persistent > $DIR/nflags
# Set up the scheduler
- echo 100
0
> $DIR/sched/interval
+ echo 100 > $DIR/sched/interval
echo 1000 > $DIR/sched/interval2
echo 0 > $DIR/sched/fill-rate
echo 1000 > $DIR/sched/interval2
echo 0 > $DIR/sched/fill-rate
- echo
32
> $DIR/sched/fill-rate2
+ echo
1
> $DIR/sched/fill-rate2
touch $DIR/sched/idle-time
echo 100 > $DIR/sched/tokens
echo 50 > $DIR/sched/tokens-min
touch $DIR/sched/idle-time
echo 100 > $DIR/sched/tokens
echo 50 > $DIR/sched/tokens-min
diff --git
a/src/planetlab.c
b/src/planetlab.c
index
1c6cbcc
..
9300744
100644
(file)
--- a/
src/planetlab.c
+++ b/
src/planetlab.c
@@
-86,7
+86,7
@@
process:
if (vc_set_ccaps(ctx, &vc_caps))
return -1;
if (vc_set_ccaps(ctx, &vc_caps))
return -1;
- if (pl_setsched(ctx,
1, 0
) < 0) {
+ if (pl_setsched(ctx,
0, 1
) < 0) {
PERROR("pl_setsched(%u)", ctx);
exit(1);
}
PERROR("pl_setsched(%u)", ctx);
exit(1);
}
@@
-183,38
+183,33
@@
do \
while (0)
int
while (0)
int
-pl_setsched(xid_t ctx, uint32_t cpu_
share, uint32_t cpu_sched_flags
)
+pl_setsched(xid_t ctx, uint32_t cpu_
min, uint32_t cpu_share
)
{
struct vc_set_sched vc_sched;
struct vc_ctx_flags vc_flags;
{
struct vc_set_sched vc_sched;
struct vc_ctx_flags vc_flags;
- uint32_t new_flags;
vc_sched.set_mask = (VC_VXSM_FILL_RATE | VC_VXSM_INTERVAL | VC_VXSM_TOKENS |
VC_VXSM_TOKENS_MIN | VC_VXSM_TOKENS_MAX | VC_VXSM_MSEC |
vc_sched.set_mask = (VC_VXSM_FILL_RATE | VC_VXSM_INTERVAL | VC_VXSM_TOKENS |
VC_VXSM_TOKENS_MIN | VC_VXSM_TOKENS_MAX | VC_VXSM_MSEC |
- VC_VXSM_FILL_RATE2 | VC_VXSM_INTERVAL2 | VC_VXSM_FORCE
|
- VC_VXSM_IDLE_TIME);
- vc_sched.
fill_rate =
0;
- vc_sched.fill_rate2 = cpu_share;
/* tokens accumulated per interval
*/
- vc_sched.interval
= vc_sched.interval
2 = 1000; /* milliseconds */
+ VC_VXSM_FILL_RATE2 | VC_VXSM_INTERVAL2 | VC_VXSM_FORCE
);
+ vc_sched.fill_rate = cpu_min; /* percent reserved */
+ vc_sched.
interval = 10
0;
+ vc_sched.fill_rate2 = cpu_share;
/* best-effort fair share of unreserved
*/
+ vc_sched.interval2 = 1000; /* milliseconds */
vc_sched.tokens = 100; /* initial allocation of tokens */
vc_sched.tokens_min = 50; /* need this many tokens to run */
vc_sched.tokens_max = 100; /* max accumulated number of tokens */
vc_sched.tokens = 100; /* initial allocation of tokens */
vc_sched.tokens_min = 50; /* need this many tokens to run */
vc_sched.tokens_max = 100; /* max accumulated number of tokens */
- if (cpu_share == (uint32_t)VC_LIM_KEEP)
- vc_sched.set_mask &= ~(VC_VXSM_FILL_RATE|VC_VXSM_FILL_RATE2);
-
- /* guaranteed CPU corresponds to SCHED_SHARE flag being cleared */
- if (cpu_sched_flags & VS_SCHED_CPU_GUARANTEED) {
- new_flags = 0;
- vc_sched.fill_rate = vc_sched.fill_rate2;
+ if (cpu_share) {
+ if (cpu_share == (uint32_t)VC_LIM_KEEP)
+ vc_sched.set_mask &= ~(VC_VXSM_FILL_RATE|VC_VXSM_FILL_RATE2);
+ else
+ vc_sched.set_mask |= VC_VXSM_IDLE_TIME;
}
}
- else
- new_flags = VC_VXF_SCHED_SHARE;
VC_SYSCALL(vc_set_sched(ctx, &vc_sched));
vc_flags.mask = VC_VXF_SCHED_FLAGS;
VC_SYSCALL(vc_set_sched(ctx, &vc_sched));
vc_flags.mask = VC_VXF_SCHED_FLAGS;
- vc_flags.flagword =
new_flags |
VC_VXF_SCHED_HARD;
+ vc_flags.flagword = VC_VXF_SCHED_HARD;
VC_SYSCALL(vc_set_cflags(ctx, &vc_flags));
return 0;
VC_SYSCALL(vc_set_cflags(ctx, &vc_flags));
return 0;
diff --git
a/src/planetlab.h
b/src/planetlab.h
index
78a6a9c
..
9d9bcb3
100644
(file)
--- a/
src/planetlab.h
+++ b/
src/planetlab.h
@@
-57,10
+57,7
@@
int
pl_setup_done(xid_t ctx);
int
pl_setup_done(xid_t ctx);
int
-pl_setsched(xid_t ctx, uint32_t cpu_share, uint32_t cpu_sched_flags);
-
-/* scheduler flags */
-#define VS_SCHED_CPU_GUARANTEED 1
+pl_setsched(xid_t ctx, uint32_t cpu_min, uint32_t cpu_share);
/* Null byte made explicit */
#define NULLBYTE_SIZE 1
/* Null byte made explicit */
#define NULLBYTE_SIZE 1
diff --git
a/util-vserver-pl.spec
b/util-vserver-pl.spec
index
6d300e4
..
a159432
100644
(file)
--- a/
util-vserver-pl.spec
+++ b/
util-vserver-pl.spec
@@
-4,7
+4,7
@@
%define url $URL$
%define name util-vserver-pl
%define url $URL$
%define name util-vserver-pl
-%define version 0.
1
+%define version 0.
2
%define taglevel 1
%define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}}
%define taglevel 1
%define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}}