[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1354190143.21562.145.camel@shinybook.infradead.org>
Date: Thu, 29 Nov 2012 11:55:43 +0000
From: David Woodhouse <dwmw2@...radead.org>
To: Krzysztof Mazur <krzysiek@...lesie.net>
Cc: David Laight <David.Laight@...LAB.COM>,
chas williams - CONTRACTOR <chas@....nrl.navy.mil>,
davem@...emloft.net, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, nathan@...verse.com.au
Subject: Re: [PATCH v2 3/3] pppoatm: protect against freeing of vcc
On Thu, 2012-11-29 at 11:57 +0100, Krzysztof Mazur wrote:
> do we really need to wait here?
> Why don't just do something like that:
>
> tasklet_disable(&card->tlet);
> spin_lock(&card->tx_queue_lock);
> for each skb in queue
> SKB_CB(skb)->vcc = NULL;
> spin_unlock(&card->tx_queue_lock);
> tasklet_enable(&card->tlet);
>
> or if we really want to call vcc->pop() for such skbs:
>
> tasklet_disable(&card->tlet);
> spin_lock(&card->tx_queue_lock);
> for each skb in queue {
> skb_get(skb);
> solos_pop(SKB_CB(skb)->vcc, skb);
> SKB_CB(skb)->vcc = NULL;
> }
> spin_unlock(&card->tx_queue_lock);
> tasklet_enable(&card->tlet);
Yes, we could certainly remove the packets from the tx_queue first.
However, in the card->using_dma case there might be a skb for this vcc
*currently* being DMA'd, and we'd still need to wait for that one.
I suppose we could just have a waitqueue in *every* TX skb, and under
card->tx_lock we could add ourselves to *that* waitqueue. Or just a
global waitqueue for DMA tx_done, perhaps. But waiting for our own
PKT_PCLOSE skb is just 'cleaner' in my view. It's simpler, and it's much
easier to test. Even if I had DMA-capable hardware, I'd have to get the
right timing to properly test that TX-pending-DMA case.
So dequeuing the packets would only serve to make pclose() slightly
faster, rather than simplifying it. It's hardly a fast path that we care
about, and I've also already ensured that there should only be one or
two packets queued per vcc *anyway*. So I'm mostly inclined not to
bother.
(I did fix the timeout argument to wait_for_completion_timeout())
--
dwmw2
Download attachment "smime.p7s" of type "application/x-pkcs7-signature" (6171 bytes)
Powered by blists - more mailing lists