[PATCH 0/2] cleanup on page size

Wei Yang posted 2 patches 4 years, 6 months ago
Test asan passed
Test checkpatch passed
Test FreeBSD passed
Test docker-mingw@fedora passed
Test docker-clang@ubuntu passed
Test docker-quick@centos7 passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20191013021145.16011-1-richardw.yang@linux.intel.com
Maintainers: Halil Pasic <pasic@linux.ibm.com>, Juan Quintela <quintela@redhat.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Eduardo Habkost <ehabkost@redhat.com>, Stefan Weil <sw@weilnetz.de>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Cornelia Huck <cohuck@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Fam Zheng <fam@euphon.net>, Alex Williamson <alex.williamson@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Denis V. Lunev" <den@openvz.org>, Markus Armbruster <armbru@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Richard Henderson <rth@twiddle.net>, Gerd Hoffmann <kraxel@redhat.com>, David Gibson <david@gibson.dropbear.id.au>, Paolo Bonzini <pbonzini@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Max Reitz <mreitz@redhat.com>, Yuval Shaia <yuval.shaia@oracle.com>, Kevin Wolf <kwolf@redhat.com>, Christian Borntraeger <borntraeger@de.ibm.com>
accel/kvm/kvm-all.c            |  6 +++---
backends/hostmem.c             |  2 +-
block.c                        |  4 ++--
block/file-posix.c             |  9 +++++----
block/io.c                     |  2 +-
block/parallels.c              |  2 +-
block/qcow2-cache.c            |  2 +-
contrib/vhost-user-gpu/vugbm.c |  2 +-
exec.c                         |  6 +++---
hw/intc/s390_flic_kvm.c        |  2 +-
hw/ppc/mac_newworld.c          |  2 +-
hw/ppc/spapr_pci.c             |  2 +-
hw/rdma/vmw/pvrdma_main.c      |  2 +-
hw/vfio/spapr.c                |  7 ++++---
include/exec/cpu-all.h         |  7 +++----
include/exec/ram_addr.h        |  2 +-
include/qemu/osdep.h           |  4 ++--
migration/migration.c          |  2 +-
migration/postcopy-ram.c       |  4 ++--
monitor/misc.c                 |  2 +-
target/ppc/kvm.c               |  2 +-
tests/vhost-user-bridge.c      |  8 ++++----
util/mmap-alloc.c              | 10 +++++-----
util/oslib-posix.c             |  4 ++--
util/oslib-win32.c             |  2 +-
util/vfio-helpers.c            | 12 ++++++------
26 files changed, 55 insertions(+), 54 deletions(-)
[PATCH 0/2] cleanup on page size
Posted by Wei Yang 4 years, 6 months ago
Patch 1 simplify the definition of xxx_PAGE_ALIGN.
Patch 2 replaces getpagesize() with qemu_real_host_page_size. This one touch a
volume of code. If some point is not correct, I'd appreciate your
notification.

Wei Yang (2):
  cpu: use ROUND_UP() to define xxx_PAGE_ALIGN
  core: replace getpagesize() with qemu_real_host_page_size

 accel/kvm/kvm-all.c            |  6 +++---
 backends/hostmem.c             |  2 +-
 block.c                        |  4 ++--
 block/file-posix.c             |  9 +++++----
 block/io.c                     |  2 +-
 block/parallels.c              |  2 +-
 block/qcow2-cache.c            |  2 +-
 contrib/vhost-user-gpu/vugbm.c |  2 +-
 exec.c                         |  6 +++---
 hw/intc/s390_flic_kvm.c        |  2 +-
 hw/ppc/mac_newworld.c          |  2 +-
 hw/ppc/spapr_pci.c             |  2 +-
 hw/rdma/vmw/pvrdma_main.c      |  2 +-
 hw/vfio/spapr.c                |  7 ++++---
 include/exec/cpu-all.h         |  7 +++----
 include/exec/ram_addr.h        |  2 +-
 include/qemu/osdep.h           |  4 ++--
 migration/migration.c          |  2 +-
 migration/postcopy-ram.c       |  4 ++--
 monitor/misc.c                 |  2 +-
 target/ppc/kvm.c               |  2 +-
 tests/vhost-user-bridge.c      |  8 ++++----
 util/mmap-alloc.c              | 10 +++++-----
 util/oslib-posix.c             |  4 ++--
 util/oslib-win32.c             |  2 +-
 util/vfio-helpers.c            | 12 ++++++------
 26 files changed, 55 insertions(+), 54 deletions(-)

-- 
2.17.1


Re: [PATCH 0/2] cleanup on page size
Posted by Michael S. Tsirkin 4 years, 6 months ago
On Sun, Oct 13, 2019 at 10:11:43AM +0800, Wei Yang wrote:
> Patch 1 simplify the definition of xxx_PAGE_ALIGN.
> Patch 2 replaces getpagesize() with qemu_real_host_page_size. This one touch a
> volume of code. If some point is not correct, I'd appreciate your
> notification.


