lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120307192219.GC30676@google.com>
Date:	Wed, 7 Mar 2012 11:22:19 -0800
From:	Tejun Heo <tj@...nel.org>
To:	Vivek Goyal <vgoyal@...hat.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>, axboe@...nel.dk,
	hughd@...gle.com, avi@...hat.com, nate@...nel.net,
	cl@...ux-foundation.org, linux-kernel@...r.kernel.org,
	dpshah@...gle.com, ctalbott@...gle.com, rni@...gle.com
Subject: Re: [PATCHSET] mempool, percpu, blkcg: fix percpu stat allocation
 and remove stats_lock

Hello, Vivek.

On Wed, Mar 07, 2012 at 02:13:34PM -0500, Vivek Goyal wrote:
> +static void blkio_stat_alloc_fn(struct work_struct *work)
> +{
> +
> +	struct delayed_work *dwork = to_delayed_work(work);
> +	struct blkio_group *blkg;
> +	int i;
> +	bool alloc_more = false;
> +
> +alloc_stats:
> +	for (i = 0; i < BLKIO_NR_POLICIES; i++) {
> +		if (pcpu_stats[i] != NULL)
> +			continue;
> +
> +		pcpu_stats[i] = alloc_percpu(struct blkio_group_stats_cpu);
> +
> +		/* Allocation failed. Try again after some time. */
> +		if (pcpu_stats[i] == NULL) {
> +			queue_delayed_work(system_nrt_wq, dwork,
> +						msecs_to_jiffies(10));
> +			return;
> +		}
> +	}
> +
> +	spin_lock_irq(&blkio_list_lock);
> +	spin_lock(&alloc_list_lock);
> +
> +	/* cgroup got deleted or queue exited. */
> +	if (list_empty(&alloc_list)) {
> +		alloc_more = false;
> +		goto unlock;
> +	}
> +
> +	blkg = list_first_entry(&alloc_list, struct blkio_group, alloc_node);
> +
> +	for (i = 0; i < BLKIO_NR_POLICIES; i++) {
> +		struct blkg_policy_data *pd = blkg->pd[i];
> +
> +		if (blkio_policy[i] && pd && !pd->stats_cpu)
> +			swap(pd->stats_cpu, pcpu_stats[i]);
> +	}
> +
> +	list_del_init(&blkg->alloc_node);
> +
> +	if (list_empty(&alloc_list))
> +		alloc_more = false;
> +	else
> +		alloc_more = true;

Sorry about being a pain in the ass for small stuff but how about the
following?

	lock_stuff()

	if (!list_empty()) {
		struct blkio_group *blkg = list_first_entry();

		for (i = 0; ..) {
			set stuff;
		}
		list_del_init();
	}
	empty = list_empty();

	unlock_stuff();

	if (!empty)
		goto repeat;

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

Powered by Openwall GNU/*/Linux Powered by OpenVZ