Re: [PATCH 2/5] KVM: Implement CR read caching for KVM paravirt_ops

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

 



Anthony Liguori wrote:
+/*
+ * Control register reads can be trapped.  Since trapping is relatively
+ * expensive, we can avoid paying the cost by caching logically.
+ */
+static unsigned long kvm_read_cr(int reg)
+{
+	struct kvm_paravirt_state *state
+		= per_cpu(paravirt_state, smp_processor_id());
+
+	if (unlikely(!state->cr_valid[reg])) {
+		if (reg == 0)
+			state->cached_cr[reg] = native_read_cr0();
+		else if (reg == 3)
+			state->cached_cr[reg] = native_read_cr3();
+		else if (reg == 4)
+			state->cached_cr[reg] = native_read_cr4();
+		else
+			BUG();
+		state->cr_valid[reg] = 1;
+	}
+	return state->cached_cr[reg];
+}
+

It would be good to declare this (and kvm_write_cr) always_inline. These functions are never called with a non-constant reg parameters, and the unsightly if tree (more readable as a switch, IMO) will fold nicely when inlined.


--
error compiling committee.c: too many arguments to function

_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/virtualization

[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux