[PATCH v2 0/4] vhost: Cleanup

Gavin Shan posted 4 patches 1 year, 7 months ago
drivers/vhost/vhost.c | 215 +++++++++++++++++++-----------------------
1 file changed, 97 insertions(+), 118 deletions(-)
[PATCH v2 0/4] vhost: Cleanup
Posted by Gavin Shan 1 year, 7 months ago
This is suggested by Michael S. Tsirkin according to [1] and the goal
is to apply smp_rmb() inside vhost_get_avail_idx() if needed. With it,
the caller of the function needn't to worry about memory barriers. Since
we're here, other cleanups are also applied.

[1] https://lore.kernel.org/virtualization/20240327155750-mutt-send-email-mst@kernel.org/

PATCH[1] improves vhost_get_avail_idx() so that smp_rmb() is applied if
         needed. Besides, the sanity checks on the retrieved available
         queue index are also squeezed to vhost_get_avail_idx()
PATCH[2] drops the local variable @last_avail_idx since it's equivalent
         to vq->last_avail_idx
PATCH[3] improves vhost_get_avail_head(), similar to what we're doing
         for vhost_get_avail_idx(), so that the relevant sanity checks
         on the head are squeezed to vhost_get_avail_head()
PATCH[4] Reformat vhost_{get, put}_user() by using tab instead of space
         as the terminator for each line

Gavin Shan (3):
  vhost: Drop variable last_avail_idx in vhost_get_vq_desc()
  vhost: Improve vhost_get_avail_head()
  vhost: Reformat vhost_{get, put}_user()

Michael S. Tsirkin (1):
  vhost: Improve vhost_get_avail_idx() with smp_rmb()

 drivers/vhost/vhost.c | 215 +++++++++++++++++++-----------------------
 1 file changed, 97 insertions(+), 118 deletions(-)

Changelog
=========
v2:
  * Improve vhost_get_avail_idx() as Michael suggested in [1]
    as above                                                     (Michael)
  * Correct @head's type from 'unsigned int' to 'int'            (ltp@intel.com)

-- 
2.44.0
Re: [PATCH v2 0/4] vhost: Cleanup
Posted by Michael S. Tsirkin 1 year, 7 months ago
On Mon, Apr 29, 2024 at 08:13:56PM +1000, Gavin Shan wrote:
> This is suggested by Michael S. Tsirkin according to [1] and the goal
> is to apply smp_rmb() inside vhost_get_avail_idx() if needed. With it,
> the caller of the function needn't to worry about memory barriers. Since
> we're here, other cleanups are also applied.
> 
> [1] https://lore.kernel.org/virtualization/20240327155750-mutt-send-email-mst@kernel.org/


Patch 1 makes some sense, gave some comments. Rest I think we should
just drop.

> PATCH[1] improves vhost_get_avail_idx() so that smp_rmb() is applied if
>          needed. Besides, the sanity checks on the retrieved available
>          queue index are also squeezed to vhost_get_avail_idx()
> PATCH[2] drops the local variable @last_avail_idx since it's equivalent
>          to vq->last_avail_idx
> PATCH[3] improves vhost_get_avail_head(), similar to what we're doing
>          for vhost_get_avail_idx(), so that the relevant sanity checks
>          on the head are squeezed to vhost_get_avail_head()
> PATCH[4] Reformat vhost_{get, put}_user() by using tab instead of space
>          as the terminator for each line
> 
> Gavin Shan (3):
>   vhost: Drop variable last_avail_idx in vhost_get_vq_desc()
>   vhost: Improve vhost_get_avail_head()
>   vhost: Reformat vhost_{get, put}_user()
> 
> Michael S. Tsirkin (1):
>   vhost: Improve vhost_get_avail_idx() with smp_rmb()
> 
>  drivers/vhost/vhost.c | 215 +++++++++++++++++++-----------------------
>  1 file changed, 97 insertions(+), 118 deletions(-)
> 
> Changelog
> =========
> v2:
>   * Improve vhost_get_avail_idx() as Michael suggested in [1]
>     as above                                                     (Michael)
>   * Correct @head's type from 'unsigned int' to 'int'            (ltp@intel.com)
> 
> -- 
> 2.44.0
Re: [PATCH v2 0/4] vhost: Cleanup
Posted by Gavin Shan 1 year, 7 months ago
On 4/30/24 04:50, Michael S. Tsirkin wrote:
> On Mon, Apr 29, 2024 at 08:13:56PM +1000, Gavin Shan wrote:
>> This is suggested by Michael S. Tsirkin according to [1] and the goal
>> is to apply smp_rmb() inside vhost_get_avail_idx() if needed. With it,
>> the caller of the function needn't to worry about memory barriers. Since
>> we're here, other cleanups are also applied.
>>
>> [1] https://lore.kernel.org/virtualization/20240327155750-mutt-send-email-mst@kernel.org/
> 
> 
> Patch 1 makes some sense, gave some comments. Rest I think we should
> just drop.
> 

Sure, v3 has been sent with PATCH[v2 2/3/4] dropped. Please take a look
when you getting a chance.

v3: https://lore.kernel.org/virtualization/20240429232748.642356-1-gshan@redhat.com/T/#u

Thanks,
Gavin