From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Daney Subject: Q: What is the struct kvm srcu protecting? Date: Thu, 02 May 2013 11:22:52 -0700 Message-ID: <5182AEFC.9070703@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit To: kvm@vger.kernel.org Return-path: Received: from mail-pd0-f176.google.com ([209.85.192.176]:47438 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760261Ab3EBSWz (ORCPT ); Thu, 2 May 2013 14:22:55 -0400 Received: by mail-pd0-f176.google.com with SMTP id x10so492550pdj.7 for ; Thu, 02 May 2013 11:22:55 -0700 (PDT) Received: from dl.caveonetworks.com (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPSA id ts3sm8249001pbc.12.2013.05.02.11.22.53 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 02 May 2013 11:22:54 -0700 (PDT) Sender: kvm-owner@vger.kernel.org List-ID: Hi, I am working on the MIPS KVM port, and am trying to figure out under which circumstances do I need to srcu_read_lock()/srcu_read_unlock() the kvm->srcu. I am looking at implementing something similar to arch/x86/kvm/x86.c at __msr_io(), where we see: . . . idx = srcu_read_lock(&vcpu->kvm->srcu); for (i = 0; i < msrs->nmsrs; ++i) if (do_msr(vcpu, entries[i].index, &entries[i].data)) break; srcu_read_unlock(&vcpu->kvm->srcu, idx); . . . Why is the srcu_read_lock() taken here? I see no srcu_dereference() in the code path that would indicate the need for obtaining the lock. I have a feeling that I am missing some essential concept about the design of this code, but I don't know what it is. Can someone explain what is happening here? Thanks in advance, David Daney