Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751688Ab2K2GNy (ORCPT ); Thu, 29 Nov 2012 01:13:54 -0500 Received: from shutemov.name ([204.155.152.216]:37573 "EHLO shutemov.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751392Ab2K2GNx (ORCPT ); Thu, 29 Nov 2012 01:13:53 -0500 Date: Thu, 29 Nov 2012 08:14:13 +0200 From: "Kirill A. Shutemov" To: Anton Vorontsov Cc: David Rientjes , Pekka Enberg , Mel Gorman , Glauber Costa , Michal Hocko , Luiz Capitulino , Andrew Morton , Greg Thelen , Leonid Moiseichuk , KOSAKI Motohiro , Minchan Kim , Bartlomiej Zolnierkiewicz , John Stultz , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com Subject: Re: [RFC] Add mempressure cgroup Message-ID: <20121129061412.GA26034@shutemov.name> References: <20121128102908.GA15415@lizard> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121128102908.GA15415@lizard> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1501 Lines: 65 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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/