Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/netbsd32 Add lockstat(1) ioctl handling.



details:   https://anonhg.NetBSD.org/src/rev/35e464dbbb8b
branches:  trunk
changeset: 974043:35e464dbbb8b
user:      simonb <simonb%NetBSD.org@localhost>
date:      Tue Jul 21 05:33:51 2020 +0000

description:
Add lockstat(1) ioctl handling.

mrg@: "looks ok."

diffstat:

 sys/compat/netbsd32/netbsd32_ioctl.c |  57 ++++++++++++++++++++++++++++++++++-
 sys/compat/netbsd32/netbsd32_ioctl.h |  23 +++++++++++++-
 2 files changed, 77 insertions(+), 3 deletions(-)

diffs (127 lines):

diff -r 218789024a99 -r 35e464dbbb8b sys/compat/netbsd32/netbsd32_ioctl.c
--- a/sys/compat/netbsd32/netbsd32_ioctl.c      Tue Jul 21 04:58:43 2020 +0000
+++ b/sys/compat/netbsd32/netbsd32_ioctl.c      Tue Jul 21 05:33:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_ioctl.c,v 1.113 2020/07/18 12:46:19 jmcneill Exp $    */
+/*     $NetBSD: netbsd32_ioctl.c,v 1.114 2020/07/21 05:33:51 simonb Exp $      */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.113 2020/07/18 12:46:19 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.114 2020/07/21 05:33:51 simonb Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ntp.h"
@@ -1043,6 +1043,54 @@
        s32p->dkwl_ncopied = p->dkwl_ncopied;
 }
 
+static inline void
+netbsd32_to_lsenable(struct netbsd32_lsenable *le32, struct lsenable *le,
+    u_long cmd)
+{
+
+       le->le_csstart = le32->le_csstart;
+       le->le_csend = le32->le_csend;
+       le->le_lockstart = le32->le_lockstart;
+       le->le_lockend = le32->le_lockend;
+       le->le_nbufs = le32->le_nbufs;
+       le->le_flags = le32->le_flags;
+       le->le_mask = le32->le_mask;
+}
+
+static inline void
+netbsd32_from_lsenable(struct lsenable *le, struct netbsd32_lsenable *le32,
+    u_long cmd)
+{
+
+       le32->le_csstart = le->le_csstart;
+       le32->le_csend = le->le_csend;
+       le32->le_lockstart = le->le_lockstart;
+       le32->le_lockend = le->le_lockend;
+       le32->le_nbufs = le->le_nbufs;
+       le32->le_flags = le->le_flags;
+       le32->le_mask = le->le_mask;
+}
+
+static inline void
+netbsd32_to_lsdisable(struct netbsd32_lsdisable *ld32, struct lsdisable *ld,
+    u_long cmd)
+{
+
+       ld->ld_size = ld32->ld_size;
+       netbsd32_to_timespec(&ld32->ld_time, &ld->ld_time);
+       memcpy(&ld->ld_time, &ld32->ld_time, sizeof(ld->ld_time));
+}
+
+static inline void
+netbsd32_from_lsdisable(struct lsdisable *ld, struct netbsd32_lsdisable *ld32,
+    u_long cmd)
+{
+
+       ld->ld_size = ld32->ld_size;
+       netbsd32_from_timespec(&ld->ld_time, &ld32->ld_time);
+       memcpy(&ld->ld_time, &ld32->ld_time, sizeof(ld->ld_time));
+}
+
 #ifdef NTP
 static int
 netbsd32_do_clockctl_ntp_adjtime(struct file *fp,
@@ -1540,6 +1588,11 @@
        case DIOCLWEDGES32:
                IOCTL_STRUCT_CONV_TO(DIOCLWEDGES, dkwedge_list);
 
+       case IOC_LOCKSTAT_ENABLE32:
+               IOCTL_STRUCT_CONV_TO(IOC_LOCKSTAT_ENABLE, lsenable);
+       case IOC_LOCKSTAT_DISABLE32:
+               IOCTL_STRUCT_CONV_TO(IOC_LOCKSTAT_DISABLE, lsdisable);
+
        default:
 #ifdef NETBSD32_DRMKMS
                if (IOCGROUP(com) == 'd') {
diff -r 218789024a99 -r 35e464dbbb8b sys/compat/netbsd32/netbsd32_ioctl.h
--- a/sys/compat/netbsd32/netbsd32_ioctl.h      Tue Jul 21 04:58:43 2020 +0000
+++ b/sys/compat/netbsd32/netbsd32_ioctl.h      Tue Jul 21 05:33:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_ioctl.h,v 1.71 2020/07/18 12:46:19 jmcneill Exp $     */
+/*     $NetBSD: netbsd32_ioctl.h,v 1.72 2020/07/21 05:33:51 simonb Exp $       */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -35,6 +35,7 @@
 #include <dev/dkvar.h>
 #include <dev/vndvar.h>
 
+#include <dev/lockstat.h>
 #include <dev/wscons/wsconsio.h>
 #include <net/route.h>
 #include <netinet/in.h>
@@ -629,4 +630,24 @@
 #define DIOCGSTRATEGY32                _IOR('d', 125, struct netbsd32_disk_strategy)
 #define DIOCSSTRATEGY32                _IOW('d', 126, struct netbsd32_disk_strategy)
 
+/* from <dev/lockstat.h> */
+struct netbsd32_lsenable {
+       netbsd32_uintptr_t      le_csstart;     /* callsite start */
+       netbsd32_uintptr_t      le_csend;       /* callsite end */
+       netbsd32_uintptr_t      le_lockstart;   /* lock address start */
+       netbsd32_uintptr_t      le_lockend;     /* lock address end */
+       netbsd32_uintptr_t      le_nbufs;       /* buffers to allocate, 0 = default */
+       u_int                   le_flags;       /* request flags */
+       u_int                   le_mask;        /* event mask (LB_*) */
+};
+
+struct netbsd32_lsdisable {
+       netbsd32_size_t         ld_size;        /* buffer space allocated */
+       struct netbsd32_timespec ld_time;       /* time spent enabled */
+       uint64_t                ld_freq[64];    /* counter HZ by CPU number */
+} __packed;
+
+#define        IOC_LOCKSTAT_ENABLE32   _IOW('L', 1, struct netbsd32_lsenable)
+#define        IOC_LOCKSTAT_DISABLE32  _IOR('L', 2, struct netbsd32_lsdisable)
+
 int    netbsd32_drm_ioctl(struct file *, unsigned long, void *, struct lwp *);



Home | Main Index | Thread Index | Old Index