[PATCH v8 07/20] job.h: add _locked public functions

Emanuele Giuseppe Esposito posted 20 patches 3 years, 7 months ago
Maintainers: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, John Snow <jsnow@redhat.com>, Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>, Wen Congyang <wencongyang2@huawei.com>, Xie Changlong <xiechanglong.d@gmail.com>, Markus Armbruster <armbru@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Fam Zheng <fam@euphon.net>
There is a newer version of this series
[PATCH v8 07/20] job.h: add _locked public functions
Posted by Emanuele Giuseppe Esposito 3 years, 7 months ago
These functions will be used later when we use the job lock.

Note: at this stage, job_{lock/unlock} and job lock guard macros
are *nop*.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
 include/qemu/job.h | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/include/qemu/job.h b/include/qemu/job.h
index b714236c1a..e887f88cb2 100644
--- a/include/qemu/job.h
+++ b/include/qemu/job.h
@@ -505,7 +505,10 @@ const char *job_type_str(const Job *job);
 /** Returns true if the job should not be visible to the management layer. */
 bool job_is_internal(Job *job);
 
-/** Returns whether the job is being cancelled. */
+/**
+ * Returns whether the job is being cancelled.
+ * Called with job_mutex *not* held.
+ */
 bool job_is_cancelled(Job *job);
 
 /* Same as job_is_cancelled(), but called with job lock held. */
@@ -518,13 +521,19 @@ bool job_is_cancelled_locked(Job *job);
  */
 bool job_cancel_requested(Job *job);
 
-/** Returns whether the job is in a completed state. */
+/**
+ * Returns whether the job is in a completed state.
+ * Called with job_mutex *not* held.
+ */
 bool job_is_completed(Job *job);
 
 /* Same as job_is_completed(), but called with job lock held. */
 bool job_is_completed_locked(Job *job);
 
-/** Returns whether the job is ready to be completed. */
+/**
+ * Returns whether the job is ready to be completed.
+ * Called with job_mutex *not* held.
+ */
 bool job_is_ready(Job *job);
 
 /* Same as job_is_ready(), but called with job lock held. */
-- 
2.31.1
Re: [PATCH v8 07/20] job.h: add _locked public functions
Posted by Vladimir Sementsov-Ogievskiy 3 years, 7 months ago
First, to subject: no function is added in this commit

Second, to my comment on previous patch: so, you decided to add "not held" comment to all functions, even that have public _locked() counterpart.
Not sure we really need it, but it's OK. Anyway, let's just add all these comments together with the functions themselves in patch 05.


On 6/29/22 17:15, Emanuele Giuseppe Esposito wrote:
> These functions will be used later when we use the job lock.
> 
> Note: at this stage, job_{lock/unlock} and job lock guard macros
> are *nop*.
> 
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> ---
>   include/qemu/job.h | 15 ++++++++++++---
>   1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/include/qemu/job.h b/include/qemu/job.h
> index b714236c1a..e887f88cb2 100644
> --- a/include/qemu/job.h
> +++ b/include/qemu/job.h
> @@ -505,7 +505,10 @@ const char *job_type_str(const Job *job);
>   /** Returns true if the job should not be visible to the management layer. */
>   bool job_is_internal(Job *job);
>   
> -/** Returns whether the job is being cancelled. */
> +/**
> + * Returns whether the job is being cancelled.
> + * Called with job_mutex *not* held.
> + */
>   bool job_is_cancelled(Job *job);
>   
>   /* Same as job_is_cancelled(), but called with job lock held. */
> @@ -518,13 +521,19 @@ bool job_is_cancelled_locked(Job *job);
>    */
>   bool job_cancel_requested(Job *job);
>   
> -/** Returns whether the job is in a completed state. */
> +/**
> + * Returns whether the job is in a completed state.
> + * Called with job_mutex *not* held.
> + */
>   bool job_is_completed(Job *job);
>   
>   /* Same as job_is_completed(), but called with job lock held. */
>   bool job_is_completed_locked(Job *job);
>   
> -/** Returns whether the job is ready to be completed. */
> +/**
> + * Returns whether the job is ready to be completed.
> + * Called with job_mutex *not* held.
> + */
>   bool job_is_ready(Job *job);
>   
>   /* Same as job_is_ready(), but called with job lock held. */


-- 
Best regards,
Vladimir
Re: [PATCH v8 07/20] job.h: add _locked public functions
Posted by Stefan Hajnoczi 3 years, 7 months ago
On Wed, Jun 29, 2022 at 10:15:25AM -0400, Emanuele Giuseppe Esposito wrote:
> These functions will be used later when we use the job lock.
> 
> Note: at this stage, job_{lock/unlock} and job lock guard macros
> are *nop*.
> 
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> ---
>  include/qemu/job.h | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>