netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: netdev@vger.kernel.org, Max Krasnyansky <maxk@qualcomm.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	David Miller <davem@davemloft.net>
Subject: Re: [PATCH] net: add destructor for skb data (rewritten)
Date: Sat, 19 Apr 2008 13:46:01 +0400	[thread overview]
Message-ID: <20080419094600.GA11682@2ka.mipt.ru> (raw)
In-Reply-To: <200804181421.25828.rusty@rustcorp.com.au>

On Fri, Apr 18, 2008 at 02:21:25PM +1000, Rusty Russell (rusty@rustcorp.com.au) wrote:
> If we want to notify something when an skb is truly finished (such as
> for tun vringfd support), we need a destructor on the data.

Can we put its invokation before pages are freed?

> +static void shinfo_put(struct skb_shared_info *shinfo, bool nohdr)
> +{
> +	struct skb_shared_info *orig;
> +
> +	do {
> +		if (atomic_sub_return(nohdr ? (1 << SKB_DATAREF_SHIFT) + 1 : 1,
> +				      &shinfo->dataref))
> +			return;
> +
> +		if (shinfo->nr_frags) {
> +			int i;
> +			for (i = 0; i < shinfo->nr_frags; i++)
> +				put_page(shinfo->frags[i].page);
> +		}
> +
> +		if (shinfo->frag_list)
> +			skb_drop_list(&shinfo->frag_list);
> +
> +		orig = shinfo->orig;
> +		if (shinfo->destructor)
> +			shinfo->destructor(shinfo);

If it is first, we can process handle pages inside destructor, otherwise
they can be out of our control.

> +		else
> +			kfree(skb_shinfo_to_head(shinfo));
> +
> +		/* We hold a payload reference to our parent. */
> +		nohdr = true;
> +	} while ((shinfo = orig) != NULL);
> +}

-- 
	Evgeniy Polyakov

  parent reply	other threads:[~2008-04-19  9:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-18  4:21 [PATCH] net: add destructor for skb data (rewritten) Rusty Russell
2008-04-19  9:35 ` David Miller
2008-04-19 16:20   ` Rusty Russell
2008-04-19  9:46 ` Evgeniy Polyakov [this message]
2008-04-19 15:49   ` Rusty Russell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080419094600.GA11682@2ka.mipt.ru \
    --to=johnpol@2ka.mipt.ru \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=maxk@qualcomm.com \
    --cc=netdev@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).