From: Michal Schmidt <mschmidt@redhat.com>
To: "Drewek, Wojciech" <wojciech.drewek@intel.com>,
"intel-wired-lan@lists.osuosl.org"
<intel-wired-lan@lists.osuosl.org>
Cc: Radoslaw Tyl <radoslawx.tyl@intel.com>,
"Nguyen, Anthony L" <anthony.l.nguyen@intel.com>,
"Brandeburg, Jesse" <jesse.brandeburg@intel.com>
Subject: Re: [Intel-wired-lan] [PATCH net-next 2/5] iavf: simplify mutex_trylock+sleep loops
Date: Tue, 10 Oct 2023 13:57:29 +0200 [thread overview]
Message-ID: <a65e79ff-7894-4095-b3bb-948b4cfa04e0@redhat.com> (raw)
In-Reply-To: <MW4PR11MB5776FAE3D86203A223769BABFDCDA@MW4PR11MB5776.namprd11.prod.outlook.com>
Dne 10. 10. 23 v 13:30 Drewek, Wojciech napsal:
>> -----Original Message-----
>> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
>> Michal Schmidt
>> Sent: Tuesday, October 10, 2023 2:25 AM
>> To: intel-wired-lan@lists.osuosl.org
>> Cc: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; Radoslaw Tyl
>> <radoslawx.tyl@intel.com>; Brandeburg, Jesse <jesse.brandeburg@intel.com>
>> Subject: [Intel-wired-lan] [PATCH net-next 2/5] iavf: simplify
>> mutex_trylock+sleep loops
>>
>> This pattern appears in two places in the iavf source code:
>> while (!mutex_trylock(...))
>> usleep_range(...);
>
> I found a few other places with similar pattern (iavf_configure_clsflower e.g).
> Do you think we can fix them as well?
I think so. But those are with some sort of a timeout, so replacing them
would be slightly less obviously correct than these here. Later.
Michal
>> That's just mutex_lock with extra steps.
>> The pattern is a leftover from when iavf used bit flags instead of
>> mutexes for locking. Commit 5ac49f3c2702 ("iavf: use mutexes for locking
>> of critical sections") replaced test_and_set_bit with !mutex_trylock,
>> preserving the pattern.
>>
>> Simplify it to mutex_lock.
>>
>> Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
>> ---
>> drivers/net/ethernet/intel/iavf/iavf_main.c | 6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c
>> b/drivers/net/ethernet/intel/iavf/iavf_main.c
>> index 98ecf5d5a2f2..03156ca523fe 100644
>> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
>> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
>> @@ -3016,8 +3016,7 @@ static void iavf_reset_task(struct work_struct
>> *work)
>> return;
>> }
>>
>> - while (!mutex_trylock(&adapter->client_lock))
>> - usleep_range(500, 1000);
>> + mutex_lock(&adapter->client_lock);
>> if (CLIENT_ENABLED(adapter)) {
>> adapter->flags &= ~(IAVF_FLAG_CLIENT_NEEDS_OPEN |
>> IAVF_FLAG_CLIENT_NEEDS_CLOSE |
>> @@ -5069,8 +5068,7 @@ static int __maybe_unused iavf_suspend(struct
>> device *dev_d)
>>
>> netif_device_detach(netdev);
>>
>> - while (!mutex_trylock(&adapter->crit_lock))
>> - usleep_range(500, 1000);
>> + mutex_lock(&adapter->crit_lock);
>>
>> if (netif_running(netdev)) {
>> rtnl_lock();
>> --
>> 2.41.0
>>
>> _______________________________________________
>> Intel-wired-lan mailing list
>> Intel-wired-lan@osuosl.org
>> https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
>
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
next prev parent reply other threads:[~2023-10-10 11:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-10 0:24 [Intel-wired-lan] [PATCH net-next 0/5] iavf: cleanup, improvements in init and Michal Schmidt
2023-10-10 0:24 ` [Intel-wired-lan] [PATCH net-next 1/5] iavf: fix comments about old bit locks Michal Schmidt
2023-10-10 11:24 ` Drewek, Wojciech
2023-10-18 11:31 ` Romanowski, Rafal
2023-10-10 0:24 ` [Intel-wired-lan] [PATCH net-next 2/5] iavf: simplify mutex_trylock+sleep loops Michal Schmidt
2023-10-10 11:30 ` Drewek, Wojciech
2023-10-10 11:57 ` Michal Schmidt [this message]
2023-10-10 12:08 ` Drewek, Wojciech
2023-10-18 11:31 ` Romanowski, Rafal
2023-10-10 0:24 ` [Intel-wired-lan] [PATCH net-next 3/5] iavf: in iavf_down, don't queue watchdog_task if comms failed Michal Schmidt
2023-10-10 11:33 ` Drewek, Wojciech
2023-10-18 11:32 ` Romanowski, Rafal
2023-10-10 0:24 ` [Intel-wired-lan] [PATCH net-next 4/5] iavf: in iavf_down, disable queues when removing the driver Michal Schmidt
2023-10-10 11:39 ` Drewek, Wojciech
2023-10-10 12:22 ` Michal Schmidt
2023-10-10 13:56 ` Drewek, Wojciech
2023-10-18 11:32 ` Romanowski, Rafal
2023-10-10 0:24 ` [Intel-wired-lan] [PATCH net-next 5/5] iavf: fix the waiting time for initial reset Michal Schmidt
2023-10-10 11:42 ` Drewek, Wojciech
2023-10-18 11:33 ` Romanowski, Rafal
2023-10-10 11:38 ` [Intel-wired-lan] [PATCH net-next 0/5] iavf: cleanup, improvements in init and Przemek Kitszel
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=a65e79ff-7894-4095-b3bb-948b4cfa04e0@redhat.com \
--to=mschmidt@redhat.com \
--cc=anthony.l.nguyen@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jesse.brandeburg@intel.com \
--cc=radoslawx.tyl@intel.com \
--cc=wojciech.drewek@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox