Re: [RFC] Add mempressure cgroup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 28, 2012 at 02:29:08AM -0800, Anton Vorontsov wrote:
> +static int mpc_pre_destroy(struct cgroup *cg)
> +{
> +	struct mpc_state *mpc = cg2mpc(cg);
> +	int ret = 0;
> +
> +	mutex_lock(&mpc->lock);
> +
> +	if (mpc->eventfd)
> +		ret = -EBUSY;

cgroup_rmdir() will unregister all events for you. No need to handle it
here.

> +
> +	mutex_unlock(&mpc->lock);
> +
> +	return ret;
> +}

> +static int mpc_register_level_event(struct cgroup *cg, struct cftype *cft,
> +				    struct eventfd_ctx *eventfd,
> +				    const char *args)
> +{
> +	struct mpc_state *mpc = cg2mpc(cg);
> +	int i;
> +	int ret;
> +
> +	mutex_lock(&mpc->lock);
> +
> +	/*
> +	 * It's easy to implement multiple thresholds, but so far we don't
> +	 * need it.
> +	 */
> +	if (mpc->eventfd) {
> +		ret = -EBUSY;
> +		goto out_unlock;
> +	}

One user which listen for one threashold per cgroup?
I think it's wrong. It's essensial for API to serve multiple users.

> +
> +	ret = -EINVAL;
> +	for (i = 0; i < VMPRESSURE_NUM_LEVELS; i++) {
> +		if (strcmp(vmpressure_str_levels[i], args))
> +			continue;
> +		mpc->eventfd = eventfd;
> +		mpc->thres = i;
> +		ret = 0;
> +		break;
> +	}
> +out_unlock:
> +	mutex_unlock(&mpc->lock);
> +
> +	return ret;
> +}

-- 
 Kirill A. Shutemov

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]