int rc;
// Check for legal values
- if (!legalshare(shares->my_guarantee) || !legalshare(shares->my_limit)
- || !legalshare(shares->total_guarantee)
- || !legalshare(shares->max_limit))
+ if (!legalshare(shares->my_guarantee)) {
+ printk("ckrm_class_set_shares: shares->my_guarantee invalid value (%d)\n",
+ shares->my_guarantee);
return -EINVAL;
+ }
+
+ if(!legalshare(shares->my_limit)) {
+ printk("ckrm_class_set_shares: shares->my_limit invalid value (%d)\n",
+ shares->my_limit);
+ return -EINVAL;
+ }
+
+ if(!legalshare(shares->total_guarantee)){
+ printk("ckrm_class_set_shares: shares->total_guarantee invalid value (%d)\n",
+ shares->total_guarantee);
+ return -EINVAL;
+ }
+
+ if(!legalshare(shares->max_limit)) {
+ printk("ckrm_class_set_shares: shares->max_limit invalid value (%d)\n",
+ shares->max_limit);
+ return -EINVAL;
+ }
rcbs = ckrm_resctlr_lookup(clstype, resname);
- if (rcbs == NULL || rcbs->set_share_values == NULL)
+ if (rcbs == NULL || rcbs->set_share_values == NULL) {
+ printk("ckrm_class_set_shares: resname=%s, rcbs=%p rcbs->set_shares_values == %p returning error\n",
+ resname, rcbs, rcbs == NULL ? NULL : rcbs->set_share_values);
return -EINVAL;
+ }
+
rc = (*rcbs->set_share_values) (core->res_class[rcbs->resid], shares);
return rc;
}
#include <linux/module.h>
#include <linux/ckrm_rc.h>
-int
-get_exe_path_name(struct task_struct *tsk, char *buf, int buflen)
+int get_exe_path_name(struct task_struct *tsk, char *buf, int buflen)
{
- struct vm_area_struct * vma;
+ struct vm_area_struct *vma;
struct vfsmount *mnt;
- struct mm_struct * mm = get_task_mm(tsk);
+ struct mm_struct *mm = get_task_mm(tsk);
struct dentry *dentry;
char *lname;
int rc = 0;
down_read(&mm->mmap_sem);
vma = mm->mmap;
while (vma) {
- if ((vma->vm_flags & VM_EXECUTABLE) &&
- vma->vm_file) {
+ if ((vma->vm_flags & VM_EXECUTABLE) && vma->vm_file) {
dentry = dget(vma->vm_file->f_dentry);
mnt = mntget(vma->vm_file->f_vfsmnt);
lname = d_path(dentry, mnt, buf, buflen);
- if (! IS_ERR(lname)) {
+ if (!IS_ERR(lname)) {
strncpy(buf, lname, strlen(lname) + 1);
} else {
- rc = (int) PTR_ERR(lname);
+ rc = (int)PTR_ERR(lname);
}
mntput(mnt);
dput(dentry);
return rc;
}
-
/*
* must be called with cnt_lock of parres held
* Caller is responsible for making sure that the new guarantee doesn't
* overflow parent's total guarantee.
*/
-void
-child_guarantee_changed(struct ckrm_shares *parent, int cur, int new)
+void child_guarantee_changed(struct ckrm_shares *parent, int cur, int new)
{
if (new == cur || !parent) {
return;
* Caller is responsible for making sure that the new limit is not more
* than parent's max_limit
*/
-void
-child_maxlimit_changed(struct ckrm_shares *parent, int new_limit)
+void child_maxlimit_changed(struct ckrm_shares *parent, int new_limit)
{
if (parent && parent->cur_max_limit < new_limit) {
parent->cur_max_limit = new_limit;
*/
int
set_shares(struct ckrm_shares *new, struct ckrm_shares *cur,
- struct ckrm_shares *par)
+ struct ckrm_shares *par)
{
int rc = -EINVAL;
int cur_usage_guar = cur->total_guarantee - cur->unused_guarantee;
- int increase_by = new->my_guarantee - cur->my_guarantee;
+ int increase_by;
+
+ if (cur->my_guarantee < 0) // DONTCARE or UNCHANGED
+ increase_by = new->my_guarantee;
+ else
+ increase_by = new->my_guarantee - cur->my_guarantee;
// Check total_guarantee for correctness
if (new->total_guarantee <= CKRM_SHARE_DONTCARE) {
+ printk("set_shares: new->total_guarantee (%d) <= CKRM_SHARE_DONTCARE\n",
+ new->total_guarantee);
goto set_share_err;
} else if (new->total_guarantee == CKRM_SHARE_UNCHANGED) {
- ;// do nothing
+ ; // do nothing
} else if (cur_usage_guar > new->total_guarantee) {
+ printk("set_shares: cur_usage_guar(%d) > new->total_guarantee (%d)\n",
+ cur_usage_guar, new->total_guarantee);
goto set_share_err;
}
-
// Check max_limit for correctness
if (new->max_limit <= CKRM_SHARE_DONTCARE) {
+ printk("set_shares: new->max_limit (%d) <= CKRM_SHARE_DONTCARE\n",
+ new->max_limit);
goto set_share_err;
} else if (new->max_limit == CKRM_SHARE_UNCHANGED) {
- ; // do nothing
+ ; // do nothing
} else if (cur->cur_max_limit > new->max_limit) {
+ printk("set_shares: cur->cur_max_limit (%d) > new->max_limit (%d)\n",
+ cur->cur_max_limit,new->max_limit);
goto set_share_err;
}
-
// Check my_guarantee for correctness
if (new->my_guarantee == CKRM_SHARE_UNCHANGED) {
- ; // do nothing
+ ; // do nothing
} else if (new->my_guarantee == CKRM_SHARE_DONTCARE) {
- ; // do nothing
+ ; // do nothing
} else if (par && increase_by > par->unused_guarantee) {
+ printk("set_shares: increase_by (%d) > par->unused_guarantee (%d)\n",
+ increase_by, par->unused_guarantee);
goto set_share_err;
}
-
// Check my_limit for correctness
if (new->my_limit == CKRM_SHARE_UNCHANGED) {
- ; // do nothing
+ ; // do nothing
} else if (new->my_limit == CKRM_SHARE_DONTCARE) {
- ; // do nothing
+ ; // do nothing
} else if (par && new->my_limit > par->max_limit) {
// I can't get more limit than my parent's limit
+ printk("set_shares: new->my_limit (%d) > par->max_limit (%d)\n",
+ new->my_limit,par->max_limit);
goto set_share_err;
-
}
-
// make sure guarantee is lesser than limit
if (new->my_limit == CKRM_SHARE_DONTCARE) {
- ; // do nothing
+ ; // do nothing
} else if (new->my_limit == CKRM_SHARE_UNCHANGED) {
if (new->my_guarantee == CKRM_SHARE_DONTCARE) {
- ; // do nothing
+ ; // do nothing
} else if (new->my_guarantee == CKRM_SHARE_UNCHANGED) {
- ; // do nothing earlier setting would 've taken care of it
+ ; // do nothing earlier setting would've
+ // taken care of it
} else if (new->my_guarantee > cur->my_limit) {
+ printk("set_shares: new->my_guarantee (%d) > cur->my_limit (%d)\n",
+ new->my_guarantee,cur->my_limit);
goto set_share_err;
}
- } else { // new->my_limit has a valid value
+ } else { // new->my_limit has a valid value
if (new->my_guarantee == CKRM_SHARE_DONTCARE) {
- ; // do nothing
+ ; // do nothing
} else if (new->my_guarantee == CKRM_SHARE_UNCHANGED) {
if (cur->my_guarantee > new->my_limit) {
+ printk("set_shares: cur->my_guarantee (%d) > new->my_limit (%d)\n",
+ cur->my_guarantee,new->my_limit);
goto set_share_err;
}
} else if (new->my_guarantee > new->my_limit) {
+ printk("set_shares: new->my_guarantee (%d) > new->my_limit (%d)\n",
+ new->my_guarantee,new->my_limit);
goto set_share_err;
}
}
if (new->my_guarantee != CKRM_SHARE_UNCHANGED) {
child_guarantee_changed(par, cur->my_guarantee,
- new->my_guarantee);
+ new->my_guarantee);
cur->my_guarantee = new->my_guarantee;
}
}
rc = 0;
-set_share_err:
+ set_share_err:
return rc;
}
EXPORT_SYMBOL(child_guarantee_changed);
EXPORT_SYMBOL(child_maxlimit_changed);
EXPORT_SYMBOL(set_shares);
-
-