From: Arnd Bergmann <arnd@arndb.de>
To: outreachy-kernel@googlegroups.com
Cc: Alison Schofield <amsfield22@gmail.com>
Subject: Re: [Outreachy kernel] [PATCH 2/3] staging: wilc1000: host_interface: replace semaphores with mutexes
Date: Tue, 16 Feb 2016 09:46:04 +0100 [thread overview]
Message-ID: <2441828.Ytg91CRYb7@wuerfel> (raw)
In-Reply-To: <4f9af8d5cac2ccb9e81ef5908ef0b3b0cdec6145.1455609607.git.amsfield22@gmail.com>
On Tuesday 16 February 2016 00:31:42 Alison Schofield wrote:
> Replace semaphores with mutexes in the host_interface driver.
>
> This is a safe performance improvement because the usage model
> meets the principle of ownership for mutexes: the thread that
> locks is the same thread that unlocks.
>
> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Good stuff in general, but it's slightly hard to review because you do
all at once. This might be more obvious if you did one patch per
semaphore.
Also, some of them look wrong:
>
> if (clients_count == 0) {
> - sema_init(&hif_sema_thread, 0);
> - sema_init(&hif_sema_driver, 0);
> - sema_init(&hif_sema_deinit, 1);
> + mutex_init(&hif_mutex_thread);
> + mutex_init(&hif_mutex_driver);
> + mutex_init(&hif_mutex_deinit);
> }
>
> - sema_init(&hif_drv->sem_test_key_block, 0);
> - sema_init(&hif_drv->sem_test_disconn_block, 0);
> - sema_init(&hif_drv->sem_get_rssi, 0);
> - sema_init(&hif_drv->sem_inactive_time, 0);
> + mutex_init(&hif_drv->mutex_wep_key);
> + mutex_init(&hif_drv->mutex_disconnect);
> + mutex_init(&hif_drv->mutex_get_rssi);
> + mutex_init(&hif_drv->mutex_inactive_time);
Note that some of these are initialized to zero (locked), others are
initialized to one (unlocked). When you have a semaphore that starts
out as locked, you need to be extra careful to ensure the lock/unlock
comes in pairs, as it equates a
mutex_init(&lock);
mutex_lock(&lock);
and some of them might be unlocked elsewhere first. Looking at
how some of these are used, I think there are some that get
released in hostIFthread(), which is a kthread and taken in
a function waiting for the kthread. Those should be converted
to wait_for_completion() rather than a mutex.
Arnd
next prev parent reply other threads:[~2016-02-16 8:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-16 8:27 [PATCH 0/3] staging: wilc1000: semaphores to mutexes in host_interface Alison Schofield
2016-02-16 8:30 ` [PATCH 1/3] staging: wilc1000: host_interface: remove unused semaphores Alison Schofield
2016-02-16 8:33 ` [Outreachy kernel] " Arnd Bergmann
2016-02-19 6:45 ` Alison Schofield
2016-02-19 8:11 ` Arnd Bergmann
2016-02-16 8:31 ` [PATCH 2/3] staging: wilc1000: host_interface: replace semaphores with mutexes Alison Schofield
2016-02-16 8:46 ` Arnd Bergmann [this message]
2016-02-16 17:36 ` [Outreachy kernel] " Greg KH
2016-02-16 18:16 ` Alison Schofield
2016-02-16 21:34 ` [Outreachy kernel] " Arnd Bergmann
2016-02-19 19:42 ` Alison Schofield
2016-02-19 19:45 ` [PATCH] staging: wilc1000: replace semaphore get_inactive_time with a completion Alison Schofield
2016-02-19 21:03 ` [Outreachy kernel] " Arnd Bergmann
2016-02-20 0:54 ` Greg KH
2016-02-20 1:06 ` Alison Schofield
2016-02-20 1:13 ` Greg KH
2016-02-16 8:36 ` [PATCH 3/3] staging: wilc1000: host_interface: destroy mutexes at init/deinit Alison Schofield
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=2441828.Ytg91CRYb7@wuerfel \
--to=arnd@arndb.de \
--cc=amsfield22@gmail.com \
--cc=outreachy-kernel@googlegroups.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.