Re: [PATCH 04/16] dma-debug: add allocator code

From: Ingo Molnar
Date: Sat Jan 10 2009 - 18:44:47 EST



* Joerg Roedel <joerg.roedel@xxxxxxx> wrote:

> + printk(KERN_ERR "DMA-API: debugging out of memory "
> + "- disabling\n");

btw., i'd suggest to not break kernel messages mid-string, but do
something like this instead:

> + printk(KERN_ERR
"DMA-API: debugging out of memory - disabling\n");

Also, i'd use WARN() - it might be useful to see what callsite depleted
the pool.

> + entry = list_entry(free_entries.next, struct dma_debug_entry, list);
> + list_del(&entry->list);
> + memset(entry, 0, sizeof(*entry));
> +
> + num_free_entries -= 1;
> + if (num_free_entries < min_free_entries)
> + min_free_entries = num_free_entries;

unlikely() i guess.

Regarding the entry pool locking:

> +static void dma_entry_free(struct dma_debug_entry *entry)
> +{
> + unsigned long flags;
> +
> + /*
> + * add to beginning of the list - this way the entries are
> + * more likely cache hot when they are reallocated.
> + */
> + spin_lock_irqsave(&free_entries_lock, flags);
> + list_add(&entry->list, &free_entries);
> + num_free_entries += 1;
> + spin_unlock_irqrestore(&free_entries_lock, flags);

it might make sense to cache entries in the buckets - hence reuse the
bucket spinlock. This means a somewhat higher effective pool size, but it
also avoids a global lock.

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/