Skip to contentSkip to conversation

Relevance of global lock (/var/lock/xl) in xl tool

Xen-devel Michał Leszczyński 4 participants 6 messages Jun 7, 2019 – Jun 11, 2019

lore
Share & tools
lore
#0 lore raw

Hello,

when either "xl restore" or "xl create" command is invoked, a global lock is acquired here:

https://github.com/xen-project/xen/blob/master/tools/xl/xl_vmcontrol.c#L876

I'm trying to figure out what is the exact importance of this lock? Is it really critical for XL operation? I have a pretty powerful machine on which I want to run a few dozen of short-lived VMs. This lock is seriously slowing me down, not letting to restore more than one domain at once. Turns out that everything still works fine (and much faster) when I comment-out the lock in the abovementioned place, but I'm not sure if it's a correct impression.

Does anyone know if there is a situation in which Xen would screw up without this lock?

Best regards,
Michał Leszczyński

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#1 lore raw
Quoted 1 line · Michał Leszczyński

Hello,

Hi,

Quoted 7 lines

when either "xl restore" or "xl create" command is invoked, a global lock is acquired here:

https://github.com/xen-project/xen/blob/master/tools/xl/xl_vmcontrol.c#L876

I'm trying to figure out what is the exact importance of this lock? Is it really critical for XL operation? I have a pretty powerful machine on which I want to run a few dozen of short-lived VMs. This lock is seriously slowing me down, not letting to restore more than one domain at once. Turns out that everything still works fine (and much faster) when I comment-out the lock in the abovementioned place, but I'm not sure if it's a correct impression.

Does anyone know if there is a situation in which Xen would screw up without this lock?

Here is the reason for the lock:
https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=ea4dce89d478d62341cd2f9d8944e215f7086144

xl: free memory before building a domain
Free the needed amount of memory before proceeding with the domain build.
Use a filelock to prevent other xl instances from conflicting during this operation.

So there are probably configurations where the lock isn't useful, or there are better ways to reserve memory for domain creation.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw

Hello,

I've tested the scenario with restoring too many domains having lock commented out. It turns out that in case when there is no memory left for XEN to allocate, all pending /xl restore/ commands will simply fail with an internal error.

As far as I understand, it's not going to do any damage unless I request too much memory?

If so, then there is some place for improvement, i.e. to make xl acquire the lock, allocate memory, release the lock and then start restoring the domain state. Maybe I could provide some pull request if I would manage to implement such behavior.

Best regards,
Michał Leszczyński

Quoted 23 lines · Anthony PERARD
Quoted 1 line · Michał Leszczyński

Hello,

Hi,

Quoted 7 lines

when either "xl restore" or "xl create" command is invoked, a global lock is acquired here:

https://github.com/xen-project/xen/blob/master/tools/xl/xl_vmcontrol.c#L876

I'm trying to figure out what is the exact importance of this lock? Is it really critical for XL operation? I have a pretty powerful machine on which I want to run a few dozen of short-lived VMs. This lock is seriously slowing me down, not letting to restore more than one domain at once. Turns out that everything still works fine (and much faster) when I comment-out the lock in the abovementioned place, but I'm not sure if it's a correct impression.

Does anyone know if there is a situation in which Xen would screw up without this lock?

Here is the reason for the lock:
https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=ea4dce89d478d62341cd2f9d8944e215f7086144

xl: free memory before building a domain
Free the needed amount of memory before proceeding with the domain build.
Use a filelock to prevent other xl instances from conflicting during this operation.

So there are probably configurations where the lock isn't useful, or there are better ways to reserve memory for domain creation.

Signature · 4 lines
Pozdrawiam
Michał Leszczyński
CERT Polska/NASK
+48 532 461 124

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw

I'd like to point out that a patch for getting ride of the lock was provided by Dmitry Isaykin on March but unfortunately seems that nobody noticed.

https://lists.xenproject.org/archives/html/xen-devel/2019-03/msg00567.html

Quoted 54 lines · Michał Leszczyński

Hello,

I've tested the scenario with restoring too many domains having lock commented out. It turns out that in case when there is no memory left for XEN to allocate, all pending *xl restore* commands will simply fail with an internal error.

As far as I understand, it's not going to do any damage unless I request too much memory?

If so, then there is some place for improvement, i.e. to make xl acquire the lock, allocate memory, release the lock and then start restoring the domain state. Maybe I could provide some pull request if I would manage to implement such behavior.

Best regards,
Michał Leszczyński

On 10.06.2019 11:41, Anthony PERARD wrote:

On Fri, Jun 07, 2019 at 02:06:30PM +0200, Michał Leszczyński wrote:

Hello,

Hi,

when either "xl restore" or "xl create" command is invoked, a global lock is acquired here:
https://github.com/xen-project/xen/blob/master/tools/xl/xl_vmcontrol.c#L876

I'm trying to figure out what is the exact importance of this lock? Is it really critical for XL operation? I have a pretty powerful machine on which I want to run a few dozen of short-lived VMs. This lock is seriously slowing me down, not letting to restore more than one domain at once. Turns out that everything still works fine (and much faster) when I comment-out the lock in the abovementioned place, but I'm not sure if it's a correct impression.

Does anyone know if there is a situation in which Xen would screw up without this lock?

Here is the reason for the lock:https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=ea4dce89d478d62341cd2f9d8944e215f7086144

xl: free memory before building a domain
Free the needed amount of memory before proceeding with the domain build.
Use a filelock to prevent other xl instances from conflicting during this operation.

So there are probably configurations where the lock isn't useful, or there are better ways to reserve memory for domain creation.

--
Pozdrawiam
Michał Leszczyński
CERT Polska/NASK
+48 532 461 124

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw

Please try to avoid top posting, it breaks the flow of the conversation.

+ Ian and Wei.

Quoted 5 lines · Fanny Dwargee

I'd like to point out that a patch for getting ride of the lock was provided by Dmitry Isaykin on March but unfortunately seems that nobody noticed.

https://lists.xenproject.org/archives/html/xen-devel/2019-03/msg00567.html

That seems like a sensible patch, iff indeed the lock is only needed for autoballooning memory.

Ian, Wei, do you think this is a sensible approach? Are there other parts of xl/libxl that rely on the lock?

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
In reply to Michał Leszczyński

Please try to avoid top posting, it breaks the flow of the conversation.

+ Ian and Wei (tools maintainers)

Quoted 9 lines · Michał Leszczyński

Hello,

I've tested the scenario with restoring too many domains having lock commented out. It turns out that in case when there is no memory left for XEN to allocate, all pending /xl restore/ commands will simply fail with an internal error.

As far as I understand, it's not going to do any damage unless I request too much memory?

Iff the lock is solely used to automatically adjust the memory balloon for dom0 in order to allocate memory to use for other domains then as long as you don't have autoballoon enabled it should be fine.

Failures during domain creation are always harmless, the only damage is the domain not being actually created.

Quoted 4 lines

If so, then there is some place for improvement, i.e. to make xl acquire the lock, allocate memory, release the lock and then start restoring the domain state. Maybe I could provide some pull request if I would manage to implement such behavior.

FWIW, there's a 'claim' hypercall which is already implemented and used by libxl that should reserve memory for a domain beforehand.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel