[RFC PATCH V2] kvm: x86: reduce rtc 0x70 access vm-exit time

2017-08-13 Thread Peng Hao
some versions of windows guest access rtc frequently because of
rtc as system tick.guest access rtc like this: write register index
to 0x70, then write or read data from 0x71. writing 0x70 port is
just as index and do nothing else. So we can use coalesced mmio to
handle this scene to reduce VM-EXIT time.
without my patch, get the vm-exit time of accessing rtc 0x70 using
perf tools: (guest OS : windows 7 64bit)
IO Port Access  Samples Samples%  Time%  Min Time  Max Time  Avg time
0x70:POUT86 30.99%74.59%   9us  29us10.75us (+- 3.41%)

with my patch
IO Port Access  Samples Samples%  Time%   Min Time  Max Time   Avg time
 0x70:POUT   10632.02%29.47%0us  10us 1.57us (+- 7.38%)

the patch is a part of optimizing rtc 0x70 port access. Another is in
qemu.

Signed-off-by: Peng Hao 
---
 Documentation/virtual/kvm/00-INDEX  |  2 ++
 Documentation/virtual/kvm/coalesced-pio.txt | 36 +
 include/uapi/linux/kvm.h|  5 ++--
 virt/kvm/coalesced_mmio.c   | 16 ++---
 virt/kvm/kvm_main.c |  2 ++
 5 files changed, 56 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/virtual/kvm/coalesced-pio.txt

diff --git a/Documentation/virtual/kvm/00-INDEX 
b/Documentation/virtual/kvm/00-INDEX
index 69fe1a8..3e4a49b 100644
--- a/Documentation/virtual/kvm/00-INDEX
+++ b/Documentation/virtual/kvm/00-INDEX
@@ -4,6 +4,8 @@ api.txt
- KVM userspace API.
 cpuid.txt
- KVM-specific cpuid leaves (x86).
+coalesced-pio.txt
+   - KVM_CAP_COALESCED_PIO
 devices/
- KVM_CAP_DEVICE_CTRL userspace API.
 halt-polling.txt
