[libvirt] [PATCH python] Release the GIL during virDomainGetMemoryStats

Nir Soffer posted 1 patch 6 years, 7 months ago
Failed in applying to current master (apply log)
libvirt-override.c | 3 +++
1 file changed, 3 insertions(+)
[libvirt] [PATCH python] Release the GIL during virDomainGetMemoryStats
Posted by Nir Soffer 6 years, 7 months ago
We discovered that the entire python process get stuck for about 30
seconds when calling virDomain.getMemoryStats() if libvirt is stuck in
virConnect.getAllDomainStats() on inaccessible storage. This blocking
cause a horrible mess in oVirt.

This patches adds the standard *_ALLOW_THREADS around the call to avoid
this unwanted blocking.

Signed-off-by: Nir Soffer <nirsof@gmail.com>
---
 libvirt-override.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libvirt-override.c b/libvirt-override.c
index 9eba4ed..0e33afb 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -363,8 +363,11 @@ libvirt_virDomainMemoryStats(PyObject *self ATTRIBUTE_UNUSED,
         return NULL;
     domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
 
+    LIBVIRT_BEGIN_ALLOW_THREADS;
     nr_stats = virDomainMemoryStats(domain, stats,
                                     VIR_DOMAIN_MEMORY_STAT_NR, 0);
+    LIBVIRT_END_ALLOW_THREADS;
+
     if (nr_stats == -1)
         return VIR_PY_NONE;
 
-- 
2.9.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python] Release the GIL during virDomainGetMemoryStats
Posted by Daniel P. Berrange 6 years, 7 months ago
On Tue, Sep 26, 2017 at 08:05:59PM +0300, Nir Soffer wrote:
> We discovered that the entire python process get stuck for about 30
> seconds when calling virDomain.getMemoryStats() if libvirt is stuck in
> virConnect.getAllDomainStats() on inaccessible storage. This blocking
> cause a horrible mess in oVirt.
> 
> This patches adds the standard *_ALLOW_THREADS around the call to avoid
> this unwanted blocking.
> 
> Signed-off-by: Nir Soffer <nirsof@gmail.com>
> ---
>  libvirt-override.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libvirt-override.c b/libvirt-override.c
> index 9eba4ed..0e33afb 100644
> --- a/libvirt-override.c
> +++ b/libvirt-override.c
> @@ -363,8 +363,11 @@ libvirt_virDomainMemoryStats(PyObject *self ATTRIBUTE_UNUSED,
>          return NULL;
>      domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
>  
> +    LIBVIRT_BEGIN_ALLOW_THREADS;
>      nr_stats = virDomainMemoryStats(domain, stats,
>                                      VIR_DOMAIN_MEMORY_STAT_NR, 0);
> +    LIBVIRT_END_ALLOW_THREADS;
> +
>      if (nr_stats == -1)
>          return VIR_PY_NONE;

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>

I'll squash in the same fix for virDomainGetDiskErrors too

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python] Release the GIL during virDomainGetMemoryStats
Posted by Nir Soffer 6 years, 7 months ago
On Wed, Sep 27, 2017 at 6:05 PM Daniel P. Berrange <berrange@redhat.com>
wrote:

> On Tue, Sep 26, 2017 at 08:05:59PM +0300, Nir Soffer wrote:
> > We discovered that the entire python process get stuck for about 30
> > seconds when calling virDomain.getMemoryStats() if libvirt is stuck in
> > virConnect.getAllDomainStats() on inaccessible storage. This blocking
> > cause a horrible mess in oVirt.
> >
> > This patches adds the standard *_ALLOW_THREADS around the call to avoid
> > this unwanted blocking.
> >
> > Signed-off-by: Nir Soffer <nirsof@gmail.com>
> > ---
> >  libvirt-override.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/libvirt-override.c b/libvirt-override.c
> > index 9eba4ed..0e33afb 100644
> > --- a/libvirt-override.c
> > +++ b/libvirt-override.c
> > @@ -363,8 +363,11 @@ libvirt_virDomainMemoryStats(PyObject *self
> ATTRIBUTE_UNUSED,
> >          return NULL;
> >      domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
> >
> > +    LIBVIRT_BEGIN_ALLOW_THREADS;
> >      nr_stats = virDomainMemoryStats(domain, stats,
> >                                      VIR_DOMAIN_MEMORY_STAT_NR, 0);
> > +    LIBVIRT_END_ALLOW_THREADS;
> > +
> >      if (nr_stats == -1)
> >          return VIR_PY_NONE;
>
> Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
>
> I'll squash in the same fix for virDomainGetDiskErrors too
>

Cool, thanks!


>
> Regards,
> Daniel
> --
> |: https://berrange.com      -o-
> https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-
> https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-
> https://www.instagram.com/dberrange :|
>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list