Skip to content
Snippets Groups Projects
  • Mike Day's avatar
    0dc3f44a
    Convert ram_list to RCU · 0dc3f44a
    Mike Day authored
    
    Allow "unlocked" reads of the ram_list by using an RCU-enabled QLIST.
    
    The ramlist mutex is kept.  call_rcu callbacks are run with the iothread
    lock taken, but that may change in the future.  Writers still take the
    ramlist mutex, but they no longer need to assume that the iothread lock
    is taken.
    
    Readers of the list, instead, no longer require either the iothread
    or ramlist mutex, but they need to use rcu_read_lock() and
    rcu_read_unlock().
    
    One place in arch_init.c was downgrading from write side to read side
    like this:
    
        qemu_mutex_lock_iothread()
        qemu_mutex_lock_ramlist()
        ...
        qemu_mutex_unlock_iothread()
        ...
        qemu_mutex_unlock_ramlist()
    
    and the equivalent idiom is:
    
        qemu_mutex_lock_ramlist()
        rcu_read_lock()
        ...
        qemu_mutex_unlock_ramlist()
        ...
        rcu_read_unlock()
    
    Reviewed-by: default avatarFam Zheng <famz@redhat.com>
    Signed-off-by: default avatarMike Day <ncmike@ncultra.org>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    0dc3f44a
    History
    Convert ram_list to RCU
    Mike Day authored
    
    Allow "unlocked" reads of the ram_list by using an RCU-enabled QLIST.
    
    The ramlist mutex is kept.  call_rcu callbacks are run with the iothread
    lock taken, but that may change in the future.  Writers still take the
    ramlist mutex, but they no longer need to assume that the iothread lock
    is taken.
    
    Readers of the list, instead, no longer require either the iothread
    or ramlist mutex, but they need to use rcu_read_lock() and
    rcu_read_unlock().
    
    One place in arch_init.c was downgrading from write side to read side
    like this:
    
        qemu_mutex_lock_iothread()
        qemu_mutex_lock_ramlist()
        ...
        qemu_mutex_unlock_iothread()
        ...
        qemu_mutex_unlock_ramlist()
    
    and the equivalent idiom is:
    
        qemu_mutex_lock_ramlist()
        rcu_read_lock()
        ...
        qemu_mutex_unlock_ramlist()
        ...
        rcu_read_unlock()
    
    Reviewed-by: default avatarFam Zheng <famz@redhat.com>
    Signed-off-by: default avatarMike Day <ncmike@ncultra.org>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>