lkml.org 
[lkml]   [2009]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 03/16] dma-debug: add hash functions for dma_debug_entries
On Fri, Jan 09, 2009 at 08:55:42PM +0300, Evgeniy Polyakov wrote:
> Hi Joerg.
>
> On Fri, Jan 09, 2009 at 05:19:17PM +0100, Joerg Roedel (joerg.roedel@amd.com) wrote:
> > +/*
> > + * Request exclusive access to a hash bucket for a given dma_debug_entry.
> > + */
> > +static struct hash_bucket *get_hash_bucket(struct dma_debug_entry *entry,
> > + unsigned long *flags)
> > +{
> > + int idx = hash_fn(entry);
> > + unsigned long __flags;
> > +
> > + spin_lock_irqsave(&dma_entry_hash[idx].lock, __flags);
> > + *flags = __flags;
> > + return &dma_entry_hash[idx];
> > +}
> > +
> > +/*
> > + * Give up exclusive access to the hash bucket
> > + */
> > +static void put_hash_bucket(struct hash_bucket *bucket,
> > + unsigned long *flags)
> > +{
> > + unsigned long __flags = *flags;
> > +
> > + spin_unlock_irqrestore(&bucket->lock, __flags);
> > +}
>
> Why do you need such ugly helpers?

Because everything else I thought about here was even more ugly. But
maybe you have a better idea? I tried to lock directly in the debug_
functions. But this is ugly and unnecessary code duplication.

>
> > + * Add an entry to a hash bucket
> > + */
> > +static void hash_bucket_add(struct hash_bucket *bucket,
> > + struct dma_debug_entry *entry)
> > +{
> > + list_add_tail(&entry->list, &bucket->list);
> > +}
>
> > +/*
> > + * Remove entry from a hash bucket list
> > + */
> > +static void hash_bucket_del(struct dma_debug_entry *entry)
> > +{
> > + list_del(&entry->list);
> > +}
>
> Do you really need this getting they are called only from single place?

Hmm, true. I will inline these functions.

Joerg


\
 
 \ /
  Last update: 2009-01-09 19:17    [W:0.288 / U:1.360 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site