All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] include: Trim some fat from osdep.h
@ 2022-02-08 20:08 Peter Maydell
  2022-02-08 20:08 ` [PATCH 1/5] include: Move qemu_madvise() and related #defines to new qemu/madvise.h Peter Maydell
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: Peter Maydell @ 2022-02-08 20:08 UTC (permalink / raw)
  To: qemu-devel

The osdep.h header is included by every C file we compile, so it helps
build times to keep it small. (As the comment at the top of the file
notes, in an ideal world this header would contain only things that
everybody needs and things where we need to apply a compatibility
workaround on some hosts.) This series trims more than 130 lines from
osdep.h (about 16% of its current size) by splitting some prototypes
that are used only in a few files out into new headers that are
included by those source files that need them.

(Looking at the size of osdep.h itself is not really the right metric,
because the real killer for compile time is going to be all the
system headers it pulls in; but it's easier to measure and looks
better for this series :-))

There's scope for more of this, I think, but there's no need to try to
do everything in one huge patchset.

thanks
-- PMM

Peter Maydell (5):
  include: Move qemu_madvise() and related #defines to new
    qemu/madvise.h
  include: Move qemu_mprotect_*() to new qemu/mprotect.h
  include: Move QEMU_MAP_* constants to mmap-alloc.h
  include: Move qemu_[id]cache_* declarations to new qemu/cacheinfo.h
  include: Move hardware version declarations to new qemu/hw-version.h

 include/qemu/cacheinfo.h   |  21 ++++++
 include/qemu/hw-version.h  |  27 ++++++++
 include/qemu/madvise.h     |  95 ++++++++++++++++++++++++++
 include/qemu/mmap-alloc.h  |  23 +++++++
 include/qemu/mprotect.h    |  14 ++++
 include/qemu/osdep.h       | 132 -------------------------------------
 accel/tcg/translate-all.c  |   1 +
 backends/hostmem-file.c    |   1 +
 backends/hostmem.c         |   1 +
 hw/arm/nseries.c           |   1 +
 hw/ide/core.c              |   1 +
 hw/scsi/megasas.c          |   1 +
 hw/scsi/scsi-bus.c         |   1 +
 hw/scsi/scsi-disk.c        |   1 +
 hw/virtio/virtio-balloon.c |   1 +
 migration/postcopy-ram.c   |   1 +
 migration/qemu-file.c      |   1 +
 migration/ram.c            |   1 +
 plugins/loader.c           |   1 +
 softmmu/physmem.c          |   1 +
 softmmu/vl.c               |   1 +
 target/i386/cpu.c          |   1 +
 target/s390x/cpu_models.c  |   1 +
 tcg/region.c               |   3 +
 tcg/tcg.c                  |   1 +
 util/atomic64.c            |   1 +
 util/cacheflush.c          |   1 +
 util/cacheinfo.c           |   1 +
 util/osdep.c               |   3 +
 util/oslib-posix.c         |   1 +
 30 files changed, 208 insertions(+), 132 deletions(-)
 create mode 100644 include/qemu/cacheinfo.h
 create mode 100644 include/qemu/hw-version.h
 create mode 100644 include/qemu/madvise.h
 create mode 100644 include/qemu/mprotect.h

-- 
2.25.1



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/5] include: Move qemu_madvise() and related #defines to new qemu/madvise.h
  2022-02-08 20:08 [PATCH 0/5] include: Trim some fat from osdep.h Peter Maydell
@ 2022-02-08 20:08 ` Peter Maydell
  2022-02-08 23:01   ` Richard Henderson
  2022-02-08 20:08 ` [PATCH 2/5] include: Move qemu_mprotect_*() to new qemu/mprotect.h Peter Maydell
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Peter Maydell @ 2022-02-08 20:08 UTC (permalink / raw)
  To: qemu-devel

The function qemu_madvise() and the QEMU_MADV_* constants associated
with it are used in only 10 files.  Move them out of osdep.h to a new
qemu/madvise.h header that is included where it is needed.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/qemu/madvise.h     | 95 ++++++++++++++++++++++++++++++++++++++
 include/qemu/osdep.h       | 82 --------------------------------
 backends/hostmem-file.c    |  1 +
 backends/hostmem.c         |  1 +
 hw/virtio/virtio-balloon.c |  1 +
 migration/postcopy-ram.c   |  1 +
 migration/qemu-file.c      |  1 +
 migration/ram.c            |  1 +
 softmmu/physmem.c          |  1 +
 tcg/region.c               |  1 +
 util/osdep.c               |  1 +
 util/oslib-posix.c         |  1 +
 12 files changed, 105 insertions(+), 82 deletions(-)
 create mode 100644 include/qemu/madvise.h

diff --git a/include/qemu/madvise.h b/include/qemu/madvise.h
new file mode 100644
index 00000000000..e155f59a0df
--- /dev/null
+++ b/include/qemu/madvise.h
@@ -0,0 +1,95 @@
+/*
+ * QEMU madvise wrapper functions
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef QEMU_MADVISE_H
+#define QEMU_MADVISE_H
+
+#define QEMU_MADV_INVALID -1
+
+#if defined(CONFIG_MADVISE)
+
+#define QEMU_MADV_WILLNEED  MADV_WILLNEED
+#define QEMU_MADV_DONTNEED  MADV_DONTNEED
+#ifdef MADV_DONTFORK
+#define QEMU_MADV_DONTFORK  MADV_DONTFORK
+#else
+#define QEMU_MADV_DONTFORK  QEMU_MADV_INVALID
+#endif
+#ifdef MADV_MERGEABLE
+#define QEMU_MADV_MERGEABLE MADV_MERGEABLE
+#else
+#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
+#endif
+#ifdef MADV_UNMERGEABLE
+#define QEMU_MADV_UNMERGEABLE MADV_UNMERGEABLE
+#else
+#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
+#endif
+#ifdef MADV_DODUMP
+#define QEMU_MADV_DODUMP MADV_DODUMP
+#else
+#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
+#endif
+#ifdef MADV_DONTDUMP
+#define QEMU_MADV_DONTDUMP MADV_DONTDUMP
+#else
+#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
+#endif
+#ifdef MADV_HUGEPAGE
+#define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE
+#else
+#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID
+#endif
+#ifdef MADV_NOHUGEPAGE
+#define QEMU_MADV_NOHUGEPAGE MADV_NOHUGEPAGE
+#else
+#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID
+#endif
+#ifdef MADV_REMOVE
+#define QEMU_MADV_REMOVE MADV_REMOVE
+#else
+#define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED
+#endif
+#ifdef MADV_POPULATE_WRITE
+#define QEMU_MADV_POPULATE_WRITE MADV_POPULATE_WRITE
+#else
+#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID
+#endif
+
+#elif defined(CONFIG_POSIX_MADVISE)
+
+#define QEMU_MADV_WILLNEED  POSIX_MADV_WILLNEED
+#define QEMU_MADV_DONTNEED  POSIX_MADV_DONTNEED
+#define QEMU_MADV_DONTFORK  QEMU_MADV_INVALID
+#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
+#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
+#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
+#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
+#define QEMU_MADV_HUGEPAGE  QEMU_MADV_INVALID
+#define QEMU_MADV_NOHUGEPAGE  QEMU_MADV_INVALID
+#define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED
+#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID
+
+#else /* no-op */
+
+#define QEMU_MADV_WILLNEED  QEMU_MADV_INVALID
+#define QEMU_MADV_DONTNEED  QEMU_MADV_INVALID
+#define QEMU_MADV_DONTFORK  QEMU_MADV_INVALID
+#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
+#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
+#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
+#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
+#define QEMU_MADV_HUGEPAGE  QEMU_MADV_INVALID
+#define QEMU_MADV_NOHUGEPAGE  QEMU_MADV_INVALID
+#define QEMU_MADV_REMOVE QEMU_MADV_INVALID
+#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID
+
+#endif
+
+int qemu_madvise(void *addr, size_t len, int advice);
+
+#endif
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index d1660d67fa9..cb74f4571a3 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -425,87 +425,6 @@ static inline void qemu_cleanup_generic_vfree(void *p)
 #define QEMU_MAP_NORESERVE  (1 << 3)
 
 
-#define QEMU_MADV_INVALID -1
-
-#if defined(CONFIG_MADVISE)
-
-#define QEMU_MADV_WILLNEED  MADV_WILLNEED
-#define QEMU_MADV_DONTNEED  MADV_DONTNEED
-#ifdef MADV_DONTFORK
-#define QEMU_MADV_DONTFORK  MADV_DONTFORK
-#else
-#define QEMU_MADV_DONTFORK  QEMU_MADV_INVALID
-#endif
-#ifdef MADV_MERGEABLE
-#define QEMU_MADV_MERGEABLE MADV_MERGEABLE
-#else
-#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
-#endif
-#ifdef MADV_UNMERGEABLE
-#define QEMU_MADV_UNMERGEABLE MADV_UNMERGEABLE
-#else
-#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
-#endif
-#ifdef MADV_DODUMP
-#define QEMU_MADV_DODUMP MADV_DODUMP
-#else
-#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
-#endif
-#ifdef MADV_DONTDUMP
-#define QEMU_MADV_DONTDUMP MADV_DONTDUMP
-#else
-#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
-#endif
-#ifdef MADV_HUGEPAGE
-#define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE
-#else
-#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID
-#endif
-#ifdef MADV_NOHUGEPAGE
-#define QEMU_MADV_NOHUGEPAGE MADV_NOHUGEPAGE
-#else
-#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID
-#endif
-#ifdef MADV_REMOVE
-#define QEMU_MADV_REMOVE MADV_REMOVE
-#else
-#define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED
-#endif
-#ifdef MADV_POPULATE_WRITE
-#define QEMU_MADV_POPULATE_WRITE MADV_POPULATE_WRITE
-#else
-#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID
-#endif
-
-#elif defined(CONFIG_POSIX_MADVISE)
-
-#define QEMU_MADV_WILLNEED  POSIX_MADV_WILLNEED
-#define QEMU_MADV_DONTNEED  POSIX_MADV_DONTNEED
-#define QEMU_MADV_DONTFORK  QEMU_MADV_INVALID
-#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
-#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
-#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
-#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
-#define QEMU_MADV_HUGEPAGE  QEMU_MADV_INVALID
-#define QEMU_MADV_NOHUGEPAGE  QEMU_MADV_INVALID
-#define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED
-#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID
-
-#else /* no-op */
-
-#define QEMU_MADV_WILLNEED  QEMU_MADV_INVALID
-#define QEMU_MADV_DONTNEED  QEMU_MADV_INVALID
-#define QEMU_MADV_DONTFORK  QEMU_MADV_INVALID
-#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
-#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
-#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
-#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
-#define QEMU_MADV_HUGEPAGE  QEMU_MADV_INVALID
-#define QEMU_MADV_NOHUGEPAGE  QEMU_MADV_INVALID
-#define QEMU_MADV_REMOVE QEMU_MADV_INVALID
-#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID
-
-#endif
 
 #ifdef _WIN32
 #define HAVE_CHARDEV_SERIAL 1
@@ -577,7 +496,6 @@ void sigaction_invoke(struct sigaction *action,
                       struct qemu_signalfd_siginfo *info);
 #endif
 
-int qemu_madvise(void *addr, size_t len, int advice);
 int qemu_mprotect_rw(void *addr, size_t size);
 int qemu_mprotect_rwx(void *addr, size_t size);
 int qemu_mprotect_none(void *addr, size_t size);
diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
index cd038024fae..25141283c4a 100644
--- a/backends/hostmem-file.c
+++ b/backends/hostmem-file.c
@@ -14,6 +14,7 @@
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "qemu/module.h"
+#include "qemu/madvise.h"
 #include "sysemu/hostmem.h"
 #include "qom/object_interfaces.h"
 #include "qom/object.h"
diff --git a/backends/hostmem.c b/backends/hostmem.c
index 4c05862ed5a..b2a5e905e86 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -19,6 +19,7 @@
 #include "qemu/config-file.h"
 #include "qom/object_interfaces.h"
 #include "qemu/mmap-alloc.h"
+#include "qemu/madvise.h"
 
 #ifdef CONFIG_NUMA
 #include <numaif.h>
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 9a4f491b54d..e6c1b0aa46f 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -17,6 +17,7 @@
 #include "qemu/iov.h"
 #include "qemu/module.h"
 #include "qemu/timer.h"
+#include "qemu/madvise.h"
 #include "hw/virtio/virtio.h"
 #include "hw/mem/pc-dimm.h"
 #include "hw/qdev-properties.h"
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index e662dd05ccf..2a2cc5faf8f 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -18,6 +18,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/rcu.h"
+#include "qemu/madvise.h"
 #include "exec/target_page.h"
 #include "migration.h"
 #include "qemu-file.h"
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index 6338d8e2ff5..1479cddad94 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -23,6 +23,7 @@
  */
 #include "qemu/osdep.h"
 #include <zlib.h>
+#include "qemu/madvise.h"
 #include "qemu/error-report.h"
 #include "qemu/iov.h"
 #include "migration.h"
diff --git a/migration/ram.c b/migration/ram.c
index 91ca743ac88..781f0745dc0 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -30,6 +30,7 @@
 #include "qemu/cutils.h"
 #include "qemu/bitops.h"
 #include "qemu/bitmap.h"
+#include "qemu/madvise.h"
 #include "qemu/main-loop.h"
 #include "xbzrle.h"
 #include "ram.h"
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index dddf70edf5d..a13289a594a 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -23,6 +23,7 @@
 
 #include "qemu/cutils.h"
 #include "qemu/cacheflush.h"
+#include "qemu/madvise.h"
 
 #ifdef CONFIG_TCG
 #include "hw/core/tcg-cpu-ops.h"
diff --git a/tcg/region.c b/tcg/region.c
index 9cc30d49225..c46021d1604 100644
--- a/tcg/region.c
+++ b/tcg/region.c
@@ -24,6 +24,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/units.h"
+#include "qemu/madvise.h"
 #include "qapi/error.h"
 #include "exec/exec-all.h"
 #include "tcg/tcg.h"
diff --git a/util/osdep.c b/util/osdep.c
index 42a0a4986ae..1999f42f6fc 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -37,6 +37,7 @@ extern int madvise(char *, size_t, int);
 #include "qemu/cutils.h"
 #include "qemu/sockets.h"
 #include "qemu/error-report.h"
+#include "qemu/madvise.h"
 #include "monitor/monitor.h"
 
 static bool fips_enabled = false;
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index ac0dbc2adc2..f2be7321c59 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -36,6 +36,7 @@
 #include "trace.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
+#include "qemu/madvise.h"
 #include "qemu/sockets.h"
 #include "qemu/thread.h"
 #include <libgen.h>
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/5] include: Move qemu_mprotect_*() to new qemu/mprotect.h
  2022-02-08 20:08 [PATCH 0/5] include: Trim some fat from osdep.h Peter Maydell
  2022-02-08 20:08 ` [PATCH 1/5] include: Move qemu_madvise() and related #defines to new qemu/madvise.h Peter Maydell
@ 2022-02-08 20:08 ` Peter Maydell
  2022-02-08 23:02   ` Richard Henderson
  2022-02-08 20:08 ` [PATCH 3/5] include: Move QEMU_MAP_* constants to mmap-alloc.h Peter Maydell
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Peter Maydell @ 2022-02-08 20:08 UTC (permalink / raw)
  To: qemu-devel

The qemu_mprotect_*() family of functions are used in very few files;
move them from osdep.h to a new qemu/mprotect.h.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/qemu/mprotect.h | 14 ++++++++++++++
 include/qemu/osdep.h    |  4 ----
 tcg/region.c            |  1 +
 util/osdep.c            |  1 +
 4 files changed, 16 insertions(+), 4 deletions(-)
 create mode 100644 include/qemu/mprotect.h

diff --git a/include/qemu/mprotect.h b/include/qemu/mprotect.h
new file mode 100644
index 00000000000..1e83d1433ee
--- /dev/null
+++ b/include/qemu/mprotect.h
@@ -0,0 +1,14 @@
+/*
+ * QEMU mprotect functions
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef QEMU_MPROTECT_H
+#define QEMU_MPROTECT_H
+
+int qemu_mprotect_rw(void *addr, size_t size);
+int qemu_mprotect_rwx(void *addr, size_t size);
+int qemu_mprotect_none(void *addr, size_t size);
+
+#endif
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index cb74f4571a3..2a52933ce0e 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -496,10 +496,6 @@ void sigaction_invoke(struct sigaction *action,
                       struct qemu_signalfd_siginfo *info);
 #endif
 
-int qemu_mprotect_rw(void *addr, size_t size);
-int qemu_mprotect_rwx(void *addr, size_t size);
-int qemu_mprotect_none(void *addr, size_t size);
-
 /*
  * Don't introduce new usage of this function, prefer the following
  * qemu_open/qemu_create that take an "Error **errp"
diff --git a/tcg/region.c b/tcg/region.c
index c46021d1604..7b4e65a52e8 100644
--- a/tcg/region.c
+++ b/tcg/region.c
@@ -25,6 +25,7 @@
 #include "qemu/osdep.h"
 #include "qemu/units.h"
 #include "qemu/madvise.h"
+#include "qemu/mprotect.h"
 #include "qapi/error.h"
 #include "exec/exec-all.h"
 #include "tcg/tcg.h"
diff --git a/util/osdep.c b/util/osdep.c
index 1999f42f6fc..72b678ca2e3 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -38,6 +38,7 @@ extern int madvise(char *, size_t, int);
 #include "qemu/sockets.h"
 #include "qemu/error-report.h"
 #include "qemu/madvise.h"
+#include "qemu/mprotect.h"
 #include "monitor/monitor.h"
 
 static bool fips_enabled = false;
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/5] include: Move QEMU_MAP_* constants to mmap-alloc.h
  2022-02-08 20:08 [PATCH 0/5] include: Trim some fat from osdep.h Peter Maydell
  2022-02-08 20:08 ` [PATCH 1/5] include: Move qemu_madvise() and related #defines to new qemu/madvise.h Peter Maydell
  2022-02-08 20:08 ` [PATCH 2/5] include: Move qemu_mprotect_*() to new qemu/mprotect.h Peter Maydell
@ 2022-02-08 20:08 ` Peter Maydell
  2022-02-08 23:03   ` Richard Henderson
  2022-02-08 20:08 ` [PATCH 4/5] include: Move qemu_[id]cache_* declarations to new qemu/cacheinfo.h Peter Maydell
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Peter Maydell @ 2022-02-08 20:08 UTC (permalink / raw)
  To: qemu-devel

The QEMU_MAP_* constants are used only as arguments to the
qemu_ram_mmap() function.  Move them to mmap-alloc.h, where that
function's prototype is defined.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/qemu/mmap-alloc.h | 23 +++++++++++++++++++++++
 include/qemu/osdep.h      | 25 -------------------------
 2 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/include/qemu/mmap-alloc.h b/include/qemu/mmap-alloc.h
index 90d0eee7053..5076695cc81 100644
--- a/include/qemu/mmap-alloc.h
+++ b/include/qemu/mmap-alloc.h
@@ -35,4 +35,27 @@ void *qemu_ram_mmap(int fd,
 
 void qemu_ram_munmap(int fd, void *ptr, size_t size);
 
+/*
+ * Abstraction of PROT_ and MAP_ flags as passed to mmap(), for example,
+ * consumed by qemu_ram_mmap().
+ */
+
+/* Map PROT_READ instead of PROT_READ | PROT_WRITE. */
+#define QEMU_MAP_READONLY   (1 << 0)
+
+/* Use MAP_SHARED instead of MAP_PRIVATE. */
+#define QEMU_MAP_SHARED     (1 << 1)
+
+/*
+ * Use MAP_SYNC | MAP_SHARED_VALIDATE if supported. Ignored without
+ * QEMU_MAP_SHARED. If mapping fails, warn and fallback to !QEMU_MAP_SYNC.
+ */
+#define QEMU_MAP_SYNC       (1 << 2)
+
+/*
+ * Use MAP_NORESERVE to skip reservation of swap space (or huge pages if
+ * applicable). Bail out if not supported/effective.
+ */
+#define QEMU_MAP_NORESERVE  (1 << 3)
+
 #endif
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 2a52933ce0e..0715d6b4509 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -401,31 +401,6 @@ static inline void qemu_cleanup_generic_vfree(void *p)
  */
 #define QEMU_AUTO_VFREE __attribute__((cleanup(qemu_cleanup_generic_vfree)))
 
-/*
- * Abstraction of PROT_ and MAP_ flags as passed to mmap(), for example,
- * consumed by qemu_ram_mmap().
- */
-
-/* Map PROT_READ instead of PROT_READ | PROT_WRITE. */
-#define QEMU_MAP_READONLY   (1 << 0)
-
-/* Use MAP_SHARED instead of MAP_PRIVATE. */
-#define QEMU_MAP_SHARED     (1 << 1)
-
-/*
- * Use MAP_SYNC | MAP_SHARED_VALIDATE if supported. Ignored without
- * QEMU_MAP_SHARED. If mapping fails, warn and fallback to !QEMU_MAP_SYNC.
- */
-#define QEMU_MAP_SYNC       (1 << 2)
-
-/*
- * Use MAP_NORESERVE to skip reservation of swap space (or huge pages if
- * applicable). Bail out if not supported/effective.
- */
-#define QEMU_MAP_NORESERVE  (1 << 3)
-
-
-
 #ifdef _WIN32
 #define HAVE_CHARDEV_SERIAL 1
 #elif defined(__linux__) || defined(__sun__) || defined(__FreeBSD__)    \
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/5] include: Move qemu_[id]cache_* declarations to new qemu/cacheinfo.h
  2022-02-08 20:08 [PATCH 0/5] include: Trim some fat from osdep.h Peter Maydell
                   ` (2 preceding siblings ...)
  2022-02-08 20:08 ` [PATCH 3/5] include: Move QEMU_MAP_* constants to mmap-alloc.h Peter Maydell
@ 2022-02-08 20:08 ` Peter Maydell
  2022-02-08 23:04   ` Richard Henderson
  2022-02-08 20:08 ` [PATCH 5/5] include: Move hardware version declarations to new qemu/hw-version.h Peter Maydell
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Peter Maydell @ 2022-02-08 20:08 UTC (permalink / raw)
  To: qemu-devel

The qemu_icache_linesize, qemu_icache_linesize_log,
qemu_dcache_linesize, and qemu_dcache_linesize_log variables are not
used in many files.  Move them out of osdep.h to a new
qemu/cacheinfo.h, and document them.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/qemu/cacheinfo.h  | 21 +++++++++++++++++++++
 include/qemu/osdep.h      |  5 -----
 accel/tcg/translate-all.c |  1 +
 plugins/loader.c          |  1 +
 tcg/region.c              |  1 +
 tcg/tcg.c                 |  1 +
 util/atomic64.c           |  1 +
 util/cacheflush.c         |  1 +
 util/cacheinfo.c          |  1 +
 9 files changed, 28 insertions(+), 5 deletions(-)
 create mode 100644 include/qemu/cacheinfo.h

diff --git a/include/qemu/cacheinfo.h b/include/qemu/cacheinfo.h
new file mode 100644
index 00000000000..019a157ea08
--- /dev/null
+++ b/include/qemu/cacheinfo.h
@@ -0,0 +1,21 @@
+/*
+ * QEMU host cacheinfo information
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef QEMU_CACHEINFO_H
+#define QEMU_CACHEINFO_H
+
+/*
+ * These variables represent our best guess at the host icache and
+ * dcache sizes, expressed both as the size in bytes and as the
+ * base-2 log of the size in bytes. They are initialized at startup
+ * (via an attribute 'constructor' function).
+ */
+extern int qemu_icache_linesize;
+extern int qemu_icache_linesize_log;
+extern int qemu_dcache_linesize;
+extern int qemu_dcache_linesize_log;
+
+#endif
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 0715d6b4509..e36f62a254e 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -616,11 +616,6 @@ pid_t qemu_fork(Error **errp);
 extern uintptr_t qemu_real_host_page_size;
 extern intptr_t qemu_real_host_page_mask;
 
-extern int qemu_icache_linesize;
-extern int qemu_icache_linesize_log;
-extern int qemu_dcache_linesize;
-extern int qemu_dcache_linesize_log;
-
 /*
  * After using getopt or getopt_long, if you need to parse another set
  * of options, then you must reset optind.  Unfortunately the way to
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index bd71db59a9a..5971cd53ab9 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -51,6 +51,7 @@
 #include "qemu/qemu-print.h"
 #include "qemu/timer.h"
 #include "qemu/main-loop.h"
+#include "qemu/cacheinfo.h"
 #include "exec/log.h"
 #include "sysemu/cpus.h"
 #include "sysemu/cpu-timers.h"
diff --git a/plugins/loader.c b/plugins/loader.c
index a4ec2816922..4883b0a1cbc 100644
--- a/plugins/loader.c
+++ b/plugins/loader.c
@@ -24,6 +24,7 @@
 #include "qemu/rcu_queue.h"
 #include "qemu/qht.h"
 #include "qemu/bitmap.h"
+#include "qemu/cacheinfo.h"
 #include "qemu/xxhash.h"
 #include "qemu/plugin.h"
 #include "hw/core/cpu.h"
diff --git a/tcg/region.c b/tcg/region.c
index 7b4e65a52e8..72afb357389 100644
--- a/tcg/region.c
+++ b/tcg/region.c
@@ -26,6 +26,7 @@
 #include "qemu/units.h"
 #include "qemu/madvise.h"
 #include "qemu/mprotect.h"
+#include "qemu/cacheinfo.h"
 #include "qapi/error.h"
 #include "exec/exec-all.h"
 #include "tcg/tcg.h"
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 5d2f0d8b103..528277d1d3c 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -36,6 +36,7 @@
 #include "qemu/qemu-print.h"
 #include "qemu/timer.h"
 #include "qemu/cacheflush.h"
+#include "qemu/cacheinfo.h"
 
 /* Note: the long term plan is to reduce the dependencies on the QEMU
    CPU definitions. Currently they are used for qemu_ld/st
diff --git a/util/atomic64.c b/util/atomic64.c
index 93037d5b116..db2c7f0fd0e 100644
--- a/util/atomic64.c
+++ b/util/atomic64.c
@@ -7,6 +7,7 @@
 #include "qemu/osdep.h"
 #include "qemu/atomic.h"
 #include "qemu/thread.h"
+#include "qemu/cacehinfo.h"
 
 #ifdef CONFIG_ATOMIC64
 #error This file must only be compiled if !CONFIG_ATOMIC64
diff --git a/util/cacheflush.c b/util/cacheflush.c
index 933355b0c99..4b57186d89c 100644
--- a/util/cacheflush.c
+++ b/util/cacheflush.c
@@ -7,6 +7,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/cacheflush.h"
+#include "qemu/cacheinfo.h"
 #include "qemu/bitops.h"
 
 
diff --git a/util/cacheinfo.c b/util/cacheinfo.c
index b182f0b6936..ab1644d490f 100644
--- a/util/cacheinfo.c
+++ b/util/cacheinfo.c
@@ -9,6 +9,7 @@
 #include "qemu/osdep.h"
 #include "qemu/host-utils.h"
 #include "qemu/atomic.h"
+#include "qemu/cacheinfo.h"
 
 int qemu_icache_linesize = 0;
 int qemu_icache_linesize_log;
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 5/5] include: Move hardware version declarations to new qemu/hw-version.h
  2022-02-08 20:08 [PATCH 0/5] include: Trim some fat from osdep.h Peter Maydell
                   ` (3 preceding siblings ...)
  2022-02-08 20:08 ` [PATCH 4/5] include: Move qemu_[id]cache_* declarations to new qemu/cacheinfo.h Peter Maydell
@ 2022-02-08 20:08 ` Peter Maydell
  2022-02-08 23:06   ` Richard Henderson
  2022-02-09  9:20   ` Philippe Mathieu-Daudé via
  2022-02-09  9:21 ` [PATCH 0/5] include: Trim some fat from osdep.h Philippe Mathieu-Daudé via
  2022-02-18 12:18 ` Peter Maydell
  6 siblings, 2 replies; 17+ messages in thread
From: Peter Maydell @ 2022-02-08 20:08 UTC (permalink / raw)
  To: qemu-devel

The "hardware version" machinery (qemu_set_hw_version(),
qemu_hw_version(), and the QEMU_HW_VERSION define) is used by fewer
than 10 files.  Move it out from osdep.h into a new
qemu/hw-version.h.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/qemu/hw-version.h | 27 +++++++++++++++++++++++++++
 include/qemu/osdep.h      | 16 ----------------
 hw/arm/nseries.c          |  1 +
 hw/ide/core.c             |  1 +
 hw/scsi/megasas.c         |  1 +
 hw/scsi/scsi-bus.c        |  1 +
 hw/scsi/scsi-disk.c       |  1 +
 softmmu/vl.c              |  1 +
 target/i386/cpu.c         |  1 +
 target/s390x/cpu_models.c |  1 +
 util/osdep.c              |  1 +
 11 files changed, 36 insertions(+), 16 deletions(-)
 create mode 100644 include/qemu/hw-version.h

diff --git a/include/qemu/hw-version.h b/include/qemu/hw-version.h
new file mode 100644
index 00000000000..730a8c904d9
--- /dev/null
+++ b/include/qemu/hw-version.h
@@ -0,0 +1,27 @@
+/*
+ * QEMU "hardware version" machinery
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef QEMU_HW_VERSION_H
+#define QEMU_HW_VERSION_H
+
+/*
+ * Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default
+ * instead of QEMU_VERSION, so setting hw_version on MachineClass
+ * is no longer mandatory.
+ *
+ * Do NOT change this string, or it will break compatibility on all
+ * machine classes that don't set hw_version.
+ */
+#define QEMU_HW_VERSION "2.5+"
+
+/* QEMU "hardware version" setting. Used to replace code that exposed
+ * QEMU_VERSION to guests in the past and need to keep compatibility.
+ * Do not use qemu_hw_version() in new code.
+ */
+void qemu_set_hw_version(const char *);
+const char *qemu_hw_version(void);
+
+#endif
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index e36f62a254e..650ba1aa505 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -534,22 +534,6 @@ static inline void qemu_timersub(const struct timeval *val1,
 
 void qemu_set_cloexec(int fd);
 
-/* Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default
- * instead of QEMU_VERSION, so setting hw_version on MachineClass
- * is no longer mandatory.
- *
- * Do NOT change this string, or it will break compatibility on all
- * machine classes that don't set hw_version.
- */
-#define QEMU_HW_VERSION "2.5+"
-
-/* QEMU "hardware version" setting. Used to replace code that exposed
- * QEMU_VERSION to guests in the past and need to keep compatibility.
- * Do not use qemu_hw_version() in new code.
- */
-void qemu_set_hw_version(const char *);
-const char *qemu_hw_version(void);
-
 void fips_set_state(bool requested);
 bool fips_get_state(void);
 
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
index af3164c5519..9c1cafae86b 100644
--- a/hw/arm/nseries.c
+++ b/hw/arm/nseries.c
@@ -24,6 +24,7 @@
 #include "chardev/char.h"
 #include "qemu/cutils.h"
 #include "qemu/bswap.h"
+#include "qemu/hw-version.h"
 #include "sysemu/reset.h"
 #include "sysemu/runstate.h"
 #include "sysemu/sysemu.h"
diff --git a/hw/ide/core.c b/hw/ide/core.c
index e28f8aad611..33463d9b8f2 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -29,6 +29,7 @@
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "qemu/timer.h"
+#include "qemu/hw-version.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/blockdev.h"
 #include "sysemu/dma.h"
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index cd43945827c..d5dfb412bac 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -28,6 +28,7 @@
 #include "hw/pci/msix.h"
 #include "qemu/iov.h"
 #include "qemu/module.h"
+#include "qemu/hw-version.h"
 #include "hw/scsi/scsi.h"
 #include "scsi/constants.h"
 #include "trace.h"
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 4057e04ce89..b2e2bc3c96c 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -3,6 +3,7 @@
 #include "qemu/error-report.h"
 #include "qemu/module.h"
 #include "qemu/option.h"
+#include "qemu/hw-version.h"
 #include "hw/qdev-properties.h"
 #include "hw/scsi/scsi.h"
 #include "migration/qemu-file-types.h"
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 9c0dc7b9468..3666b8d9468 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -25,6 +25,7 @@
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "qemu/module.h"
+#include "qemu/hw-version.h"
 #include "hw/scsi/scsi.h"
 #include "migration/qemu-file-types.h"
 #include "migration/vmstate.h"
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 5e1b35ba489..1fe028800fd 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -36,6 +36,7 @@
 #include "qemu-version.h"
 #include "qemu/cutils.h"
 #include "qemu/help_option.h"
+#include "qemu/hw-version.h"
 #include "qemu/uuid.h"
 #include "sysemu/reset.h"
 #include "sysemu/runstate.h"
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index aa9e6368004..c9954df4a74 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -21,6 +21,7 @@
 #include "qemu/units.h"
 #include "qemu/cutils.h"
 #include "qemu/qemu-print.h"
+#include "qemu/hw-version.h"
 #include "cpu.h"
 #include "tcg/helper-tcg.h"
 #include "sysemu/reset.h"
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index 11e06cc51fa..17ae771939b 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -19,6 +19,7 @@
 #include "qapi/error.h"
 #include "qapi/visitor.h"
 #include "qemu/module.h"
+#include "qemu/hw-version.h"
 #include "qemu/qemu-print.h"
 #ifndef CONFIG_USER_ONLY
 #include "sysemu/sysemu.h"
diff --git a/util/osdep.c b/util/osdep.c
index 72b678ca2e3..7c4deda6feb 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -39,6 +39,7 @@ extern int madvise(char *, size_t, int);
 #include "qemu/error-report.h"
 #include "qemu/madvise.h"
 #include "qemu/mprotect.h"
+#include "qemu/hw-version.h"
 #include "monitor/monitor.h"
 
 static bool fips_enabled = false;
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/5] include: Move qemu_madvise() and related #defines to new qemu/madvise.h
  2022-02-08 20:08 ` [PATCH 1/5] include: Move qemu_madvise() and related #defines to new qemu/madvise.h Peter Maydell
@ 2022-02-08 23:01   ` Richard Henderson
  0 siblings, 0 replies; 17+ messages in thread
From: Richard Henderson @ 2022-02-08 23:01 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel

On 2/9/22 07:08, Peter Maydell wrote:
> The function qemu_madvise() and the QEMU_MADV_* constants associated
> with it are used in only 10 files.  Move them out of osdep.h to a new
> qemu/madvise.h header that is included where it is needed.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   include/qemu/madvise.h     | 95 ++++++++++++++++++++++++++++++++++++++
>   include/qemu/osdep.h       | 82 --------------------------------
>   backends/hostmem-file.c    |  1 +
>   backends/hostmem.c         |  1 +
>   hw/virtio/virtio-balloon.c |  1 +
>   migration/postcopy-ram.c   |  1 +
>   migration/qemu-file.c      |  1 +
>   migration/ram.c            |  1 +
>   softmmu/physmem.c          |  1 +
>   tcg/region.c               |  1 +
>   util/osdep.c               |  1 +
>   util/oslib-posix.c         |  1 +
>   12 files changed, 105 insertions(+), 82 deletions(-)
>   create mode 100644 include/qemu/madvise.h

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/5] include: Move qemu_mprotect_*() to new qemu/mprotect.h
  2022-02-08 20:08 ` [PATCH 2/5] include: Move qemu_mprotect_*() to new qemu/mprotect.h Peter Maydell
@ 2022-02-08 23:02   ` Richard Henderson
  0 siblings, 0 replies; 17+ messages in thread
From: Richard Henderson @ 2022-02-08 23:02 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel

On 2/9/22 07:08, Peter Maydell wrote:
> The qemu_mprotect_*() family of functions are used in very few files;
> move them from osdep.h to a new qemu/mprotect.h.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   include/qemu/mprotect.h | 14 ++++++++++++++
>   include/qemu/osdep.h    |  4 ----
>   tcg/region.c            |  1 +
>   util/osdep.c            |  1 +
>   4 files changed, 16 insertions(+), 4 deletions(-)
>   create mode 100644 include/qemu/mprotect.h

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/5] include: Move QEMU_MAP_* constants to mmap-alloc.h
  2022-02-08 20:08 ` [PATCH 3/5] include: Move QEMU_MAP_* constants to mmap-alloc.h Peter Maydell
@ 2022-02-08 23:03   ` Richard Henderson
  0 siblings, 0 replies; 17+ messages in thread
From: Richard Henderson @ 2022-02-08 23:03 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel

On 2/9/22 07:08, Peter Maydell wrote:
> The QEMU_MAP_* constants are used only as arguments to the
> qemu_ram_mmap() function.  Move them to mmap-alloc.h, where that
> function's prototype is defined.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   include/qemu/mmap-alloc.h | 23 +++++++++++++++++++++++
>   include/qemu/osdep.h      | 25 -------------------------
>   2 files changed, 23 insertions(+), 25 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/5] include: Move qemu_[id]cache_* declarations to new qemu/cacheinfo.h
  2022-02-08 20:08 ` [PATCH 4/5] include: Move qemu_[id]cache_* declarations to new qemu/cacheinfo.h Peter Maydell
@ 2022-02-08 23:04   ` Richard Henderson
  0 siblings, 0 replies; 17+ messages in thread
From: Richard Henderson @ 2022-02-08 23:04 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel

On 2/9/22 07:08, Peter Maydell wrote:
> The qemu_icache_linesize, qemu_icache_linesize_log,
> qemu_dcache_linesize, and qemu_dcache_linesize_log variables are not
> used in many files.  Move them out of osdep.h to a new
> qemu/cacheinfo.h, and document them.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   include/qemu/cacheinfo.h  | 21 +++++++++++++++++++++
>   include/qemu/osdep.h      |  5 -----
>   accel/tcg/translate-all.c |  1 +
>   plugins/loader.c          |  1 +
>   tcg/region.c              |  1 +
>   tcg/tcg.c                 |  1 +
>   util/atomic64.c           |  1 +
>   util/cacheflush.c         |  1 +
>   util/cacheinfo.c          |  1 +
>   9 files changed, 28 insertions(+), 5 deletions(-)
>   create mode 100644 include/qemu/cacheinfo.h

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/5] include: Move hardware version declarations to new qemu/hw-version.h
  2022-02-08 20:08 ` [PATCH 5/5] include: Move hardware version declarations to new qemu/hw-version.h Peter Maydell
@ 2022-02-08 23:06   ` Richard Henderson
  2022-02-09  9:20   ` Philippe Mathieu-Daudé via
  1 sibling, 0 replies; 17+ messages in thread
From: Richard Henderson @ 2022-02-08 23:06 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel

On 2/9/22 07:08, Peter Maydell wrote:
> The "hardware version" machinery (qemu_set_hw_version(),
> qemu_hw_version(), and the QEMU_HW_VERSION define) is used by fewer
> than 10 files.  Move it out from osdep.h into a new
> qemu/hw-version.h.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   include/qemu/hw-version.h | 27 +++++++++++++++++++++++++++
>   include/qemu/osdep.h      | 16 ----------------
>   hw/arm/nseries.c          |  1 +
>   hw/ide/core.c             |  1 +
>   hw/scsi/megasas.c         |  1 +
>   hw/scsi/scsi-bus.c        |  1 +
>   hw/scsi/scsi-disk.c       |  1 +
>   softmmu/vl.c              |  1 +
>   target/i386/cpu.c         |  1 +
>   target/s390x/cpu_models.c |  1 +
>   util/osdep.c              |  1 +
>   11 files changed, 36 insertions(+), 16 deletions(-)
>   create mode 100644 include/qemu/hw-version.h

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/5] include: Move hardware version declarations to new qemu/hw-version.h
  2022-02-08 20:08 ` [PATCH 5/5] include: Move hardware version declarations to new qemu/hw-version.h Peter Maydell
  2022-02-08 23:06   ` Richard Henderson
@ 2022-02-09  9:20   ` Philippe Mathieu-Daudé via
  2022-02-09  9:25     ` Peter Maydell
  1 sibling, 1 reply; 17+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-09  9:20 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel

On 8/2/22 21:08, Peter Maydell wrote:
> The "hardware version" machinery (qemu_set_hw_version(),
> qemu_hw_version(), and the QEMU_HW_VERSION define) is used by fewer
> than 10 files.  Move it out from osdep.h into a new
> qemu/hw-version.h.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   include/qemu/hw-version.h | 27 +++++++++++++++++++++++++++
>   include/qemu/osdep.h      | 16 ----------------
>   hw/arm/nseries.c          |  1 +
>   hw/ide/core.c             |  1 +
>   hw/scsi/megasas.c         |  1 +
>   hw/scsi/scsi-bus.c        |  1 +
>   hw/scsi/scsi-disk.c       |  1 +
>   softmmu/vl.c              |  1 +
>   target/i386/cpu.c         |  1 +
>   target/s390x/cpu_models.c |  1 +
>   util/osdep.c              |  1 +
>   11 files changed, 36 insertions(+), 16 deletions(-)
>   create mode 100644 include/qemu/hw-version.h
> 
> diff --git a/include/qemu/hw-version.h b/include/qemu/hw-version.h
> new file mode 100644
> index 00000000000..730a8c904d9
> --- /dev/null
> +++ b/include/qemu/hw-version.h
> @@ -0,0 +1,27 @@
> +/*
> + * QEMU "hardware version" machinery
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +#ifndef QEMU_HW_VERSION_H
> +#define QEMU_HW_VERSION_H
> +
> +/*
> + * Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default
> + * instead of QEMU_VERSION, so setting hw_version on MachineClass
> + * is no longer mandatory.
> + *
> + * Do NOT change this string, or it will break compatibility on all
> + * machine classes that don't set hw_version.
> + */
> +#define QEMU_HW_VERSION "2.5+"
> +
> +/* QEMU "hardware version" setting. Used to replace code that exposed
> + * QEMU_VERSION to guests in the past and need to keep compatibility.
> + * Do not use qemu_hw_version() in new code.

Can you include the "legacy" word somewhere in the include path?

I'm hesitating between having a single include/qemu/legacy/, using
a prefix or suffix.

Thanks,

Phil.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 0/5] include: Trim some fat from osdep.h
  2022-02-08 20:08 [PATCH 0/5] include: Trim some fat from osdep.h Peter Maydell
                   ` (4 preceding siblings ...)
  2022-02-08 20:08 ` [PATCH 5/5] include: Move hardware version declarations to new qemu/hw-version.h Peter Maydell
@ 2022-02-09  9:21 ` Philippe Mathieu-Daudé via
  2022-02-18 12:18 ` Peter Maydell
  6 siblings, 0 replies; 17+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-09  9:21 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel

On 8/2/22 21:08, Peter Maydell wrote:
> The osdep.h header is included by every C file we compile, so it helps
> build times to keep it small. (As the comment at the top of the file
> notes, in an ideal world this header would contain only things that
> everybody needs and things where we need to apply a compatibility
> workaround on some hosts.) This series trims more than 130 lines from
> osdep.h (about 16% of its current size) by splitting some prototypes
> that are used only in a few files out into new headers that are
> included by those source files that need them.
> 
> (Looking at the size of osdep.h itself is not really the right metric,
> because the real killer for compile time is going to be all the
> system headers it pulls in; but it's easier to measure and looks
> better for this series :-))
> 
> There's scope for more of this, I think, but there's no need to try to
> do everything in one huge patchset.
> 
> thanks
> -- PMM
> 
> Peter Maydell (5):
>    include: Move qemu_madvise() and related #defines to new
>      qemu/madvise.h
>    include: Move qemu_mprotect_*() to new qemu/mprotect.h
>    include: Move QEMU_MAP_* constants to mmap-alloc.h
>    include: Move qemu_[id]cache_* declarations to new qemu/cacheinfo.h
>    include: Move hardware version declarations to new qemu/hw-version.h

TIL qemu_hw_version().

Series:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/5] include: Move hardware version declarations to new qemu/hw-version.h
  2022-02-09  9:20   ` Philippe Mathieu-Daudé via
@ 2022-02-09  9:25     ` Peter Maydell
  2022-02-09 10:10       ` Philippe Mathieu-Daudé via
  0 siblings, 1 reply; 17+ messages in thread
From: Peter Maydell @ 2022-02-09  9:25 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel

On Wed, 9 Feb 2022 at 09:20, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> On 8/2/22 21:08, Peter Maydell wrote:
> > The "hardware version" machinery (qemu_set_hw_version(),
> > qemu_hw_version(), and the QEMU_HW_VERSION define) is used by fewer
> > than 10 files.  Move it out from osdep.h into a new
> > qemu/hw-version.h.
> >
> > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> > ---
> >   include/qemu/hw-version.h | 27 +++++++++++++++++++++++++++
> >   include/qemu/osdep.h      | 16 ----------------
> >   hw/arm/nseries.c          |  1 +
> >   hw/ide/core.c             |  1 +
> >   hw/scsi/megasas.c         |  1 +
> >   hw/scsi/scsi-bus.c        |  1 +
> >   hw/scsi/scsi-disk.c       |  1 +
> >   softmmu/vl.c              |  1 +
> >   target/i386/cpu.c         |  1 +
> >   target/s390x/cpu_models.c |  1 +
> >   util/osdep.c              |  1 +
> >   11 files changed, 36 insertions(+), 16 deletions(-)
> >   create mode 100644 include/qemu/hw-version.h
> >
> > diff --git a/include/qemu/hw-version.h b/include/qemu/hw-version.h
> > new file mode 100644
> > index 00000000000..730a8c904d9
> > --- /dev/null
> > +++ b/include/qemu/hw-version.h
> > @@ -0,0 +1,27 @@
> > +/*
> > + * QEMU "hardware version" machinery
> > + *
> > + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> > + * See the COPYING file in the top-level directory.
> > + */
> > +#ifndef QEMU_HW_VERSION_H
> > +#define QEMU_HW_VERSION_H
> > +
> > +/*
> > + * Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default
> > + * instead of QEMU_VERSION, so setting hw_version on MachineClass
> > + * is no longer mandatory.
> > + *
> > + * Do NOT change this string, or it will break compatibility on all
> > + * machine classes that don't set hw_version.
> > + */
> > +#define QEMU_HW_VERSION "2.5+"
> > +
> > +/* QEMU "hardware version" setting. Used to replace code that exposed
> > + * QEMU_VERSION to guests in the past and need to keep compatibility.
> > + * Do not use qemu_hw_version() in new code.
>
> Can you include the "legacy" word somewhere in the include path?

I'm not completely convinced that (a) we have a clear idea of
what of our APIs are legacy and what are not or (b) that we could
coherently move the 'legacy' ones into separate files.
If you want to propose something like that as an RFC, I don't
100% object to it, but I don't want to do a very small subset
of that as part of what is really just a "get stuff out of osdep"
series.

thanks
-- PMM


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/5] include: Move hardware version declarations to new qemu/hw-version.h
  2022-02-09  9:25     ` Peter Maydell
@ 2022-02-09 10:10       ` Philippe Mathieu-Daudé via
  2022-02-09 13:44         ` Peter Maydell
  0 siblings, 1 reply; 17+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-09 10:10 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

On 9/2/22 10:25, Peter Maydell wrote:
> On Wed, 9 Feb 2022 at 09:20, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>>
>> On 8/2/22 21:08, Peter Maydell wrote:
>>> The "hardware version" machinery (qemu_set_hw_version(),
>>> qemu_hw_version(), and the QEMU_HW_VERSION define) is used by fewer
>>> than 10 files.  Move it out from osdep.h into a new
>>> qemu/hw-version.h.
>>>
>>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>>> ---
>>>    include/qemu/hw-version.h | 27 +++++++++++++++++++++++++++
>>>    include/qemu/osdep.h      | 16 ----------------
>>>    hw/arm/nseries.c          |  1 +
>>>    hw/ide/core.c             |  1 +
>>>    hw/scsi/megasas.c         |  1 +
>>>    hw/scsi/scsi-bus.c        |  1 +
>>>    hw/scsi/scsi-disk.c       |  1 +
>>>    softmmu/vl.c              |  1 +
>>>    target/i386/cpu.c         |  1 +
>>>    target/s390x/cpu_models.c |  1 +
>>>    util/osdep.c              |  1 +
>>>    11 files changed, 36 insertions(+), 16 deletions(-)
>>>    create mode 100644 include/qemu/hw-version.h

>>> +/*
>>> + * Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default
>>> + * instead of QEMU_VERSION, so setting hw_version on MachineClass
>>> + * is no longer mandatory.
>>> + *
>>> + * Do NOT change this string, or it will break compatibility on all
>>> + * machine classes that don't set hw_version.
>>> + */
>>> +#define QEMU_HW_VERSION "2.5+"
>>> +
>>> +/* QEMU "hardware version" setting. Used to replace code that exposed
>>> + * QEMU_VERSION to guests in the past and need to keep compatibility.
>>> + * Do not use qemu_hw_version() in new code.
>>
>> Can you include the "legacy" word somewhere in the include path?
> 
> I'm not completely convinced that (a) we have a clear idea of
> what of our APIs are legacy and what are not or (b) that we could
> coherently move the 'legacy' ones into separate files.
> If you want to propose something like that as an RFC, I don't
> 100% object to it, but I don't want to do a very small subset
> of that as part of what is really just a "get stuff out of osdep"
> series.

OK, thanks.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/5] include: Move hardware version declarations to new qemu/hw-version.h
  2022-02-09 10:10       ` Philippe Mathieu-Daudé via
@ 2022-02-09 13:44         ` Peter Maydell
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Maydell @ 2022-02-09 13:44 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel

On Wed, 9 Feb 2022 at 10:10, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> On 9/2/22 10:25, Peter Maydell wrote:
> > On Wed, 9 Feb 2022 at 09:20, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> > I'm not completely convinced that (a) we have a clear idea of
> > what of our APIs are legacy and what are not or (b) that we could
> > coherently move the 'legacy' ones into separate files.
> > If you want to propose something like that as an RFC, I don't
> > 100% object to it, but I don't want to do a very small subset
> > of that as part of what is really just a "get stuff out of osdep"
> > series.
>
> OK, thanks.

Thinking about the 'legacy API' issue a bit, rather than putting
them in particular include paths, maybe we could have a file
we list them in, and have checkpatch automatically check for new
uses of them. But I think our major problems with legacy APIs are
more "we never go through and complete transitions" rather than
"new code coming in uses old APIs we're trying to move away from"...

-- PMM


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 0/5] include: Trim some fat from osdep.h
  2022-02-08 20:08 [PATCH 0/5] include: Trim some fat from osdep.h Peter Maydell
                   ` (5 preceding siblings ...)
  2022-02-09  9:21 ` [PATCH 0/5] include: Trim some fat from osdep.h Philippe Mathieu-Daudé via
@ 2022-02-18 12:18 ` Peter Maydell
  6 siblings, 0 replies; 17+ messages in thread
From: Peter Maydell @ 2022-02-18 12:18 UTC (permalink / raw)
  To: qemu-devel

On Tue, 8 Feb 2022 at 20:08, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> The osdep.h header is included by every C file we compile, so it helps
> build times to keep it small. (As the comment at the top of the file
> notes, in an ideal world this header would contain only things that
> everybody needs and things where we need to apply a compatibility
> workaround on some hosts.) This series trims more than 130 lines from
> osdep.h (about 16% of its current size) by splitting some prototypes
> that are used only in a few files out into new headers that are
> included by those source files that need them.



Applied to target-arm.next, thanks.

-- PMM


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-02-18 12:20 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-08 20:08 [PATCH 0/5] include: Trim some fat from osdep.h Peter Maydell
2022-02-08 20:08 ` [PATCH 1/5] include: Move qemu_madvise() and related #defines to new qemu/madvise.h Peter Maydell
2022-02-08 23:01   ` Richard Henderson
2022-02-08 20:08 ` [PATCH 2/5] include: Move qemu_mprotect_*() to new qemu/mprotect.h Peter Maydell
2022-02-08 23:02   ` Richard Henderson
2022-02-08 20:08 ` [PATCH 3/5] include: Move QEMU_MAP_* constants to mmap-alloc.h Peter Maydell
2022-02-08 23:03   ` Richard Henderson
2022-02-08 20:08 ` [PATCH 4/5] include: Move qemu_[id]cache_* declarations to new qemu/cacheinfo.h Peter Maydell
2022-02-08 23:04   ` Richard Henderson
2022-02-08 20:08 ` [PATCH 5/5] include: Move hardware version declarations to new qemu/hw-version.h Peter Maydell
2022-02-08 23:06   ` Richard Henderson
2022-02-09  9:20   ` Philippe Mathieu-Daudé via
2022-02-09  9:25     ` Peter Maydell
2022-02-09 10:10       ` Philippe Mathieu-Daudé via
2022-02-09 13:44         ` Peter Maydell
2022-02-09  9:21 ` [PATCH 0/5] include: Trim some fat from osdep.h Philippe Mathieu-Daudé via
2022-02-18 12:18 ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.