lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 06 Dec 2021 09:13:27 +0000
From:   yajun.deng@...ux.dev
To:     "Peter Zijlstra" <peterz@...radead.org>
Cc:     mingo@...hat.com, juri.lelli@...hat.com,
        vincent.guittot@...aro.org, dietmar.eggemann@....com,
        rostedt@...dmis.org, bsegall@...gle.com, mgorman@...e.de,
        bristot@...hat.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] completion: introduce complete_put() helper function

December 6, 2021 4:34 PM, "Peter Zijlstra" <peterz@...radead.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@...ux.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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