lkml.org 
[lkml]   [2012]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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


\
 
 \ /
  Last update: 2012-03-07 20:25    [W:0.125 / U:0.656 seconds]
©2003-2014 Jasper Spaans. Advertise on this site