Source-Changes-HG archive

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

[src/trunk]: src/external/cddl/osnet/dist/tools/ctf/cvt Add fixup operation t...



details:   https://anonhg.NetBSD.org/src/rev/5936304ab29a
branches:  trunk
changeset: 962360:5936304ab29a
user:      hannken <hannken%NetBSD.org@localhost>
date:      Tue Jul 16 07:26:41 2019 +0000

description:
Add fixup operation to remove private mutex types for x86.

For GENERIC the number of types goes down from 47351 to 33981.

diffstat:

 external/cddl/osnet/dist/tools/ctf/cvt/fixup_tdescs.c |  49 +++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)

diffs (61 lines):

diff -r f12e8775bb65 -r 5936304ab29a external/cddl/osnet/dist/tools/ctf/cvt/fixup_tdescs.c
--- a/external/cddl/osnet/dist/tools/ctf/cvt/fixup_tdescs.c     Tue Jul 16 07:26:00 2019 +0000
+++ b/external/cddl/osnet/dist/tools/ctf/cvt/fixup_tdescs.c     Tue Jul 16 07:26:41 2019 +0000
@@ -276,8 +276,57 @@
        lml->ml_next = cpum;
 }
 
+#ifdef __NetBSD__
+
+/*
+ * The kmutex structure comes in two flavours, with or without __MUTEX_PRIVATE
+ * defined.  Since many structures include kmutexes this causes massive amounts
+ * of duplication on merge (~ 40% for a GENERIC kernel).  Remove the private
+ * fields if we see them.
+ */
+static void
+fix_kmutex_private(tdata_t *td, size_t ptrsize)
+{
+       tdesc_t *desc;
+       mlist_t *ml;
+
+       /*
+        * X86 kmutex is either
+        *      union {
+        *              volatile uintptr_t mtxa_owner;
+        *      } u
+        * or
+        *      union {
+        *              volatile uintptr_t mtxa_owner;
+        *              struct {
+        *                      ...
+        *              } s;
+        *      } u
+        * so we remove "struct s" if we find it.
+        */
+       if ((desc = lookup_tdesc(td, "kmutex")) != NULL &&
+           desc->t_type == STRUCT &&
+           (ml = desc->t_members) != NULL &&
+           streq(ml->ml_name, "u") &&
+           (desc = ml->ml_type) != NULL &&
+           desc->t_type == UNION &&
+           (ml = desc->t_members) != NULL &&
+           streq(ml->ml_name, "mtxa_owner") &&
+           (ml = ml->ml_next) != NULL &&
+           streq(ml->ml_name, "s") &&
+           ml->ml_next == NULL) {
+               /* Found, delete member "s". */
+               desc->t_members->ml_next = NULL;
+       }
+}
+
+#endif /* __NetBSD__ */
+
 void
 cvt_fixups(tdata_t *td, size_t ptrsize)
 {
        fix_small_cpu_struct(td, ptrsize);
+#ifdef __NetBSD__
+       fix_kmutex_private(td, ptrsize);
+#endif
 }



Home | Main Index | Thread Index | Old Index