From: Jonathan Corbet <corbet@lwn.net>
To: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] docs: kref: Clarify the use of two kref_put() in example code
Date: Wed, 19 Feb 2020 03:58:18 -0700 [thread overview]
Message-ID: <20200219035818.08ad246f@lwn.net> (raw)
In-Reply-To: <20200213125311.21256-1-manivannan.sadhasivam@linaro.org>
On Thu, 13 Feb 2020 18:23:11 +0530
Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> wrote:
> Eventhough the current documentation explains that the reference count
> gets incremented by both kref_init() and kref_get(), it is often
> misunderstood that only one instance of kref_put() is needed in the
> example code. So let's clarify that a bit.
>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
> Documentation/kref.txt | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/Documentation/kref.txt b/Documentation/kref.txt
> index 3af384156d7e..c61eea6f1bf2 100644
> --- a/Documentation/kref.txt
> +++ b/Documentation/kref.txt
> @@ -128,6 +128,10 @@ 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.
>
> +In the above example, kref_put() will be called 2 times in both success
> +and error paths. This is necessary because the reference count got
> +incremented 2 times by kref_init() and kref_get().
Out of curiosity, where have you seen this misunderstanding happening?
I'm not really opposed to this change, but I don't understand why it's
really needed.
Thanks,
jon
next prev parent reply other threads:[~2020-02-19 10:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-13 12:53 [PATCH] docs: kref: Clarify the use of two kref_put() in example code Manivannan Sadhasivam
2020-02-19 10:58 ` Jonathan Corbet [this message]
2020-02-19 11:10 ` Manivannan Sadhasivam
2020-02-25 10:39 ` Jonathan Corbet
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=20200219035818.08ad246f@lwn.net \
--to=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manivannan.sadhasivam@linaro.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;
as well as URLs for NNTP newsgroup(s).