CVS commit: src/usr.sbin/puffs/mount_sysctlfs
Module Name:src Committed By: ryo Date: Sun Apr 2 18:23:02 UTC 2023 Modified Files: src/usr.sbin/puffs/mount_sysctlfs: sysctlfs.c Log Message: add missing '\n' To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/puffs/mount_sysctlfs/sysctlfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/puffs/mount_sysctlfs/sysctlfs.c diff -u src/usr.sbin/puffs/mount_sysctlfs/sysctlfs.c:1.20 src/usr.sbin/puffs/mount_sysctlfs/sysctlfs.c:1.21 --- src/usr.sbin/puffs/mount_sysctlfs/sysctlfs.c:1.20 Wed Nov 23 17:25:11 2016 +++ src/usr.sbin/puffs/mount_sysctlfs/sysctlfs.c Sun Apr 2 18:23:02 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: sysctlfs.c,v 1.20 2016/11/23 17:25:11 christos Exp $ */ +/* $NetBSD: sysctlfs.c,v 1.21 2023/04/02 18:23:02 ryo Exp $ */ /*- * Copyright (c) 2006, 2007 Antti Kantee. All Rights Reserved. @@ -33,7 +33,7 @@ #include #ifndef lint -__RCSID("$NetBSD: sysctlfs.c,v 1.20 2016/11/23 17:25:11 christos Exp $"); +__RCSID("$NetBSD: sysctlfs.c,v 1.21 2023/04/02 18:23:02 ryo Exp $"); #endif /* !lint */ #include @@ -226,7 +226,7 @@ static void __dead usage(void) { - fprintf(stderr, "Usage: %s [-o ] sysctlfs mountpath", + fprintf(stderr, "Usage: %s [-o ] sysctlfs mountpath\n", getprogname()); exit(1); }
CVS commit: src/usr.sbin/puffs/mount_sysctlfs
Module Name:src Committed By: ryo Date: Sun Apr 2 18:23:02 UTC 2023 Modified Files: src/usr.sbin/puffs/mount_sysctlfs: sysctlfs.c Log Message: add missing '\n' To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/puffs/mount_sysctlfs/sysctlfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/sysctl
Module Name:src Committed By: ryo Date: Sun Apr 2 18:15:24 UTC 2023 Modified Files: src/sbin/sysctl: sysctl.c Log Message: commonize case block To generate a diff of this commit: cvs rdiff -u -r1.164 -r1.165 src/sbin/sysctl/sysctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/sysctl/sysctl.c diff -u src/sbin/sysctl/sysctl.c:1.164 src/sbin/sysctl/sysctl.c:1.165 --- src/sbin/sysctl/sysctl.c:1.164 Sun Apr 2 18:11:26 2023 +++ src/sbin/sysctl/sysctl.c Sun Apr 2 18:15:24 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: sysctl.c,v 1.164 2023/04/02 18:11:26 ryo Exp $ */ +/* $NetBSD: sysctl.c,v 1.165 2023/04/02 18:15:24 ryo Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\ #if 0 static char sccsid[] = "@(#)sysctl.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: sysctl.c,v 1.164 2023/04/02 18:11:26 ryo Exp $"); +__RCSID("$NetBSD: sysctl.c,v 1.165 2023/04/02 18:15:24 ryo Exp $"); #endif #endif /* not lint */ @@ -940,13 +940,6 @@ parse(char *l, regex_t *re, size_t *last } switch (type) { - case CTLTYPE_NODE: - /* - * XXX old behavior is to print. should we error instead? - */ - print_tree([0], namelen, node, CTLTYPE_NODE, 0, re, - lastcompiled); - break; case CTLTYPE_INT: case CTLTYPE_BOOL: case CTLTYPE_QUAD: @@ -955,6 +948,7 @@ parse(char *l, regex_t *re, size_t *last case CTLTYPE_STRING: write_string([0], namelen, node, value, optional); break; + case CTLTYPE_NODE: case CTLTYPE_STRUCT: /* * XXX old behavior is to print. should we error instead?
CVS commit: src/sbin/sysctl
Module Name:src Committed By: ryo Date: Sun Apr 2 18:15:24 UTC 2023 Modified Files: src/sbin/sysctl: sysctl.c Log Message: commonize case block To generate a diff of this commit: cvs rdiff -u -r1.164 -r1.165 src/sbin/sysctl/sysctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/sysctl
Module Name:src Committed By: ryo Date: Sun Apr 2 18:11:26 UTC 2023 Modified Files: src/sbin/sysctl: sysctl.c Log Message: don't pass add=1 to print_tree() when displaying by specifying nodes. For example, "sysctl -w kern.mbuf=" had been displayed extra node names in the MIB. # sysctl -w kern.mbuf= kern.mbuf.mbuf.msize = 512 kern.mbuf.mbuf.mclbytes = 2048 : To generate a diff of this commit: cvs rdiff -u -r1.163 -r1.164 src/sbin/sysctl/sysctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/sysctl
Module Name:src Committed By: ryo Date: Sun Apr 2 18:11:26 UTC 2023 Modified Files: src/sbin/sysctl: sysctl.c Log Message: don't pass add=1 to print_tree() when displaying by specifying nodes. For example, "sysctl -w kern.mbuf=" had been displayed extra node names in the MIB. # sysctl -w kern.mbuf= kern.mbuf.mbuf.msize = 512 kern.mbuf.mbuf.mclbytes = 2048 : To generate a diff of this commit: cvs rdiff -u -r1.163 -r1.164 src/sbin/sysctl/sysctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/sysctl/sysctl.c diff -u src/sbin/sysctl/sysctl.c:1.163 src/sbin/sysctl/sysctl.c:1.164 --- src/sbin/sysctl/sysctl.c:1.163 Tue Dec 28 16:06:57 2021 +++ src/sbin/sysctl/sysctl.c Sun Apr 2 18:11:26 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: sysctl.c,v 1.163 2021/12/28 16:06:57 christos Exp $ */ +/* $NetBSD: sysctl.c,v 1.164 2023/04/02 18:11:26 ryo Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\ #if 0 static char sccsid[] = "@(#)sysctl.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: sysctl.c,v 1.163 2021/12/28 16:06:57 christos Exp $"); +__RCSID("$NetBSD: sysctl.c,v 1.164 2023/04/02 18:11:26 ryo Exp $"); #endif #endif /* not lint */ @@ -944,7 +944,7 @@ parse(char *l, regex_t *re, size_t *last /* * XXX old behavior is to print. should we error instead? */ - print_tree([0], namelen, node, CTLTYPE_NODE, 1, re, + print_tree([0], namelen, node, CTLTYPE_NODE, 0, re, lastcompiled); break; case CTLTYPE_INT:
CVS commit: src/sys/dev/pci
Module Name:src Committed By: ryo Date: Thu Jan 26 01:24:19 UTC 2023 Modified Files: src/sys/dev/pci: if_aq.c Log Message: - Don't discard a packet even if the TX descriptor is temporarily not enough, and error messages are not output. - The argument to aq_encap_txring() need not be an mbuf reference, pass an entity. pointed out by nisimura@. thanks To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/dev/pci/if_aq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_aq.c diff -u src/sys/dev/pci/if_aq.c:1.43 src/sys/dev/pci/if_aq.c:1.44 --- src/sys/dev/pci/if_aq.c:1.43 Sat Jan 14 13:20:15 2023 +++ src/sys/dev/pci/if_aq.c Thu Jan 26 01:24:19 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: if_aq.c,v 1.43 2023/01/14 13:20:15 ryo Exp $ */ +/* $NetBSD: if_aq.c,v 1.44 2023/01/26 01:24:19 ryo Exp $ */ /** * aQuantia Corporation Network Driver @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.43 2023/01/14 13:20:15 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.44 2023/01/26 01:24:19 ryo Exp $"); #ifdef _KERNEL_OPT #include "opt_if_aq.h" @@ -5323,10 +5323,9 @@ aq_rxring_reset(struct aq_softc *sc, str (((idx) >= (AQ_RXD_NUM - 1)) ? 0 : ((idx) + 1)) static int -aq_encap_txring(struct aq_softc *sc, struct aq_txring *txring, struct mbuf **mp) +aq_encap_txring(struct aq_softc *sc, struct aq_txring *txring, struct mbuf *m) { bus_dmamap_t map; - struct mbuf *m = *mp; uint32_t ctl1, ctl1_ctx, ctl2; int idx, i, error; @@ -5353,11 +5352,8 @@ aq_encap_txring(struct aq_softc *sc, str * +1 is additional descriptor for context (vlan, etc,.) */ if ((map->dm_nsegs + 1) > txring->txr_nfree) { - device_printf(sc->sc_dev, - "TX: not enough descriptors left %d for %d segs\n", - txring->txr_nfree, map->dm_nsegs + 1); bus_dmamap_unload(sc->sc_dmat, map); - return ENOBUFS; + return EAGAIN; } /* sync dma for mbuf */ @@ -5823,7 +5819,7 @@ static void aq_send_common_locked(struct ifnet *ifp, struct aq_softc *sc, struct aq_txring *txring, bool is_transmit) { - struct mbuf *m; + struct mbuf *m, *n; int npkt, error; if (txring->txr_nfree < AQ_TXD_MIN) @@ -5834,18 +5830,22 @@ aq_send_common_locked(struct ifnet *ifp, m = pcq_peek(txring->txr_pcq); else IFQ_POLL(>if_snd, m); - if (m == NULL) break; + error = aq_encap_txring(sc, txring, m); + if (error == EAGAIN) { + /* Not enough descriptors available. try again later */ + break; + } + if (is_transmit) pcq_get(txring->txr_pcq); else - IFQ_DEQUEUE(>if_snd, m); + IFQ_DEQUEUE(>if_snd, n); - error = aq_encap_txring(sc, txring, ); if (error != 0) { - /* too many mbuf chains? or not enough descriptors? */ + /* too many mbuf chains? or other errors. */ m_freem(m); if_statinc(ifp, if_oerrors); break;
CVS commit: src/sys/dev/pci
Module Name:src Committed By: ryo Date: Thu Jan 26 01:24:19 UTC 2023 Modified Files: src/sys/dev/pci: if_aq.c Log Message: - Don't discard a packet even if the TX descriptor is temporarily not enough, and error messages are not output. - The argument to aq_encap_txring() need not be an mbuf reference, pass an entity. pointed out by nisimura@. thanks To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/dev/pci/if_aq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/doc
Module Name:src Committed By: ryo Date: Sat Jan 14 13:20:54 UTC 2023 Modified Files: src/doc: CHANGES Log Message: add support for AQC113-116 to aq(4) To generate a diff of this commit: cvs rdiff -u -r1.2947 -r1.2948 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/doc
Module Name:src Committed By: ryo Date: Sat Jan 14 13:20:54 UTC 2023 Modified Files: src/doc: CHANGES Log Message: add support for AQC113-116 to aq(4) To generate a diff of this commit: cvs rdiff -u -r1.2947 -r1.2948 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2947 src/doc/CHANGES:1.2948 --- src/doc/CHANGES:1.2947 Thu Jan 12 12:05:15 2023 +++ src/doc/CHANGES Sat Jan 14 13:20:54 2023 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2947 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2948 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -45,3 +45,4 @@ Changes from NetBSD 10.0 to NetBSD 11.0: Baytrail [msaitoh 20230107] piixpm(4): Add support new AMD chipsets that do not have indirect access I/O ports. [msaitoh 20230110] + aq(4): add support for AQC113-116 [ryo 20230114]
CVS commit: src/share/man/man4
Module Name:src Committed By: ryo Date: Sat Jan 14 13:20:40 UTC 2023 Modified Files: src/share/man/man4: aq.4 Log Message: - add AQC113 and the variants - fix first appeared version to 9.1. it was backported. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/aq.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/aq.4 diff -u src/share/man/man4/aq.4:1.4 src/share/man/man4/aq.4:1.5 --- src/share/man/man4/aq.4:1.4 Fri Apr 24 04:37:27 2020 +++ src/share/man/man4/aq.4 Sat Jan 14 13:20:40 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: aq.4,v 1.4 2020/04/24 04:37:27 ryo Exp $ +.\" $NetBSD: aq.4,v 1.5 2023/01/14 13:20:40 ryo Exp $ .\" .\" Copyright (c) 2020 Ryo Shimizu .\" All rights reserved. @@ -24,7 +24,7 @@ .\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd April 24, 2020 +.Dd January 14, 2023 .Dt AQ 4 .Os .Sh NAME @@ -64,6 +64,22 @@ AQC111S 5 Gigabit Network Adapter .It AQC112S 2.5 Gigabit Network Adapter .It +AQC113DEV 10 Gigabit Network Adapter +.It +AQC113 10 Gigabit Network Adapter +.It +AQC113C 10 Gigabit Network Adapter +.It +AQC113CA 10 Gigabit Network Adapter +.It +AQC113CS 10 Gigabit Network Adapter +.It +AQC114CS 5 Gigabit Network Adapter +.It +AQC115C 2.5 Gigabit Network Adapter +.It +AQC116C Gigabit Network Adapter +.It D100 10 Gigabit Network Adapter .It D107 10 Gigabit Network Adapter @@ -83,7 +99,7 @@ D109 2.5 Gigabit Network Adapter The .Nm driver first appeared in -.Nx 10.0 , +.Nx 9.1 , and is based on the .Fx driver of the same name, but has been drastically rewritten by Ryo Shimizu.
CVS commit: src/share/man/man4
Module Name:src Committed By: ryo Date: Sat Jan 14 13:20:40 UTC 2023 Modified Files: src/share/man/man4: aq.4 Log Message: - add AQC113 and the variants - fix first appeared version to 9.1. it was backported. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/aq.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/pci
Module Name:src Committed By: ryo Date: Sat Jan 14 13:20:15 UTC 2023 Modified Files: src/sys/dev/pci: if_aq.c Log Message: Added support for the Aquantia (Marvell) AQC113 10G Network Adapter and the variants, to aq(4) To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/dev/pci/if_aq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_aq.c diff -u src/sys/dev/pci/if_aq.c:1.42 src/sys/dev/pci/if_aq.c:1.43 --- src/sys/dev/pci/if_aq.c:1.42 Sat Jan 14 13:17:50 2023 +++ src/sys/dev/pci/if_aq.c Sat Jan 14 13:20:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: if_aq.c,v 1.42 2023/01/14 13:17:50 ryo Exp $ */ +/* $NetBSD: if_aq.c,v 1.43 2023/01/14 13:20:15 ryo Exp $ */ /** * aQuantia Corporation Network Driver @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.42 2023/01/14 13:17:50 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.43 2023/01/14 13:20:15 ryo Exp $"); #ifdef _KERNEL_OPT #include "opt_if_aq.h" @@ -116,19 +116,29 @@ __KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1. #define AQ_RSS_HASHKEY_SIZE 40 #define AQ_RSS_INDIRECTION_TABLE_MAX 64 -#define AQ_JUMBO_MTU_REV_A 9000 -#define AQ_JUMBO_MTU_REV_B 16338 +#define AQ1_JUMBO_MTU_REV_A 9000 +#define AQ1_JUMBO_MTU_REV_B 16338 +#define AQ2_JUMBO_MTU 16338 /* * TERMINOLOGY + * ATL (AQ1) = Atlantic. AQC100,107-109,111,112. + * ATL2 (AQ2) = Atlantic2. AQC113-116. * MPI = MAC PHY INTERFACE? * RPO = RX Protocol Offloading * TPO = TX Protocol Offloading * RPF = RX Packet Filter * TPB = TX Packet buffer * RPB = RX Packet buffer + * ART = Action Resolver Table + * TC = Traffic Class */ +enum aq_hwtype { + HWTYPE_AQ1, + HWTYPE_AQ2 +}; + /* registers */ #define AQ_FW_SOFTRESET_REG 0x #define AQ_FW_SOFTRESET_RESET __BIT(15) /* soft reset bit */ @@ -136,6 +146,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1. #define AQ_FW_VERSION_REG 0x0018 #define AQ_HW_REVISION_REG 0x001c +#define AQ2_HW_FPGA_VERSION_REG 0x00f4 /* AQ2 */ #define AQ_GLB_NVR_INTERFACE1_REG 0x0100 #define AQ_FW_MBOX_CMD_REG 0x0200 @@ -182,7 +193,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1. #define RBL_STATUS_HOST_BOOT 0xf1a7 #define AQ_FW_GLB_CPU_SEM_REG(i) (0x03a0 + (i) * 4) -#define AQ_FW_SEM_RAM_REG AQ_FW_GLB_CPU_SEM_REG(2) +#define AQ1_FW_SEM_RAM_REG AQ_FW_GLB_CPU_SEM_REG(2) +#define AQ2_ART_SEM_REGAQ_FW_GLB_CPU_SEM_REG(3) #define AQ_FW_GLB_CTL2_REG 0x0404 #define AQ_FW_GLB_CTL2_MCP_UP_FORCE_INTERRUPT __BIT(1) @@ -194,7 +206,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1. #define AQ_PCI_REG_CONTROL_6_REG 0x1014 -// msix bitmap */ +/* msix bitmap */ #define AQ_INTR_STATUS_REG 0x2000 /* intr status */ #define AQ_INTR_STATUS_CLR_REG 0x2050 /* intr status clear */ #define AQ_INTR_MASK_REG 0x2060 /* intr mask set */ @@ -212,7 +224,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1. /* AQ_GEN_INTR_MAP_REG[AQ_RINGS_NUM] 0x2180-0x2200 */ #define AQ_GEN_INTR_MAP_REG(i) (0x2180 + (i) * 4) -#define AQ_B0_ERR_INT8U +#define AQ_B0_ERR_INT8 #define AQ_INTR_CTRL_REG 0x2300 #define AQ_INTR_CTRL_IRQMODE __BITS(1,0) @@ -231,8 +243,9 @@ __KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1. #define FW_MPI_RESETCTRL_RESET_DIS __BIT(29) #define RX_SYSCONTROL_REG 0x5000 -#define RX_SYSCONTROL_RPB_DMA_LOOPBACK __BIT(6) -#define RX_SYSCONTROL_RPF_TPO_LOOPBACK __BIT(8) +#define RX_SYSCONTROL_RPF_TPO_SYS_LOOPBACK __BIT(8) +#define RX_SYSCONTROL_RPB_DMA_SYS_LOOPBACK __BIT(6) +#define RX_SYSCONTROL_RPB_DMA_NET_LOOPBACK __BIT(4) #define RX_SYSCONTROL_RESET_DIS __BIT(29) #define RX_TCP_RSS_HASH_REG 0x5040 @@ -252,14 +265,19 @@ __KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1. #define RPF_L2BC_ACTION __BITS(12,14) #define RPF_L2BC_THRESHOLD __BITS(31,16) -/* RPF_L2UC_*_REG[34] (actual [38]?) */ +/* RPF_L2UC_*_REG[34] (AQ2 has [38]) */ #define RPF_L2UC_LSW_REG(i) (0x5110 + (i) * 8) #define RPF_L2UC_MSW_REG(i) (0x5114 + (i) * 8) #define RPF_L2UC_MSW_MACADDR_HI __BITS(15,0) #define RPF_L2UC_MSW_ACTION __BITS(18,16) +#define RPF_L2UC_MSW_TAG __BITS(27,22) /* AQ2 */ #define RPF_L2UC_MSW_EN __BIT(31) -#define AQ_HW_MAC_OWN 0 /* index of own address */ -#define AQ_HW_MAC_NUM 34 + +#define AQ_HW_MAC_OWN0 /* index of own address */ +#define AQ1_HW_MAC_NUM34 +#define AQ2_HW_MAC_NUM38 +#define AQ_HW_MAC_NUM(sc) \ + (HWTYPE_AQ2_P((sc)) ? AQ2_HW_MAC_NUM : AQ1_HW_MAC_NUM) /* RPF_MCAST_FILTER_REG[8] 0x5250-0x5270 */ #define RPF_MCAST_FILTER_REG(i) (0x5250 + (i) * 4) @@ -283,6 +301,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1. #define RPF_VLAN_FILTER_RXQ_EN __BIT(28) #define RPF_VLAN_FILTER_RXQ __BITS(24,20) #define RPF_VLAN_FILTER_ACTION __BITS(18,16) +#define RPF_VLAN_FILTER_TAG __BITS(15,12) /* AQ2 */ #define RPF_VLAN_FILTER_ID __BITS(11,0) /* RPF_ETHERTYPE_FILTER_REG[AQ_RINGS_NUM]
CVS commit: src/sys/dev/pci
Module Name:src Committed By: ryo Date: Sat Jan 14 13:20:15 UTC 2023 Modified Files: src/sys/dev/pci: if_aq.c Log Message: Added support for the Aquantia (Marvell) AQC113 10G Network Adapter and the variants, to aq(4) To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/dev/pci/if_aq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/pci
Module Name:src Committed By: ryo Date: Sat Jan 14 13:19:32 UTC 2023 Modified Files: src/sys/dev/pci: pcidevs.h pcidevs_data.h Log Message: regen To generate a diff of this commit: cvs rdiff -u -r1.1455 -r1.1456 src/sys/dev/pci/pcidevs.h cvs rdiff -u -r1.1454 -r1.1455 src/sys/dev/pci/pcidevs_data.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/pci
Module Name:src Committed By: ryo Date: Sat Jan 14 13:19:32 UTC 2023 Modified Files: src/sys/dev/pci: pcidevs.h pcidevs_data.h Log Message: regen To generate a diff of this commit: cvs rdiff -u -r1.1455 -r1.1456 src/sys/dev/pci/pcidevs.h cvs rdiff -u -r1.1454 -r1.1455 src/sys/dev/pci/pcidevs_data.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. diffs are larger than 1MB and have been omitted
CVS commit: src/sys/dev/pci
Module Name:src Committed By: ryo Date: Sat Jan 14 13:18:17 UTC 2023 Modified Files: src/sys/dev/pci: pcidevs Log Message: add Aquantia (Marvell) AQC113 ethernet devices and the variants To generate a diff of this commit: cvs rdiff -u -r1.1474 -r1.1475 src/sys/dev/pci/pcidevs Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/pcidevs diff -u src/sys/dev/pci/pcidevs:1.1474 src/sys/dev/pci/pcidevs:1.1475 --- src/sys/dev/pci/pcidevs:1.1474 Wed Jan 4 03:12:09 2023 +++ src/sys/dev/pci/pcidevs Sat Jan 14 13:18:17 2023 @@ -1,4 +1,4 @@ -$NetBSD: pcidevs,v 1.1474 2023/01/04 03:12:09 msaitoh Exp $ +$NetBSD: pcidevs,v 1.1475 2023/01/14 13:18:17 ryo Exp $ /* * Copyright (c) 1995, 1996 Christopher G. Demetriou @@ -1404,17 +1404,25 @@ product APPLE BCM5701 0x1645 BCM5701 /* Aquantia Corp. */ product AQUANTIA AQC100 0x00b1 AQC100 10 Gigabit Network Adapter +product AQUANTIA AQC113DEV 0x00c0 AQC113DEV 10 Gigabit Network Adapter +product AQUANTIA AQC113 0x04c0 AQC113 10 Gigabit Network Adapter product AQUANTIA AQC107 0x07b1 AQC107 10 Gigabit Network Adapter product AQUANTIA AQC108 0x08b1 AQC108 5 Gigabit Network Adapter product AQUANTIA AQC109 0x09b1 AQC109 2.5 Gigabit Network Adapter product AQUANTIA AQC111 0x11b1 AQC111 5 Gigabit Network Adapter +product AQUANTIA AQC116C 0x11c0 AQC116C Gigabit Network Adapter product AQUANTIA AQC112 0x12b1 AQC112 2.5 Gigabit Network Adapter +product AQUANTIA AQC115C 0x12c0 AQC115C 2.5 Gigabit Network Adapter +product AQUANTIA AQC113C 0x14c0 AQC113C 10 Gigabit Network Adapter +product AQUANTIA AQC113CA 0x34c0 AQC113CA 10 Gigabit Network Adapter product AQUANTIA AQC100S 0x80b1 AQC100S 10 Gigabit Network Adapter product AQUANTIA AQC107S 0x87b1 AQC107S 10 Gigabit Network Adapter product AQUANTIA AQC108S 0x88b1 AQC108S 5 Gigabit Network Adapter product AQUANTIA AQC109S 0x89b1 AQC109S 2.5 Gigabit Network Adapter product AQUANTIA AQC111S 0x91b1 AQC111S 5 Gigabit Network Adapter product AQUANTIA AQC112S 0x92b1 AQC112S 2.5 Gigabit Network Adapter +product AQUANTIA AQC114CS 0x93c0 AQC114CS 5 Gigabit Network Adapter +product AQUANTIA AQC113CS 0x94c0 AQC113CS 10 Gigabit Network Adapter product AQUANTIA D100 0xd100 D100 10 Gigabit Network Adapter product AQUANTIA D107 0xd107 D107 10 Gigabit Network Adapter product AQUANTIA D108 0xd108 D108 5 Gigabit Network Adapter
CVS commit: src/sys/dev/pci
Module Name:src Committed By: ryo Date: Sat Jan 14 13:18:17 UTC 2023 Modified Files: src/sys/dev/pci: pcidevs Log Message: add Aquantia (Marvell) AQC113 ethernet devices and the variants To generate a diff of this commit: cvs rdiff -u -r1.1474 -r1.1475 src/sys/dev/pci/pcidevs Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/pci
Module Name:src Committed By: ryo Date: Sat Jan 14 13:17:50 UTC 2023 Modified Files: src/sys/dev/pci: if_aq.c Log Message: fix indentation To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/pci/if_aq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_aq.c diff -u src/sys/dev/pci/if_aq.c:1.41 src/sys/dev/pci/if_aq.c:1.42 --- src/sys/dev/pci/if_aq.c:1.41 Sat Jan 14 13:17:20 2023 +++ src/sys/dev/pci/if_aq.c Sat Jan 14 13:17:50 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: if_aq.c,v 1.41 2023/01/14 13:17:20 ryo Exp $ */ +/* $NetBSD: if_aq.c,v 1.42 2023/01/14 13:17:50 ryo Exp $ */ /** * aQuantia Corporation Network Driver @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.41 2023/01/14 13:17:20 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.42 2023/01/14 13:17:50 ryo Exp $"); #ifdef _KERNEL_OPT #include "opt_if_aq.h" @@ -5003,10 +5003,10 @@ aq_ioctl(struct ifnet *ifp, unsigned lon case SIOCDELMULTI: AQ_LOCK(sc); if ((sc->sc_if_flags & IFF_RUNNING) != 0) { - /* - * Multicast list has changed; set the hardware filter - * accordingly. - */ + /* + * Multicast list has changed; set the hardware filter + * accordingly. + */ error = aq_set_filter(sc); } AQ_UNLOCK(sc);
CVS commit: src/sys/dev/pci
Module Name:src Committed By: ryo Date: Sat Jan 14 13:17:50 UTC 2023 Modified Files: src/sys/dev/pci: if_aq.c Log Message: fix indentation To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/pci/if_aq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/pci
Module Name:src Committed By: ryo Date: Sat Jan 14 13:17:20 UTC 2023 Modified Files: src/sys/dev/pci: if_aq.c Log Message: - avoid panic when failing during attach or detach with modload/drvctl. - free workqueue resources when detaching. - remove debug message. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/dev/pci/if_aq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_aq.c diff -u src/sys/dev/pci/if_aq.c:1.40 src/sys/dev/pci/if_aq.c:1.41 --- src/sys/dev/pci/if_aq.c:1.40 Sat Jan 14 13:16:27 2023 +++ src/sys/dev/pci/if_aq.c Sat Jan 14 13:17:20 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: if_aq.c,v 1.40 2023/01/14 13:16:27 ryo Exp $ */ +/* $NetBSD: if_aq.c,v 1.41 2023/01/14 13:17:20 ryo Exp $ */ /** * aQuantia Corporation Network Driver @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.40 2023/01/14 13:16:27 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.41 2023/01/14 13:17:20 ryo Exp $"); #ifdef _KERNEL_OPT #include "opt_if_aq.h" @@ -931,7 +931,8 @@ struct aq_firmware_ops { #define AQ_EVCNT_ATTACH_MISC(sc, name, desc)\ AQ_EVCNT_ATTACH(sc, name, desc, EVCNT_TYPE_MISC) #define AQ_EVCNT_DETACH(sc, name) \ - evcnt_detach(&(sc)->sc_evcount_##name##_ev) + if ((sc)->sc_evcount_##name##_name[0] != '\0') \ + evcnt_detach(&(sc)->sc_evcount_##name##_ev) #define AQ_EVCNT_ADD(sc, name, val) \ ((sc)->sc_evcount_##name##_ev.ev_count += (val)) #endif /* AQ_EVENT_COUNTERS */ @@ -1587,6 +1588,9 @@ aq_detach(device_t self, int flags __unu struct ifnet * const ifp = >sc_ethercom.ec_if; int i; + if (sc->sc_dev == NULL) + return 0; + if (sc->sc_iosize != 0) { if (ifp->if_softc != NULL) { IFNET_LOCK(ifp); @@ -1601,12 +1605,19 @@ aq_detach(device_t self, int flags __unu } } if (sc->sc_nintrs > 0) { + callout_stop(>sc_tick_ch); + pci_intr_release(sc->sc_pc, sc->sc_intrs, sc->sc_nintrs); sc->sc_intrs = NULL; sc->sc_nintrs = 0; } + if (sc->sc_reset_wq != NULL) { + workqueue_destroy(sc->sc_reset_wq); + sc->sc_reset_wq = NULL; + } + aq_txrx_rings_free(sc); if (ifp->if_softc != NULL) { @@ -1614,7 +1625,6 @@ aq_detach(device_t self, int flags __unu if_detach(ifp); } - aprint_debug_dev(sc->sc_dev, "%s: bus_space_unmap\n", __func__); bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_iosize); sc->sc_iosize = 0; } @@ -1647,10 +1657,14 @@ aq_detach(device_t self, int flags __unu AQ_EVCNT_DETACH(sc, cprc); #endif - ifmedia_fini(>sc_media); + if (sc->sc_ethercom.ec_ifmedia != NULL) { + ifmedia_fini(>sc_media); + sc->sc_ethercom.ec_ifmedia = NULL; + } mutex_destroy(>sc_mpi_mutex); mutex_destroy(>sc_mutex); + sc->sc_dev = NULL; return 0; }
CVS commit: src/sys/dev/pci
Module Name:src Committed By: ryo Date: Sat Jan 14 13:17:20 UTC 2023 Modified Files: src/sys/dev/pci: if_aq.c Log Message: - avoid panic when failing during attach or detach with modload/drvctl. - free workqueue resources when detaching. - remove debug message. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/dev/pci/if_aq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/pci
Module Name:src Committed By: ryo Date: Sat Jan 14 13:16:27 UTC 2023 Modified Files: src/sys/dev/pci: if_aq.c Log Message: fix build error in sys/module/if_aq/ avoid error of "comparison of integer expressions of different signedness" and -Werror=sign-compare To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/dev/pci/if_aq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/pci
Module Name:src Committed By: ryo Date: Sat Jan 14 13:16:27 UTC 2023 Modified Files: src/sys/dev/pci: if_aq.c Log Message: fix build error in sys/module/if_aq/ avoid error of "comparison of integer expressions of different signedness" and -Werror=sign-compare To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/dev/pci/if_aq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_aq.c diff -u src/sys/dev/pci/if_aq.c:1.39 src/sys/dev/pci/if_aq.c:1.40 --- src/sys/dev/pci/if_aq.c:1.39 Wed Nov 2 20:38:22 2022 +++ src/sys/dev/pci/if_aq.c Sat Jan 14 13:16:27 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: if_aq.c,v 1.39 2022/11/02 20:38:22 andvar Exp $ */ +/* $NetBSD: if_aq.c,v 1.40 2023/01/14 13:16:27 ryo Exp $ */ /** * aQuantia Corporation Network Driver @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.39 2022/11/02 20:38:22 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.40 2023/01/14 13:16:27 ryo Exp $"); #ifdef _KERNEL_OPT #include "opt_if_aq.h" @@ -1008,7 +1008,7 @@ struct aq_softc { #define FEATURES_REV_B0 0x2000 #define FEATURES_REV_B1 0x4000 #define FEATURES_REV_B (FEATURES_REV_B0|FEATURES_REV_B1) - uint32_t sc_max_mtu; + int sc_max_mtu; uint32_t sc_mbox_addr; bool sc_rbl_enabled; @@ -3874,7 +3874,7 @@ aq_watchdog_check(struct aq_softc * cons AQ_LOCKED(sc); bool ok = true; - for (u_int n = 0; n < sc->sc_nqueues; n++) { + for (int n = 0; n < sc->sc_nqueues; n++) { struct aq_txring *txring = >sc_queue[n].txring; mutex_enter(>txr_mutex); @@ -4810,7 +4810,7 @@ aq_unset_stopping_flags(struct aq_softc AQ_LOCKED(sc); /* Must unset stopping flags in ascending order. */ - for (unsigned i = 0; i < sc->sc_nqueues; i++) { + for (int i = 0; i < sc->sc_nqueues; i++) { struct aq_txring *txr = >sc_queue[i].txring; struct aq_rxring *rxr = >sc_queue[i].rxring; @@ -4833,7 +4833,7 @@ aq_set_stopping_flags(struct aq_softc *s AQ_LOCKED(sc); /* Must unset stopping flags in ascending order. */ - for (unsigned i = 0; i < sc->sc_nqueues; i++) { + for (int i = 0; i < sc->sc_nqueues; i++) { struct aq_txring *txr = >sc_queue[i].txring; struct aq_rxring *rxr = >sc_queue[i].rxring; @@ -4920,7 +4920,7 @@ aq_handle_reset_work(struct work *work, __func__, AQ_READ_REG(sc, AQ_INTR_MASK_REG), AQ_READ_REG(sc, AQ_INTR_STATUS_REG)); - for (u_int n = 0; n < sc->sc_nqueues; n++) { + for (int n = 0; n < sc->sc_nqueues; n++) { struct aq_txring *txring = >sc_queue[n].txring; u_int head = AQ_READ_REG_BIT(sc, TX_DMA_DESC_HEAD_PTR_REG(txring->txr_index),
CVS commit: src/sys/arch/aarch64/aarch64
Module Name:src Committed By: ryo Date: Thu Jan 12 10:46:48 UTC 2023 Modified Files: src/sys/arch/aarch64/aarch64: bus_space_asm_generic.S Log Message: fixed a bug that bus_space_read_region_{2,4,8}_swap() accesses wrong address. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/aarch64/aarch64/bus_space_asm_generic.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/aarch64/bus_space_asm_generic.S diff -u src/sys/arch/aarch64/aarch64/bus_space_asm_generic.S:1.5 src/sys/arch/aarch64/aarch64/bus_space_asm_generic.S:1.6 --- src/sys/arch/aarch64/aarch64/bus_space_asm_generic.S:1.5 Thu Nov 12 11:28:39 2020 +++ src/sys/arch/aarch64/aarch64/bus_space_asm_generic.S Thu Jan 12 10:46:48 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: bus_space_asm_generic.S,v 1.5 2020/11/12 11:28:39 jmcneill Exp $ */ +/* $NetBSD: bus_space_asm_generic.S,v 1.6 2023/01/12 10:46:48 ryo Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu @@ -29,7 +29,7 @@ #include #include "assym.h" -RCSID("$NetBSD: bus_space_asm_generic.S,v 1.5 2020/11/12 11:28:39 jmcneill Exp $") +RCSID("$NetBSD: bus_space_asm_generic.S,v 1.6 2023/01/12 10:46:48 ryo Exp $") .macro generate_bsfunc funcname, dsbop /* uint8_t {funcname}_bs_r_1(x0:tag, x1:addr, x2:offset) */ @@ -389,7 +389,7 @@ ENTRY_NP(\funcname\()_bs_rr_2_swap) 0: lsl x2, x2, x8 /* offset <<= tag->bs_stride */ 1: - ldrh w8, [x1, x9] /* value = *src */ + ldrh w8, [x1, x2] /* value = *src */ subs x4, x4, #1 /* count-- */ add x2, x2, x9 /* src += delta */ rev16 w8, w8 @@ -419,7 +419,7 @@ ENTRY_NP(\funcname\()_bs_rr_4_swap) 0: lsl x2, x2, x8 /* offset <<= tag->bs_stride */ 1: - ldr w8, [x1, x9] /* value = *src */ + ldr w8, [x1, x2] /* value = *src */ subs x4, x4, #1 /* count-- */ add x2, x2, x9 /* src += delta */ rev w8, w8 @@ -449,7 +449,7 @@ ENTRY_NP(\funcname\()_bs_rr_8_swap) 0: lsl x2, x2, x8 /* offset <<= tag->bs_stride */ 1: - ldr x8, [x1, x9] /* value = *src */ + ldr x8, [x1, x2] /* value = *src */ subs x4, x4, #1 /* count-- */ add x2, x2, x9 /* src += delta */ rev x8, x8
CVS commit: src/sys/arch/aarch64/aarch64
Module Name:src Committed By: ryo Date: Thu Jan 12 10:46:48 UTC 2023 Modified Files: src/sys/arch/aarch64/aarch64: bus_space_asm_generic.S Log Message: fixed a bug that bus_space_read_region_{2,4,8}_swap() accesses wrong address. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/aarch64/aarch64/bus_space_asm_generic.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Mon Dec 26 08:00:13 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof.c Log Message: fixed parsing of event options. if event option was specivied, it was stuck in a busy loop. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/tprof/tprof.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/tprof/tprof.c diff -u src/usr.sbin/tprof/tprof.c:1.19 src/usr.sbin/tprof/tprof.c:1.20 --- src/usr.sbin/tprof/tprof.c:1.19 Mon Dec 26 03:25:55 2022 +++ src/usr.sbin/tprof/tprof.c Mon Dec 26 08:00:13 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof.c,v 1.19 2022/12/26 03:25:55 ryoon Exp $ */ +/* $NetBSD: tprof.c,v 1.20 2022/12/26 08:00:13 ryo Exp $ */ /* * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ #include #ifndef lint -__RCSID("$NetBSD: tprof.c,v 1.19 2022/12/26 03:25:55 ryoon Exp $"); +__RCSID("$NetBSD: tprof.c,v 1.20 2022/12/26 08:00:13 ryo Exp $"); #endif /* not lint */ #include @@ -310,6 +310,7 @@ tprof_parse_event(tprof_param_t *param, "invalid option: '%c'", *opt); goto done; } + opt++; } } else if (allow_option) { param->p_flags |= TPROF_PARAM_USER;
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Mon Dec 26 08:00:13 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof.c Log Message: fixed parsing of event options. if event option was specivied, it was stuck in a busy loop. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/tprof/tprof.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/tprof
Module Name:src Committed By: ryo Date: Thu Dec 22 06:59:33 UTC 2022 Modified Files: src/sys/dev/tprof: tprof_armv7.c tprof_armv8.c Log Message: Even if an overflow interrupt is occured for a counter outside tprof management, the bit of onverflow status register must be cleared to prevent an interrupt storm. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/tprof/tprof_armv7.c cvs rdiff -u -r1.18 -r1.19 src/sys/dev/tprof/tprof_armv8.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/tprof/tprof_armv7.c diff -u src/sys/dev/tprof/tprof_armv7.c:1.11 src/sys/dev/tprof/tprof_armv7.c:1.12 --- src/sys/dev/tprof/tprof_armv7.c:1.11 Sat Dec 3 20:24:21 2022 +++ src/sys/dev/tprof/tprof_armv7.c Thu Dec 22 06:59:32 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_armv7.c,v 1.11 2022/12/03 20:24:21 ryo Exp $ */ +/* $NetBSD: tprof_armv7.c,v 1.12 2022/12/22 06:59:32 ryo Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tprof_armv7.c,v 1.11 2022/12/03 20:24:21 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tprof_armv7.c,v 1.12 2022/12/22 06:59:32 ryo Exp $"); #include #include @@ -225,7 +225,7 @@ armv7_pmu_intr(void *priv) tprof_backend_softc_t *sc = pmu_intr_arg; tprof_frame_info_t tfi; int bit; - const uint32_t pmovs = armreg_pmovsr_read() & PMOVS_P; + const uint32_t pmovs = armreg_pmovsr_read(); uint64_t *counters_offset = percpu_getptr_remote(sc->sc_ctr_offset_percpu, curcpu()); @@ -248,7 +248,7 @@ armv7_pmu_intr(void *priv) tfi.tfi_pc >= VM_MIN_KERNEL_ADDRESS && tfi.tfi_pc < VM_MAX_KERNEL_ADDRESS; tprof_sample(NULL, ); - } else { + } else if (ISSET(sc->sc_ctr_ovf_mask, __BIT(bit))) { /* counter has overflowed */ counters_offset[bit] += __BIT(32); } Index: src/sys/dev/tprof/tprof_armv8.c diff -u src/sys/dev/tprof/tprof_armv8.c:1.18 src/sys/dev/tprof/tprof_armv8.c:1.19 --- src/sys/dev/tprof/tprof_armv8.c:1.18 Thu Dec 1 00:32:52 2022 +++ src/sys/dev/tprof/tprof_armv8.c Thu Dec 22 06:59:32 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_armv8.c,v 1.18 2022/12/01 00:32:52 ryo Exp $ */ +/* $NetBSD: tprof_armv8.c,v 1.19 2022/12/22 06:59:32 ryo Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tprof_armv8.c,v 1.18 2022/12/01 00:32:52 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tprof_armv8.c,v 1.19 2022/12/22 06:59:32 ryo Exp $"); #include #include @@ -197,7 +197,7 @@ armv8_pmu_intr(void *priv) tprof_backend_softc_t *sc = pmu_intr_arg; tprof_frame_info_t tfi; int bit; - const uint32_t pmovs = reg_pmovsset_el0_read() & PMOVS_P; + const uint32_t pmovs = reg_pmovsset_el0_read(); uint64_t *counters_offset = percpu_getptr_remote(sc->sc_ctr_offset_percpu, curcpu()); @@ -220,7 +220,7 @@ armv8_pmu_intr(void *priv) tfi.tfi_pc >= VM_MIN_KERNEL_ADDRESS && tfi.tfi_pc < VM_MAX_KERNEL_ADDRESS; tprof_sample(NULL, ); - } else { + } else if (ISSET(sc->sc_ctr_ovf_mask, __BIT(bit))) { /* counter has overflowed */ counters_offset[bit] += __BIT(32); }
CVS commit: src/sys/dev/tprof
Module Name:src Committed By: ryo Date: Thu Dec 22 06:59:33 UTC 2022 Modified Files: src/sys/dev/tprof: tprof_armv7.c tprof_armv8.c Log Message: Even if an overflow interrupt is occured for a counter outside tprof management, the bit of onverflow status register must be cleared to prevent an interrupt storm. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/tprof/tprof_armv7.c cvs rdiff -u -r1.18 -r1.19 src/sys/dev/tprof/tprof_armv8.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/aarch64/aarch64
Module Name:src Committed By: ryo Date: Thu Dec 22 06:58:47 UTC 2022 Modified Files: src/sys/arch/aarch64/aarch64: cpu.c Log Message: PMCR_EL0.LC should be set. ARM deprecates use of PMCR_EL0.LC=0 To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sys/arch/aarch64/aarch64/cpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/aarch64/cpu.c diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.71 src/sys/arch/aarch64/aarch64/cpu.c:1.72 --- src/sys/arch/aarch64/aarch64/cpu.c:1.71 Thu Dec 22 06:58:07 2022 +++ src/sys/arch/aarch64/aarch64/cpu.c Thu Dec 22 06:58:47 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.71 2022/12/22 06:58:07 ryo Exp $ */ +/* $NetBSD: cpu.c,v 1.72 2022/12/22 06:58:47 ryo Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.71 2022/12/22 06:58:07 ryo Exp $"); +__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.72 2022/12/22 06:58:47 ryo Exp $"); #include "locators.h" #include "opt_arm_debug.h" @@ -498,7 +498,7 @@ cpu_init_counter(struct cpu_info *ci) return; } - reg_pmcr_el0_write(PMCR_E | PMCR_C); + reg_pmcr_el0_write(PMCR_E | PMCR_C | PMCR_LC); reg_pmintenclr_el1_write(PMINTEN_C | PMINTEN_P); reg_pmcntenset_el0_write(PMCNTEN_C);
CVS commit: src/sys/arch/aarch64/aarch64
Module Name:src Committed By: ryo Date: Thu Dec 22 06:58:47 UTC 2022 Modified Files: src/sys/arch/aarch64/aarch64: cpu.c Log Message: PMCR_EL0.LC should be set. ARM deprecates use of PMCR_EL0.LC=0 To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sys/arch/aarch64/aarch64/cpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch
Module Name:src Committed By: ryo Date: Thu Dec 22 06:58:08 UTC 2022 Modified Files: src/sys/arch/aarch64/aarch64: cpu.c src/sys/arch/arm/arm: cpufunc.c src/sys/arch/arm/arm32: arm32_boot.c Log Message: Explicitly disable overflow interrupts before enabling the cycle counter. To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/sys/arch/aarch64/aarch64/cpu.c cvs rdiff -u -r1.184 -r1.185 src/sys/arch/arm/arm/cpufunc.c cvs rdiff -u -r1.44 -r1.45 src/sys/arch/arm/arm32/arm32_boot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/aarch64/cpu.c diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.70 src/sys/arch/aarch64/aarch64/cpu.c:1.71 --- src/sys/arch/aarch64/aarch64/cpu.c:1.70 Sun May 29 16:14:41 2022 +++ src/sys/arch/aarch64/aarch64/cpu.c Thu Dec 22 06:58:07 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.70 2022/05/29 16:14:41 ryo Exp $ */ +/* $NetBSD: cpu.c,v 1.71 2022/12/22 06:58:07 ryo Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.70 2022/05/29 16:14:41 ryo Exp $"); +__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.71 2022/12/22 06:58:07 ryo Exp $"); #include "locators.h" #include "opt_arm_debug.h" @@ -499,6 +499,7 @@ cpu_init_counter(struct cpu_info *ci) } reg_pmcr_el0_write(PMCR_E | PMCR_C); + reg_pmintenclr_el1_write(PMINTEN_C | PMINTEN_P); reg_pmcntenset_el0_write(PMCNTEN_C); const uint32_t prev = cpu_counter32(); Index: src/sys/arch/arm/arm/cpufunc.c diff -u src/sys/arch/arm/arm/cpufunc.c:1.184 src/sys/arch/arm/arm/cpufunc.c:1.185 --- src/sys/arch/arm/arm/cpufunc.c:1.184 Mon May 16 07:07:17 2022 +++ src/sys/arch/arm/arm/cpufunc.c Thu Dec 22 06:58:07 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.c,v 1.184 2022/05/16 07:07:17 skrll Exp $ */ +/* $NetBSD: cpufunc.c,v 1.185 2022/12/22 06:58:07 ryo Exp $ */ /* * arm7tdmi support code Copyright (c) 2001 John Fremlin @@ -49,7 +49,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.184 2022/05/16 07:07:17 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.185 2022/12/22 06:58:07 ryo Exp $"); #include "opt_arm_start.h" #include "opt_compat_netbsd.h" @@ -1964,6 +1964,7 @@ set_cpufuncs(void) * Start and reset the PMC Cycle Counter. */ armreg_pmcr_write(ARM11_PMCCTL_E | ARM11_PMCCTL_P | ARM11_PMCCTL_C); + armreg_pmintenclr_write(PMINTEN_C | PMINTEN_P); armreg_pmcntenset_write(CORTEX_CNTENS_C); return 0; } Index: src/sys/arch/arm/arm32/arm32_boot.c diff -u src/sys/arch/arm/arm32/arm32_boot.c:1.44 src/sys/arch/arm/arm32/arm32_boot.c:1.45 --- src/sys/arch/arm/arm32/arm32_boot.c:1.44 Sun Oct 31 16:23:47 2021 +++ src/sys/arch/arm/arm32/arm32_boot.c Thu Dec 22 06:58:08 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: arm32_boot.c,v 1.44 2021/10/31 16:23:47 skrll Exp $ */ +/* $NetBSD: arm32_boot.c,v 1.45 2022/12/22 06:58:08 ryo Exp $ */ /* * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved. @@ -122,7 +122,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: arm32_boot.c,v 1.44 2021/10/31 16:23:47 skrll Exp $"); +__KERNEL_RCSID(1, "$NetBSD: arm32_boot.c,v 1.45 2022/12/22 06:58:08 ryo Exp $"); #include "opt_arm_debug.h" #include "opt_cputypes.h" @@ -407,6 +407,7 @@ cpu_hatch(struct cpu_info *ci, u_int cpu * Start and reset the PMC Cycle Counter. */ armreg_pmcr_write(ARM11_PMCCTL_E|ARM11_PMCCTL_P|ARM11_PMCCTL_C); + armreg_pmintenclr_write(PMINTEN_C | PMINTEN_P); armreg_pmcntenset_write(CORTEX_CNTENS_C); } #endif
CVS commit: src/sys/arch
Module Name:src Committed By: ryo Date: Thu Dec 22 06:58:08 UTC 2022 Modified Files: src/sys/arch/aarch64/aarch64: cpu.c src/sys/arch/arm/arm: cpufunc.c src/sys/arch/arm/arm32: arm32_boot.c Log Message: Explicitly disable overflow interrupts before enabling the cycle counter. To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/sys/arch/aarch64/aarch64/cpu.c cvs rdiff -u -r1.184 -r1.185 src/sys/arch/arm/arm/cpufunc.c cvs rdiff -u -r1.44 -r1.45 src/sys/arch/arm/arm32/arm32_boot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/tprof
Module Name:src Committed By: ryo Date: Fri Dec 16 17:38:56 UTC 2022 Modified Files: src/sys/dev/tprof: tprof.c Log Message: tprof_lock is not a spin mutex. use mutex_{enter,exit}(). oops To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/dev/tprof/tprof.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/tprof/tprof.c diff -u src/sys/dev/tprof/tprof.c:1.21 src/sys/dev/tprof/tprof.c:1.22 --- src/sys/dev/tprof/tprof.c:1.21 Fri Dec 16 07:59:42 2022 +++ src/sys/dev/tprof/tprof.c Fri Dec 16 17:38:56 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof.c,v 1.21 2022/12/16 07:59:42 ryo Exp $ */ +/* $NetBSD: tprof.c,v 1.22 2022/12/16 17:38:56 ryo Exp $ */ /*- * Copyright (c)2008,2009,2010 YAMAMOTO Takashi, @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tprof.c,v 1.21 2022/12/16 07:59:42 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tprof.c,v 1.22 2022/12/16 17:38:56 ryo Exp $"); #include #include @@ -885,9 +885,9 @@ tprof_poll(dev_t dev, int events, struct static void filt_tprof_read_detach(struct knote *kn) { - mutex_spin_enter(_lock); + mutex_enter(_lock); selremove_knote(_selp, kn); - mutex_spin_exit(_lock); + mutex_exit(_lock); } static int @@ -896,7 +896,7 @@ filt_tprof_read_event(struct knote *kn, int rv = 0; if ((hint & NOTE_SUBMIT) == 0) - mutex_spin_enter(_lock); + mutex_enter(_lock); if (!STAILQ_EMPTY(_list)) { tprof_buf_t *buf; @@ -911,7 +911,7 @@ filt_tprof_read_event(struct knote *kn, } if ((hint & NOTE_SUBMIT) == 0) - mutex_spin_exit(_lock); + mutex_exit(_lock); return rv; } @@ -929,9 +929,9 @@ tprof_kqfilter(dev_t dev, struct knote * switch (kn->kn_filter) { case EVFILT_READ: kn->kn_fop = _read_filtops; - mutex_spin_enter(_lock); + mutex_enter(_lock); selrecord_knote(_selp, kn); - mutex_spin_exit(_lock); + mutex_exit(_lock); break; default: return EINVAL;
CVS commit: src/sys/dev/tprof
Module Name:src Committed By: ryo Date: Fri Dec 16 17:38:56 UTC 2022 Modified Files: src/sys/dev/tprof: tprof.c Log Message: tprof_lock is not a spin mutex. use mutex_{enter,exit}(). oops To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/dev/tprof/tprof.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/tprof
_PARAM_KERN; + } + + if (scale != NULL) { + if (*scale == '=') { + scale++; + n = strtoull(scale, , 0); + if (*p != '\0') { +error = -1; + } else { +param->p_value2 = n; +param->p_flags |= +TPROF_PARAM_VALUE2_TRIGGERCOUNT; + } + } else { + if (strncasecmp("0x", scale, 2) == 0) +d = strtol(scale, , 0); + else +d = strtod(scale, ); + if (*p != '\0' || d <= 0) { +error = -1; + } else { +param->p_value2 = 0x1ULL / d; +param->p_flags |= TPROF_PARAM_VALUE2_SCALE; + } + } + + if (error != 0) { + snprintf(errmsgbuf, sizeof(errmsgbuf), + "invalid scale: %s", scale); + goto done; + } + } + + done: + if (eventnamep != NULL) + *eventnamep = event; + if (error != 0 && errmsgp != NULL) + *errmsgp = errmsgbuf; + return error; +} + static void tprof_monitor_common(bool do_profile, int argc, char **argv) { @@ -273,7 +364,7 @@ tprof_monitor_common(bool do_profile, in pid_t pid; pthread_t pt; int ret, ch, i; - char *tokens[2], *p; + char *p, *errmsg; tprof_countermask_t mask = TPROF_COUNTERMASK_ALL; memset(params, 0, sizeof(params)); @@ -290,23 +381,12 @@ tprof_monitor_common(bool do_profile, in optarg); break; case 'e': - p = estrdup(optarg); - tokens[0] = strtok(p, ":"); - tokens[1] = strtok(NULL, ":"); - tprof_event_lookup(tokens[0], [nevent]); - - if (tokens[1] == NULL) { -params[nevent].p_flags |= -(TPROF_PARAM_USER | TPROF_PARAM_KERN); - } else { -if (strchr(tokens[1], 'u')) - params[nevent].p_flags |= - TPROF_PARAM_USER; -if (strchr(tokens[1], 'k')) - params[nevent].p_flags |= - TPROF_PARAM_KERN; + if (tprof_parse_event([nevent], optarg, + TPROF_PARSE_EVENT_F_ALLOWOPTION | + (do_profile ? TPROF_PARSE_EVENT_F_ALLOWSCALE : 0), + [nevent], ) != 0) { +errx(EXIT_FAILURE, "%s", errmsg); } - eventname[nevent] = tokens[0]; eventnamewidth[nevent] = strlen(eventname[nevent]); if (eventnamewidth[nevent] < COUNTER_COLUMNS_WIDTH) eventnamewidth[nevent] = COUNTER_COLUMNS_WIDTH; Index: src/usr.sbin/tprof/tprof.h diff -u src/usr.sbin/tprof/tprof.h:1.3 src/usr.sbin/tprof/tprof.h:1.4 --- src/usr.sbin/tprof/tprof.h:1.3 Thu Dec 1 00:43:27 2022 +++ src/usr.sbin/tprof/tprof.h Fri Dec 16 08:02:04 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof.h,v 1.3 2022/12/01 00:43:27 ryo Exp $ */ +/* $NetBSD: tprof.h,v 1.4 2022/12/16 08:02:04 ryo Exp $ */ /* * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -38,5 +38,10 @@ int tprof_event_init(uint32_t); void tprof_event_list(void); void tprof_event_lookup(const char *, struct tprof_param *); +int tprof_parse_event(tprof_param_t *, const char *, uint32_t, const char **, +char **); +#define TPROF_PARSE_EVENT_F_ALLOWOPTION 0x0001 +#define TPROF_PARSE_EVENT_F_ALLOWSCALE 0x0002 + void tprof_analyze(int, char **); void tprof_top(int, char **); Index: src/usr.sbin/tprof/tprof_top.c diff -u src/usr.sbin/tprof/tprof_top.c:1.6 src/usr.sbin/tprof/tprof_top.c:1.7 --- src/usr.sbin/tprof/tprof_top.c:1.6 Fri Dec 16 08:00:47 2022 +++ src/usr.sbin/tprof/tprof_top.c Fri Dec 16 08:02:04 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_top.c,v 1.6 2022/12/16 08:00:47 ryo Exp $ */ +/* $NetBSD: tprof_top.c,v 1.7 2022/12/16 08:02:04 ryo Exp $ */ /*- * Copyright (c) 2022 Ryo Shimizu @@ -28,7 +28,7 @@ #include #ifndef lint -__RCSID("$NetBSD: tprof_top.c,v 1.6 2022/12/16 08:00:47 ryo Exp $"); +__RCSID("$NetBSD: tprof_top.c,v 1.7 2022/12/16 08:02:04 ryo Exp $"); #endif /* not lint */ #include @@ -919,33 +919,6 @@ tprof_top_usage(void) exit(EXIT_FAILURE); } -static int -parse_event_scale(tprof_param_t *param, const char *str) -{ - double d; - uint64_t n; - char *p; - - if (str[0] == '=') { - str++; - n = strtoull(str, , 0); - if (*p != '\0') - return -1; - param->p_value2 = n; - param->p_flags |= TPROF_PARAM_VALUE2_TRIGGERCOUNT; - } else { - if (strncasecmp("0x", str, 2) == 0) - d = strtol(str, , 0); - else - d = strtod(str, ); - if (*p != '\0') - return -1; - param->p_value2 = 0x1ULL / d; - param->p_flags |= TPROF_PARAM_VALUE2_SCALE; - } - return 0; -} - __dead void tprof_top(int argc, char **argv) { @@ -954,7 +927,7 @@ tprof_top(int argc, char **argv) ssize_t tprof_bufsize, len; u_int i; int ch, ret; - char *tprof_buf, *tokens[2], *p; + char *tprof_buf, *p, *errmsg; bool noinput = false; memset(params, 0, sizeof(params)); @@ -969,18 +942,11 @@ tprof_top(int argc, char **argv) opt_showcounter = 1; break; case 'e': - p = estrdup(optarg); - tokens[0] = strtok(p, ","); - tokens[1] = strtok(NULL, ","); - tprof_event_lookup(tokens[0], [nevent]); - if (tokens[1] != NULL) { -if (parse_event_scale([nevent], -tokens[1]) != 0) { - die_errc(EXIT_FAILURE, 0, - "invalid sc
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Fri Dec 16 08:02:04 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof.8 tprof.c tprof.h tprof_top.c Log Message: the "scale" option can be specified in the event name even in "tprof monitor" To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/tprof/tprof.8 cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/tprof/tprof.c cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/tprof/tprof.h cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/tprof/tprof_top.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Fri Dec 16 08:00:48 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof.8 tprof_top.c Log Message: - added 'c' command to tprof-top to show/hide event counter. - column widths were not calculated correctly and sometimes displayed incorrectly. - use putp() for terminfo str. - fix build error with llvm. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/tprof/tprof.8 cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/tprof/tprof_top.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/tprof/tprof.8 diff -u src/usr.sbin/tprof/tprof.8:1.22 src/usr.sbin/tprof/tprof.8:1.23 --- src/usr.sbin/tprof/tprof.8:1.22 Fri Dec 9 01:59:51 2022 +++ src/usr.sbin/tprof/tprof.8 Fri Dec 16 08:00:47 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: tprof.8,v 1.22 2022/12/09 01:59:51 ryo Exp $ +.\" $NetBSD: tprof.8,v 1.23 2022/12/16 08:00:47 ryo Exp $ .\" .\" Copyright (c)2011 YAMAMOTO Takashi, .\" All rights reserved. @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd December 9, 2022 +.Dd December 16, 2022 .Dt TPROF 8 .Os .Sh NAME @@ -175,6 +175,8 @@ These commands are currently recognized: .Bl -tag -width XXcommandsX -offset indent .It Ic a toggle accumurative mode. +.It Ic c +shows/hides the event counters. .It Ic q quit .Nm . Index: src/usr.sbin/tprof/tprof_top.c diff -u src/usr.sbin/tprof/tprof_top.c:1.5 src/usr.sbin/tprof/tprof_top.c:1.6 --- src/usr.sbin/tprof/tprof_top.c:1.5 Fri Dec 9 02:19:07 2022 +++ src/usr.sbin/tprof/tprof_top.c Fri Dec 16 08:00:47 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_top.c,v 1.5 2022/12/09 02:19:07 ryo Exp $ */ +/* $NetBSD: tprof_top.c,v 1.6 2022/12/16 08:00:47 ryo Exp $ */ /*- * Copyright (c) 2022 Ryo Shimizu @@ -28,7 +28,7 @@ #include #ifndef lint -__RCSID("$NetBSD: tprof_top.c,v 1.5 2022/12/09 02:19:07 ryo Exp $"); +__RCSID("$NetBSD: tprof_top.c,v 1.6 2022/12/16 08:00:47 ryo Exp $"); #endif /* not lint */ #include @@ -154,10 +154,10 @@ reset_cursor_pos(void) /* cursor_up * n */ if ((p = tigetstr("cuu")) != NULL) { - printf("%s", tparm(p, win.ws_row - 1, 0, 0, 0, 0, 0, 0, 0, 0)); + putp(tparm(p, win.ws_row - 1, 0, 0, 0, 0, 0, 0, 0, 0)); } else if ((p = tigetstr("cuu1")) != NULL) { for (i = win.ws_row - 1; i > 0; i--) - printf("%s", p); + putp(p); } } @@ -170,7 +170,7 @@ clr_to_eol(void) return; if ((p = tigetstr("el")) != NULL) - printf("%s", p); + putp(p); } /* newline, and clearing to end of line if needed */ @@ -288,7 +288,7 @@ sigalrm_handler(int signo) sigalrm = 1; } -static void +__dead static void die(int signo) { tty_restore(); @@ -297,7 +297,7 @@ die(int signo) exit(EXIT_SUCCESS); } -static void __dead +__dead static void die_errc(int status, int code, const char *fmt, ...) { va_list ap; @@ -676,20 +676,21 @@ show_count_per_event(int *lim) do_redraw = true; } } - for (i = 0; i < nevent; i++) { - for (n = 0; n < ncpu; n++) { - l = snprintf(buf, sizeof(buf), "%"PRIu64, - sample_n_per_event_cpu[opt_mode][nevent * n + i]); - if (sample_cpu_width[n] < (u_int)l) { -sample_cpu_width[n] = l; -do_redraw = true; - } + for (n = 0; n < ncpu; n++) { + uint64_t sum = 0; + for (i = 0; i < nevent; i++) + sum += sample_n_per_event_cpu[opt_mode][nevent * n + i]; + l = snprintf(buf, sizeof(buf), "%"PRIu64, sum); + if (sample_cpu_width[n] < (u_int)l) { + sample_cpu_width[n] = l; + do_redraw = true; } } if (do_redraw) { - lim_printf(lim, " Rate %*s Eventname ", - sample_event_width, "Sample#"); + lim_printf(lim, " Rate %*s %-*s", + sample_event_width, "Sample#", + SYMBOL_LEN, "Eventname"); for (n = 0; n < ncpu; n++) { snprintf(buf, sizeof(buf), "CPU%d", n); lim_printf(lim, " %*s", sample_cpu_width[n], buf); @@ -796,8 +797,9 @@ sample_show(void) lim_newline(); if (do_redraw) { - lim_printf(, " Rate %*s Symbol ", - sample_event_width, "Sample#"); + lim_printf(, " Rate %*s %-*s", + sample_event_width, "Sample#", + SYMBOL_LEN, "Symbol"); for (n = 0; n < ncpu; n++) { snprintf(namebuf, sizeof(namebuf), "CPU%d", n); lim_printf(, " %*s", sample_cpu_width[n], namebuf); @@ -944,7 +946,7 @@ parse_event_scale(tprof_param_t *param, return 0; } -void +__dead void tprof_top(int argc, char **argv) { tprof_param_t params[TPROF_MAXCOUNTERS]; @@ -1046,12 +1048,12 @@ tprof_top(int argc, char **argv) printf("collecting samples...");
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Fri Dec 16 08:00:48 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof.8 tprof_top.c Log Message: - added 'c' command to tprof-top to show/hide event counter. - column widths were not calculated correctly and sometimes displayed incorrectly. - use putp() for terminfo str. - fix build error with llvm. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/tprof/tprof.8 cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/tprof/tprof_top.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/tprof
Module Name:src Committed By: ryo Date: Fri Dec 16 07:59:42 UTC 2022 Modified Files: src/sys/dev/tprof: tprof.c Log Message: - Add support select(2)/poll(2) on /dev/tprof. - Changed sampling buffer switching frequency (which is the frequency of tprof_worker() calls and also the maximum block time of read(2) of /dev/tprof) from 1sec to 125ms. This improve tprof top responsiveness. - The maximum number of sampling buffers is now adjusted according to the number of CPUs. Previously it was fixed at 100 and was insufficient if ncpu was greater than this. The maximum number of samples per second per CPU is calculated by "TPROF_MAX_SAMPLES_PER_BUF * (HZ of tprof_worker)". Therefore, currently, 1 * (1000/125) = 8 maximum samplings per CPU. The actual value will vary slightly from this due to tprof_worker and read(2) timing. This value may need to be adjusted more in the future. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/dev/tprof/tprof.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/tprof
Module Name:src Committed By: ryo Date: Fri Dec 16 07:59:42 UTC 2022 Modified Files: src/sys/dev/tprof: tprof.c Log Message: - Add support select(2)/poll(2) on /dev/tprof. - Changed sampling buffer switching frequency (which is the frequency of tprof_worker() calls and also the maximum block time of read(2) of /dev/tprof) from 1sec to 125ms. This improve tprof top responsiveness. - The maximum number of sampling buffers is now adjusted according to the number of CPUs. Previously it was fixed at 100 and was insufficient if ncpu was greater than this. The maximum number of samples per second per CPU is calculated by "TPROF_MAX_SAMPLES_PER_BUF * (HZ of tprof_worker)". Therefore, currently, 1 * (1000/125) = 8 maximum samplings per CPU. The actual value will vary slightly from this due to tprof_worker and read(2) timing. This value may need to be adjusted more in the future. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/dev/tprof/tprof.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/tprof/tprof.c diff -u src/sys/dev/tprof/tprof.c:1.20 src/sys/dev/tprof/tprof.c:1.21 --- src/sys/dev/tprof/tprof.c:1.20 Sun Dec 11 01:36:49 2022 +++ src/sys/dev/tprof/tprof.c Fri Dec 16 07:59:42 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof.c,v 1.20 2022/12/11 01:36:49 chs Exp $ */ +/* $NetBSD: tprof.c,v 1.21 2022/12/16 07:59:42 ryo Exp $ */ /*- * Copyright (c)2008,2009,2010 YAMAMOTO Takashi, @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tprof.c,v 1.20 2022/12/11 01:36:49 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tprof.c,v 1.21 2022/12/16 07:59:42 ryo Exp $"); #include #include @@ -39,8 +39,10 @@ __KERNEL_RCSID(0, "$NetBSD: tprof.c,v 1. #include #include #include +#include #include #include +#include #include #include @@ -78,9 +80,7 @@ typedef struct tprof_buf { } tprof_buf_t; #define TPROF_BUF_BYTESIZE(sz) \ (sizeof(tprof_buf_t) + (sz) * sizeof(tprof_sample_t)) -#define TPROF_MAX_SAMPLES_PER_BUF (TPROF_HZ * 2) - -#define TPROF_MAX_BUF 100 +#define TPROF_MAX_SAMPLES_PER_BUF TPROF_HZ typedef struct { tprof_buf_t *c_buf; @@ -111,6 +111,7 @@ static u_int tprof_nbuf_on_list; /* L: # static struct workqueue *tprof_wq; static struct percpu *tprof_cpus __read_mostly; /* tprof_cpu_t * */ static u_int tprof_samples_per_buf; +static u_int tprof_max_buf; tprof_backend_t *tprof_backend; /* S: */ static LIST_HEAD(, tprof_backend) tprof_backends = @@ -122,6 +123,7 @@ static off_t tprof_reader_offset; /* R: static kmutex_t tprof_startstop_lock; static kcondvar_t tprof_cv; /* L: */ +static struct selinfo tprof_selp; /* L: */ static struct tprof_stat tprof_stat; /* L: */ @@ -229,13 +231,14 @@ tprof_worker(struct work *wk, void *dumm } if (buf->b_used == 0) { tprof_stat.ts_emptybuf++; - } else if (tprof_nbuf_on_list < TPROF_MAX_BUF) { + } else if (tprof_nbuf_on_list < tprof_max_buf) { tprof_stat.ts_sample += buf->b_used; tprof_stat.ts_overflow += buf->b_overflow; tprof_stat.ts_buf++; STAILQ_INSERT_TAIL(_list, buf, b_list); tprof_nbuf_on_list++; buf = NULL; + selnotify(_selp, 0, NOTE_SUBMIT); cv_broadcast(_reader_cv); } else { tprof_stat.ts_dropbuf_sample += buf->b_used; @@ -246,7 +249,7 @@ tprof_worker(struct work *wk, void *dumm tprof_buf_free(buf); } if (!shouldstop) { - callout_schedule(>c_callout, hz); + callout_schedule(>c_callout, hz / 8); } } @@ -364,6 +367,7 @@ tprof_start(tprof_countermask_t runmask) } tprof_samples_per_buf = TPROF_MAX_SAMPLES_PER_BUF; + tprof_max_buf = ncpu * 3; error = workqueue_create(_wq, "tprofmv", tprof_worker, NULL, PRI_NONE, IPL_SOFTCLOCK, WQ_MPSAFE | WQ_PERCPU); if (error != 0) { @@ -860,12 +864,89 @@ tprof_close(dev_t dev, int flags, int ty } static int +tprof_poll(dev_t dev, int events, struct lwp *l) +{ + int revents; + + revents = events & (POLLIN | POLLRDNORM); + if (revents == 0) + return 0; + + mutex_enter(_lock); + if (STAILQ_EMPTY(_list)) { + revents = 0; + selrecord(l, _selp); + } + mutex_exit(_lock); + + return revents; +} + +static void +filt_tprof_read_detach(struct knote *kn) +{ + mutex_spin_enter(_lock); + selremove_knote(_selp, kn); + mutex_spin_exit(_lock); +} + +static int +filt_tprof_read_event(struct knote *kn, long hint) +{ + int rv = 0; + + if ((hint & NOTE_SUBMIT) == 0) + mutex_spin_enter(_lock); + + if (!STAILQ_EMPTY(_list)) { + tprof_buf_t *buf; + int64_t n = 0; + + STAILQ_FOREACH(buf, _list, b_list) { + n += buf->b_used; + } + kn->kn_data = n * sizeof(tprof_sample_t); + + rv = 1; + } + + if ((hint & NOTE_SUBMIT) == 0) + mutex_spin_exit(_lock); + + return rv; +} + +static const struct filterops tprof_read_filtops = { + .f_flags = FILTEROP_ISFD | FILTEROP_MPSAFE, + .f_attach = NULL, + .f_detach = filt_tprof_read_detach, + .f_event = filt_tprof_read_event, +}; +
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Fri Dec 9 02:19:07 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof_top.c Log Message: if column width changes, the screen must be updated. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/tprof/tprof_top.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/tprof/tprof_top.c diff -u src/usr.sbin/tprof/tprof_top.c:1.4 src/usr.sbin/tprof/tprof_top.c:1.5 --- src/usr.sbin/tprof/tprof_top.c:1.4 Fri Dec 9 01:56:40 2022 +++ src/usr.sbin/tprof/tprof_top.c Fri Dec 9 02:19:07 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_top.c,v 1.4 2022/12/09 01:56:40 ryo Exp $ */ +/* $NetBSD: tprof_top.c,v 1.5 2022/12/09 02:19:07 ryo Exp $ */ /*- * Copyright (c) 2022 Ryo Shimizu @@ -28,7 +28,7 @@ #include #ifndef lint -__RCSID("$NetBSD: tprof_top.c,v 1.4 2022/12/09 01:56:40 ryo Exp $"); +__RCSID("$NetBSD: tprof_top.c,v 1.5 2022/12/09 02:19:07 ryo Exp $"); #endif /* not lint */ #include @@ -671,15 +671,19 @@ show_count_per_event(int *lim) for (i = 0; i < nevent; i++) { l = snprintf(buf, sizeof(buf), "%"PRIu64, sample_n_per_event[opt_mode][i]); - if (sample_event_width < (u_int)l) + if (sample_event_width < (u_int)l) { sample_event_width = l; + do_redraw = true; + } } for (i = 0; i < nevent; i++) { for (n = 0; n < ncpu; n++) { l = snprintf(buf, sizeof(buf), "%"PRIu64, sample_n_per_event_cpu[opt_mode][nevent * n + i]); - if (sample_cpu_width[n] < (u_int)l) + if (sample_cpu_width[n] < (u_int)l) { sample_cpu_width[n] = l; +do_redraw = true; + } } }
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Fri Dec 9 02:19:07 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof_top.c Log Message: if column width changes, the screen must be updated. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/tprof/tprof_top.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/doc
Module Name:src Committed By: ryo Date: Fri Dec 9 02:01:09 UTC 2022 Modified Files: src/doc: CHANGES Log Message: fix typo To generate a diff of this commit: cvs rdiff -u -r1.2935 -r1.2936 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2935 src/doc/CHANGES:1.2936 --- src/doc/CHANGES:1.2935 Thu Dec 8 06:30:15 2022 +++ src/doc/CHANGES Fri Dec 9 02:01:09 2022 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2935 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2936 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -750,7 +750,7 @@ Changes from NetBSD 9.0 to NetBSD 10.0: ifconfig(8): Allow configuration of interfaces as explicitly unnumbered. [knakahara 20221125] tprof: Revamped tprof(4), and multiple event counters can be - referenced with tprof(8). Add some improvements to prof(8). + referenced with tprof(8). Add some improvements to tprof(8). [ryo 20221201] tprof: Add AMD family 19h (zen3 and zen4) support to tprof(4) and tprof(8). [msaitoh 20221208]
CVS commit: src/doc
Module Name:src Committed By: ryo Date: Fri Dec 9 02:01:09 UTC 2022 Modified Files: src/doc: CHANGES Log Message: fix typo To generate a diff of this commit: cvs rdiff -u -r1.2935 -r1.2936 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Fri Dec 9 01:59:51 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof.8 Log Message: supported AMD family added To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/tprof/tprof.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/tprof/tprof.8 diff -u src/usr.sbin/tprof/tprof.8:1.21 src/usr.sbin/tprof/tprof.8:1.22 --- src/usr.sbin/tprof/tprof.8:1.21 Fri Dec 9 01:56:40 2022 +++ src/usr.sbin/tprof/tprof.8 Fri Dec 9 01:59:51 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: tprof.8,v 1.21 2022/12/09 01:56:40 ryo Exp $ +.\" $NetBSD: tprof.8,v 1.22 2022/12/09 01:59:51 ryo Exp $ .\" .\" Copyright (c)2011 YAMAMOTO Takashi, .\" All rights reserved. @@ -202,6 +202,8 @@ x86 AMD Family 15h .It x86 AMD Family 17h .It +x86 AMD Family 19h +.It x86 Intel Generic (all Intel CPUs) .It x86 Intel Skylake/Kabylake
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Fri Dec 9 01:59:51 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof.8 Log Message: supported AMD family added To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/tprof/tprof.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Fri Dec 9 01:56:40 UTC 2022 Modified Files: src/usr.sbin/tprof: Makefile tprof.8 tprof_top.c Log Message: mainly fixes around display. - use terminfo - dynamically adjust column widths - mode can be changed while running To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/tprof/Makefile cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/tprof/tprof.8 cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/tprof/tprof_top.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Fri Dec 9 01:56:40 UTC 2022 Modified Files: src/usr.sbin/tprof: Makefile tprof.8 tprof_top.c Log Message: mainly fixes around display. - use terminfo - dynamically adjust column widths - mode can be changed while running To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/tprof/Makefile cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/tprof/tprof.8 cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/tprof/tprof_top.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/tprof/Makefile diff -u src/usr.sbin/tprof/Makefile:1.12 src/usr.sbin/tprof/Makefile:1.13 --- src/usr.sbin/tprof/Makefile:1.12 Thu Dec 1 00:43:27 2022 +++ src/usr.sbin/tprof/Makefile Fri Dec 9 01:56:40 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.12 2022/12/01 00:43:27 ryo Exp $ +# $NetBSD: Makefile,v 1.13 2022/12/09 01:56:40 ryo Exp $ .PATH: ${.CURDIR}/arch @@ -21,11 +21,15 @@ CPPFLAGS+= -I${NETBSDSRCDIR}/sys/ LDADD+= -lpthread LDADD+= -lm LDADD+= -lelf +LDADD+= -lterminfo LDADD+= -lutil DPADD+= ${LIBPTHREAD} DPADD+= ${LIBM} DPADD+= ${LIBELF} +DPADD+= ${LIBTERMINFO} DPADD+= ${LIBUTIL} +COPTS.tprof_top.c = -Wno-format-nonliteral + .include .include Index: src/usr.sbin/tprof/tprof.8 diff -u src/usr.sbin/tprof/tprof.8:1.20 src/usr.sbin/tprof/tprof.8:1.21 --- src/usr.sbin/tprof/tprof.8:1.20 Fri Dec 9 01:55:46 2022 +++ src/usr.sbin/tprof/tprof.8 Fri Dec 9 01:56:40 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: tprof.8,v 1.20 2022/12/09 01:55:46 ryo Exp $ +.\" $NetBSD: tprof.8,v 1.21 2022/12/09 01:56:40 ryo Exp $ .\" .\" Copyright (c)2011 YAMAMOTO Takashi, .\" All rights reserved. @@ -166,6 +166,21 @@ show the delta of the event counters. .It Fl u Userland processes are also included in the profiling. .El +.Pp +While +.Nm +.Ar top +is running, it accepts commands from the terminal. +These commands are currently recognized: +.Bl -tag -width XXcommandsX -offset indent +.It Ic a +toggle accumurative mode. +.It Ic q +quit +.Nm . +.It Ic z +clear accumulated data. +.El .El .Sh EXAMPLES The following command profiles the system during 20 seconds and writes the Index: src/usr.sbin/tprof/tprof_top.c diff -u src/usr.sbin/tprof/tprof_top.c:1.3 src/usr.sbin/tprof/tprof_top.c:1.4 --- src/usr.sbin/tprof/tprof_top.c:1.3 Fri Dec 9 01:55:46 2022 +++ src/usr.sbin/tprof/tprof_top.c Fri Dec 9 01:56:40 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_top.c,v 1.3 2022/12/09 01:55:46 ryo Exp $ */ +/* $NetBSD: tprof_top.c,v 1.4 2022/12/09 01:56:40 ryo Exp $ */ /*- * Copyright (c) 2022 Ryo Shimizu @@ -28,15 +28,17 @@ #include #ifndef lint -__RCSID("$NetBSD: tprof_top.c,v 1.3 2022/12/09 01:55:46 ryo Exp $"); +__RCSID("$NetBSD: tprof_top.c,v 1.4 2022/12/09 01:56:40 ryo Exp $"); #endif /* not lint */ #include #include -#include #include +#include +#include #include +#include #include #include #include @@ -46,6 +48,8 @@ __RCSID("$NetBSD: tprof_top.c,v 1.3 2022 #include #include #include +#include +#include #include #include @@ -57,6 +61,9 @@ __RCSID("$NetBSD: tprof_top.c,v 1.3 2022 #define SAMPLE_MODE_INSTANTANEOUS 1 #define SAMPLE_MODE_NUM 2 +#define LINESTR "-" +#define SYMBOL_LEN 32 /* symbol and event name */ + struct sample_elm { struct rb_node node; uint64_t addr; @@ -80,9 +87,14 @@ static int opt_userland = 0; static int opt_showcounter = 0; /* for display */ +static char *term; static struct winsize win; static int nontty; +static struct termios termios_save; +static bool termios_saved; static long top_interval = 1; +static bool do_redraw; +static u_int nshow; /* for profiling and counting samples */ static sig_atomic_t sigalrm; @@ -95,6 +107,8 @@ static rb_tree_t rb_tree_sample; struct ptrarray sample_list[SAMPLE_MODE_NUM]; static u_int sample_n_kern[SAMPLE_MODE_NUM]; static u_int sample_n_user[SAMPLE_MODE_NUM]; +static u_int sample_event_width = 7; +static u_int *sample_cpu_width; /* [ncpu] */ static uint32_t *sample_n_kern_per_cpu[SAMPLE_MODE_NUM]; /* [ncpu] */ static uint32_t *sample_n_user_per_cpu[SAMPLE_MODE_NUM]; /* [ncpu] */ static uint64_t *sample_n_per_event[SAMPLE_MODE_NUM]; /* [nevent] */ @@ -127,43 +141,145 @@ cycle_event_name(void) return cycleevent; } -/* XXX: use terminfo or curses */ static void -cursor_address(u_int x, u_int y) +reset_cursor_pos(void) { - if (nontty) + int i; + char *p; + + if (nontty || term == NULL) return; - printf("\e[%u;%uH", y - 1, x - 1); + + printf("\r"); + + /* cursor_up * n */ + if ((p = tigetstr("cuu")) != NULL) { + printf("%s", tparm(p, win.ws_row - 1, 0, 0, 0, 0, 0, 0, 0, 0)); + } else if ((p = tigetstr("cuu1")) != NULL) { + for (i = win.ws_row - 1; i > 0; i--) +
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Fri Dec 9 01:55:46 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof.8 tprof_top.c Log Message: add accumulative mode. "tprof top -a" To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/tprof/tprof.8 cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/tprof/tprof_top.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Fri Dec 9 01:55:46 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof.8 tprof_top.c Log Message: add accumulative mode. "tprof top -a" To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/tprof/tprof.8 cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/tprof/tprof_top.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/tprof/tprof.8 diff -u src/usr.sbin/tprof/tprof.8:1.19 src/usr.sbin/tprof/tprof.8:1.20 --- src/usr.sbin/tprof/tprof.8:1.19 Thu Dec 1 00:43:27 2022 +++ src/usr.sbin/tprof/tprof.8 Fri Dec 9 01:55:46 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: tprof.8,v 1.19 2022/12/01 00:43:27 ryo Exp $ +.\" $NetBSD: tprof.8,v 1.20 2022/12/09 01:55:46 ryo Exp $ .\" .\" Copyright (c)2011 YAMAMOTO Takashi, .\" All rights reserved. @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd December 1, 2022 +.Dd December 9, 2022 .Dt TPROF 8 .Os .Sh NAME @@ -137,8 +137,7 @@ Per symbol. .Op Fl e Ar ... .Oc .Op Fl i Ar interval -.Op Fl c -.Op Fl u +.Op Fl acu .Xc Displays profiling results in real-time. .Ar name @@ -158,6 +157,10 @@ is specified, profiling is performed eve .Bl -tag -width XXintervalX -offset indent .It Fl i Ar interval set the update interval in seconds. The default value is 1. +.It Fl a +Starts in accumulation mode. The display is updated every +.Ar interval +second, but the values are accumulative. .It Fl c show the delta of the event counters. .It Fl u @@ -226,7 +229,9 @@ utility was written by .An YAMAMOTO Takashi . It was revamped by .An Maxime Villard -in 2018. +in 2018, and by +.An Ryo Shimizu +in 2022. .Sh CAVEATS The contents and representation of recorded samples are undocumented and will likely be changed for future releases of Index: src/usr.sbin/tprof/tprof_top.c diff -u src/usr.sbin/tprof/tprof_top.c:1.2 src/usr.sbin/tprof/tprof_top.c:1.3 --- src/usr.sbin/tprof/tprof_top.c:1.2 Thu Dec 1 03:32:24 2022 +++ src/usr.sbin/tprof/tprof_top.c Fri Dec 9 01:55:46 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_top.c,v 1.2 2022/12/01 03:32:24 ryo Exp $ */ +/* $NetBSD: tprof_top.c,v 1.3 2022/12/09 01:55:46 ryo Exp $ */ /*- * Copyright (c) 2022 Ryo Shimizu @@ -28,7 +28,7 @@ #include #ifndef lint -__RCSID("$NetBSD: tprof_top.c,v 1.2 2022/12/01 03:32:24 ryo Exp $"); +__RCSID("$NetBSD: tprof_top.c,v 1.3 2022/12/09 01:55:46 ryo Exp $"); #endif /* not lint */ #include @@ -37,7 +37,6 @@ __RCSID("$NetBSD: tprof_top.c,v 1.2 2022 #include #include -#include #include #include #include @@ -54,14 +53,79 @@ __RCSID("$NetBSD: tprof_top.c,v 1.2 2022 #include "tprof.h" #include "ksyms.h" -static struct sym **ksyms; -static size_t nksyms; -static sig_atomic_t sigalrm; +#define SAMPLE_MODE_ACCUMULATIVE 0 +#define SAMPLE_MODE_INSTANTANEOUS 1 +#define SAMPLE_MODE_NUM 2 + +struct sample_elm { + struct rb_node node; + uint64_t addr; + const char *name; + uint32_t flags; +#define SAMPLE_ELM_FLAGS_USER 0x0001 + uint32_t num[SAMPLE_MODE_NUM]; + uint32_t num_cpu[]; /* [SAMPLE_MODE_NUM][ncpu] */ +#define SAMPLE_ELM_NUM_CPU(e, k) \ + ((e)->num_cpu + (k) * ncpu) +}; + +struct ptrarray { + void **pa_ptrs; + size_t pa_allocnum; + size_t pa_inuse; +}; + +static int opt_mode = SAMPLE_MODE_INSTANTANEOUS; +static int opt_userland = 0; +static int opt_showcounter = 0; + +/* for display */ static struct winsize win; +static int nontty; static long top_interval = 1; + +/* for profiling and counting samples */ +static sig_atomic_t sigalrm; +static struct sym **ksyms; +static size_t nksyms; static u_int nevent; static const char *eventname[TPROF_MAXCOUNTERS]; -static int nontty; +static size_t sizeof_sample_elm; +static rb_tree_t rb_tree_sample; +struct ptrarray sample_list[SAMPLE_MODE_NUM]; +static u_int sample_n_kern[SAMPLE_MODE_NUM]; +static u_int sample_n_user[SAMPLE_MODE_NUM]; +static uint32_t *sample_n_kern_per_cpu[SAMPLE_MODE_NUM]; /* [ncpu] */ +static uint32_t *sample_n_user_per_cpu[SAMPLE_MODE_NUM]; /* [ncpu] */ +static uint64_t *sample_n_per_event[SAMPLE_MODE_NUM]; /* [nevent] */ +static uint64_t *sample_n_per_event_cpu[SAMPLE_MODE_NUM]; /* [ncpu] */ + +/* raw event counter */ +static uint64_t *counters; /* counters[2][ncpu][nevent] */ +static u_int counters_i; + +static const char * +cycle_event_name(void) +{ + const char *cycleevent; + + switch (tprof_info.ti_ident) { + case TPROF_IDENT_INTEL_GENERIC: + cycleevent = "unhalted-core-cycles"; + break; + case TPROF_IDENT_AMD_GENERIC: + cycleevent = "LsNotHaltedCyc"; + break; + case TPROF_IDENT_ARMV8_GENERIC: + case TPROF_IDENT_ARMV7_GENERIC: + cycleevent = "CPU_CYCLES"; + break; + default: + cycleevent = NULL; + break; + } + return cycleeve
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Mon Dec 5 05:02:45 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof.c Log Message: fix build error with llvm To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/tprof/tprof.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/tprof/tprof.c diff -u src/usr.sbin/tprof/tprof.c:1.16 src/usr.sbin/tprof/tprof.c:1.17 --- src/usr.sbin/tprof/tprof.c:1.16 Thu Dec 1 00:43:27 2022 +++ src/usr.sbin/tprof/tprof.c Mon Dec 5 05:02:45 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof.c,v 1.16 2022/12/01 00:43:27 ryo Exp $ */ +/* $NetBSD: tprof.c,v 1.17 2022/12/05 05:02:45 ryo Exp $ */ /* * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ #include #ifndef lint -__RCSID("$NetBSD: tprof.c,v 1.16 2022/12/01 00:43:27 ryo Exp $"); +__RCSID("$NetBSD: tprof.c,v 1.17 2022/12/05 05:02:45 ryo Exp $"); #endif /* not lint */ #include @@ -98,8 +98,8 @@ u_int eventnamewidth[TPROF_MAXCOUNTERS]; static void tprof_list(int, char **); static void tprof_monitor_common(bool, int, char **) __dead; -static void tprof_monitor(int, char **); -static void tprof_count(int, char **); +static void tprof_monitor(int, char **) __dead; +static void tprof_count(int, char **) __dead; static struct cmdtab { const char *label;
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Mon Dec 5 05:02:45 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof.c Log Message: fix build error with llvm To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/tprof/tprof.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ryo Date: Sat Dec 3 20:24:21 UTC 2022 Modified Files: src/sys/arch/arm/include: armreg.h src/sys/dev/tprof: tprof_armv7.c Log Message: move ARMv7 PMC register definitions to armreg.h from tprof_armv7.c To generate a diff of this commit: cvs rdiff -u -r1.135 -r1.136 src/sys/arch/arm/include/armreg.h cvs rdiff -u -r1.10 -r1.11 src/sys/dev/tprof/tprof_armv7.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/include/armreg.h diff -u src/sys/arch/arm/include/armreg.h:1.135 src/sys/arch/arm/include/armreg.h:1.136 --- src/sys/arch/arm/include/armreg.h:1.135 Fri May 20 19:34:22 2022 +++ src/sys/arch/arm/include/armreg.h Sat Dec 3 20:24:21 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: armreg.h,v 1.135 2022/05/20 19:34:22 andvar Exp $ */ +/* $NetBSD: armreg.h,v 1.136 2022/12/03 20:24:21 ryo Exp $ */ /* * Copyright (c) 1998, 2001 Ben Harris @@ -485,6 +485,26 @@ #define ARM11_PMCEVT_RETURN_MISS 38 /* return addr. mispredicted */ #define ARM11_PMCEVT_CYCLE 255 /* Increment each cycle */ +/* ARMv7 PMCR, Performance Monitor Control Register */ +#define PMCR_N __BITS(15,11) +#define PMCR_D __BIT(3) +#define PMCR_E __BIT(0) + +/* ARMv7 INTEN{SET,CLR}, Performance Monitors Interrupt Enable Set register */ +#define PMINTEN_C __BIT(31) +#define PMINTEN_P __BITS(30,0) +#define PMCNTEN_C __BIT(31) +#define PMCNTEN_P __BITS(30,0) + +/* ARMv7 PMOVSR, Performance Monitors Overflow Flag Status Register */ +#define PMOVS_C __BIT(31) +#define PMOVS_P __BITS(30,0) + +/* ARMv7 PMXEVTYPER, Performance Monitors Event Type Select Register */ +#define PMEVTYPER_P __BIT(31) +#define PMEVTYPER_U __BIT(30) +#define PMEVTYPER_EVTCOUNT __BITS(7,0) + /* Defines for ARM CORTEX performance counters */ #define CORTEX_CNTENS_C __BIT(31) /* Enables the cycle counter */ #define CORTEX_CNTENC_C __BIT(31) /* Disables the cycle counter */ Index: src/sys/dev/tprof/tprof_armv7.c diff -u src/sys/dev/tprof/tprof_armv7.c:1.10 src/sys/dev/tprof/tprof_armv7.c:1.11 --- src/sys/dev/tprof/tprof_armv7.c:1.10 Thu Dec 1 00:32:52 2022 +++ src/sys/dev/tprof/tprof_armv7.c Sat Dec 3 20:24:21 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_armv7.c,v 1.10 2022/12/01 00:32:52 ryo Exp $ */ +/* $NetBSD: tprof_armv7.c,v 1.11 2022/12/03 20:24:21 ryo Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tprof_armv7.c,v 1.10 2022/12/01 00:32:52 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tprof_armv7.c,v 1.11 2022/12/03 20:24:21 ryo Exp $"); #include #include @@ -42,22 +42,6 @@ __KERNEL_RCSID(0, "$NetBSD: tprof_armv7. #include -#define PMCR_N __BITS(15,11) -#define PMCR_D __BIT(3) -#define PMCR_E __BIT(0) - -#define PMINTEN_C __BIT(31) -#define PMINTEN_P __BITS(30,0) -#define PMCNTEN_C __BIT(31) -#define PMCNTEN_P __BITS(30,0) - -#define PMOVS_C __BIT(31) -#define PMOVS_P __BITS(30,0) - -#define PMEVTYPER_P __BIT(31) -#define PMEVTYPER_U __BIT(30) -#define PMEVTYPER_EVTCOUNT __BITS(7,0) - static uint16_t cortexa9_events[] = { 0x40, 0x41, 0x42, 0x50, 0x51,
CVS commit: src/sys
Module Name:src Committed By: ryo Date: Sat Dec 3 20:24:21 UTC 2022 Modified Files: src/sys/arch/arm/include: armreg.h src/sys/dev/tprof: tprof_armv7.c Log Message: move ARMv7 PMC register definitions to armreg.h from tprof_armv7.c To generate a diff of this commit: cvs rdiff -u -r1.135 -r1.136 src/sys/arch/arm/include/armreg.h cvs rdiff -u -r1.10 -r1.11 src/sys/dev/tprof/tprof_armv7.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Thu Dec 1 03:32:24 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof_top.c Log Message: fix build error of printf format To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/tprof/tprof_top.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/tprof/tprof_top.c diff -u src/usr.sbin/tprof/tprof_top.c:1.1 src/usr.sbin/tprof/tprof_top.c:1.2 --- src/usr.sbin/tprof/tprof_top.c:1.1 Thu Dec 1 00:43:27 2022 +++ src/usr.sbin/tprof/tprof_top.c Thu Dec 1 03:32:24 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_top.c,v 1.1 2022/12/01 00:43:27 ryo Exp $ */ +/* $NetBSD: tprof_top.c,v 1.2 2022/12/01 03:32:24 ryo Exp $ */ /*- * Copyright (c) 2022 Ryo Shimizu @@ -28,7 +28,7 @@ #include #ifndef lint -__RCSID("$NetBSD: tprof_top.c,v 1.1 2022/12/01 00:43:27 ryo Exp $"); +__RCSID("$NetBSD: tprof_top.c,v 1.2 2022/12/01 03:32:24 ryo Exp $"); #endif /* not lint */ #include @@ -387,7 +387,7 @@ show_count_per_event(void) printf("%5.2f%%", sample_nsample_per_event[i] * 100.00 / nsample_total); } - printf("%8lu ", sample_nsample_per_event[i]); + printf("%8"PRIu64" ", sample_nsample_per_event[i]); printf("%-32.32s", eventname[i]); for (n = 0; n < ncpu; n++) { @@ -481,10 +481,10 @@ sample_show(void) name = e->name; if (name == NULL) { if (e->flags & SAMPLE_ELM_FLAGS_USER) { -snprintf(namebuf, sizeof(namebuf), "", +snprintf(namebuf, sizeof(namebuf), "", e->addr); } else { -snprintf(namebuf, sizeof(namebuf), "0x%016lx", +snprintf(namebuf, sizeof(namebuf), "0x%016"PRIx64, e->addr); } name = namebuf;
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Thu Dec 1 03:32:24 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof_top.c Log Message: fix build error of printf format To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/tprof/tprof_top.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/sys
Module Name:src Committed By: ryo Date: Thu Dec 1 00:48:05 UTC 2022 Modified Files: src/sys/sys: param.h Log Message: tprof module revamped. Welcome to 9.99.108 To generate a diff of this commit: cvs rdiff -u -r1.720 -r1.721 src/sys/sys/param.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/param.h diff -u src/sys/sys/param.h:1.720 src/sys/sys/param.h:1.721 --- src/sys/sys/param.h:1.720 Fri Nov 25 08:40:15 2022 +++ src/sys/sys/param.h Thu Dec 1 00:48:05 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.720 2022/11/25 08:40:15 knakahara Exp $ */ +/* $NetBSD: param.h,v 1.721 2022/12/01 00:48:05 ryo Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -67,7 +67,7 @@ * 2.99.9 (299000900) */ -#define __NetBSD_Version__ 999010700 /* NetBSD 9.99.107 */ +#define __NetBSD_Version__ 999010800 /* NetBSD 9.99.108 */ #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \ (m) * 100) + (p) * 100) <= __NetBSD_Version__)
CVS commit: src/sys/sys
Module Name:src Committed By: ryo Date: Thu Dec 1 00:48:05 UTC 2022 Modified Files: src/sys/sys: param.h Log Message: tprof module revamped. Welcome to 9.99.108 To generate a diff of this commit: cvs rdiff -u -r1.720 -r1.721 src/sys/sys/param.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/tprof
fo; +extern int ncpu; +extern int devfd; +extern u_int ncounters; + int tprof_event_init(uint32_t); void tprof_event_list(void); void tprof_event_lookup(const char *, struct tprof_param *); void tprof_analyze(int, char **); +void tprof_top(int, char **); Index: src/usr.sbin/tprof/tprof_analyze.c diff -u src/usr.sbin/tprof/tprof_analyze.c:1.7 src/usr.sbin/tprof/tprof_analyze.c:1.8 --- src/usr.sbin/tprof/tprof_analyze.c:1.7 Thu Dec 1 00:41:10 2022 +++ src/usr.sbin/tprof/tprof_analyze.c Thu Dec 1 00:43:27 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_analyze.c,v 1.7 2022/12/01 00:41:10 ryo Exp $ */ +/* $NetBSD: tprof_analyze.c,v 1.8 2022/12/01 00:43:27 ryo Exp $ */ /* * Copyright (c) 2010,2011,2012 YAMAMOTO Takashi, @@ -28,7 +28,7 @@ #include #ifndef lint -__RCSID("$NetBSD: tprof_analyze.c,v 1.7 2022/12/01 00:41:10 ryo Exp $"); +__RCSID("$NetBSD: tprof_analyze.c,v 1.8 2022/12/01 00:43:27 ryo Exp $"); #endif /* not lint */ #include @@ -192,7 +192,7 @@ tprof_analyze(int argc, char **argv) errx(EXIT_FAILURE, "fopen"); } - ksymload(); + ksymload(NULL); rb_tree_init(, _ops); /* @@ -245,7 +245,7 @@ tprof_analyze(int argc, char **argv) const char *name; uint64_t offset; - name = ksymlookup(a->addr, ); + name = ksymlookup(a->addr, , NULL); if (name != NULL) { a->addr -= offset; } @@ -310,7 +310,7 @@ tprof_analyze(int argc, char **argv) a = l[i]; if (a->in_kernel) { - name = ksymlookup(a->addr, ); + name = ksymlookup(a->addr, , NULL); } else { name = NULL; } Added files: Index: src/usr.sbin/tprof/tprof_top.c diff -u /dev/null src/usr.sbin/tprof/tprof_top.c:1.1 --- /dev/null Thu Dec 1 00:43:27 2022 +++ src/usr.sbin/tprof/tprof_top.c Thu Dec 1 00:43:27 2022 @@ -0,0 +1,739 @@ +/* $NetBSD: tprof_top.c,v 1.1 2022/12/01 00:43:27 ryo Exp $ */ + +/*- + * Copyright (c) 2022 Ryo Shimizu + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#ifndef lint +__RCSID("$NetBSD: tprof_top.c,v 1.1 2022/12/01 00:43:27 ryo Exp $"); +#endif /* not lint */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "tprof.h" +#include "ksyms.h" + +static struct sym **ksyms; +static size_t nksyms; +static sig_atomic_t sigalrm; +static struct winsize win; +static long top_interval = 1; +static u_int nevent; +static const char *eventname[TPROF_MAXCOUNTERS]; +static int nontty; + +/* XXX: use terminfo or curses */ +static void +cursor_address(u_int x, u_int y) +{ + if (nontty) + return; + printf("\e[%u;%uH", y - 1, x - 1); +} + +static void +cursor_home(void) +{ + if (nontty) + return; + printf("\e[H"); +} + +static void +cls_eol(void) +{ + if (nontty) + return; + printf("\e[K"); +} + +static void +cls_eos(void) +{ + if (nontty) + return; + printf("\e[J"); +} + +static void +sigwinch_handler(int signo) +{ + nontty = ioctl(STDOUT_FILENO, TIOCGWINSZ, ); +} + +static void +sigalrm_handler(int signo) +{ + sigalrm = 1; +} + +struct sample_elm { + struct rb_node node; + uint64_t addr; + const char *name; + uint32_t flags; +#define SAMPLE_ELM_FLAGS_USER 0x0001 + uint32_t num; + uint32_t numcpu[]; +}; + +static size_t sizeof_sample_elm; +static rb_tree_t rb_tree_sample; +static char *samplebuf; +static u_int sample_nused; +static u_int sample_kern_nsample; +static u_int sample_user_nsample; +static u_int sample_max = 1024 * 512; /* XXX */ +static uint32_t *sample_nsample_kern_per_cpu; +static uint32_t *sample_nsample_user_per_cpu; +static uint64_t *sample_nsamp
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Thu Dec 1 00:43:27 UTC 2022 Modified Files: src/usr.sbin/tprof: Makefile ksyms.c ksyms.h tprof.8 tprof.c tprof.h tprof_analyze.c Added Files: src/usr.sbin/tprof: tprof_top.c Log Message: add "top" subcommand to tprof(8) To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/tprof/Makefile cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/tprof/ksyms.c \ src/usr.sbin/tprof/ksyms.h cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/tprof/tprof.8 cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/tprof/tprof.c cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/tprof/tprof.h cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/tprof/tprof_analyze.c cvs rdiff -u -r0 -r1.1 src/usr.sbin/tprof/tprof_top.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Thu Dec 1 00:41:10 UTC 2022 Modified Files: src/usr.sbin/tprof: Makefile tprof_analyze.c Added Files: src/usr.sbin/tprof: ksyms.c ksyms.h Log Message: split ksyms stuff into ksyms.[ch] To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/tprof/Makefile cvs rdiff -u -r0 -r1.1 src/usr.sbin/tprof/ksyms.c src/usr.sbin/tprof/ksyms.h cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/tprof/tprof_analyze.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/tprof/Makefile diff -u src/usr.sbin/tprof/Makefile:1.10 src/usr.sbin/tprof/Makefile:1.11 --- src/usr.sbin/tprof/Makefile:1.10 Tue Nov 17 10:47:17 2020 +++ src/usr.sbin/tprof/Makefile Thu Dec 1 00:41:10 2022 @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.10 2020/11/17 10:47:17 rin Exp $ +# $NetBSD: Makefile,v 1.11 2022/12/01 00:41:10 ryo Exp $ .PATH: ${.CURDIR}/arch PROG= tprof MAN= tprof.8 -SRCS= tprof.c tprof_analyze.c +SRCS= tprof.c tprof_analyze.c ksyms.c .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" SRCS+= tprof_x86.c Index: src/usr.sbin/tprof/tprof_analyze.c diff -u src/usr.sbin/tprof/tprof_analyze.c:1.6 src/usr.sbin/tprof/tprof_analyze.c:1.7 --- src/usr.sbin/tprof/tprof_analyze.c:1.6 Thu Dec 1 00:32:52 2022 +++ src/usr.sbin/tprof/tprof_analyze.c Thu Dec 1 00:41:10 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_analyze.c,v 1.6 2022/12/01 00:32:52 ryo Exp $ */ +/* $NetBSD: tprof_analyze.c,v 1.7 2022/12/01 00:41:10 ryo Exp $ */ /* * Copyright (c) 2010,2011,2012 YAMAMOTO Takashi, @@ -28,7 +28,7 @@ #include #ifndef lint -__RCSID("$NetBSD: tprof_analyze.c,v 1.6 2022/12/01 00:32:52 ryo Exp $"); +__RCSID("$NetBSD: tprof_analyze.c,v 1.7 2022/12/01 00:41:10 ryo Exp $"); #endif /* not lint */ #include @@ -46,8 +46,7 @@ __RCSID("$NetBSD: tprof_analyze.c,v 1.6 #include #include #include "tprof.h" - -#define _PATH_KSYMS "/dev/ksyms" +#include "ksyms.h" #include @@ -68,147 +67,6 @@ struct addr { static rb_tree_t addrtree; -struct sym { - char *name; - uint64_t value; - uint64_t size; -}; - -static struct sym **syms = NULL; -static size_t nsyms = 0; - -static int -compare_value(const void *p1, const void *p2) -{ - const struct sym *s1 = *(const struct sym * const *)p1; - const struct sym *s2 = *(const struct sym * const *)p2; - - if (s1->value > s2->value) { - return -1; - } else if (s1->value < s2->value) { - return 1; - } - /* - * to produce a stable result, it's better not to return 0 - * even for __strong_alias. - */ - if (s1->size > s2->size) { - return -1; - } else if (s1->size < s2->size) { - return 1; - } - return strcmp(s1->name, s2->name); -} - -static void -ksymload(void) -{ - Elf *e; - Elf_Scn *s; - GElf_Shdr sh_store; - GElf_Shdr *sh; - Elf_Data *d; - int fd; - size_t size, i; - - fd = open(_PATH_KSYMS, O_RDONLY); - if (fd == -1) { - err(EXIT_FAILURE, "open " _PATH_KSYMS); - } - if (elf_version(EV_CURRENT) == EV_NONE) { - goto elffail; - } - e = elf_begin(fd, ELF_C_READ, NULL); - if (e == NULL) { - goto elffail; - } - for (s = elf_nextscn(e, NULL); s != NULL; s = elf_nextscn(e, s)) { - sh = gelf_getshdr(s, _store); - if (sh == NULL) { - goto elffail; - } - if (sh->sh_type == SHT_SYMTAB) { - break; - } - } - if (s == NULL) { - errx(EXIT_FAILURE, "no symtab"); - } - d = elf_getdata(s, NULL); - if (d == NULL) { - goto elffail; - } - assert(sh->sh_size == d->d_size); - size = sh->sh_size / sh->sh_entsize; - for (i = 1; i < size; i++) { - GElf_Sym st_store; - GElf_Sym *st; - struct sym *sym; - - st = gelf_getsym(d, (int)i, _store); - if (st == NULL) { - goto elffail; - } - if (ELF_ST_TYPE(st->st_info) != STT_FUNC) { - continue; - } - sym = emalloc(sizeof(*sym)); - sym->name = estrdup(elf_strptr(e, sh->sh_link, st->st_name)); - sym->value = (uint64_t)st->st_value; - sym->size = st->st_size; - nsyms++; - syms = erealloc(syms, sizeof(*syms) * nsyms); - syms[nsyms - 1] = sym; - } - qsort(syms, nsyms, sizeof(*syms), compare_value); - return; -elffail: - errx(EXIT_FAILURE, "libelf: %s", elf_errmsg(elf_errno())); -} - -static const char * -ksymlookup(uint64_t value, uint64_t *offset) -{ - size_t hi; - size_t lo; - size_t i; - - /* - * try to find the smallest i for which syms[i]->value <= value. - * syms[] is ordered by syms[]->value in the descending order. - */ - - hi = nsyms - 1; - lo = 0; - while (lo < hi) { - const size_t mid = (lo + hi) / 2; - const struct sym *sym = syms[mid]; - - assert(syms[lo]->value >= sym->value); - assert(sym->value >= syms[hi]->value); - if (sym->value <= value) { - hi = mid; - continue; - } - lo = mid + 1; - } - assert(lo == nsyms - 1 || syms[lo]->value <= value); - assert(lo == 0 || syms[lo - 1]->value > value); - for (i = lo; i < nsyms; i++) { - const struct sym *sym = syms[i]; - - if (sym->value <= value && - (sym->size == 0 || value -
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Thu Dec 1 00:41:10 UTC 2022 Modified Files: src/usr.sbin/tprof: Makefile tprof_analyze.c Added Files: src/usr.sbin/tprof: ksyms.c ksyms.h Log Message: split ksyms stuff into ksyms.[ch] To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/tprof/Makefile cvs rdiff -u -r0 -r1.1 src/usr.sbin/tprof/ksyms.c src/usr.sbin/tprof/ksyms.h cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/tprof/tprof_analyze.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Thu Dec 1 00:40:05 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof.8 tprof.c Log Message: Improve tprof(8) - Added "tprof count" subcommand to perform counts only. - Event options (u,k) are now optional. The default value is both userland and kernel. (:uk) - Event counters can be displayed with SIGINFO during `tprof monitor' or `tprof count'. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/tprof/tprof.8 cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/tprof/tprof.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/tprof/tprof.8 diff -u src/usr.sbin/tprof/tprof.8:1.17 src/usr.sbin/tprof/tprof.8:1.18 --- src/usr.sbin/tprof/tprof.8:1.17 Thu Dec 1 00:32:52 2022 +++ src/usr.sbin/tprof/tprof.8 Thu Dec 1 00:40:05 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: tprof.8,v 1.17 2022/12/01 00:32:52 ryo Exp $ +.\" $NetBSD: tprof.8,v 1.18 2022/12/01 00:40:05 ryo Exp $ .\" .\" Copyright (c)2011 YAMAMOTO Takashi, .\" All rights reserved. @@ -66,7 +66,7 @@ Valid actions are: Display a list of performance counter events available on the system. .It monitor Xo .Fl e -.Ar name:option +.Ar name[:option] .Op Fl e Ar ... .Op Fl o Ar outfile .Ar command @@ -81,12 +81,25 @@ specifies the source of the event; it mu .Ar u (userland) and .Ar k -(kernel). +(kernel). If omitted, it is assumed that both are specified. The collected samples are written into the file .Ar outfile if specified. The default is .Dq Pa tprof.out . +.It count Xo +.Fl e +.Ar name[:option] +.Op Fl e Ar ... +.Op Fl i Ar interval +.Ar command +.Xc +Same as +.Ar monitor , +but does not do any profiling, +only outputs counters every +.Ar interval +second. .It analyze Xo .Op Fl CkLPs .Op Fl p Ar pid Index: src/usr.sbin/tprof/tprof.c diff -u src/usr.sbin/tprof/tprof.c:1.14 src/usr.sbin/tprof/tprof.c:1.15 --- src/usr.sbin/tprof/tprof.c:1.14 Thu Dec 1 00:32:52 2022 +++ src/usr.sbin/tprof/tprof.c Thu Dec 1 00:40:05 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof.c,v 1.14 2022/12/01 00:32:52 ryo Exp $ */ +/* $NetBSD: tprof.c,v 1.15 2022/12/01 00:40:05 ryo Exp $ */ /* * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -57,10 +57,12 @@ #include #ifndef lint -__RCSID("$NetBSD: tprof.c,v 1.14 2022/12/01 00:32:52 ryo Exp $"); +__RCSID("$NetBSD: tprof.c,v 1.15 2022/12/01 00:40:05 ryo Exp $"); #endif /* not lint */ +#include #include +#include #include #include @@ -69,13 +71,16 @@ __RCSID("$NetBSD: tprof.c,v 1.14 2022/12 #include #include #include +#include #include #include #include #include #include #include +#include #include +#include #include "tprof.h" #define _PATH_TPROF "/dev/tprof" @@ -84,10 +89,17 @@ struct tprof_info tprof_info; u_int ncounters; int devfd; int outfd; +int ncpu; u_int nevent; +double interval = 0x; /* XXX */ +const char *eventname[TPROF_MAXCOUNTERS]; +u_int eventnamewidth[TPROF_MAXCOUNTERS]; +#define COUNTER_COLUMNS_WIDTH 11 static void tprof_list(int, char **); -static void tprof_monitor(int, char **) __dead; +static void tprof_monitor_common(bool, int, char **) __dead; +static void tprof_monitor(int, char **); +static void tprof_count(int, char **); static struct cmdtab { const char *label; @@ -97,6 +109,7 @@ static struct cmdtab { } const tprof_cmdtab[] = { { "list", false, false, tprof_list }, { "monitor", true, false, tprof_monitor }, + { "count", true, false, tprof_count }, { "analyze", true, true, tprof_analyze }, { NULL, false, false, NULL }, }; @@ -109,15 +122,33 @@ usage(void) fprintf(stderr, "\n"); fprintf(stderr, "\tlist\n"); fprintf(stderr, "\t\tList the available events.\n"); - fprintf(stderr, "\tmonitor -e name:option [-e ...] [-o outfile] command\n"); + fprintf(stderr, "\tmonitor -e name[:option] [-e ...] [-o outfile] command\n"); fprintf(stderr, "\t\tMonitor the event 'name' with option 'option'\n" "\t\tcounted during the execution of 'command'.\n"); + fprintf(stderr, "\tcount -e name[:option] [-e ...] [-i interval]" + " command\n"); + fprintf(stderr, "\t\tSame as monitor, but does not profile," + " only outputs a counter.\n"); fprintf(stderr, "\tanalyze [-CkLPs] [-p pid] file\n"); fprintf(stderr, "\t\tAnalyze the samples of the file 'file'.\n"); exit(EXIT_FAILURE); } +static int +getncpu(void) +{ + size_t size; + int mib[2]; + + mib[0] = CTL_HW; + mib[1] = HW_NCPU; + size = sizeof(ncpu); + if (sysctl(mib, 2, , , NULL, 0) == -1) + ncpu = 1; + return ncpu; +} + static void * process_samples(void *dummy) { @@ -150,13 +181,87 @@ process_samples(void *dummy) } static void +show_counters(void) +{ + unsigned int i; + int n, ret; + + fprintf(stderr, " "); + for (i = 0; i < nevent; i++) + fprintf(stderr, " %*s", eventnamewidth[i], eventname[i]); + fprintf(stderr, "\n"); + + for (n = 0; n < ncpu; n++) { + tprof_counts_t
CVS commit: src/usr.sbin/tprof
Module Name:src Committed By: ryo Date: Thu Dec 1 00:40:05 UTC 2022 Modified Files: src/usr.sbin/tprof: tprof.8 tprof.c Log Message: Improve tprof(8) - Added "tprof count" subcommand to perform counts only. - Event options (u,k) are now optional. The default value is both userland and kernel. (:uk) - Event counters can be displayed with SIGINFO during `tprof monitor' or `tprof count'. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/tprof/tprof.8 cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/tprof/tprof.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: ryo Date: Thu Dec 1 00:32:52 UTC 2022 Modified Files: src/sys/arch/aarch64/include: armreg.h src/sys/dev/tprof: tprof.c tprof.h tprof_armv7.c tprof_armv8.c tprof_ioctl.h tprof_types.h tprof_x86.c tprof_x86_amd.c tprof_x86_intel.c src/usr.sbin/tprof: tprof.8 tprof.c tprof_analyze.c Log Message: Improve tprof(4) - Multiple events can now be handled simultaneously. - Counters should be configured with TPROF_IOC_CONFIGURE_EVENT in advance, instead of being configured at TPROF_IOC_START. - The configured counters can be started and stopped repeatedly by PROF_IOC_START/TPROF_IOC_STOP. - The value of the performance counter can be obtained at any timing as a 64bit value with TPROF_IOC_GETCOUNTS. - Backend common parts are handled in tprof.c as much as possible, and functions on the tprof_backend side have been reimplemented to be more primitive. - The reset value of counter overflows for profiling can now be adjusted. It is calculated by default from the CPU clock (speed of cycle counter) and TPROF_HZ, but for some events the value may be too large to be sufficient for profiling. The event counter can be specified as a ratio to the default or as an absolute value when configuring the event counter. - Due to overall changes, API and ABI have been changed. TPROF_VERSION and TPROF_BACKEND_VERSION were updated. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/arch/aarch64/include/armreg.h cvs rdiff -u -r1.18 -r1.19 src/sys/dev/tprof/tprof.c cvs rdiff -u -r1.6 -r1.7 src/sys/dev/tprof/tprof.h cvs rdiff -u -r1.9 -r1.10 src/sys/dev/tprof/tprof_armv7.c cvs rdiff -u -r1.17 -r1.18 src/sys/dev/tprof/tprof_armv8.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/tprof/tprof_ioctl.h \ src/sys/dev/tprof/tprof_x86_intel.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/tprof/tprof_types.h \ src/sys/dev/tprof/tprof_x86_amd.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/tprof/tprof_x86.c cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/tprof/tprof.8 cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/tprof/tprof.c cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/tprof/tprof_analyze.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/include/armreg.h diff -u src/sys/arch/aarch64/include/armreg.h:1.62 src/sys/arch/aarch64/include/armreg.h:1.63 --- src/sys/arch/aarch64/include/armreg.h:1.62 Thu Dec 1 00:29:10 2022 +++ src/sys/arch/aarch64/include/armreg.h Thu Dec 1 00:32:52 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: armreg.h,v 1.62 2022/12/01 00:29:10 ryo Exp $ */ +/* $NetBSD: armreg.h,v 1.63 2022/12/01 00:32:52 ryo Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -248,6 +248,10 @@ AARCH64REG_READ_INLINE(id_aa64dfr0_el1) #define ID_AA64DFR0_EL1_PMUVER_NONE 0 #define ID_AA64DFR0_EL1_PMUVER_V3 1 #define ID_AA64DFR0_EL1_PMUVER_NOV3 2 +#define ID_AA64DFR0_EL1_PMUVER_V3P1 4 +#define ID_AA64DFR0_EL1_PMUVER_V3P4 5 +#define ID_AA64DFR0_EL1_PMUVER_V3P5 6 +#define ID_AA64DFR0_EL1_PMUVER_V3P7 7 #define ID_AA64DFR0_EL1_PMUVER_IMPL 15 #define ID_AA64DFR0_EL1_TRACEVER __BITS(4,7) #define ID_AA64DFR0_EL1_TRACEVER_NONE 0 @@ -1221,6 +1225,7 @@ AARCH64REG_WRITE_INLINE(pmcr_el0) #define PMCR_IMP __BITS(31,24) // Implementor code #define PMCR_IDCODE __BITS(23,16) // Identification code #define PMCR_N __BITS(15,11) // Number of event counters +#define PMCR_LP __BIT(7) // Long event counter enable #define PMCR_LC __BIT(6) // Long cycle counter enable #define PMCR_DP __BIT(5) // Disable cycle counter when event // counting is prohibited Index: src/sys/dev/tprof/tprof.c diff -u src/sys/dev/tprof/tprof.c:1.18 src/sys/dev/tprof/tprof.c:1.19 --- src/sys/dev/tprof/tprof.c:1.18 Thu Dec 1 00:27:59 2022 +++ src/sys/dev/tprof/tprof.c Thu Dec 1 00:32:52 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof.c,v 1.18 2022/12/01 00:27:59 ryo Exp $ */ +/* $NetBSD: tprof.c,v 1.19 2022/12/01 00:32:52 ryo Exp $ */ /*- * Copyright (c)2008,2009,2010 YAMAMOTO Takashi, @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tprof.c,v 1.18 2022/12/01 00:27:59 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tprof.c,v 1.19 2022/12/01 00:32:52 ryo Exp $"); #include #include @@ -42,12 +42,17 @@ __KERNEL_RCSID(0, "$NetBSD: tprof.c,v 1. #include #include #include +#include #include #include #include "ioconf.h" +#ifndef TPROF_HZ +#define TPROF_HZ 1 +#endif + /* * locking order: * tprof_reader_lock -> tprof_lock @@ -73,7 +78,7 @@ typedef struct tprof_buf { } tprof_buf_t; #define TPROF_BUF_BYTESIZE(sz) \ (sizeof(tprof_buf_t) + (sz) * sizeof(tprof_sample_t)) -#define TPROF_MAX_SAMPLES_PER_BUF 1 +#define TPROF_MAX_SAMPLES_PER_BUF (TPROF_HZ * 2) #define TPROF_MAX_BUF 100 @@ -85,14 +90,20 @@ typedef struct { } __aligned(CACHE_LINE_SIZE) tprof_cpu_t; typedef struct tprof_backend { + /* + *
CVS commit: src
Module Name:src Committed By: ryo Date: Thu Dec 1 00:32:52 UTC 2022 Modified Files: src/sys/arch/aarch64/include: armreg.h src/sys/dev/tprof: tprof.c tprof.h tprof_armv7.c tprof_armv8.c tprof_ioctl.h tprof_types.h tprof_x86.c tprof_x86_amd.c tprof_x86_intel.c src/usr.sbin/tprof: tprof.8 tprof.c tprof_analyze.c Log Message: Improve tprof(4) - Multiple events can now be handled simultaneously. - Counters should be configured with TPROF_IOC_CONFIGURE_EVENT in advance, instead of being configured at TPROF_IOC_START. - The configured counters can be started and stopped repeatedly by PROF_IOC_START/TPROF_IOC_STOP. - The value of the performance counter can be obtained at any timing as a 64bit value with TPROF_IOC_GETCOUNTS. - Backend common parts are handled in tprof.c as much as possible, and functions on the tprof_backend side have been reimplemented to be more primitive. - The reset value of counter overflows for profiling can now be adjusted. It is calculated by default from the CPU clock (speed of cycle counter) and TPROF_HZ, but for some events the value may be too large to be sufficient for profiling. The event counter can be specified as a ratio to the default or as an absolute value when configuring the event counter. - Due to overall changes, API and ABI have been changed. TPROF_VERSION and TPROF_BACKEND_VERSION were updated. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/arch/aarch64/include/armreg.h cvs rdiff -u -r1.18 -r1.19 src/sys/dev/tprof/tprof.c cvs rdiff -u -r1.6 -r1.7 src/sys/dev/tprof/tprof.h cvs rdiff -u -r1.9 -r1.10 src/sys/dev/tprof/tprof_armv7.c cvs rdiff -u -r1.17 -r1.18 src/sys/dev/tprof/tprof_armv8.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/tprof/tprof_ioctl.h \ src/sys/dev/tprof/tprof_x86_intel.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/tprof/tprof_types.h \ src/sys/dev/tprof/tprof_x86_amd.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/tprof/tprof_x86.c cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/tprof/tprof.8 cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/tprof/tprof.c cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/tprof/tprof_analyze.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/tprof
Module Name:src Committed By: ryo Date: Thu Dec 1 00:29:51 UTC 2022 Modified Files: src/sys/dev/tprof: tprof_armv7.c Log Message: tprof_armv7 initializes on each CPUs, like tprof_armv8. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/tprof/tprof_armv7.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/tprof
Module Name:src Committed By: ryo Date: Thu Dec 1 00:29:51 UTC 2022 Modified Files: src/sys/dev/tprof: tprof_armv7.c Log Message: tprof_armv7 initializes on each CPUs, like tprof_armv8. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/tprof/tprof_armv7.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/tprof/tprof_armv7.c diff -u src/sys/dev/tprof/tprof_armv7.c:1.8 src/sys/dev/tprof/tprof_armv7.c:1.9 --- src/sys/dev/tprof/tprof_armv7.c:1.8 Thu Dec 1 00:29:10 2022 +++ src/sys/dev/tprof/tprof_armv7.c Thu Dec 1 00:29:51 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_armv7.c,v 1.8 2022/12/01 00:29:10 ryo Exp $ */ +/* $NetBSD: tprof_armv7.c,v 1.9 2022/12/01 00:29:51 ryo Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tprof_armv7.c,v 1.8 2022/12/01 00:29:10 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tprof_armv7.c,v 1.9 2022/12/01 00:29:51 ryo Exp $"); #include #include @@ -258,8 +258,8 @@ armv7_pmu_intr(void *priv) return 1; } -int -armv7_pmu_init(void) +static void +armv7_pmu_init_cpu(void *arg1, void *arg2) { /* Disable user mode access to performance monitors */ armreg_pmuserenr_write(0); @@ -269,6 +269,13 @@ armv7_pmu_init(void) /* Disable counters */ armreg_pmcntenclr_write(PMCNTEN_P); +} + +int +armv7_pmu_init(void) +{ + uint64_t xc = xc_broadcast(0, armv7_pmu_init_cpu, NULL, NULL); + xc_wait(xc); return tprof_backend_register("tprof_armv7", _armv7_pmu_ops, TPROF_BACKEND_VERSION);
CVS commit: src/sys
Module Name:src Committed By: ryo Date: Thu Dec 1 00:29:10 UTC 2022 Modified Files: src/sys/arch/aarch64/include: armreg.h src/sys/dev/tprof: tprof_armv7.c tprof_armv8.c Log Message: PMCR.E should not be disabled from tprof. PMCR.E controls not only performance event counters but also the cycle counter operation, and the cycle counter may be used for cpu_counter. Similarly, the 31st bit in PMINTENCLR and PMCNTENCLR controls the cycle counter, not performance event counters, and should not be modified. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/sys/arch/aarch64/include/armreg.h cvs rdiff -u -r1.7 -r1.8 src/sys/dev/tprof/tprof_armv7.c cvs rdiff -u -r1.16 -r1.17 src/sys/dev/tprof/tprof_armv8.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/include/armreg.h diff -u src/sys/arch/aarch64/include/armreg.h:1.61 src/sys/arch/aarch64/include/armreg.h:1.62 --- src/sys/arch/aarch64/include/armreg.h:1.61 Mon May 2 10:13:15 2022 +++ src/sys/arch/aarch64/include/armreg.h Thu Dec 1 00:29:10 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: armreg.h,v 1.61 2022/05/02 10:13:15 skrll Exp $ */ +/* $NetBSD: armreg.h,v 1.62 2022/12/01 00:29:10 ryo Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -1250,10 +1250,16 @@ AARCH64REG_WRITE_INLINE(pmevtyper1_el0) AARCH64REG_WRITE_INLINE(pmintenclr_el1) AARCH64REG_WRITE_INLINE(pmintenset_el1) +#define PMINTEN_C __BIT(31) // for the cycle counter +#define PMINTEN_P __BITS(30,0) // for event counters (0-30) + AARCH64REG_WRITE_INLINE(pmovsclr_el0) AARCH64REG_READ_INLINE(pmovsset_el0) AARCH64REG_WRITE_INLINE(pmovsset_el0) +#define PMOVS_C __BIT(31) // for the cycle counter +#define PMOVS_P __BITS(30,0) // for event counters (0-30) + AARCH64REG_WRITE_INLINE(pmselr_el0) AARCH64REG_WRITE_INLINE(pmswinc_el0) Index: src/sys/dev/tprof/tprof_armv7.c diff -u src/sys/dev/tprof/tprof_armv7.c:1.7 src/sys/dev/tprof/tprof_armv7.c:1.8 --- src/sys/dev/tprof/tprof_armv7.c:1.7 Tue Nov 1 11:03:01 2022 +++ src/sys/dev/tprof/tprof_armv7.c Thu Dec 1 00:29:10 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_armv7.c,v 1.7 2022/11/01 11:03:01 jmcneill Exp $ */ +/* $NetBSD: tprof_armv7.c,v 1.8 2022/12/01 00:29:10 ryo Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tprof_armv7.c,v 1.7 2022/11/01 11:03:01 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tprof_armv7.c,v 1.8 2022/12/01 00:29:10 ryo Exp $"); #include #include @@ -45,6 +45,11 @@ __KERNEL_RCSID(0, "$NetBSD: tprof_armv7. #define PMCR_D __BIT(3) #define PMCR_E __BIT(0) +#define PMINTEN_C __BIT(31) +#define PMINTEN_P __BITS(30,0) +#define PMCNTEN_C __BIT(31) +#define PMCNTEN_P __BITS(30,0) + #define PMEVTYPER_P __BIT(31) #define PMEVTYPER_U __BIT(30) #define PMEVTYPER_EVTCOUNT __BITS(7,0) @@ -161,18 +166,12 @@ static void armv7_pmu_stop_cpu(void *arg1, void *arg2) { const uint32_t counter_mask = __BIT(armv7_pmu_counter); - uint32_t pmcr; /* Disable overflow interrupts */ armreg_pmintenclr_write(counter_mask); /* Disable event counter */ armreg_pmcntenclr_write(counter_mask); - - /* Disable performance monitor */ - pmcr = armreg_pmcr_read(); - pmcr &= ~PMCR_E; - armreg_pmcr_write(pmcr); } static uint64_t @@ -266,13 +265,10 @@ armv7_pmu_init(void) armreg_pmuserenr_write(0); /* Disable interrupts */ - armreg_pmintenclr_write(~0U); + armreg_pmintenclr_write(PMINTEN_P); /* Disable counters */ - armreg_pmcntenclr_write(~0U); - - /* Disable performance monitor */ - armreg_pmcr_write(0); + armreg_pmcntenclr_write(PMCNTEN_P); return tprof_backend_register("tprof_armv7", _armv7_pmu_ops, TPROF_BACKEND_VERSION); Index: src/sys/dev/tprof/tprof_armv8.c diff -u src/sys/dev/tprof/tprof_armv8.c:1.16 src/sys/dev/tprof/tprof_armv8.c:1.17 --- src/sys/dev/tprof/tprof_armv8.c:1.16 Thu Nov 10 07:54:20 2022 +++ src/sys/dev/tprof/tprof_armv8.c Thu Dec 1 00:29:10 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_armv8.c,v 1.16 2022/11/10 07:54:20 ryo Exp $ */ +/* $NetBSD: tprof_armv8.c,v 1.17 2022/12/01 00:29:10 ryo Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tprof_armv8.c,v 1.16 2022/11/10 07:54:20 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tprof_armv8.c,v 1.17 2022/12/01 00:29:10 ryo Exp $"); #include #include @@ -112,7 +112,7 @@ armv8_pmu_start_cpu(void *arg1, void *ar /* Enable event counter */ reg_pmcntenset_el0_write(counter_mask); - reg_pmcr_el0_write(PMCR_E); + reg_pmcr_el0_write(reg_pmcr_el0_read() | PMCR_E); } static void @@ -125,7 +125,6 @@ armv8_pmu_stop_cpu(void *arg1, void *arg /* Disable event counter */ reg_pmcntenclr_el0_write(counter_mask); - reg_pmcr_el0_write(0); } static uint64_t @@ -214,7 +213,7 @@ armv8_pmu_init_cpu(void *arg1, void *arg
CVS commit: src/sys
Module Name:src Committed By: ryo Date: Thu Dec 1 00:29:10 UTC 2022 Modified Files: src/sys/arch/aarch64/include: armreg.h src/sys/dev/tprof: tprof_armv7.c tprof_armv8.c Log Message: PMCR.E should not be disabled from tprof. PMCR.E controls not only performance event counters but also the cycle counter operation, and the cycle counter may be used for cpu_counter. Similarly, the 31st bit in PMINTENCLR and PMCNTENCLR controls the cycle counter, not performance event counters, and should not be modified. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/sys/arch/aarch64/include/armreg.h cvs rdiff -u -r1.7 -r1.8 src/sys/dev/tprof/tprof_armv7.c cvs rdiff -u -r1.16 -r1.17 src/sys/dev/tprof/tprof_armv8.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/tprof
Module Name:src Committed By: ryo Date: Thu Dec 1 00:27:59 UTC 2022 Modified Files: src/sys/dev/tprof: tprof.c Log Message: don't call kpreempt_{disable,enable}() from an interrupt handler. Fixed a problem in which the system would freeze if a high load (e.g., build.sh -j20) was applied while running `tprof monitor -e LsNotHaltedCyc ...' on x86. This almost eliminates the problem, but still is not enough. tprof_x86 uses NMI interrupts, which are interrupted even in splhigh(), leaving the possibility of being interrupted in the splhigh section of percpu_cpu_swap(). To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/tprof/tprof.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/tprof/tprof.c diff -u src/sys/dev/tprof/tprof.c:1.17 src/sys/dev/tprof/tprof.c:1.18 --- src/sys/dev/tprof/tprof.c:1.17 Mon Mar 28 12:33:21 2022 +++ src/sys/dev/tprof/tprof.c Thu Dec 1 00:27:59 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof.c,v 1.17 2022/03/28 12:33:21 riastradh Exp $ */ +/* $NetBSD: tprof.c,v 1.18 2022/12/01 00:27:59 ryo Exp $ */ /*- * Copyright (c)2008,2009,2010 YAMAMOTO Takashi, @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tprof.c,v 1.17 2022/03/28 12:33:21 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tprof.c,v 1.18 2022/12/01 00:27:59 ryo Exp $"); #include #include @@ -115,9 +115,18 @@ static kcondvar_t tprof_cv; /* L: */ static struct tprof_stat tprof_stat; /* L: */ static tprof_cpu_t * +tprof_cpu_direct(struct cpu_info *ci) +{ + tprof_cpu_t **cp; + + cp = percpu_getptr_remote(tprof_cpus, ci); + return *cp; +} + +static tprof_cpu_t * tprof_cpu(struct cpu_info *ci) { - tprof_cpu_t **cp, *c; + tprof_cpu_t *c; /* * As long as xcalls are blocked -- e.g., by kpreempt_disable @@ -126,8 +135,7 @@ tprof_cpu(struct cpu_info *ci) * moved to a new buffer, but we can safely read from it. */ kpreempt_disable(); - cp = percpu_getptr_remote(tprof_cpus, ci); - c = *cp; + c = tprof_cpu_direct(ci); kpreempt_enable(); return c; @@ -433,7 +441,7 @@ tprof_backend_lookup(const char *name) void tprof_sample(void *unused, const tprof_frame_info_t *tfi) { - tprof_cpu_t * const c = tprof_curcpu(); + tprof_cpu_t * const c = tprof_cpu_direct(curcpu()); tprof_buf_t * const buf = c->c_buf; tprof_sample_t *sp; const uintptr_t pc = tfi->tfi_pc;
CVS commit: src/sys/dev/tprof
Module Name:src Committed By: ryo Date: Thu Dec 1 00:27:59 UTC 2022 Modified Files: src/sys/dev/tprof: tprof.c Log Message: don't call kpreempt_{disable,enable}() from an interrupt handler. Fixed a problem in which the system would freeze if a high load (e.g., build.sh -j20) was applied while running `tprof monitor -e LsNotHaltedCyc ...' on x86. This almost eliminates the problem, but still is not enough. tprof_x86 uses NMI interrupts, which are interrupted even in splhigh(), leaving the possibility of being interrupted in the splhigh section of percpu_cpu_swap(). To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/tprof/tprof.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys
*/ @@ -803,6 +800,7 @@ int m_tag_copy_chain(struct mbuf *, struct mbuf *); */ #define PACKET_TAG_MPLS29 /* Indicate it's for MPLS */ #define PACKET_TAG_SRCROUTE30 /* IPv4 source routing */ +#define PACKET_TAG_ETHERNET_SRC31 /* * Return the number of bytes in the mbuf chain, m. Since l2_shalen is fixed to ETHER_ADDR_LEN for now, the tag name should be PACKET_TAG_ETHERNET_SRC instead of PACKET_TAG_L2SHA for now. If all L2 addresses are to be treated extensively, the structure of mtag should include the size, but that will not be necessary just yet. -- ryo shimizu
Re: CVS commit: src/sys/dev/tprof
>I think this is a bug in your device tree because the KASSERT was >intentional: > > - In the ACPI case, we probe for CPU PMU support before calling >armv8_pmu_init. > - In the FDT case, the PMU attaches to a node described in the device >tree. > >So if you hit this KASSERT, AFAICT it means your device tree is describing >a device that is not there. Unless I'm missing something here. I tried to fix it to work properly as a kernel module for debugging and improving tprof itself, but the current implement is difficult due to the acpi/fdt pmu interrupt and tprof, so I gave up :-P I'll revert it. thanks! -- ryo shimizu
CVS commit: src/sys/dev/tprof
Module Name:src Committed By: ryo Date: Thu Nov 10 07:54:20 UTC 2022 Modified Files: src/sys/dev/tprof: tprof_armv8.c Log Message: revert my previous commit. since armv8_pmu_init is only called when it is reliably worked by ACPI or fdt, there is no need for dynamic checks. pointed out by jmcneill@, thanks To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/dev/tprof/tprof_armv8.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/tprof
Module Name:src Committed By: ryo Date: Thu Nov 10 07:54:20 UTC 2022 Modified Files: src/sys/dev/tprof: tprof_armv8.c Log Message: revert my previous commit. since armv8_pmu_init is only called when it is reliably worked by ACPI or fdt, there is no need for dynamic checks. pointed out by jmcneill@, thanks To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/dev/tprof/tprof_armv8.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/tprof/tprof_armv8.c diff -u src/sys/dev/tprof/tprof_armv8.c:1.15 src/sys/dev/tprof/tprof_armv8.c:1.16 --- src/sys/dev/tprof/tprof_armv8.c:1.15 Wed Nov 9 19:06:46 2022 +++ src/sys/dev/tprof/tprof_armv8.c Thu Nov 10 07:54:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_armv8.c,v 1.15 2022/11/09 19:06:46 ryo Exp $ */ +/* $NetBSD: tprof_armv8.c,v 1.16 2022/11/10 07:54:20 ryo Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tprof_armv8.c,v 1.15 2022/11/09 19:06:46 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tprof_armv8.c,v 1.16 2022/11/10 07:54:20 ryo Exp $"); #include #include @@ -233,8 +233,7 @@ armv8_pmu_detect(void) int armv8_pmu_init(void) { - if (!armv8_pmu_detect()) - return ENOTSUP; + KASSERT(armv8_pmu_detect()); uint64_t xc = xc_broadcast(0, armv8_pmu_init_cpu, NULL, NULL); xc_wait(xc);
CVS commit: src/sys/dev/tprof
Module Name:src Committed By: ryo Date: Wed Nov 9 19:06:46 UTC 2022 Modified Files: src/sys/dev/tprof: tprof_armv8.c Log Message: If the hardware does not support PMU, return an error instead of KASSERT. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/dev/tprof/tprof_armv8.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/tprof
Module Name:src Committed By: ryo Date: Wed Nov 9 19:06:46 UTC 2022 Modified Files: src/sys/dev/tprof: tprof_armv8.c Log Message: If the hardware does not support PMU, return an error instead of KASSERT. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/dev/tprof/tprof_armv8.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/tprof/tprof_armv8.c diff -u src/sys/dev/tprof/tprof_armv8.c:1.14 src/sys/dev/tprof/tprof_armv8.c:1.15 --- src/sys/dev/tprof/tprof_armv8.c:1.14 Mon May 16 09:42:32 2022 +++ src/sys/dev/tprof/tprof_armv8.c Wed Nov 9 19:06:46 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_armv8.c,v 1.14 2022/05/16 09:42:32 jmcneill Exp $ */ +/* $NetBSD: tprof_armv8.c,v 1.15 2022/11/09 19:06:46 ryo Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tprof_armv8.c,v 1.14 2022/05/16 09:42:32 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tprof_armv8.c,v 1.15 2022/11/09 19:06:46 ryo Exp $"); #include #include @@ -233,7 +233,8 @@ armv8_pmu_detect(void) int armv8_pmu_init(void) { - KASSERT(armv8_pmu_detect()); + if (!armv8_pmu_detect()) + return ENOTSUP; uint64_t xc = xc_broadcast(0, armv8_pmu_init_cpu, NULL, NULL); xc_wait(xc);
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: ryo Date: Wed Nov 9 19:03:38 UTC 2022 Modified Files: src/sys/arch/arm/fdt: pmu_fdt.c Log Message: fdt/pmu was not working. do return only if there is an error. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/fdt/pmu_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/fdt/pmu_fdt.c diff -u src/sys/arch/arm/fdt/pmu_fdt.c:1.10 src/sys/arch/arm/fdt/pmu_fdt.c:1.11 --- src/sys/arch/arm/fdt/pmu_fdt.c:1.10 Thu Nov 25 09:36:20 2021 +++ src/sys/arch/arm/fdt/pmu_fdt.c Wed Nov 9 19:03:38 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: pmu_fdt.c,v 1.10 2021/11/25 09:36:20 skrll Exp $ */ +/* $NetBSD: pmu_fdt.c,v 1.11 2022/11/09 19:03:38 ryo Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.10 2021/11/25 09:36:20 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.11 2022/11/09 19:03:38 ryo Exp $"); #include #include @@ -137,8 +137,8 @@ pmu_fdt_init(device_t self) if (error) { aprint_error_dev(self, "couldn't initialise PMU event counter"); + return; } - return; } ih = kmem_zalloc(sizeof(void *) * ncpu, KM_SLEEP);
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: ryo Date: Wed Nov 9 19:03:38 UTC 2022 Modified Files: src/sys/arch/arm/fdt: pmu_fdt.c Log Message: fdt/pmu was not working. do return only if there is an error. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/fdt/pmu_fdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/distrib/sets/lists/misc
Module Name:src Committed By: ryo Date: Fri Oct 14 19:43:36 UTC 2022 Modified Files: src/distrib/sets/lists/misc: mi Log Message: add new files To generate a diff of this commit: cvs rdiff -u -r1.223 -r1.224 src/distrib/sets/lists/misc/mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/misc/mi diff -u src/distrib/sets/lists/misc/mi:1.223 src/distrib/sets/lists/misc/mi:1.224 --- src/distrib/sets/lists/misc/mi:1.223 Mon Jun 6 10:56:27 2022 +++ src/distrib/sets/lists/misc/mi Fri Oct 14 19:43:35 2022 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.223 2022/06/06 10:56:27 nia Exp $ +# $NetBSD: mi,v 1.224 2022/10/14 19:43:35 ryo Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -1356,7 +1356,12 @@ ./usr/share/examples/asm/README misc-asm-examples share ./usr/share/examples/asm/hello misc-asm-examples ./usr/share/examples/asm/hello/Makefile misc-asm-examples share +./usr/share/examples/asm/hello/arm.s misc-asm-examples share +./usr/share/examples/asm/hello/aarch64.s misc-asm-examples share +./usr/share/examples/asm/hello/i386.s misc-asm-examples share ./usr/share/examples/asm/hello/powerpc.s misc-asm-examples share +./usr/share/examples/asm/hello/sh3.s misc-asm-examples share +./usr/share/examples/asm/hello/x86_64.s misc-asm-examples share ./usr/share/examples/atf misc-atf-examples ./usr/share/examples/atf/atf-run.hooks misc-atf-examples share,atf,!kyua ./usr/share/examples/atf/atf-run.hooks misc-obsolete share,kyua,obsolete
CVS commit: src/distrib/sets/lists/misc
Module Name:src Committed By: ryo Date: Fri Oct 14 19:43:36 UTC 2022 Modified Files: src/distrib/sets/lists/misc: mi Log Message: add new files To generate a diff of this commit: cvs rdiff -u -r1.223 -r1.224 src/distrib/sets/lists/misc/mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/share/examples/asm/hello
Module Name:src Committed By: ryo Date: Fri Oct 14 19:42:14 UTC 2022 Modified Files: src/share/examples/asm/hello: Makefile.inst Log Message: - Since the example is for a cpu, use MACHINE_CPU instead of MACHINE_ARCH. - In some cpu, it is necessary to use GOT to make it a PIE, which are too complicated as examples, so MKPIE=no by default. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/share/examples/asm/hello/Makefile.inst Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/examples/asm/hello/Makefile.inst diff -u src/share/examples/asm/hello/Makefile.inst:1.1 src/share/examples/asm/hello/Makefile.inst:1.2 --- src/share/examples/asm/hello/Makefile.inst:1.1 Sat Nov 12 01:18:41 2011 +++ src/share/examples/asm/hello/Makefile.inst Fri Oct 14 19:42:13 2022 @@ -1,12 +1,13 @@ -# $NetBSD: Makefile.inst,v 1.1 2011/11/12 01:18:41 jmmv Exp $ +# $NetBSD: Makefile.inst,v 1.2 2022/10/14 19:42:13 ryo Exp $ .include -.if exists(${MACHINE_ARCH}.s) +.if exists(${MACHINE_CPU}.s) PROG= hello MAN= # empty LDFLAGS= -nostdlib -SRCS= ${MACHINE_ARCH}.s +SRCS= ${MACHINE_CPU}.s +MKPIE= no .endif .include
CVS commit: src/share/examples/asm/hello
Module Name:src Committed By: ryo Date: Fri Oct 14 19:42:14 UTC 2022 Modified Files: src/share/examples/asm/hello: Makefile.inst Log Message: - Since the example is for a cpu, use MACHINE_CPU instead of MACHINE_ARCH. - In some cpu, it is necessary to use GOT to make it a PIE, which are too complicated as examples, so MKPIE=no by default. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/share/examples/asm/hello/Makefile.inst Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/share/examples/asm/hello
Module Name:src Committed By: ryo Date: Fri Oct 14 19:41:18 UTC 2022 Modified Files: src/share/examples/asm/hello: Makefile Added Files: src/share/examples/asm/hello: aarch64.s arm.s i386.s sh3.s x86_64.s Log Message: add more examples To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/share/examples/asm/hello/Makefile cvs rdiff -u -r0 -r1.1 src/share/examples/asm/hello/aarch64.s \ src/share/examples/asm/hello/arm.s src/share/examples/asm/hello/i386.s \ src/share/examples/asm/hello/sh3.s src/share/examples/asm/hello/x86_64.s Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/examples/asm/hello/Makefile diff -u src/share/examples/asm/hello/Makefile:1.1 src/share/examples/asm/hello/Makefile:1.2 --- src/share/examples/asm/hello/Makefile:1.1 Sat Nov 12 01:18:41 2011 +++ src/share/examples/asm/hello/Makefile Fri Oct 14 19:41:18 2022 @@ -1,9 +1,9 @@ -# $NetBSD: Makefile,v 1.1 2011/11/12 01:18:41 jmmv Exp $ +# $NetBSD: Makefile,v 1.2 2022/10/14 19:41:18 ryo Exp $ .include .if ${MKSHARE} != "no" -FILES= Makefile.inst powerpc.s +FILES= Makefile.inst aarch64.s arm.s i386.s powerpc.s sh3.s x86_64.s FILESDIR= /usr/share/examples/asm/hello FILESNAME_Makefile.inst= Makefile .endif Added files: Index: src/share/examples/asm/hello/aarch64.s diff -u /dev/null src/share/examples/asm/hello/aarch64.s:1.1 --- /dev/null Fri Oct 14 19:41:18 2022 +++ src/share/examples/asm/hello/aarch64.s Fri Oct 14 19:41:18 2022 @@ -0,0 +1,84 @@ +/* $NetBSD: aarch64.s,v 1.1 2022/10/14 19:41:18 ryo Exp $ */ + +/*- + * Copyright (c) 2022 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * assemble & link: + * as -o aarch64.o aarch64.s + * ld -o hello -e _start aarch64.o + */ + + /* -- */ + + /* + * This ELF section is used by the kernel to determine, among other + * things, the system call interface used by the binary. + * + * Normally, /usr/lib/crti.o is linked, but here it is written manually. + * + * SEE ALSO: + * - http://www.netbsd.org/docs/kernel/elf-notes.html + * - src/sys/sys/exec_elf.h + * - src/lib/csu/common/sysident.S + * - src/lib/csu/arch/aarch64/crti.S + */ + .section ".note.netbsd.ident", "a" + .p2align 2 + .long 7 /* ELF_NOTE_NETBSD_NAMESZ */ + .long 4 /* ELF_NOTE_NETBSD_DESCSZ */ + .long 1 /* ELF_NOTE_TYPE_NETBSD_TAG */ + .ascii "NetBSD\0\0" /* ELF_NOTE_NETBSD_NAME */ + .long 99901 /* __NetBSD_Version__ (sys/sys/param.h) */ + + + /* -- */ + + .section ".rodata" +message: + .ascii "Hello, world!\n" + .set MESSAGE_SIZE, . - message + + + /* -- */ + + .section ".text" + .p2align 2 + + .global _start + .type _start, %function +_start: + /* write(STDOUT_FILENO, message, MESSAGE_SIZE) */ + mov x0, #1 /* x0: fd = STDOUT_FILENO */ + adr x1, message /* x1: buf = message */ + mov x2, #MESSAGE_SIZE /* x2: nbytes = MESSAGE_SIZE */ + svc #4 /* SYS_write */ + + /* exit(0) */ + mov x0, #0 /* x0: status = 0 */ + svc #1 /* SYS_exit */ + + .size _start, . - _start Index: src/share/examples/asm/hello/arm.s diff -u /dev/null src/share/examples/asm/hello/arm.s:1.1 --- /dev/null Fri Oct 14 19:41:18 2022 +++ src/share/examples/asm/hello/arm.s Fri Oct 14 19:41:18 2022 @@ -0,0 +1,88 @@ +/* $NetBSD: arm.s,v 1.1 2022/10/14 19:41:18 ryo Exp $ */ + +/*- + * Copyright (c) 2022 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and
CVS commit: src/share/examples/asm/hello
Module Name:src Committed By: ryo Date: Fri Oct 14 19:41:18 UTC 2022 Modified Files: src/share/examples/asm/hello: Makefile Added Files: src/share/examples/asm/hello: aarch64.s arm.s i386.s sh3.s x86_64.s Log Message: add more examples To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/share/examples/asm/hello/Makefile cvs rdiff -u -r0 -r1.1 src/share/examples/asm/hello/aarch64.s \ src/share/examples/asm/hello/arm.s src/share/examples/asm/hello/i386.s \ src/share/examples/asm/hello/sh3.s src/share/examples/asm/hello/x86_64.s Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ryo Date: Fri Oct 14 19:39:32 UTC 2022 Modified Files: src/sys/netinet: in_pcb.c src/sys/netinet6: in6_pcb.c Log Message: Avoid error of "-Wreturn-local-addr", and simplify the logic. However, -Wreturn-local-addr is still disabled by default by GCC_NO_RETURN_LOCAL_ADDR in bsd.own.mk because it causes errors in other parts. To generate a diff of this commit: cvs rdiff -u -r1.190 -r1.191 src/sys/netinet/in_pcb.c cvs rdiff -u -r1.170 -r1.171 src/sys/netinet6/in6_pcb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/netinet/in_pcb.c diff -u src/sys/netinet/in_pcb.c:1.190 src/sys/netinet/in_pcb.c:1.191 --- src/sys/netinet/in_pcb.c:1.190 Mon Aug 29 09:14:02 2022 +++ src/sys/netinet/in_pcb.c Fri Oct 14 19:39:32 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: in_pcb.c,v 1.190 2022/08/29 09:14:02 knakahara Exp $ */ +/* $NetBSD: in_pcb.c,v 1.191 2022/10/14 19:39:32 ryo Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -93,7 +93,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.190 2022/08/29 09:14:02 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.191 2022/10/14 19:39:32 ryo Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -935,6 +935,7 @@ in_pcblookup_port(struct inpcbtable *tab if (vp && table->vestige) { void *state = (*table->vestige->init_ports4)(laddr, lport_arg, lookup_wildcard); vestigial_inpcb_t better; + bool has_better = false; while (table->vestige && (*table->vestige->next_port4)(state, vp)) { @@ -959,7 +960,7 @@ in_pcblookup_port(struct inpcbtable *tab continue; if (wildcard < matchwild) { better = *vp; -match = (void*) +has_better = true; matchwild = wildcard; if (matchwild == 0) @@ -967,13 +968,9 @@ in_pcblookup_port(struct inpcbtable *tab } } - if (match) { - if (match != (void*)) -return match; - else { -*vp = better; -return 0; - } + if (has_better) { + *vp = better; + return 0; } } Index: src/sys/netinet6/in6_pcb.c diff -u src/sys/netinet6/in6_pcb.c:1.170 src/sys/netinet6/in6_pcb.c:1.171 --- src/sys/netinet6/in6_pcb.c:1.170 Mon Aug 29 09:14:02 2022 +++ src/sys/netinet6/in6_pcb.c Fri Oct 14 19:39:32 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: in6_pcb.c,v 1.170 2022/08/29 09:14:02 knakahara Exp $ */ +/* $NetBSD: in6_pcb.c,v 1.171 2022/10/14 19:39:32 ryo Exp $ */ /* $KAME: in6_pcb.c,v 1.84 2001/02/08 18:02:08 itojun Exp $ */ /* @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.170 2022/08/29 09:14:02 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.171 2022/10/14 19:39:32 ryo Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1055,6 +1055,7 @@ in6_pcblookup_port(struct inpcbtable *ta if (vp && table->vestige && table->vestige->init_ports6) { struct vestigial_inpcb better; + bool has_better = false; void *state; state = (*table->vestige->init_ports6)(laddr6, @@ -1087,7 +1088,7 @@ in6_pcblookup_port(struct inpcbtable *ta continue; if (wildcard < matchwild) { better = *vp; -match = (void*) +has_better = true; matchwild = wildcard; if (matchwild == 0) @@ -1095,13 +1096,9 @@ in6_pcblookup_port(struct inpcbtable *ta } } - if (match) { - if (match != (void*)) -return match; - else { -*vp = better; -return 0; - } + if (has_better) { + *vp = better; + return 0; } } return (match);
CVS commit: src/sys
Module Name:src Committed By: ryo Date: Fri Oct 14 19:39:32 UTC 2022 Modified Files: src/sys/netinet: in_pcb.c src/sys/netinet6: in6_pcb.c Log Message: Avoid error of "-Wreturn-local-addr", and simplify the logic. However, -Wreturn-local-addr is still disabled by default by GCC_NO_RETURN_LOCAL_ADDR in bsd.own.mk because it causes errors in other parts. To generate a diff of this commit: cvs rdiff -u -r1.190 -r1.191 src/sys/netinet/in_pcb.c cvs rdiff -u -r1.170 -r1.171 src/sys/netinet6/in6_pcb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/inet
Module Name:src Committed By: ryo Date: Thu Oct 6 06:05:31 UTC 2022 Modified Files: src/tests/lib/libc/inet: t_inet_network.c Log Message: add tests for PR/57046. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/inet/t_inet_network.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/inet/t_inet_network.c diff -u src/tests/lib/libc/inet/t_inet_network.c:1.4 src/tests/lib/libc/inet/t_inet_network.c:1.5 --- src/tests/lib/libc/inet/t_inet_network.c:1.4 Thu Apr 9 16:47:56 2015 +++ src/tests/lib/libc/inet/t_inet_network.c Thu Oct 6 06:05:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: t_inet_network.c,v 1.4 2015/04/09 16:47:56 ginsbach Exp $ */ +/* $NetBSD: t_inet_network.c,v 1.5 2022/10/06 06:05:31 ryo Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_inet_network.c,v 1.4 2015/04/09 16:47:56 ginsbach Exp $"); +__RCSID("$NetBSD: t_inet_network.c,v 1.5 2022/10/06 06:05:31 ryo Exp $"); #include @@ -92,6 +92,9 @@ ATF_TC_BODY(inet_network_err, tc) 0x); H_REQUIRE("255.255.255.255", 0x); H_REQUIRE("x", 0x); + H_REQUIRE("x1", 0x); + H_REQUIRE("xab", 0x); + H_REQUIRE("x100", 0x); H_REQUIRE("078", 0x); H_REQUIRE("127.0xfff", 0x); }
CVS commit: src/tests/lib/libc/inet
Module Name:src Committed By: ryo Date: Thu Oct 6 06:05:31 UTC 2022 Modified Files: src/tests/lib/libc/inet: t_inet_network.c Log Message: add tests for PR/57046. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/inet/t_inet_network.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libc/inet
Module Name:src Committed By: ryo Date: Thu Oct 6 06:03:06 UTC 2022 Modified Files: src/lib/libc/inet: inet_network.c Log Message: fix fixPR/57046. inet_network(3) returns INADDR_NONE when network names such as /x[0-9a-f][0-9a-f]/. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libc/inet/inet_network.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libc/inet
Module Name:src Committed By: ryo Date: Thu Oct 6 06:03:06 UTC 2022 Modified Files: src/lib/libc/inet: inet_network.c Log Message: fix fixPR/57046. inet_network(3) returns INADDR_NONE when network names such as /x[0-9a-f][0-9a-f]/. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libc/inet/inet_network.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/inet/inet_network.c diff -u src/lib/libc/inet/inet_network.c:1.4 src/lib/libc/inet/inet_network.c:1.5 --- src/lib/libc/inet/inet_network.c:1.4 Sun Jan 20 04:56:08 2008 +++ src/lib/libc/inet/inet_network.c Thu Oct 6 06:03:06 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: inet_network.c,v 1.4 2008/01/20 04:56:08 christos Exp $ */ +/* $NetBSD: inet_network.c,v 1.5 2022/10/06 06:03:06 ryo Exp $ */ /* * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: inet_network.c,v 1.4 2008/01/20 04:56:08 christos Exp $"); +__RCSID("$NetBSD: inet_network.c,v 1.5 2022/10/06 06:03:06 ryo Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -71,10 +71,11 @@ inet_network(const char *cp) again: val = 0; base = 10; digit = 0; - if (*cp == '0') + if (*cp == '0') { digit = 1, base = 8, cp++; - if (*cp == 'x' || *cp == 'X') - digit = 0, base = 16, cp++; + if (*cp == 'x' || *cp == 'X') + digit = 0, base = 16, cp++; + } while ((c = *cp) != 0) { if (isdigit(c)) { if (base == 8 && (c == '8' || c == '9'))
CVS commit: src/sys/arch/dreamcast/dev/microcode
Module Name:src Committed By: ryo Date: Sun Sep 25 21:26:22 UTC 2022 Modified Files: src/sys/arch/dreamcast/dev/microcode: aica_arm.c aica_arm_locore.S Log Message: improve comment, update mailaddr, and remove clause 3 from my licenses. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/dreamcast/dev/microcode/aica_arm.c cvs rdiff -u -r1.4 -r1.5 \ src/sys/arch/dreamcast/dev/microcode/aica_arm_locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/dreamcast/dev/microcode
Module Name:src Committed By: ryo Date: Sun Sep 25 21:26:22 UTC 2022 Modified Files: src/sys/arch/dreamcast/dev/microcode: aica_arm.c aica_arm_locore.S Log Message: improve comment, update mailaddr, and remove clause 3 from my licenses. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/dreamcast/dev/microcode/aica_arm.c cvs rdiff -u -r1.4 -r1.5 \ src/sys/arch/dreamcast/dev/microcode/aica_arm_locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/dreamcast/dev/microcode/aica_arm.c diff -u src/sys/arch/dreamcast/dev/microcode/aica_arm.c:1.7 src/sys/arch/dreamcast/dev/microcode/aica_arm.c:1.8 --- src/sys/arch/dreamcast/dev/microcode/aica_arm.c:1.7 Sun Sep 25 21:19:20 2022 +++ src/sys/arch/dreamcast/dev/microcode/aica_arm.c Sun Sep 25 21:26:22 2022 @@ -1,7 +1,7 @@ -/* $NetBSD: aica_arm.c,v 1.7 2022/09/25 21:19:20 ryo Exp $ */ +/* $NetBSD: aica_arm.c,v 1.8 2022/09/25 21:26:22 ryo Exp $ */ /* - * Copyright (c) 2003 SHIMIZU Ryo + * Copyright (c) 2003 Ryo Shimizu * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -13,8 +13,6 @@ * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in the *documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - *derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES Index: src/sys/arch/dreamcast/dev/microcode/aica_arm_locore.S diff -u src/sys/arch/dreamcast/dev/microcode/aica_arm_locore.S:1.4 src/sys/arch/dreamcast/dev/microcode/aica_arm_locore.S:1.5 --- src/sys/arch/dreamcast/dev/microcode/aica_arm_locore.S:1.4 Sun Sep 25 21:19:20 2022 +++ src/sys/arch/dreamcast/dev/microcode/aica_arm_locore.S Sun Sep 25 21:26:22 2022 @@ -1,7 +1,7 @@ -/* $NetBSD: aica_arm_locore.S,v 1.4 2022/09/25 21:19:20 ryo Exp $ */ +/* $NetBSD: aica_arm_locore.S,v 1.5 2022/09/25 21:26:22 ryo Exp $ */ /* - * Copyright (c) 2003 SHIMIZU Ryo + * Copyright (c) 2003 Ryo Shimizu * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -13,8 +13,6 @@ * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in the *documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - *derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -45,8 +43,8 @@ exp_reset: mov sp,#0xff00 /* setup stack */ mrs r0,CPSR /* disable interrupt */ - bic r0,r0,#0x80 - bic r0,r0,#0x40 + bic r0,r0,#0x80 /* disable IRQ */ + bic r0,r0,#0x40 /* disbale FIQ */ msr CPSR_all,r0 mrc p15,0,r0,c1,c0,0 /* read control register */
CVS commit: src/sys/arch/dreamcast/dev/microcode
Module Name:src Committed By: ryo Date: Sun Sep 25 21:19:20 UTC 2022 Modified Files: src/sys/arch/dreamcast/dev/microcode: Makefile aica_arm.c aica_arm_locore.S aica_armcode.h Log Message: arm side of aica(4) sometimes became unresponsive when audioplay was performed several times. - disabled data cache at startup. - compiled with cross-arm-none-eabi-gcc-8.3.0nb4 of pkg. - added memset() in asm because gcc8 (and later) detects the zero clear part in own bzero function and calls memset internally, and bzero were replaced with memset. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/dreamcast/dev/microcode/Makefile cvs rdiff -u -r1.6 -r1.7 src/sys/arch/dreamcast/dev/microcode/aica_arm.c cvs rdiff -u -r1.3 -r1.4 \ src/sys/arch/dreamcast/dev/microcode/aica_arm_locore.S cvs rdiff -u -r1.4 -r1.5 src/sys/arch/dreamcast/dev/microcode/aica_armcode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/dreamcast/dev/microcode/Makefile diff -u src/sys/arch/dreamcast/dev/microcode/Makefile:1.5 src/sys/arch/dreamcast/dev/microcode/Makefile:1.6 --- src/sys/arch/dreamcast/dev/microcode/Makefile:1.5 Mon May 6 17:12:50 2019 +++ src/sys/arch/dreamcast/dev/microcode/Makefile Sun Sep 25 21:19:20 2022 @@ -1,15 +1,16 @@ -# $NetBSD: Makefile,v 1.5 2019/05/06 17:12:50 ryo Exp $ +# $NetBSD: Makefile,v 1.6 2022/09/25 21:19:20 ryo Exp $ S = ${.CURDIR}/../../../.. -CC = ${TOOLDIR}/bin/arm--netbsdelf-gcc -OBJCOPY = ${TOOLDIR}/bin/arm--netbsdelf-objcopy +TOOLDIR ?= /usr/pkg/cross-arm-none-eabi + +CC = ${TOOLDIR}/bin/arm-none-eabi-gcc +OBJCOPY = ${TOOLDIR}/bin/arm-none-eabi-objcopy CFLAGS = -W -Wall -mlittle-endian CFLAGS += -O3 -mcpu=arm7 CFLAGS += -fomit-frame-pointer -funroll-loops -finline-functions CFLAGS += -I${S} -#AFLAGS = -mcpu=arm7tdmi -mthumb -mthumb-interwork -mapcs-32 all: aica_armcode.h Index: src/sys/arch/dreamcast/dev/microcode/aica_arm.c diff -u src/sys/arch/dreamcast/dev/microcode/aica_arm.c:1.6 src/sys/arch/dreamcast/dev/microcode/aica_arm.c:1.7 --- src/sys/arch/dreamcast/dev/microcode/aica_arm.c:1.6 Mon May 6 17:12:50 2019 +++ src/sys/arch/dreamcast/dev/microcode/aica_arm.c Sun Sep 25 21:19:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: aica_arm.c,v 1.6 2019/05/06 17:12:50 ryo Exp $ */ +/* $NetBSD: aica_arm.c,v 1.7 2022/09/25 21:19:20 ryo Exp $ */ /* * Copyright (c) 2003 SHIMIZU Ryo @@ -56,11 +56,11 @@ typedef unsigned long uint32_t; #define CH_WRITE_2(ch,off,val) REG_WRITE_2(((ch) << 7) + (off), val) #define CH_WRITE_4(ch,off,val) REG_WRITE_4(((ch) << 7) + (off), val) +void *memset(void *, int, unsigned long); + void aica_init(void); inline int in_first_half(unsigned int); inline int in_second_half(unsigned int); -void bzero_4(void *, unsigned int); -void bzero(void *, unsigned int); uint32_t rate2reg(unsigned int); void aica_stop(void); void aica_main(void); @@ -120,29 +120,6 @@ in_second_half(unsigned int loophalf) return REG_READ_4(0x2814) >= loophalf; } - -void -bzero_4(void *b, unsigned int len) -{ - uint32_t *p; - - p = b; - len = (len + 3) & ~3; - for (; len != 0; len -= 4) - *p++ = 0; -} - -void -bzero(void *b,unsigned int len) -{ - uint8_t *p; - - p = b; - for (; len != 0; len--) - *p++ = 0; -} - - uint32_t rate2reg(unsigned int rate) { @@ -197,8 +174,8 @@ aica_stop(void) CH_WRITE_4(0, 0x00, 0x8000); CH_WRITE_4(1, 0x00, 0x8000); - bzero_4((void *)AICA_DMABUF_LEFT, AICA_DMABUF_SIZE); - bzero_4((void *)AICA_DMABUF_RIGHT, AICA_DMABUF_SIZE); + memset((void *)AICA_DMABUF_LEFT, 0, AICA_DMABUF_SIZE); + memset((void *)AICA_DMABUF_RIGHT, 0, AICA_DMABUF_SIZE); } void @@ -214,8 +191,8 @@ aica_main(void) REG_WRITE_4(0x28b4, 0x0020); /* INT Enable to SH4 */ - bzero_4((void *)AICA_DMABUF_LEFT, AICA_DMABUF_SIZE); - bzero_4((void *)AICA_DMABUF_RIGHT, AICA_DMABUF_SIZE); + memset((void *)AICA_DMABUF_LEFT, 0, AICA_DMABUF_SIZE); + memset((void *)AICA_DMABUF_RIGHT, 0, AICA_DMABUF_SIZE); play_state = 0; serial = aicacmd->serial = 0; @@ -348,15 +325,15 @@ aica_main(void) case AICA_COMMAND_STOP: switch (play_state) { case 1: -bzero_4((void *)(AICA_DMABUF_LEFT + blksize), +memset((void *)(AICA_DMABUF_LEFT + blksize), 0, blksize); -bzero_4((void *)(AICA_DMABUF_RIGHT + blksize), +memset((void *)(AICA_DMABUF_RIGHT + blksize), 0, blksize); play_state = 3; break; case 2: -bzero_4((void *)AICA_DMABUF_LEFT, blksize); -bzero_4((void *)AICA_DMABUF_RIGHT, blksize); +memset((void *)AICA_DMABUF_LEFT, 0, blksize); +memset((void *)AICA_DMABUF_RIGHT, 0, blksize); play_state = 4; break; default: Index: src/sys/arch/dreamcast/dev/microcode/aica_arm_locore.S diff -u src/sys/arch/dreamcast/dev/microcode/aica_arm_locore.S:1.3 src/sys/arch/dreamcast/dev/microcode/aica_arm_locore.S:1.4 ---
CVS commit: src/sys/arch/dreamcast/dev/microcode
Module Name:src Committed By: ryo Date: Sun Sep 25 21:19:20 UTC 2022 Modified Files: src/sys/arch/dreamcast/dev/microcode: Makefile aica_arm.c aica_arm_locore.S aica_armcode.h Log Message: arm side of aica(4) sometimes became unresponsive when audioplay was performed several times. - disabled data cache at startup. - compiled with cross-arm-none-eabi-gcc-8.3.0nb4 of pkg. - added memset() in asm because gcc8 (and later) detects the zero clear part in own bzero function and calls memset internally, and bzero were replaced with memset. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/dreamcast/dev/microcode/Makefile cvs rdiff -u -r1.6 -r1.7 src/sys/arch/dreamcast/dev/microcode/aica_arm.c cvs rdiff -u -r1.3 -r1.4 \ src/sys/arch/dreamcast/dev/microcode/aica_arm_locore.S cvs rdiff -u -r1.4 -r1.5 src/sys/arch/dreamcast/dev/microcode/aica_armcode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/aarch64/aarch64
Module Name:src Committed By: ryo Date: Thu Sep 22 21:48:19 UTC 2022 Modified Files: src/sys/arch/aarch64/aarch64: db_trace.c Log Message: oops, my previous commit is bad. revert previous. is a frame pointer, not a trapframe, and it worked correctly. (e.g., trace $x29) To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/aarch64/aarch64/db_trace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/aarch64/db_trace.c diff -u src/sys/arch/aarch64/aarch64/db_trace.c:1.22 src/sys/arch/aarch64/aarch64/db_trace.c:1.23 --- src/sys/arch/aarch64/aarch64/db_trace.c:1.22 Thu Sep 22 21:00:46 2022 +++ src/sys/arch/aarch64/aarch64/db_trace.c Thu Sep 22 21:48:18 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: db_trace.c,v 1.22 2022/09/22 21:00:46 ryo Exp $ */ +/* $NetBSD: db_trace.c,v 1.23 2022/09/22 21:48:18 ryo Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.22 2022/09/22 21:00:46 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.23 2022/09/22 21:48:18 ryo Exp $"); #include #include @@ -497,6 +497,15 @@ db_sp_trace(struct trapframe *tf, db_add db_addr_t pc, sp, lr0; bool allow_leaf_function = false; + if (tf == NULL) { + /* + * In the case of "trace/s ", + * the specified frame pointer address is considered + * a trapframe (or a switchframe) address. + */ + tf = (struct trapframe *)fp; + } + pr_frame(tf, pr); db_read_bytes((db_addr_t)tf, sizeof(tf_buf), (char *)_buf); @@ -801,15 +810,6 @@ db_stack_trace_print(db_expr_t addr, boo if (count > MAXBACKTRACE) count = MAXBACKTRACE; - if (tf == NULL) { - /* - * In the case of "trace ", - * the specified frame pointer address is considered - * a trapframe (or a switchframe) address. - */ - tf = (struct trapframe *)fp; - } - if (trace_sp) { /* trace $lr pushed to sp */ db_sp_trace(tf, fp, count, flags, pr);
CVS commit: src/sys/arch/aarch64/aarch64
Module Name:src Committed By: ryo Date: Thu Sep 22 21:48:19 UTC 2022 Modified Files: src/sys/arch/aarch64/aarch64: db_trace.c Log Message: oops, my previous commit is bad. revert previous. is a frame pointer, not a trapframe, and it worked correctly. (e.g., trace $x29) To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/aarch64/aarch64/db_trace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.