[PATCH v2 0/4] Clean up includes

Markus Armbruster posted 4 patches 1 year, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20221222120813.727830-1-armbru@redhat.com
Maintainers: Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, "Daniel P. Berrangé" <berrange@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <ani@anisinha.ca>, Peter Maydell <peter.maydell@linaro.org>, Laurent Vivier <laurent@vivier.eu>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Ben Widawsky <ben.widawsky@intel.com>, Jonathan Cameron <jonathan.cameron@huawei.com>, Alistair Francis <Alistair.Francis@wdc.com>, Bin Meng <bin.meng@windriver.com>, Palmer Dabbelt <palmer@dabbelt.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Xiaojuan Yang <yangxiaojuan@loongson.cn>, Song Gao <gaosong@loongson.cn>, Richard Henderson <richard.henderson@linaro.org>, Helge Deller <deller@gmx.de>, Jason Wang <jasowang@redhat.com>, Vikram Garhwal <vikram.garhwal@amd.com>, Francisco Iglesias <francisco.iglesias@amd.com>, "Cédric Le Goater" <clg@kaod.org>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, Gerd Hoffmann <kraxel@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Riku Voipio <riku.voipio@iki.fi>, Michael Roth <michael.roth@amd.com>, Konstantin Kostiuk <kkostiuk@redhat.com>, Taylor Simpson <tsimpson@quicinc.com>
There is a newer version of this series
docs/devel/style.rst                        | 7 +++++++
bsd-user/qemu.h                             | 1 -
crypto/block-luks-priv.h                    | 1 -
include/exec/plugin-gen.h                   | 1 +
include/hw/acpi/erst.h                      | 3 +++
include/hw/char/cmsdk-apb-uart.h            | 1 +
include/hw/char/goldfish_tty.h              | 1 +
include/hw/char/xilinx_uartlite.h           | 1 +
include/hw/cris/etraxfs.h                   | 1 +
include/hw/cxl/cxl_host.h                   | 1 -
include/hw/display/macfb.h                  | 3 ++-
include/hw/dma/sifive_pdma.h                | 2 ++
include/hw/i386/ioapic_internal.h           | 1 +
include/hw/i386/sgx-epc.h                   | 1 +
include/hw/input/pl050.h                    | 1 -
include/hw/intc/goldfish_pic.h              | 2 ++
include/hw/intc/loongarch_pch_msi.h         | 2 ++
include/hw/intc/loongarch_pch_pic.h         | 2 ++
include/hw/intc/nios2_vic.h                 | 2 ++
include/hw/misc/mchp_pfsoc_dmc.h            | 2 ++
include/hw/misc/mchp_pfsoc_ioscb.h          | 2 ++
include/hw/misc/mchp_pfsoc_sysreg.h         | 2 ++
include/hw/misc/pvpanic.h                   | 1 +
include/hw/misc/sifive_e_prci.h             | 3 ++-
include/hw/misc/sifive_u_otp.h              | 3 ++-
include/hw/misc/sifive_u_prci.h             | 3 ++-
include/hw/misc/virt_ctrl.h                 | 2 ++
include/hw/misc/xlnx-versal-pmc-iou-slcr.h  | 1 +
include/hw/net/lasi_82596.h                 | 2 +-
include/hw/net/xlnx-zynqmp-can.h            | 1 +
include/hw/ppc/pnv_psi.h                    | 2 +-
include/hw/riscv/boot_opensbi.h             | 2 ++
include/hw/riscv/microchip_pfsoc.h          | 3 +++
include/hw/riscv/numa.h                     | 1 +
include/hw/riscv/sifive_u.h                 | 2 ++
include/hw/riscv/spike.h                    | 2 +-
include/hw/riscv/virt.h                     | 2 +-
include/hw/ssi/sifive_spi.h                 | 3 +++
include/hw/timer/sse-timer.h                | 1 +
include/hw/tricore/triboard.h               | 1 -
include/hw/usb/hcd-dwc3.h                   | 1 +
include/hw/usb/hcd-musb.h                   | 2 ++
include/hw/usb/xlnx-usb-subsystem.h         | 2 ++
include/hw/usb/xlnx-versal-usb2-ctrl-regs.h | 3 +++
include/hw/virtio/virtio-mmio.h             | 2 +-
include/hw/virtio/virtio.h                  | 1 -
include/qemu/plugin-memory.h                | 3 +++
include/qemu/userfaultfd.h                  | 1 -
include/sysemu/dirtyrate.h                  | 2 ++
include/sysemu/dump.h                       | 1 +
include/user/syscall-trace.h                | 1 +
net/vmnet_int.h                             | 1 -
qga/cutils.h                                | 1 -
target/hexagon/hex_arch_types.h             | 1 -
target/hexagon/mmvec/macros.h               | 1 -
target/riscv/pmu.h                          | 1 -
hw/virtio/virtio-qmp.c                      | 1 +
hw/virtio/virtio.c                          | 1 +
qga/cutils.c                                | 3 ++-
59 files changed, 82 insertions(+), 22 deletions(-)
[PATCH v2 0/4] Clean up includes
Posted by Markus Armbruster 1 year, 4 months ago
Back in 2016, we discussed[1] rules for headers, and these were
generally liked:

