Skip to contentSkip to conversation

KVM: Start lock documentation

PATCH Applied Jan Kiszka 3 participants 7 messages Feb 9, 2011 – Mar 6, 2011

Subsystems (2)
lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 KVM: Start lock documentation

The goal of this document shall be
- overview of all locks used in KVM core
- provide details on the scope of each lock
- explain the lock type, specifically of a raw spin locks
- provide a lock ordering guide

Start with one dependency chain and two locks.

---
 Documentation/kvm/locking.txt |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/kvm/locking.txt
Documentation/kvm/locking.txt new file +30 -0
new file mode 100644
index 0000000..23f9092
@@ -0,0 +1,30 @@
+KVM Lock Overview
+=================
+
+1. Acquisition Orders
+---------------------
+
+kvm_lock
++-> kvm::srcu / kvm::lock
+    +-> kvm::slots_lock
+        +-> kvm::mmu_lock
+...
+
+
+2. Reference
+------------
+
+Name:		kvm_lock
+Type:		raw_spinlock
+Arch:		any
+Protects:	- vm_list
+		- hardware virtualization enable/disable
+Comment:	'raw' because hardware enabling/disabling must be atomic /wrt
+		migration.
+
+Name:		kvm_arch::tsc_write_lock
+Type:		raw_spinlock
+Arch:		x86
+Protects:	- kvm_arch::{last_tsc_write,last_tsc_nsec,last_tsc_offset}
+		- tsc offset in vmcb
+Comment:	'raw' because updating the tsc offsets must not be preempted.
Signature · 1 line
1.7.1
author
#1 lore raw
Quoted 40 lines · Jan Kiszka

The goal of this document shall be
- overview of all locks used in KVM core
- provide details on the scope of each lock
- explain the lock type, specifically of a raw spin locks
- provide a lock ordering guide

Start with one dependency chain and two locks.

---
 Documentation/kvm/locking.txt |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/kvm/locking.txt
Documentation/kvm/locking.txt new file +20 -0
new file mode 100644
index 0000000..23f9092
@@ -0,0 +1,30 @@
+KVM Lock Overview
+=================
+
+1. Acquisition Orders
+---------------------
+
+kvm_lock
++-> kvm::srcu / kvm::lock
+    +-> kvm::slots_lock
+        +-> kvm::mmu_lock
+...
+
+
+2. Reference
+------------
+
+Name:		kvm_lock
+Type:		raw_spinlock
+Arch:		any
+Protects:	- vm_list

Documentation/kvm/locking.txt line 30

Quoted 10 lines
Documentation/kvm/locking.txt new file +10 -0
+		- hardware virtualization enable/disable
+Comment:	'raw' because hardware enabling/disabling must be atomic /wrt
+		migration.
+
+Name:		kvm_arch::tsc_write_lock
+Type:		raw_spinlock
+Arch:		x86
+Protects:	- kvm_arch::{last_tsc_write,last_tsc_nsec,last_tsc_offset}
+		- tsc offset in vmcb
+Comment:	'raw' because updating the tsc offsets must not be preempted.

Sorry, Zach, you should likely have a look at this as well.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#2 lore raw
In reply to Jan Kiszka
Quoted 21 lines · Jan Kiszka

The goal of this document shall be
- overview of all locks used in KVM core
- provide details on the scope of each lock
- explain the lock type, specifically of a raw spin locks
- provide a lock ordering guide

Start with one dependency chain and two locks.

---
 Documentation/kvm/locking.txt |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/kvm/locking.txt
Documentation/kvm/locking.txt new file +1 -0
new file mode 100644
index 0000000..23f9092
@@ -0,0 +1,30 @@
+KVM Lock Overview

Documentation/kvm/locking.txt line 11

Quoted 10 lines
Documentation/kvm/locking.txt new file +10 -0
+=================
+
+1. Acquisition Orders
+---------------------
+
+kvm_lock
++-> kvm::srcu / kvm::lock
+    +-> kvm::slots_lock
+        +-> kvm::mmu_lock
+...

Its not easy to understand what you mean here. What kvm_lock has to do with the ordering described below it?

Other than that, "Reference" section structure is fine... (yeah, Avi has been asking it for ages).

Quoted 24 lines
Documentation/kvm/locking.txt new file +18 -0
+
+2. Reference
+------------
+
+Name:		kvm_lock
+Type:		raw_spinlock
+Arch:		any
+Protects:	- vm_list
+		- hardware virtualization enable/disable
+Comment:	'raw' because hardware enabling/disabling must be atomic /wrt
+		migration.
+
+Name:		kvm_arch::tsc_write_lock
+Type:		raw_spinlock
+Arch:		x86
+Protects:	- kvm_arch::{last_tsc_write,last_tsc_nsec,last_tsc_offset}
+		- tsc offset in vmcb
+Comment:	'raw' because updating the tsc offsets must not be preempted.
Signature · 5 lines
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
Quoted 26 lines · Marcelo Tosatti
Quoted 25 lines · Jan Kiszka