Pls queue at the trivial branch.

> Wei Yang (2):
>   cpu: use ROUND_UP() to define xxx_PAGE_ALIGN
>   core: replace getpagesize() with qemu_real_host_page_size
> 
>  accel/kvm/kvm-all.c            |  6 +++---
>  backends/hostmem.c             |  2 +-
>  block.c                        |  4 ++--
>  block/file-posix.c             |  9 +++++----
>  block/io.c                     |  2 +-
>  block/parallels.c              |  2 +-
>  block/qcow2-cache.c            |  2 +-
>  contrib/vhost-user-gpu/vugbm.c |  2 +-
>  exec.c                         |  6 +++---
>  hw/intc/s390_flic_kvm.c        |  2 +-
>  hw/ppc/mac_newworld.c          |  2 +-
>  hw/ppc/spapr_pci.c             |  2 +-
>  hw/rdma/vmw/pvrdma_main.c      |  2 +-
>  hw/vfio/spapr.c                |  7 ++++---
>  include/exec/cpu-all.h         |  7 +++----
>  include/exec/ram_addr.h        |  2 +-
>  include/qemu/osdep.h           |  4 ++--
>  migration/migration.c          |  2 +-
>  migration/postcopy-ram.c       |  4 ++--
>  monitor/misc.c                 |  2 +-
>  target/ppc/kvm.c               |  2 +-
>  tests/vhost-user-bridge.c      |  8 ++++----
>  util/mmap-alloc.c              | 10 +++++-----
>  util/oslib-posix.c             |  4 ++--
>  util/oslib-win32.c             |  2 +-
>  util/vfio-helpers.c            | 12 ++++++------
>  26 files changed, 55 insertions(+), 54 deletions(-)
> 
> -- 
> 2.17.1

Re: [PATCH 0/2] cleanup on page size
Posted by Wei Yang 4 years, 6 months ago
Hi, All,

I got one page size related question, hope to get some hint.

There is one comment in page_size_init().

    /* NOTE: we can always suppose that qemu_host_page_size >=
       TARGET_PAGE_SIZE */

The final result is true, since we compare qemu_host_page_size with
TARGET_PAGE_SIZE and if not qemu_host_page_size will be assigned to
TARGET_PAGE_SIZE.

Generally, there is no problem, but one corner case for migration.

In function ram_save_host_page(), it tries to save a whole host page. Or to be
specific, it tries to save a whole REAL host page.

The potential problem is when qemu_real_host_page_size < TARGET_PAGE_SIZE,
this whole host page would be a wrong range.

So I am wondering why we have the assumption written in page_size_init()?

I tried to dig out who and why we have this comment, but found the first
commit is

    commit 54936004fddc52c321cb3f9a9a51140e782bed5d
    Author: bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
    Date:   Tue May 13 00:25:15 2003 +0000
    
        mmap emulation
    
    
        git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@158 c046a42c-6fe2-441c-8c8c-71466251a162

There is no reason logged.

On Sun, Oct 13, 2019 at 10:11:43AM +0800, Wei Yang wrote:
>Patch 1 simplify the definition of xxx_PAGE_ALIGN.
>Patch 2 replaces getpagesize() with qemu_real_host_page_size. This one touch a
>volume of code. If some point is not correct, I'd appreciate your
>notification.
>
>Wei Yang (2):
>  cpu: use ROUND_UP() to define xxx_PAGE_ALIGN
>  core: replace getpagesize() with qemu_real_host_page_size
>
> accel/kvm/kvm-all.c            |  6 +++---
> backends/hostmem.c             |  2 +-
> block.c                        |  4 ++--
> block/file-posix.c             |  9 +++++----
> block/io.c                     |  2 +-
> block/parallels.c              |  2 +-
> block/qcow2-cache.c            |  2 +-
> contrib/vhost-user-gpu/vugbm.c |  2 +-
> exec.c                         |  6 +++---
> hw/intc/s390_flic_kvm.c        |  2 +-
> hw/ppc/mac_newworld.c          |  2 +-
> hw/ppc/spapr_pci.c             |  2 +-
> hw/rdma/vmw/pvrdma_main.c      |  2 +-
> hw/vfio/spapr.c                |  7 ++++---
> include/exec/cpu-all.h         |  7 +++----
> include/exec/ram_addr.h        |  2 +-
> include/qemu/osdep.h           |  4 ++--
> migration/migration.c          |  2 +-
> migration/postcopy-ram.c       |  4 ++--
> monitor/misc.c                 |  2 +-
> target/ppc/kvm.c               |  2 +-
> tests/vhost-user-bridge.c      |  8 ++++----
> util/mmap-alloc.c              | 10 +++++-----
> util/oslib-posix.c             |  4 ++--
> util/oslib-win32.c             |  2 +-
> util/vfio-helpers.c            | 12 ++++++------
> 26 files changed, 55 insertions(+), 54 deletions(-)
>
>-- 
>2.17.1

-- 
Wei Yang
Help you, Help me