1. Have a carefully curated header that's included everywhere first.  We
   got that already thanks to Peter: osdep.h.

2. Headers should normally include everything they need beyond osdep.h.
   If exceptions are needed for some reason, they must be documented in
   the header.  If all that's needed from a header is typedefs, put
   those into qemu/typedefs.h instead of including the header.

3. Cyclic inclusion is forbidden.

This series fixes a number of rule violations.

It is based on

    [PATCH v2 0/4] hw/ppc: Clean up includes
    [PATCH v2 0/7] include/hw/pci include/hw/cxl: Clean up includes
    [PATCH v2 0/3] block: Clean up includes
    [PATCH v3 0/5] coroutine: Clean up includes

With all of these applied, just three inclusion loops remain reachable
from include/:

    target/microblaze/cpu.h target/microblaze/mmu.h

    target/nios2/cpu.h target/nios2/mmu.h

    target/riscv/cpu.h target/riscv/pmp.h

Breaking them would be nice, but I'm out of steam.

v2:
* Rebased
* PATCH 3: v1 posted separately
* PATCH 4: New

[1] Message-ID: <87h9g8j57d.fsf@blackfin.pond.sub.org>
    https://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg03345.html

Based-on: <20221222104628.659681-1-armbru@redhat.com>

Markus Armbruster (4):
  include/hw/virtio: Break inclusion loop
  include: Include headers where needed
  include: Don't include qemu/osdep.h
  docs/devel: Rules on #include in headers

 docs/devel/style.rst                        | 7 +++++++
 bsd-user/qemu.h                             | 1 -
 crypto/block-luks-priv.h                    | 1 -
 include/exec/plugin-gen.h                   | 1 +
 include/hw/acpi/erst.h                      | 3 +++
 include/hw/char/cmsdk-apb-uart.h            | 1 +
 include/hw/char/goldfish_tty.h              | 1 +
 include/hw/char/xilinx_uartlite.h           | 1 +
 include/hw/cris/etraxfs.h                   | 1 +
 include/hw/cxl/cxl_host.h                   | 1 -
 include/hw/display/macfb.h                  | 3 ++-
 include/hw/dma/sifive_pdma.h                | 2 ++
 include/hw/i386/ioapic_internal.h           | 1 +
 include/hw/i386/sgx-epc.h                   | 1 +
 include/hw/input/pl050.h                    | 1 -
 include/hw/intc/goldfish_pic.h              | 2 ++
 include/hw/intc/loongarch_pch_msi.h         | 2 ++
 include/hw/intc/loongarch_pch_pic.h         | 2 ++
 include/hw/intc/nios2_vic.h                 | 2 ++
 include/hw/misc/mchp_pfsoc_dmc.h            | 2 ++
 include/hw/misc/mchp_pfsoc_ioscb.h          | 2 ++
 include/hw/misc/mchp_pfsoc_sysreg.h         | 2 ++
 include/hw/misc/pvpanic.h                   | 1 +
 include/hw/misc/sifive_e_prci.h             | 3 ++-
 include/hw/misc/sifive_u_otp.h              | 3 ++-
 include/hw/misc/sifive_u_prci.h             | 3 ++-
 include/hw/misc/virt_ctrl.h                 | 2 ++
 include/hw/misc/xlnx-versal-pmc-iou-slcr.h  | 1 +
 include/hw/net/lasi_82596.h                 | 2 +-
 include/hw/net/xlnx-zynqmp-can.h            | 1 +
 include/hw/ppc/pnv_psi.h                    | 2 +-
 include/hw/riscv/boot_opensbi.h             | 2 ++
 include/hw/riscv/microchip_pfsoc.h          | 3 +++
 include/hw/riscv/numa.h                     | 1 +
 include/hw/riscv/sifive_u.h                 | 2 ++
 include/hw/riscv/spike.h                    | 2 +-
 include/hw/riscv/virt.h                     | 2 +-
 include/hw/ssi/sifive_spi.h                 | 3 +++
 include/hw/timer/sse-timer.h                | 1 +
 include/hw/tricore/triboard.h               | 1 -
 include/hw/usb/hcd-dwc3.h                   | 1 +
 include/hw/usb/hcd-musb.h                   | 2 ++
 include/hw/usb/xlnx-usb-subsystem.h         | 2 ++
 include/hw/usb/xlnx-versal-usb2-ctrl-regs.h | 3 +++
 include/hw/virtio/virtio-mmio.h             | 2 +-
 include/hw/virtio/virtio.h                  | 1 -
 include/qemu/plugin-memory.h                | 3 +++
 include/qemu/userfaultfd.h                  | 1 -
 include/sysemu/dirtyrate.h                  | 2 ++
 include/sysemu/dump.h                       | 1 +
 include/user/syscall-trace.h                | 1 +
 net/vmnet_int.h                             | 1 -
 qga/cutils.h                                | 1 -
 target/hexagon/hex_arch_types.h             | 1 -
 target/hexagon/mmvec/macros.h               | 1 -
 target/riscv/pmu.h                          | 1 -
 hw/virtio/virtio-qmp.c                      | 1 +
 hw/virtio/virtio.c                          | 1 +
 qga/cutils.c                                | 3 ++-
 59 files changed, 82 insertions(+), 22 deletions(-)

-- 
2.38.1
Re: [PATCH v2 0/4] Clean up includes
Posted by Michael S. Tsirkin 1 year, 3 months ago
On Thu, Dec 22, 2022 at 01:08:09PM +0100, Markus Armbruster wrote:
> Back in 2016, we discussed[1] rules for headers, and these were
> generally liked:
> 
> 1. Have a carefully curated header that's included everywhere first.  We
>    got that already thanks to Peter: osdep.h.
> 
> 2. Headers should normally include everything they need beyond osdep.h.
>    If exceptions are needed for some reason, they must be documented in
>    the header.  If all that's needed from a header is typedefs, put
>    those into qemu/typedefs.h instead of including the header.
> 
> 3. Cyclic inclusion is forbidden.
> 
> This series fixes a number of rule violations.

I had to drop this for now due to failures on bsd in particular.
See Peter's answer to my pull.
Markus when you merge this feel free to use:

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>


> It is based on
> 
>     [PATCH v2 0/4] hw/ppc: Clean up includes
>     [PATCH v2 0/7] include/hw/pci include/hw/cxl: Clean up includes
>     [PATCH v2 0/3] block: Clean up includes
>     [PATCH v3 0/5] coroutine: Clean up includes
> 
> With all of these applied, just three inclusion loops remain reachable
> from include/:
> 
>     target/microblaze/cpu.h target/microblaze/mmu.h
> 
>     target/nios2/cpu.h target/nios2/mmu.h
> 
>     target/riscv/cpu.h target/riscv/pmp.h
> 
> Breaking them would be nice, but I'm out of steam.
> 
> v2:
> * Rebased
> * PATCH 3: v1 posted separately
> * PATCH 4: New
> 
> [1] Message-ID: <87h9g8j57d.fsf@blackfin.pond.sub.org>
>     https://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg03345.html
> 
> Based-on: <20221222104628.659681-1-armbru@redhat.com>
> 
> Markus Armbruster (4):
>   include/hw/virtio: Break inclusion loop
>   include: Include headers where needed
>   include: Don't include qemu/osdep.h
>   docs/devel: Rules on #include in headers
> 
>  docs/devel/style.rst                        | 7 +++++++
>  bsd-user/qemu.h                             | 1 -
>  crypto/block-luks-priv.h                    | 1 -
>  include/exec/plugin-gen.h                   | 1 +
>  include/hw/acpi/erst.h                      | 3 +++
>  include/hw/char/cmsdk-apb-uart.h            | 1 +
>  include/hw/char/goldfish_tty.h              | 1 +
>  include/hw/char/xilinx_uartlite.h           | 1 +
>  include/hw/cris/etraxfs.h                   | 1 +
>  include/hw/cxl/cxl_host.h                   | 1 -
>  include/hw/display/macfb.h                  | 3 ++-
>  include/hw/dma/sifive_pdma.h                | 2 ++
>  include/hw/i386/ioapic_internal.h           | 1 +
>  include/hw/i386/sgx-epc.h                   | 1 +
>  include/hw/input/pl050.h                    | 1 -
>  include/hw/intc/goldfish_pic.h              | 2 ++
>  include/hw/intc/loongarch_pch_msi.h         | 2 ++
>  include/hw/intc/loongarch_pch_pic.h         | 2 ++
>  include/hw/intc/nios2_vic.h                 | 2 ++
>  include/hw/misc/mchp_pfsoc_dmc.h            | 2 ++
>  include/hw/misc/mchp_pfsoc_ioscb.h          | 2 ++
>  include/hw/misc/mchp_pfsoc_sysreg.h         | 2 ++
>  include/hw/misc/pvpanic.h                   | 1 +
>  include/hw/misc/sifive_e_prci.h             | 3 ++-
>  include/hw/misc/sifive_u_otp.h              | 3 ++-
>  include/hw/misc/sifive_u_prci.h             | 3 ++-
>  include/hw/misc/virt_ctrl.h                 | 2 ++
>  include/hw/misc/xlnx-versal-pmc-iou-slcr.h  | 1 +
>  include/hw/net/lasi_82596.h                 | 2 +-
>  include/hw/net/xlnx-zynqmp-can.h            | 1 +
>  include/hw/ppc/pnv_psi.h                    | 2 +-
>  include/hw/riscv/boot_opensbi.h             | 2 ++
>  include/hw/riscv/microchip_pfsoc.h          | 3 +++
>  include/hw/riscv/numa.h                     | 1 +
>  include/hw/riscv/sifive_u.h                 | 2 ++
>  include/hw/riscv/spike.h                    | 2 +-
>  include/hw/riscv/virt.h                     | 2 +-
>  include/hw/ssi/sifive_spi.h                 | 3 +++
>  include/hw/timer/sse-timer.h                | 1 +
>  include/hw/tricore/triboard.h               | 1 -
>  include/hw/usb/hcd-dwc3.h                   | 1 +
>  include/hw/usb/hcd-musb.h                   | 2 ++
>  include/hw/usb/xlnx-usb-subsystem.h         | 2 ++
>  include/hw/usb/xlnx-versal-usb2-ctrl-regs.h | 3 +++
>  include/hw/virtio/virtio-mmio.h             | 2 +-
>  include/hw/virtio/virtio.h                  | 1 -
>  include/qemu/plugin-memory.h                | 3 +++
>  include/qemu/userfaultfd.h                  | 1 -
>  include/sysemu/dirtyrate.h                  | 2 ++
>  include/sysemu/dump.h                       | 1 +
>  include/user/syscall-trace.h                | 1 +
>  net/vmnet_int.h                             | 1 -
>  qga/cutils.h                                | 1 -
>  target/hexagon/hex_arch_types.h             | 1 -
>  target/hexagon/mmvec/macros.h               | 1 -
>  target/riscv/pmu.h                          | 1 -
>  hw/virtio/virtio-qmp.c                      | 1 +
>  hw/virtio/virtio.c                          | 1 +
>  qga/cutils.c                                | 3 ++-
>  59 files changed, 82 insertions(+), 22 deletions(-)
> 
> -- 
> 2.38.1
Re: [PATCH v2 0/4] Clean up includes
Posted by Michael S. Tsirkin 1 year, 4 months ago
On Thu, Dec 22, 2022 at 01:08:09PM +0100, Markus Armbruster wrote:
> Back in 2016, we discussed[1] rules for headers, and these were
> generally liked:
> 
> 1. Have a carefully curated header that's included everywhere first.  We
>    got that already thanks to Peter: osdep.h.
> 
> 2. Headers should normally include everything they need beyond osdep.h.
>    If exceptions are needed for some reason, they must be documented in
>    the header.  If all that's needed from a header is typedefs, put
>    those into qemu/typedefs.h instead of including the header.
> 
> 3. Cyclic inclusion is forbidden.
> 
> This series fixes a number of rule violations.


