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]
Message-ID: <nycvar.YFH.7.76.2108201420570.15313@cbobk.fhfr.pm>
Date:   Fri, 20 Aug 2021 14:21:05 +0200 (CEST)
From:   Jiri Kosina <jikos@...nel.org>
To:     Christophe JAILLET <christophe.jaillet@...adoo.fr>
cc:     benjamin.tissoires@...hat.com, linux-input@...r.kernel.org,
        linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] HID: logitech-hidpp: Use 'atomic_inc_return' instead of
 hand-writing it

On Fri, 23 Jul 2021, Christophe JAILLET wrote:

> This function logs a warning if the workqueue gets too big.
> In order to save a few cycles, use 'atomic_inc_return()' instead of an
> 'atomic_inc()/atomic_read()' sequence.
> 
> This axes a line of code and saves a 'atomic_read()' call.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
> ---
>  drivers/hid/hid-logitech-hidpp.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
> index 61635e629469..a7fa35245c2e 100644
> --- a/drivers/hid/hid-logitech-hidpp.c
> +++ b/drivers/hid/hid-logitech-hidpp.c
> @@ -2240,11 +2240,10 @@ static int hidpp_ff_queue_work(struct hidpp_ff_private_data *data, int effect_id
>  	wd->size = size;
>  	memcpy(wd->params, params, size);
>  
> -	atomic_inc(&data->workqueue_size);
> +	s = atomic_inc_return(&data->workqueue_size);
>  	queue_work(data->wq, &wd->work);
>  
>  	/* warn about excessive queue size */
> -	s = atomic_read(&data->workqueue_size);
>  	if (s >= 20 && s % 20 == 0)
>  		hid_warn(data->hidpp->hid_dev, "Force feedback command queue contains %d commands, causing substantial delays!", s);

Applied, thank you.

-- 
Jiri Kosina
SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