diff --git a/Documentation/virtual/kvm/coalesced-pio.txt 
b/Documentation/virtual/kvm/coalesced-pio.txt
new file mode 100644
index 000..34bf50a
--- /dev/null
+++ b/Documentation/virtual/kvm/coalesced-pio.txt
@@ -0,0 +1,36 @@
+Linux KVM Coalesced PIO:
+
+Coalesced pio is base on coalesced mmio. When the write access to a port
+of a device does a simple work or can delay, then follows a access to the
+same device, it can use coalesced pio optimizing method.
+
+using coalesced pio, the write access to port A of a device do not exit
+to userspace, and just record the value in shared coalesced ring in kernel.
+Then following access to the port B of the same device or read access to
+the port A will get the previous write value of port A firstly in usersapce
+according to the shared coalesced ring.
+
+Now just use coalesced pio for rtc 0x70 port and we can find other ports
+in the future.
+
+for example: rtc port 0x70
+without coalesced pio:
+  guest write port 0x70
+vm_exit to userspace
+  userspace set register index: regindex
+vm_entry
+  guest read or write 0x71
+vm_exit to userspace
+  usersapce get/set rtc regisers[regindex]
+vm_entry
+
+with coalesced pio:
+  guest write port 0x70
+vm_exit to kernel
+vm_entry
+  guest read or write 0x71
+vm_exit to userspace
+  usersapce set register index: regindex
+  usersapce get/set rtc regisers[regindex]
+vm_entry
+
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index 6cd63c1..3e681f9 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -415,13 +415,13 @@ struct kvm_run {
 struct kvm_coalesced_mmio_zone {
__u64 addr;
__u32 size;
-   __u32 pad;
+   __u32 pio;
 };
 
 struct kvm_coalesced_mmio {
__u64 phys_addr;
__u32 len;
-   __u32 pad;
+   __u32 pio;
__u8  data[8];
 };
 
@@ -929,6 +929,7 @@ struct kvm_ppc_resize_hpt {
 #define KVM_CAP_PPC_SMT_POSSIBLE 147
 #define KVM_CAP_HYPERV_SYNIC2 148
 #define KVM_CAP_HYPERV_VP_INDEX 149
+#define KVM_CAP_COALESCED_PIO 150
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
diff --git a/virt/kvm/coalesced_mmio.c b/virt/kvm/coalesced_mmio.c
index 571c1ce..0811907 100644
--- a/virt/kvm/coalesced_mmio.c
+++ b/virt/kvm/coalesced_mmio.c
@@ -82,6 +82,7 @@ static int coalesced_mmio_write(struct kvm_vcpu *vcpu,
ring->coalesced_mmio[ring->last].phys_addr = addr;
ring->coalesced_mmio[ring->last].len = len;
memcpy(ring->coalesced_mmio[ring->last].data, val, len);
+   ring->coalesced_mmio[ring->last].pio = dev->zone.pio;
smp_wmb();
ring->last = (ring->last + 1) % KVM_COALESCED_MMIO_MAX;
spin_unlock(&dev->kvm->ring_lock);
@@ -148,8 +149,12 @@ int kvm_vm_ioctl_register_coalesced_mmio(struct kvm *kvm,
dev->zone = *zone;
 
mutex_lock(&kvm->slots_lock);
-   ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, zone->addr,
- zone->size, &dev->dev);
+   if (zone->pio == 0)
+   ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, zone->addr,
+   zone->size, &dev->dev);
+   else
+   ret = kvm_io_bus_register_dev(kvm, KVM_PIO_BUS, zone->addr,
+ 

Re: [PATCH v2 3/3] gpio: mockup: use irq_sim

2017-08-13 Thread Linus Walleij
On Tue, Aug 1, 2017 at 4:50 PM, Bartosz Golaszewski  wrote:

> Shrink the driver by removing the code dealing with dummy interrupts
> and replacing it with calls to the irq_sim API.
>
> Signed-off-by: Bartosz Golaszewski 

Reviewed-by: Linus Walleij 

Tglx/Marc: feel free to merge this with the rest into the irqchip tree.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


docs build questions

2017-08-13 Thread Randy Dunlap
Hi,

[on linux v4.13-rc4]

> sphinx-build --version
Sphinx (sphinx-build) 1.2.3


I'm getting some docs build errors and warnings. Do I need a newer
version of Sphinx or some options added?

Documentation/input/devices/xpad.rst:137: ERROR: Error in "code-block" 
directive:
unknown option: "caption".

where those lines are:
.. code-block:: none
   :caption: dump from InterAct PowerPad Pro (Germany)

~

Documentation/doc-guide/sphinx.rst:121: ERROR: Unknown target name: "sphinx c 
domain".

~~~

Lots of ERRORs where a doc comment is of the form GPP_ (ending with a '_'):

../block/bio.c:404: ERROR: Unknown target name: "gfp".



and later I get a fatal error:

Exception occurred:
  File ".../lnx-413-rc4/Documentation/sphinx/kfigure.py", line 240, in 
convert_image
translator.builder.imagedir,
AttributeError: 'StandaloneHTMLBuilder' object has no attribute 'imagedir'


Thanks.
-- 
~Randy
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Documentation: stable-kernel-rules: fix broken git urls

2017-08-13 Thread Andrii Bordunov
git.kernel.org links don't work (fatal: repository ... not found).
Update them with the current style from https://git.kernel.org

There is no HTTP option, so also switch HTTP -> HTTPS.

Signed-off-by: Andrii Bordunov 
---
 Documentation/process/stable-kernel-rules.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/process/stable-kernel-rules.rst 
b/Documentation/process/stable-kernel-rules.rst
index 61e9c78bd6d1..36a2dded525b 100644
--- a/Documentation/process/stable-kernel-rules.rst
+++ b/Documentation/process/stable-kernel-rules.rst
@@ -166,12 +166,12 @@ Trees
  - The queues of patches, for both completed versions and in progress
versions can be found at:
 
-   http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
+   https://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git
 
  - The finalized and tagged releases of all stable kernels can be found
in separate branches per version at:
 
-   http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git
+   https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
 
 
 Review committee
-- 
2.13.4

--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: docs build questions

2017-08-13 Thread Markus Heiser
Hi Randy,

> Am 13.08.2017 um 19:29 schrieb Randy Dunlap :
> 
> Hi,
> 
> [on linux v4.13-rc4]
> 
>> sphinx-build --version
> Sphinx (sphinx-build) 1.2.3

see "Sphinx Install" Documentation/doc-guide/sphinx.rst (ATM in Jon's docs-next)

 The ReST markups currently used by the Documentation/ files are meant to be
 built with ``Sphinx`` version 1.3 or upper. If you're desiring to build
 PDF outputs, it is recommended to use version 1.4.6 or upper.

Sorry for the mess in the past. Mauro has now cleared this up for us / thanks 
Mauro

> I'm getting some docs build errors and warnings. Do I need a newer
> version of Sphinx or some options added?

No options needed, update Sphinx should help.

> Documentation/input/devices/xpad.rst:137: ERROR: Error in "code-block" 
> directive:
> unknown option: "caption".
> 
> where those lines are:
> .. code-block:: none
>  :caption: dump from InterAct PowerPad Pro (Germany)

Sphinx version

> 
> ~
> 
> Documentation/doc-guide/sphinx.rst:121: ERROR: Unknown target name: "sphinx c 
> domain".

Sphinx version

> 
> ~~~
> 
> Lots of ERRORs where a doc comment is of the form GPP_ (ending with a '_'):
> 
> ../block/bio.c:404: ERROR: Unknown target name: "gfp".

Yes, this is a conflict since comments are reST Markup.

 https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html

In sources we like to use FOO_ (ending with a '_'), which is a
hyperlink markup in reST:

 http://www.sphinx-doc.org/en/stable/rest.html#hyperlinks

The only solution I see is to replace FOO_ with ``FOO_``

> 
> 
> 
> and later I get a fatal error:
> 
> Exception occurred:
> File ".../lnx-413-rc4/Documentation/sphinx/kfigure.py", line 240, in 
> convert_image
>   translator.builder.imagedir,
> AttributeError: 'StandaloneHTMLBuilder' object has no attribute 'imagedir'

Sphinx version.


-- Markus 
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html