linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: yajun.deng@linux.dev
To: "Peter Zijlstra" <peterz@infradead.org>
Cc: mingo@redhat.com, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	bristot@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] completion: introduce complete_put() helper function
Date: Mon, 06 Dec 2021 09:13:27 +0000	[thread overview]
Message-ID: <0a2496c3503ba85205a5da0d8e61ea78@linux.dev> (raw)
In-Reply-To: <Ya3LFV2W05TZzMnC@hirez.programming.kicks-ass.net>

December 6, 2021 4:34 PM, "Peter Zijlstra" <peterz@infradead.org> wrote:

> On Mon, Dec 06, 2021 at 12:03:19PM +0800, Yajun Deng wrote:
> 
>> There are many cases where it is necessary to decrease refcount and test,
>> then called complete(). So introduce complete_put() helper function.
>> 
>> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
>> ---
>> kernel/sched/completion.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>> 
>> diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
>> index a778554f9dad..dcb737f1edc2 100644
>> --- a/kernel/sched/completion.c
>> +++ b/kernel/sched/completion.c
>> @@ -38,6 +38,13 @@ void complete(struct completion *x)
>> }
>> EXPORT_SYMBOL(complete);
>> 
>> +void complete_put(refcount_t *r, struct completion *x)
>> +{
>> + if (refcount_dec_and_test(r))
>> + complete(x);
>> +}
>> +EXPORT_SYMBOL(complete_put);
> 
> Please submit such things as part of the series that makes use of them.

Here is a typical use case:       vim drivers/infiniband/core/device.c +101
static void ib_client_put(struct ib_client *client)
{
        if (refcount_dec_and_test(&client->uses))
                complete(&client->uses_zero);
}

Each driver needs to define a xxx_put() function if they want to use it, we can add this helper function for them.

      parent reply	other threads:[~2021-12-06  9:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-06  4:03 [PATCH] completion: introduce complete_put() helper function Yajun Deng
2021-12-06  7:17 ` kernel test robot
2021-12-06  7:37 ` kernel test robot
2021-12-06  8:34 ` Peter Zijlstra
2021-12-06  9:13 ` yajun.deng [this message]

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=0a2496c3503ba85205a5da0d8e61ea78@linux.dev \
    --to=yajun.deng@linux.dev \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@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).