[PATCH v2 0/3] qemu-sem-posix: use monotonic clock instead

Longpeng(Mike) via posted 3 patches 2 years, 2 months ago
Test checkpatch failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220222090507.2028-1-longpeng2@huawei.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>
include/qemu/thread-posix.h |   9 +--
meson.build                 |  12 ++-
util/qemu-thread-posix.c    | 178 +++++++++++++++-----------------------------
3 files changed, 73 insertions(+), 126 deletions(-)
[PATCH v2 0/3] qemu-sem-posix: use monotonic clock instead
Posted by Longpeng(Mike) via 2 years, 2 months ago
The qemu_sem_timedwait() uses system time as default, it would be affected by
changes to the system time. In the real scenario, the time that goes faster or
slower is a common case and the NTP service could help us to sync time
periodically.

This patchset uses monotonic clock instead of the realtime clock, this could
make sure we would not be affected by the system time anymore.

Changes v1(RFC) -> v2:
 Patch 2:
  - clean the code [Paolo]
  - use pthread_condattr_setclock when initializing qemu-cond. [Paolo]
 Patch 3:
  - new added, make the qemu-sem code neater. [Longpeng]

Longpeng (Mike) (3):
  sem-posix: remove the posix semaphore support
  sem-posix: use monotonic clock instead
  sem-posix: refactor qemu-sem with qemu-cond and qemu-mutex

 include/qemu/thread-posix.h |   9 +--
 meson.build                 |  12 ++-
 util/qemu-thread-posix.c    | 178 +++++++++++++++-----------------------------
 3 files changed, 73 insertions(+), 126 deletions(-)

-- 
1.8.3.1


Re: [PATCH v2 0/3] qemu-sem-posix: use monotonic clock instead
Posted by Paolo Bonzini 2 years, 2 months ago
On 2/22/22 10:05, Longpeng(Mike) via wrote:
> The qemu_sem_timedwait() uses system time as default, it would be affected by
> changes to the system time. In the real scenario, the time that goes faster or
> slower is a common case and the NTP service could help us to sync time
> periodically.
> 
> This patchset uses monotonic clock instead of the realtime clock, this could
> make sure we would not be affected by the system time anymore.
> 
> Changes v1(RFC) -> v2:
>   Patch 2:
>    - clean the code [Paolo]
>    - use pthread_condattr_setclock when initializing qemu-cond. [Paolo]
>   Patch 3:
>    - new added, make the qemu-sem code neater. [Longpeng]
> 
> Longpeng (Mike) (3):
>    sem-posix: remove the posix semaphore support
>    sem-posix: use monotonic clock instead
>    sem-posix: refactor qemu-sem with qemu-cond and qemu-mutex
> 
>   include/qemu/thread-posix.h |   9 +--
>   meson.build                 |  12 ++-
>   util/qemu-thread-posix.c    | 178 +++++++++++++++-----------------------------
>   3 files changed, 73 insertions(+), 126 deletions(-)
> 

Queued, thanks!  I also sent a small optimization patch on top.

Paolo