qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC] support memory reserved feature and optimize mlock gu


From: Zhanghailiang
Subject: [Qemu-devel] [RFC] support memory reserved feature and optimize mlock guest memory propose
Date: Wed, 5 Mar 2014 08:01:42 +0000

Hi all

Currently, we use cgroup(memory) to support memory QoS on KVM platform, and use "mlock" on qemu to support "memory reserved".

The "mlock" seems to be not appropriate.

Now qemu "mlock" memory in the main thread, which would lock iothread (qemu_mutex_lock_iothread), if the memory size is large, that will consume lots of time.

It means whenever we want to set a new 'mlock', the VM would be blocked for a while.

Here is my optimization:

  1. Add a global variable (lock_ram_size) to save the value of "memory reserved";

  2. Add a qmp commond "set_ram_minguarantee" to change lock_ram_size;

  3. Create a new thread to mlock(lock_ram_zie), while is waked up by the "set_ram_minguarantee" qmp command.

Flow chart:

           main funciton           qmp command "set_ram_minguarantee"

                 |                           |

                 |                           |

        create "mlock" thread           change value of lock_ram_size

                 |                           |

                 |                           |

    |------>thread wait<-------------wake up "mlock" thread

    |            |

    |            |

    |            |

    |-------mlock(lock_ram_zie)

 

We have tested this demo a few days, it seems to be worked well.

But we are not sure is there any other problems , if the main thread and mlock thread access one memory zone at one time without a mutex lock.

Is it workable?Or Is there any other idea to support "memory reserved" ?

 

Thanks

zhanghailiang


reply via email to

[Prev in Thread] Current Thread [Next in Thread]