[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160105220128.GJ5995@mtj.duckdns.org>
Date: Tue, 5 Jan 2016 17:01:28 -0500
From: Tejun Heo <tj@...nel.org>
To: Parav Pandit <pandit.parav@...il.com>
Cc: cgroups@...r.kernel.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-rdma@...r.kernel.org,
lizefan@...wei.com, hannes@...xchg.org, dledford@...hat.com,
liranl@...lanox.com, sean.hefty@...el.com,
jgunthorpe@...idianresearch.com, haggaie@...lanox.com,
corbet@....net, james.l.morris@...cle.com, serge@...lyn.com,
ogerlitz@...lanox.com, matanb@...lanox.com, raindel@...lanox.com,
akpm@...ux-foundation.org, linux-security-module@...r.kernel.org
Subject: Re: [PATCHv1 3/6] rdmacg: implements rdma cgroup
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists