public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Parav Pandit <pandit.parav@gmail.com>
Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org,
	lizefan@huawei.com, hannes@cmpxchg.org, dledford@redhat.com,
	liranl@mellanox.com, sean.hefty@intel.com,
	jgunthorpe@obsidianresearch.com, haggaie@mellanox.com,
	corbet@lwn.net, james.l.morris@oracle.com, serge@hallyn.com,
	ogerlitz@mellanox.com, matanb@mellanox.com, raindel@mellanox.com,
	akpm@linux-foundation.org, linux-security-module@vger.kernel.org
Subject: Re: [PATCHv1 3/6] rdmacg: implements rdma cgroup
Date: Tue, 5 Jan 2016 17:01:28 -0500	[thread overview]
Message-ID: <20160105220128.GJ5995@mtj.duckdns.org> (raw)
In-Reply-To: <1452020286-9508-4-git-send-email-pandit.parav@gmail.com>

Hello,

On Wed, Jan 06, 2016 at 12:28:03AM +0530, Parav Pandit wrote:
> +/* hash table to keep map of tgid to owner cgroup */
> +DEFINE_HASHTABLE(pid_cg_map_tbl, 7);
> +DEFINE_SPINLOCK(pid_cg_map_lock);	/* lock to protect hash table access */
> +
> +/* Keeps mapping of pid to its owning cgroup at rdma level,
> + * This mapping doesn't change, even if process migrates from one to other
> + * rdma cgroup.
> + */
> +struct pid_cg_map {
> +	struct pid *pid;		/* hash key */
> +	struct rdma_cgroup *cg;
> +
> +	struct hlist_node hlist;	/* pid to cgroup hash table link */
> +	atomic_t refcnt;		/* count active user tasks to figure out
> +					 * when to free the memory
> +					 */
> +};

Ugh, there's something clearly wrong here.  Why does the rdma
controller need to keep track of pid cgroup membership?

> +static void _dealloc_cg_rpool(struct rdma_cgroup *cg,
> +			      struct cg_resource_pool *rpool)
> +{
> +	spin_lock(&cg->cg_list_lock);
> +
> +	/* if its started getting used by other task,
> +	 * before we take the spin lock, then skip,
> +	 * freeing it.
> +	 */

Please follow CodingStyle.

> +	if (atomic_read(&rpool->refcnt) == 0) {
> +		list_del_init(&rpool->cg_list);
> +		spin_unlock(&cg->cg_list_lock);
> +
> +		_free_cg_rpool(rpool);
> +		return;
> +	}
> +	spin_unlock(&cg->cg_list_lock);
> +}
> +
> +static void dealloc_cg_rpool(struct rdma_cgroup *cg,
> +			     struct cg_resource_pool *rpool)
> +{
> +	/* Don't free the resource pool which is created by the
> +	 * user, otherwise we miss the configured limits. We don't
> +	 * gain much either by splitting storage of limit and usage.
> +	 * So keep it around until user deletes the limits.
> +	 */
> +	if (atomic_read(&rpool->creator) == RDMACG_RPOOL_CREATOR_DEFAULT)
> +		_dealloc_cg_rpool(cg, rpool);

I'm pretty sure you can get away with an fixed length array of
counters.  Please keep it simple.  It's a simple hard limit enforcer.
There's no need to create a massive dynamic infrastrucure.

Thanks.

-- 
tejun

  reply	other threads:[~2016-01-05 22:01 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-05 18:58 [PATCHv1 0/6] rdma controller support Parav Pandit
2016-01-05 18:58 ` [PATCHv1 1/6] rdmacg: Added rdma cgroup header file Parav Pandit
2016-01-05 18:58 ` [PATCHv1 2/6] IB/core: Added members to support rdma cgroup Parav Pandit
2016-01-05 21:56   ` Tejun Heo
2016-01-06 23:16     ` Parav Pandit
2016-01-07 15:07       ` Tejun Heo
2016-01-07 19:40         ` Parav Pandit
2016-01-05 18:58 ` [PATCHv1 3/6] rdmacg: implements " Parav Pandit
2016-01-05 22:01   ` Tejun Heo [this message]
2016-01-06 23:33     ` Parav Pandit
2016-01-07 15:29       ` Tejun Heo
2016-01-07 20:25         ` Parav Pandit
2016-01-07 20:28           ` Tejun Heo
2016-01-07 20:39             ` Parav Pandit
2016-01-07 20:41               ` Tejun Heo
2016-01-05 18:58 ` [PATCHv1 4/6] IB/core: rdmacg support infrastructure APIs Parav Pandit
2016-01-05 18:58 ` [PATCHv1 5/6] IB/core: use rdma cgroup for resource accounting Parav Pandit
2016-01-05 18:58 ` [PATCHv1 6/6] rdmacg: Added documentation for rdma controller Parav Pandit
2016-01-05 21:53   ` Tejun Heo
2016-01-06 22:44     ` Parav Pandit
2016-01-06 22:57       ` Tejun Heo
2016-01-06 23:52         ` Parav Pandit
2016-01-07 15:42           ` Tejun Heo
2016-01-07 19:43             ` Parav Pandit
2016-01-05 21:56 ` [PATCHv1 0/6] rdma controller support Tejun Heo
2016-01-06 23:13   ` Parav Pandit
2016-01-07 15:07     ` Tejun Heo
2016-01-07 20:01       ` Parav Pandit
2016-01-07 20:06         ` Tejun Heo
2016-01-07 20:32           ` Parav Pandit
2016-01-07 20:34             ` Tejun Heo
2016-01-07 20:46               ` Parav Pandit
2016-01-07 20:49                 ` Tejun Heo
2016-01-07 20:50                   ` Tejun Heo
2016-01-07 21:01                     ` Parav Pandit
2016-01-07 21:07                       ` Tejun Heo
2016-01-07 21:10                         ` Parav Pandit
2016-01-07 21:04                   ` Parav Pandit
2016-01-07 21:08                     ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160105220128.GJ5995@mtj.duckdns.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=corbet@lwn.net \
    --cc=dledford@redhat.com \
    --cc=haggaie@mellanox.com \
    --cc=hannes@cmpxchg.org \
    --cc=james.l.morris@oracle.com \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=liranl@mellanox.com \
    --cc=lizefan@huawei.com \
    --cc=matanb@mellanox.com \
    --cc=ogerlitz@mellanox.com \
    --cc=pandit.parav@gmail.com \
    --cc=raindel@mellanox.com \
    --cc=sean.hefty@intel.com \
    --cc=serge@hallyn.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox