public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ralph Corderoy <ralph@inputplus.co.uk>
To: Corey Minyard <cminyard@mvista.com>
Cc: Greg KH <greg@kroah.com>, lkml <linux-kernel@vger.kernel.org>
Subject: Re: Documentation for krefs
Date: Wed, 02 Mar 2005 21:30:06 +0000	[thread overview]
Message-ID: <200503022130.j22LU6H02463@blake.inputplus.co.uk> (raw)
In-Reply-To: <422617F1.2080404@mvista.com>


Hi Corey,

> Here is the documentation for krefs, with the kref_checked stuff
> removed and a few other things cleaned up.

Great, more documentation.  :-)  A few minor points...

> +To use a kref, add a one to your data structures like:

s/a one/one/

> +You must initialize the kref after you allocate it.  To do this, call
> +kref init as so:

s/kref init/kref_init/

> +Once you have a refcount, you must follow the following rules:

s/refcount/initialised kref/

> +	if (task == ERR_PTR(-ENOMEM)) {
> +		rv = -ENOMEM;
> +	        kref_put(&data->refcount);

s/)/, data_release)/

> +		goto out;
> +	}
> +
> +	.
> +	. do stuff with data here
> +	.
> + out:
> +	kref_put(data, data_release);

s/data/\&data->refcount/ ?

> +	return rv;
> +}
> +
> +This way, it doesn't matter what order the two threads handle the
> +data, the put handles knowing when the data is free and releasing it.

s/put/kref_put()/

> +The kref_get() does not require a lock, since we already have a valid
> +pointer that we own a refcount for.  The put needs no lock because
> +nothing tries to get the data without already holding a pointer.

Cheers,


Ralph.


  reply	other threads:[~2005-03-02 21:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-02 19:45 Documentation for krefs Corey Minyard
2005-03-02 21:30 ` Ralph Corderoy [this message]
2005-03-02 22:13   ` Dmitry Torokhov

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=200503022130.j22LU6H02463@blake.inputplus.co.uk \
    --to=ralph@inputplus.co.uk \
    --cc=cminyard@mvista.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /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