The goal of this document shall be
- overview of all locks used in KVM core
- provide details on the scope of each lock
- explain the lock type, specifically of a raw spin locks
- provide a lock ordering guide

Start with one dependency chain and two locks.

---
  Documentation/kvm/locking.txt |   30 ++++++++++++++++++++++++++++++
  1 files changed, 30 insertions(+), 0 deletions(-)

create mode 100644 Documentation/kvm/locking.txt

Documentation/kvm/locking.txt new file +5 -0
new file mode 100644
index 0000000..23f9092
@@ -0,0 +1,30 @@
+KVM Lock Overview
+=================
+
+1. Acquisition Orders
+---------------------
Quoted 9 lines

Documentation/kvm/locking.txt line 11

Quoted 6 lines
Documentation/kvm/locking.txt new file +6 -0
+
+kvm_lock
++->  kvm::srcu / kvm::lock
+    +->  kvm::slots_lock
+        +->  kvm::mmu_lock
+...

Its not easy to understand what you mean here. What kvm_lock has to do with the ordering described below it?

Yeah, I meant to make the same comment but forgot. I suggest a union of paths:

kvm::srcu (read) -> { fields }
| kvm::slots_lock(write) -> { fields }

but let's start with the reference section.

author
#4 lore raw
In reply to Marcelo Tosatti
Quoted 27 lines · Marcelo Tosatti
Quoted 26 lines · Jan Kiszka

The goal of this document shall be
- overview of all locks used in KVM core
- provide details on the scope of each lock
- explain the lock type, specifically of a raw spin locks
- provide a lock ordering guide

Start with one dependency chain and two locks.

---
 Documentation/kvm/locking.txt |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/kvm/locking.txt
Documentation/kvm/locking.txt new file +6 -0
new file mode 100644
index 0000000..23f9092
@@ -0,0 +1,30 @@
+KVM Lock Overview
+=================
+
+1. Acquisition Orders
+---------------------
+
Quoted 8 lines

Documentation/kvm/locking.txt line 11

Quoted 5 lines
Documentation/kvm/locking.txt new file +5 -0
+kvm_lock
++-> kvm::srcu / kvm::lock
+    +-> kvm::slots_lock
+        +-> kvm::mmu_lock
+...

Its not easy to understand what you mean here. What kvm_lock has to do with the ordering described below it?

kvm_lock is the head of this chain, i.e. there are code paths where it is taken first, then kvm::lock, etc.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#5 lore raw
Quoted 34 lines · Jan Kiszka
Quoted 33 lines · Marcelo Tosatti
Quoted 31 lines · Jan Kiszka

The goal of this document shall be
- overview of all locks used in KVM core
- provide details on the scope of each lock
- explain the lock type, specifically of a raw spin locks
- provide a lock ordering guide

Start with one dependency chain and two locks.

---

  Documentation/kvm/locking.txt |   30 ++++++++++++++++++++++++++++++
  1 files changed, 30 insertions(+), 0 deletions(-)

create mode 100644 Documentation/kvm/locking.txt

diff --git a/Documentation/kvm/locking.txt b/Documentation/kvm/locking.txt new file mode 100644
index 0000000..23f9092
--- /dev/null
+++ b/Documentation/kvm/locking.txt
@@ -0,0 +1,30 @@
+KVM Lock Overview
+=================
+
+1. Acquisition Orders
+---------------------
+
+kvm_lock
++-> kvm::srcu / kvm::lock
+ +-> kvm::slots_lock
+ +-> kvm::mmu_lock
+...

Quoted 6 lines
Quoted 2 lines

Its not easy to understand what you mean here. What kvm_lock has to do with the ordering described below it?

kvm_lock is the head of this chain, i.e. there are code paths where it is taken first, then kvm::lock, etc.

Right, but it is not mandatory for most fields protected by the lock.

So we have
- which locks _may_ nest, and how
- which locks _must_ nest, and how, to access a particular field (may
depend on type of access for rcu)

Signature · 1 line
error compiling committee.c: too many arguments to function
Applied
#6 lore raw
In reply to Jan Kiszka
Quoted 8 lines · Jan Kiszka

The goal of this document shall be
- overview of all locks used in KVM core
- provide details on the scope of each lock
- explain the lock type, specifically of a raw spin locks
- provide a lock ordering guide

Start with one dependency chain and two locks.

Applied, with the dependency chain omitted, thanks.

Future patches which affect locking will be required to update this document.

Signature · 1 line
error compiling committee.c: too many arguments to function