[EMAIL PROTECTED] wrote:
> 03/12 - ckrm_core_handle_shares
> 
> Provides functions to set/get shares of a specific resource of a class
> Defines a teardown function that is intended to be called when user
> disables CKRM (by umount of RCFS)
> --
> 
> Signed-Off-By: Chandra Seetharaman <[EMAIL PROTECTED]>
> Signed-Off-By: Hubertus Franke <[EMAIL PROTECTED]>
> Signed-Off-By: Shailabh Nagar <[EMAIL PROTECTED]>
> Signed-Off-By: Gerrit Huizenga <[EMAIL PROTECTED]>
> Signed-off-by: MAEDA Naoaki <[EMAIL PROTECTED]>
> Signed-Off-By: Matt Helsley <[EMAIL PROTECTED]>
> 
>  include/linux/ckrm.h      |   15 ++
>  include/linux/ckrm_rc.h   |   16 +++
>  kernel/ckrm/Makefile      |    2 
>  kernel/ckrm/ckrm.c        |   22 ++++
>  kernel/ckrm/ckrm_shares.c |  240 
> ++++++++++++++++++++++++++++++++++++++++++++++
>  5 files changed, 294 insertions(+), 1 deletion(-)
> 
> Index: linux-2.6.16/include/linux/ckrm.h
> ===================================================================
> --- linux-2.6.16.orig/include/linux/ckrm.h
> +++ linux-2.6.16/include/linux/ckrm.h
> @@ -54,6 +54,20 @@
>   * locked.
>  */
>  struct ckrm_shares {
> +     /* shares only set by userspace */
> +     int min_shares; /* try to set to maximum expected shares needed */
                                         minimum expected shares needed?

> +     int max_shares; /* maximum fraction of the parent's resources allowed */
> +     int child_shares_divisor; /* >= 1, may not be DONT_CARE */
> +
> +     /*
> +      * share values invisible to userspace.  adjusted when userspace
> +      * sets shares
> +      */
> +     int unused_min_shares;
> +             /* 0 <= unused_min_shares <= (child_shares_divisor -
> +              *                      Sum of min_shares of children)
> +              */
> +     int cur_max_shares; /* max(children's max_shares). need better name */
>  };

<snip>

> +static inline int is_share_valid(int share)
> +{
> +     return ((share == CKRM_SHARE_DONT_CARE) ||
> +                             is_share_quantitative(share));
> +}

CKRM_SHARE_UNSUPPORTED also should be regarded as a valid share.
Otherwise changing share is always failed if one of min_share
or max_share is CKRM_SHARE_UNSUPPORTED due to are_shares_valid()
check.

<snip>

> +int ckrm_set_controller_shares(struct ckrm_class *class,
> +                                     struct ckrm_controller *ctlr,
> +                                     const struct ckrm_shares *new_shares)
> +{
> +     struct ckrm_shares *shares, *parent_shares;
> +     int prev_min, prev_max, rc;
> +
> +     if (!ctlr->shares_changed)
> +             return -EINVAL;
> +
> +     shares = ckrm_get_controller_shares(class, ctlr);
> +     if (!shares)
> +             return -EINVAL;
> +
> +     prev_min = shares->min_shares;
> +     prev_max = shares->max_shares;
> +
> +     spin_lock(&class->parent->class_lock);

Accessing class->parent->class_lock is not safe, because
it could be NULL if the class is root class.

ckrm_is_class_root(class) should be checked before accessing
class->parent->class_lock.

> +     spin_lock(&class->class_lock);
> +     parent_shares = ckrm_get_controller_shares(class->parent, ctlr);
> +     rc = ckrm_set_shares(new_shares, shares, parent_shares);
> +     spin_unlock(&class->class_lock);
> +
> +     if (rc) {
> +             spin_unlock(&class->parent->class_lock);

The same issue.

> +             return rc;
> +     }
> +     if (ckrm_is_class_root(class))
> +             goto call_controller;
> +
> +     /* Notify parent about changes in my shares */
> +     ckrm_child_min_shares_changed(parent_shares, prev_min,
> +                                   shares->min_shares);
> +     if (prev_max != shares->max_shares)
> +             ckrm_set_cur_max_shares(class->parent, ctlr);
> +
> +call_controller:
> +     spin_unlock(&class->parent->class_lock);

And here.

> +     ctlr->shares_changed(shares);
> +     return 0;
> +}

Thanks,
MAEDA Naoaki



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
ckrm-tech mailing list
https://lists.sourceforge.net/lists/listinfo/ckrm-tech

Reply via email to