Conflicted with some patches I'm merging so I queued this up too.
Thanks!

> It is based on
> 
>     [PATCH v2 0/4] hw/ppc: Clean up includes
>     [PATCH v2 0/7] include/hw/pci include/hw/cxl: Clean up includes
>     [PATCH v2 0/3] block: Clean up includes
>     [PATCH v3 0/5] coroutine: Clean up includes
> 
> With all of these applied, just three inclusion loops remain reachable
> from include/:
> 
>     target/microblaze/cpu.h target/microblaze/mmu.h
> 
>     target/nios2/cpu.h target/nios2/mmu.h
> 
>     target/riscv/cpu.h target/riscv/pmp.h
> 
> Breaking them would be nice, but I'm out of steam.
> 
> v2:
> * Rebased
> * PATCH 3: v1 posted separately
> * PATCH 4: New
> 
> [1] Message-ID: <87h9g8j57d.fsf@blackfin.pond.sub.org>
>     https://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg03345.html
> 
> Based-on: <20221222104628.659681-1-armbru@redhat.com>
> 
> Markus Armbruster (4):
>   include/hw/virtio: Break inclusion loop
>   include: Include headers where needed
>   include: Don't include qemu/osdep.h
>   docs/devel: Rules on #include in headers
> 
>  docs/devel/style.rst                        | 7 +++++++
>  bsd-user/qemu.h                             | 1 -
>  crypto/block-luks-priv.h                    | 1 -
>  include/exec/plugin-gen.h                   | 1 +
>  include/hw/acpi/erst.h                      | 3 +++
>  include/hw/char/cmsdk-apb-uart.h            | 1 +
>  include/hw/char/goldfish_tty.h              | 1 +
>  include/hw/char/xilinx_uartlite.h           | 1 +
>  include/hw/cris/etraxfs.h                   | 1 +
>  include/hw/cxl/cxl_host.h                   | 1 -
>  include/hw/display/macfb.h                  | 3 ++-
>  include/hw/dma/sifive_pdma.h                | 2 ++
>  include/hw/i386/ioapic_internal.h           | 1 +
>  include/hw/i386/sgx-epc.h                   | 1 +
>  include/hw/input/pl050.h                    | 1 -
>  include/hw/intc/goldfish_pic.h              | 2 ++
>  include/hw/intc/loongarch_pch_msi.h         | 2 ++
>  include/hw/intc/loongarch_pch_pic.h         | 2 ++
>  include/hw/intc/nios2_vic.h                 | 2 ++
>  include/hw/misc/mchp_pfsoc_dmc.h            | 2 ++
>  include/hw/misc/mchp_pfsoc_ioscb.h          | 2 ++
>  include/hw/misc/mchp_pfsoc_sysreg.h         | 2 ++
>  include/hw/misc/pvpanic.h                   | 1 +
>  include/hw/misc/sifive_e_prci.h             | 3 ++-
>  include/hw/misc/sifive_u_otp.h              | 3 ++-
>  include/hw/misc/sifive_u_prci.h             | 3 ++-
>  include/hw/misc/virt_ctrl.h                 | 2 ++
>  include/hw/misc/xlnx-versal-pmc-iou-slcr.h  | 1 +
>  include/hw/net/lasi_82596.h                 | 2 +-
>  include/hw/net/xlnx-zynqmp-can.h            | 1 +
>  include/hw/ppc/pnv_psi.h                    | 2 +-
>  include/hw/riscv/boot_opensbi.h             | 2 ++
>  include/hw/riscv/microchip_pfsoc.h          | 3 +++
>  include/hw/riscv/numa.h                     | 1 +
>  include/hw/riscv/sifive_u.h                 | 2 ++
>  include/hw/riscv/spike.h                    | 2 +-
>  include/hw/riscv/virt.h                     | 2 +-
>  include/hw/ssi/sifive_spi.h                 | 3 +++
>  include/hw/timer/sse-timer.h                | 1 +
>  include/hw/tricore/triboard.h               | 1 -
>  include/hw/usb/hcd-dwc3.h                   | 1 +
>  include/hw/usb/hcd-musb.h                   | 2 ++
>  include/hw/usb/xlnx-usb-subsystem.h         | 2 ++
>  include/hw/usb/xlnx-versal-usb2-ctrl-regs.h | 3 +++
>  include/hw/virtio/virtio-mmio.h             | 2 +-
>  include/hw/virtio/virtio.h                  | 1 -
>  include/qemu/plugin-memory.h                | 3 +++
>  include/qemu/userfaultfd.h                  | 1 -
>  include/sysemu/dirtyrate.h                  | 2 ++
>  include/sysemu/dump.h                       | 1 +
>  include/user/syscall-trace.h                | 1 +
>  net/vmnet_int.h                             | 1 -
>  qga/cutils.h                                | 1 -
>  target/hexagon/hex_arch_types.h             | 1 -
>  target/hexagon/mmvec/macros.h               | 1 -
>  target/riscv/pmu.h                          | 1 -
>  hw/virtio/virtio-qmp.c                      | 1 +
>  hw/virtio/virtio.c                          | 1 +
>  qga/cutils.c                                | 3 ++-
>  59 files changed, 82 insertions(+), 22 deletions(-)
> 
> -- 
> 2.38.1
Re: [PATCH v2 0/4] Clean up includes
Posted by Markus Armbruster 1 year, 4 months ago
Michael, I forgot to add your R-bys.  I'll fix that in the next
revision if I need one, else in the pull request.