Merge ^/head r277804 through r277843.
This commit is contained in:
commit
e375b19ff6
@ -1113,7 +1113,7 @@ amfs_generic_mount_child(am_node *new_mp, int *error_return)
|
||||
new_mp->am_transp = (SVCXPRT *) xmalloc(sizeof(SVCXPRT));
|
||||
*(new_mp->am_transp) = *current_transp;
|
||||
}
|
||||
if (error && (new_mp->am_mnt->mf_ops == &amfs_error_ops))
|
||||
if (error && new_mp->am_mnt && (new_mp->am_mnt->mf_ops == &amfs_error_ops))
|
||||
new_mp->am_error = error;
|
||||
|
||||
if (new_mp->am_error > 0)
|
||||
|
@ -494,7 +494,7 @@ readent:
|
||||
buf[0] = '\0';
|
||||
fgets(buf, 256, passwd_fp);
|
||||
passwd_line++;
|
||||
if (!buf || buf[0] == '\0')
|
||||
if (buf[0] == '\0')
|
||||
goto readent;
|
||||
|
||||
/* read user name */
|
||||
|
@ -210,7 +210,7 @@ static struct {
|
||||
};
|
||||
|
||||
static int copy_from_tempfile(const char *src, const char *dst,
|
||||
int infd, int *outfd);
|
||||
int infd, int *outfd, int in_place);
|
||||
static void create_file(struct elfcopy *ecp, const char *src,
|
||||
const char *dst);
|
||||
static void elfcopy_main(struct elfcopy *ecp, int argc, char **argv);
|
||||
@ -523,33 +523,39 @@ create_tempfile(char **fn, int *fd)
|
||||
#undef _TEMPFILEPATH
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy temporary file with path src and file descriptor infd to path dst.
|
||||
* If in_place is set act as if editing the file in place, avoiding rename()
|
||||
* to preserve hard and symbolic links. Output file remains open, with file
|
||||
* descriptor returned in outfd.
|
||||
*/
|
||||
static int
|
||||
copy_from_tempfile(const char *src, const char *dst, int infd, int *outfd)
|
||||
copy_from_tempfile(const char *src, const char *dst, int infd, int *outfd,
|
||||
int in_place)
|
||||
{
|
||||
int tmpfd;
|
||||
|
||||
/*
|
||||
* First, check if we can use rename().
|
||||
*/
|
||||
if (rename(src, dst) >= 0) {
|
||||
*outfd = infd;
|
||||
return (0);
|
||||
} else if (errno != EXDEV)
|
||||
return (-1);
|
||||
if (in_place == 0) {
|
||||
if (rename(src, dst) >= 0) {
|
||||
*outfd = infd;
|
||||
return (0);
|
||||
} else if (errno != EXDEV)
|
||||
return (-1);
|
||||
|
||||
/*
|
||||
* If the rename() failed due to 'src' and 'dst' residing in
|
||||
* two different file systems, invoke a helper function in
|
||||
* libelftc to do the copy.
|
||||
*/
|
||||
|
||||
/*
|
||||
* If the rename() failed due to 'src' and 'dst' residing in
|
||||
* two different file systems, invoke a helper function in
|
||||
* libelftc to do the copy.
|
||||
*/
|
||||
if (unlink(dst) < 0)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (unlink(dst) < 0)
|
||||
return (-1);
|
||||
|
||||
if ((tmpfd = open(dst, O_CREAT | O_WRONLY, 0755)) < 0)
|
||||
return (-1);
|
||||
|
||||
if (lseek(infd, 0, SEEK_SET) < 0)
|
||||
if ((tmpfd = open(dst, O_CREAT | O_TRUNC | O_WRONLY, 0755)) < 0)
|
||||
return (-1);
|
||||
|
||||
if (elftc_copyfile(infd, tmpfd) < 0)
|
||||
@ -578,6 +584,7 @@ create_file(struct elfcopy *ecp, const char *src, const char *dst)
|
||||
struct stat sb;
|
||||
char *tempfile, *elftemp;
|
||||
int efd, ifd, ofd, ofd0, tfd;
|
||||
int in_place;
|
||||
|
||||
tempfile = NULL;
|
||||
|
||||
@ -718,10 +725,15 @@ copy_done:
|
||||
#endif
|
||||
|
||||
if (tempfile != NULL) {
|
||||
if (dst == NULL)
|
||||
in_place = 0;
|
||||
if (dst == NULL) {
|
||||
dst = src;
|
||||
if (lstat(dst, &sb) != -1 &&
|
||||
(sb.st_nlink > 1 || S_ISLNK(sb.st_mode)))
|
||||
in_place = 1;
|
||||
}
|
||||
|
||||
if (copy_from_tempfile(tempfile, dst, ofd, &tfd) < 0)
|
||||
if (copy_from_tempfile(tempfile, dst, ofd, &tfd, in_place) < 0)
|
||||
err(EXIT_FAILURE, "creation of %s failed", dst);
|
||||
|
||||
free(tempfile);
|
||||
|
@ -54,9 +54,6 @@ overflow_head() {
|
||||
atf_set "descr" "Test overflow cases"
|
||||
}
|
||||
overflow_body() {
|
||||
# Begin FreeBSD
|
||||
atf_expect_fail "FreeBSD's expr does not check overflow to the same degree NetBSD's expr does; see bug 196867 for more details"
|
||||
# End FreeBSD
|
||||
test_expr '4611686018427387904 + 4611686018427387903' \
|
||||
'9223372036854775807'
|
||||
test_expr '4611686018427387904 + 4611686018427387904' \
|
||||
|
@ -74,10 +74,14 @@ static int p6_allocate_pmc(enum pmc_event _pe, char *_ctrspec,
|
||||
static int tsc_allocate_pmc(enum pmc_event _pe, char *_ctrspec,
|
||||
struct pmc_op_pmcallocate *_pmc_config);
|
||||
#endif
|
||||
#if defined(__arm__)
|
||||
#if defined(__XSCALE__)
|
||||
static int xscale_allocate_pmc(enum pmc_event _pe, char *_ctrspec,
|
||||
struct pmc_op_pmcallocate *_pmc_config);
|
||||
#endif
|
||||
static int armv7_allocate_pmc(enum pmc_event _pe, char *_ctrspec,
|
||||
struct pmc_op_pmcallocate *_pmc_config);
|
||||
#endif
|
||||
#if defined(__mips__)
|
||||
static int mips_allocate_pmc(enum pmc_event _pe, char* ctrspec,
|
||||
struct pmc_op_pmcallocate *_pmc_config);
|
||||
@ -153,6 +157,7 @@ PMC_CLASSDEP_TABLE(p4, P4);
|
||||
PMC_CLASSDEP_TABLE(p5, P5);
|
||||
PMC_CLASSDEP_TABLE(p6, P6);
|
||||
PMC_CLASSDEP_TABLE(xscale, XSCALE);
|
||||
PMC_CLASSDEP_TABLE(armv7, ARMV7);
|
||||
PMC_CLASSDEP_TABLE(mips24k, MIPS24K);
|
||||
PMC_CLASSDEP_TABLE(octeon, OCTEON);
|
||||
PMC_CLASSDEP_TABLE(ucf, UCF);
|
||||
@ -286,6 +291,7 @@ PMC_MDEP_TABLE(p4, P4, PMC_CLASS_SOFT, PMC_CLASS_TSC);
|
||||
PMC_MDEP_TABLE(p5, P5, PMC_CLASS_SOFT, PMC_CLASS_TSC);
|
||||
PMC_MDEP_TABLE(p6, P6, PMC_CLASS_SOFT, PMC_CLASS_TSC);
|
||||
PMC_MDEP_TABLE(xscale, XSCALE, PMC_CLASS_SOFT, PMC_CLASS_XSCALE);
|
||||
PMC_MDEP_TABLE(armv7, ARMV7, PMC_CLASS_SOFT, PMC_CLASS_ARMV7);
|
||||
PMC_MDEP_TABLE(mips24k, MIPS24K, PMC_CLASS_SOFT, PMC_CLASS_MIPS24K);
|
||||
PMC_MDEP_TABLE(octeon, OCTEON, PMC_CLASS_SOFT, PMC_CLASS_OCTEON);
|
||||
PMC_MDEP_TABLE(ppc7450, PPC7450, PMC_CLASS_SOFT, PMC_CLASS_PPC7450);
|
||||
@ -346,9 +352,12 @@ PMC_CLASS_TABLE_DESC(p6, P6, p6, p6);
|
||||
#if defined(__i386__) || defined(__amd64__)
|
||||
PMC_CLASS_TABLE_DESC(tsc, TSC, tsc, tsc);
|
||||
#endif
|
||||
#if defined(__arm__)
|
||||
#if defined(__XSCALE__)
|
||||
PMC_CLASS_TABLE_DESC(xscale, XSCALE, xscale, xscale);
|
||||
#endif
|
||||
PMC_CLASS_TABLE_DESC(armv7, ARMV7, armv7, armv7);
|
||||
#endif
|
||||
#if defined(__mips__)
|
||||
PMC_CLASS_TABLE_DESC(mips24k, MIPS24K, mips24k, mips);
|
||||
PMC_CLASS_TABLE_DESC(octeon, OCTEON, octeon, mips);
|
||||
@ -2371,6 +2380,7 @@ soft_allocate_pmc(enum pmc_event pe, char *ctrspec,
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if defined(__arm__)
|
||||
#if defined(__XSCALE__)
|
||||
|
||||
static struct pmc_event_alias xscale_aliases[] = {
|
||||
@ -2394,6 +2404,25 @@ xscale_allocate_pmc(enum pmc_event pe, char *ctrspec __unused,
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct pmc_event_alias armv7_aliases[] = {
|
||||
EV_ALIAS("dc-misses", "L1_DCACHE_REFILL"),
|
||||
EV_ALIAS("ic-misses", "L1_ICACHE_REFILL"),
|
||||
EV_ALIAS("instructions", "INSTR_EXECUTED"),
|
||||
EV_ALIAS(NULL, NULL)
|
||||
};
|
||||
static int
|
||||
armv7_allocate_pmc(enum pmc_event pe, char *ctrspec __unused,
|
||||
struct pmc_op_pmcallocate *pmc_config __unused)
|
||||
{
|
||||
switch (pe) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__mips__)
|
||||
|
||||
static struct pmc_event_alias mips24k_aliases[] = {
|
||||
@ -2886,6 +2915,10 @@ pmc_event_names_of_class(enum pmc_class cl, const char ***eventnames,
|
||||
ev = xscale_event_table;
|
||||
count = PMC_EVENT_TABLE_SIZE(xscale);
|
||||
break;
|
||||
case PMC_CLASS_ARMV7:
|
||||
ev = armv7_event_table;
|
||||
count = PMC_EVENT_TABLE_SIZE(armv7);
|
||||
break;
|
||||
case PMC_CLASS_MIPS24K:
|
||||
ev = mips24k_event_table;
|
||||
count = PMC_EVENT_TABLE_SIZE(mips24k);
|
||||
@ -3163,11 +3196,17 @@ pmc_init(void)
|
||||
case PMC_CPU_GENERIC:
|
||||
PMC_MDEP_INIT(generic);
|
||||
break;
|
||||
#if defined(__arm__)
|
||||
#if defined(__XSCALE__)
|
||||
case PMC_CPU_INTEL_XSCALE:
|
||||
PMC_MDEP_INIT(xscale);
|
||||
pmc_class_table[n] = &xscale_class_table_descr;
|
||||
break;
|
||||
#endif
|
||||
case PMC_CPU_ARMV7:
|
||||
PMC_MDEP_INIT(armv7);
|
||||
pmc_class_table[n] = &armv7_class_table_descr;
|
||||
break;
|
||||
#endif
|
||||
#if defined(__mips__)
|
||||
case PMC_CPU_MIPS_24K:
|
||||
@ -3369,6 +3408,9 @@ _pmc_name_of_event(enum pmc_event pe, enum pmc_cputype cpu)
|
||||
} else if (pe >= PMC_EV_XSCALE_FIRST && pe <= PMC_EV_XSCALE_LAST) {
|
||||
ev = xscale_event_table;
|
||||
evfence = xscale_event_table + PMC_EVENT_TABLE_SIZE(xscale);
|
||||
} else if (pe >= PMC_EV_ARMV7_FIRST && pe <= PMC_EV_ARMV7_LAST) {
|
||||
ev = armv7_event_table;
|
||||
evfence = armv7_event_table + PMC_EVENT_TABLE_SIZE(armv7);
|
||||
} else if (pe >= PMC_EV_MIPS24K_FIRST && pe <= PMC_EV_MIPS24K_LAST) {
|
||||
ev = mips24k_event_table;
|
||||
evfence = mips24k_event_table + PMC_EVENT_TABLE_SIZE(mips24k);
|
||||
|
@ -109,7 +109,7 @@ IMAGES+= memstick.img
|
||||
IMAGES+= mini-memstick.img
|
||||
.endif
|
||||
|
||||
CLEANFILES= packagesystem *.txz MANIFEST system ${IMAGES}
|
||||
CLEANFILES= packagesystem *.txz MANIFEST release ${IMAGES}
|
||||
.if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES)
|
||||
. for I in ${IMAGES}
|
||||
CLEANFILES+= ${I}.xz
|
||||
@ -118,7 +118,7 @@ CLEANFILES+= ${I}.xz
|
||||
.if defined(WITH_DVD) && !empty(WITH_DVD)
|
||||
CLEANFILES+= pkg-stage
|
||||
.endif
|
||||
CLEANDIRS= dist ftp release bootonly dvd
|
||||
CLEANDIRS= dist ftp disc1 bootonly dvd
|
||||
beforeclean:
|
||||
chflags -R noschg .
|
||||
.include <bsd.obj.mk>
|
||||
@ -165,57 +165,57 @@ reldoc:
|
||||
.endfor
|
||||
cp rdoc/${RELNOTES_LANG}/readme/docbook.css reldoc
|
||||
|
||||
system: packagesystem
|
||||
disc1: packagesystem
|
||||
# Install system
|
||||
mkdir -p release
|
||||
mkdir -p ${.TARGET}
|
||||
cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
|
||||
DESTDIR=${.OBJDIR}/release MK_RESCUE=no MK_KERNEL_SYMBOLS=no \
|
||||
DESTDIR=${.OBJDIR}/${.TARGET} MK_RESCUE=no MK_KERNEL_SYMBOLS=no \
|
||||
MK_PROFILE=no MK_SENDMAIL=no MK_TESTS=no MK_LIB32=no \
|
||||
MK_DEBUG_FILES=no
|
||||
# Copy distfiles
|
||||
mkdir -p release/usr/freebsd-dist
|
||||
mkdir -p ${.TARGET}/usr/freebsd-dist
|
||||
for dist in MANIFEST $$(ls *.txz | grep -v -- '-dbg'); \
|
||||
do cp $${dist} release/usr/freebsd-dist; \
|
||||
do cp $${dist} ${.TARGET}/usr/freebsd-dist; \
|
||||
done
|
||||
# Copy documentation, if generated
|
||||
.if !defined(NODOC)
|
||||
cp reldoc/* release
|
||||
cp reldoc/* ${.TARGET}
|
||||
.endif
|
||||
# Set up installation environment
|
||||
ln -fs /tmp/bsdinstall_etc/resolv.conf release/etc/resolv.conf
|
||||
echo sendmail_enable=\"NONE\" > release/etc/rc.conf
|
||||
echo hostid_enable=\"NO\" >> release/etc/rc.conf
|
||||
echo debug.witness.trace=0 >> release/etc/sysctl.conf
|
||||
echo vfs.mountroot.timeout=\"10\" >> release/boot/loader.conf
|
||||
cp ${.CURDIR}/rc.local release/etc
|
||||
ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
|
||||
echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
|
||||
echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
|
||||
echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf
|
||||
echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf
|
||||
cp ${.CURDIR}/rc.local ${.TARGET}/etc
|
||||
touch ${.TARGET}
|
||||
|
||||
bootonly: packagesystem
|
||||
# Install system
|
||||
mkdir -p bootonly
|
||||
mkdir -p ${.TARGET}
|
||||
cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
|
||||
DESTDIR=${.OBJDIR}/bootonly MK_AMD=no MK_AT=no \
|
||||
DESTDIR=${.OBJDIR}/${.TARGET} MK_AMD=no MK_AT=no \
|
||||
MK_GAMES=no MK_GROFF=no \
|
||||
MK_INSTALLLIB=no MK_LIB32=no MK_MAIL=no \
|
||||
MK_NCP=no MK_TOOLCHAIN=no MK_PROFILE=no \
|
||||
MK_INSTALLIB=no MK_RESCUE=no MK_DICT=no \
|
||||
MK_KERNEL_SYMBOLS=no MK_TESTS=no MK_DEBUG_FILES=no
|
||||
# Copy manifest only (no distfiles) to get checksums
|
||||
mkdir -p bootonly/usr/freebsd-dist
|
||||
cp MANIFEST bootonly/usr/freebsd-dist
|
||||
mkdir -p ${.TARGET}/usr/freebsd-dist
|
||||
cp MANIFEST ${.TARGET}/usr/freebsd-dist
|
||||
# Copy documentation, if generated
|
||||
.if !defined(NODOC)
|
||||
cp reldoc/* bootonly
|
||||
cp reldoc/* ${.TARGET}
|
||||
.endif
|
||||
# Set up installation environment
|
||||
ln -fs /tmp/bsdinstall_etc/resolv.conf bootonly/etc/resolv.conf
|
||||
echo sendmail_enable=\"NONE\" > bootonly/etc/rc.conf
|
||||
echo hostid_enable=\"NO\" >> bootonly/etc/rc.conf
|
||||
echo debug.witness.trace=0 >> bootonly/etc/sysctl.conf
|
||||
echo vfs.mountroot.timeout=\"10\" >> bootonly/boot/loader.conf
|
||||
cp ${.CURDIR}/rc.local bootonly/etc
|
||||
ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
|
||||
echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
|
||||
echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
|
||||
echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf
|
||||
echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf
|
||||
cp ${.CURDIR}/rc.local ${.TARGET}/etc
|
||||
|
||||
dvd:
|
||||
dvd: packagesystem
|
||||
# Install system
|
||||
mkdir -p ${.TARGET}
|
||||
cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
|
||||
@ -240,8 +240,8 @@ dvd:
|
||||
touch ${.TARGET}
|
||||
|
||||
release.iso: disc1.iso
|
||||
disc1.iso: system
|
||||
sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_CD ${.TARGET} release
|
||||
disc1.iso: disc1
|
||||
sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_CD ${.TARGET} disc1
|
||||
|
||||
dvd1.iso: dvd pkg-stage
|
||||
sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_DVD ${.TARGET} dvd
|
||||
@ -250,11 +250,11 @@ bootonly.iso: bootonly
|
||||
sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_BO ${.TARGET} bootonly
|
||||
|
||||
memstick: memstick.img
|
||||
memstick.img: system
|
||||
sh ${.CURDIR}/${TARGET}/make-memstick.sh release ${.TARGET}
|
||||
memstick.img: disc1
|
||||
sh ${.CURDIR}/${TARGET}/make-memstick.sh disc1 ${.TARGET}
|
||||
|
||||
mini-memstick: mini-memstick.img
|
||||
mini-memstick.img: system
|
||||
mini-memstick.img: bootonly
|
||||
sh ${.CURDIR}/${TARGET}/make-memstick.sh bootonly ${.TARGET}
|
||||
|
||||
packagesystem: base.txz kernel.txz ${EXTRA_PACKAGES}
|
||||
@ -279,7 +279,7 @@ ftp: packagesystem
|
||||
cp *.txz MANIFEST ftp
|
||||
|
||||
release: real-release vm-release cloudware-release
|
||||
@true
|
||||
touch ${.TARGET}
|
||||
|
||||
real-release:
|
||||
${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj
|
||||
|
@ -5,7 +5,7 @@
|
||||
# Usage: make-manifest.sh foo1.txz foo2.txz ...
|
||||
#
|
||||
# The output file looks like this (tab-delimited):
|
||||
# foo1.txz SHA256-checksu Number-of-files foo1 Description Install-by-default
|
||||
# foo1.txz SHA256-checksum Number-of-files foo1 Description Install-by-default
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
@ -17,7 +17,9 @@ desc_games="Games (fortune, etc.)"
|
||||
desc_lib32="32-bit compatibility libraries"
|
||||
desc_ports="Ports tree"
|
||||
desc_src="System source code"
|
||||
desc_tests="Test suite"
|
||||
src_default=off
|
||||
tests_default=off
|
||||
|
||||
for i in $*; do
|
||||
echo "`basename $i` `sha256 -q $i` `tar tvf $i | wc -l | tr -d ' '` `basename $i .txz` \"`eval echo \\\$desc_$(basename $i .txz)`\" `eval echo \\\${$(basename $i .txz)_default:-on}`"
|
||||
|
@ -24,7 +24,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd January 16, 2015
|
||||
.Dd January 28, 2015
|
||||
.Dt RELEASE 7
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -546,7 +546,7 @@ Major subtargets called by targets above:
|
||||
Generates all the distribution archives
|
||||
.Pq base, kernel, ports, doc
|
||||
applicable on this platform.
|
||||
.It Cm system
|
||||
.It Cm disc1
|
||||
Builds a bootable installation system containing all the distribution files
|
||||
packaged by the
|
||||
.Cm packagesystem
|
||||
|
@ -37,6 +37,7 @@
|
||||
*/
|
||||
|
||||
#include "opt_platform.h"
|
||||
#include "opt_hwpmc_hooks.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
@ -50,6 +51,8 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/bus.h>
|
||||
#include <sys/interrupt.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/pmc.h>
|
||||
#include <sys/pmckern.h>
|
||||
|
||||
#include <machine/atomic.h>
|
||||
#include <machine/intr.h>
|
||||
@ -190,6 +193,10 @@ arm_irq_handler(struct trapframe *frame)
|
||||
arm_mask_irq(i);
|
||||
}
|
||||
}
|
||||
#ifdef HWPMC_HOOKS
|
||||
if (pmc_hook && (PCPU_GET(curthread)->td_pflags & TDP_CALLCHAIN))
|
||||
pmc_hook(PCPU_GET(curthread), PMC_FN_USER_CALLCHAIN, frame);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -30,12 +30,15 @@
|
||||
#define _MACHINE_PMC_MDEP_H_
|
||||
|
||||
#define PMC_MDEP_CLASS_INDEX_XSCALE 1
|
||||
#define PMC_MDEP_CLASS_INDEX_ARMV7 1
|
||||
/*
|
||||
* On the ARM platform we support the following PMCs.
|
||||
*
|
||||
* XSCALE Intel XScale processors
|
||||
* ARMV7 ARM Cortex-A processors
|
||||
*/
|
||||
#include <dev/hwpmc/hwpmc_xscale.h>
|
||||
#include <dev/hwpmc/hwpmc_armv7.h>
|
||||
|
||||
union pmc_md_op_pmcallocate {
|
||||
uint64_t __pad[4];
|
||||
@ -48,6 +51,7 @@ union pmc_md_op_pmcallocate {
|
||||
#ifdef _KERNEL
|
||||
union pmc_md_pmc {
|
||||
struct pmc_md_xscale_pmc pm_xscale;
|
||||
struct pmc_md_armv7_pmc pm_armv7;
|
||||
};
|
||||
|
||||
#define PMC_IN_KERNEL_STACK(S,START,END) \
|
||||
@ -73,6 +77,8 @@ union pmc_md_pmc {
|
||||
*/
|
||||
struct pmc_mdep *pmc_xscale_initialize(void);
|
||||
void pmc_xscale_finalize(struct pmc_mdep *_md);
|
||||
struct pmc_mdep *pmc_armv7_initialize(void);
|
||||
void pmc_armv7_finalize(struct pmc_mdep *_md);
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_MACHINE_PMC_MDEP_H_ */
|
||||
|
@ -9,6 +9,7 @@ arm/arm/cpufunc_asm_armv5.S standard
|
||||
arm/arm/cpufunc_asm_arm10.S standard
|
||||
arm/arm/cpufunc_asm_arm11.S standard
|
||||
arm/arm/cpufunc_asm_armv7.S standard
|
||||
arm/arm/pmu.c optional hwpmc
|
||||
|
||||
arm/ti/ti_common.c standard
|
||||
arm/ti/ti_cpuid.c standard
|
||||
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
|
||||
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
|
||||
* Copyright (c) 2014 by Saso Kiselkov. All rights reserved.
|
||||
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
|
||||
|
@ -70,6 +70,7 @@ crypto/des/des_enc.c optional crypto | ipsec | netsmb
|
||||
dev/fb/fb.c optional sc
|
||||
dev/fdt/fdt_arm_platform.c optional platform fdt
|
||||
dev/hwpmc/hwpmc_arm.c optional hwpmc
|
||||
dev/hwpmc/hwpmc_armv7.c optional hwpmc
|
||||
dev/kbd/kbd.c optional sc | vt
|
||||
dev/syscons/scgfbrndr.c optional sc
|
||||
dev/syscons/scterm-teken.c optional sc
|
||||
|
@ -282,7 +282,8 @@ typedef struct {
|
||||
halRadioRetentionSupport : 1,
|
||||
halSpectralScanSupport : 1,
|
||||
halRxUsingLnaMixing : 1,
|
||||
halRxDoMyBeacon : 1;
|
||||
halRxDoMyBeacon : 1,
|
||||
halHwUapsdTrig : 1;
|
||||
|
||||
uint32_t halWirelessModes;
|
||||
uint16_t halTotalQueues;
|
||||
|
@ -891,8 +891,8 @@ ath_rate_tx_complete(struct ath_softc *sc, struct ath_node *an,
|
||||
|
||||
if (!mrr || ts->ts_finaltsi == 0) {
|
||||
if (!IS_RATE_DEFINED(sn, final_rix)) {
|
||||
device_printf(sc->sc_dev, "%s: ts_rate=%d ts_finaltsi=%d\n",
|
||||
__func__, ts->ts_rate, ts->ts_finaltsi);
|
||||
device_printf(sc->sc_dev, "%s: ts_rate=%d ts_finaltsi=%d, final_rix=%d\n",
|
||||
__func__, ts->ts_rate, ts->ts_finaltsi, final_rix);
|
||||
badrate(ifp, 0, ts->ts_rate, long_tries, status);
|
||||
return;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ struct sample_node {
|
||||
#ifdef _KERNEL
|
||||
|
||||
#define ATH_NODE_SAMPLE(an) ((struct sample_node *)&(an)[1])
|
||||
#define IS_RATE_DEFINED(sn, rix) (((sn)->ratemask & (1<<(rix))) != 0)
|
||||
#define IS_RATE_DEFINED(sn, rix) (((uint64_t) (sn)->ratemask & (1ULL<<((uint64_t) rix))) != 0)
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
|
@ -47,9 +47,12 @@ pmc_md_initialize()
|
||||
#ifdef CPU_XSCALE_IXP425
|
||||
if (cpu_class == CPU_CLASS_XSCALE)
|
||||
return pmc_xscale_initialize();
|
||||
else
|
||||
#endif
|
||||
return NULL;
|
||||
#ifdef CPU_CORTEXA
|
||||
if (cpu_class == CPU_CLASS_CORTEXA)
|
||||
return pmc_armv7_initialize();
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
@ -62,6 +65,10 @@ pmc_md_finalize(struct pmc_mdep *md)
|
||||
KASSERT(0, ("[arm,%d] Unknown CPU Class 0x%x", __LINE__,
|
||||
cpu_class));
|
||||
#endif
|
||||
#ifdef CPU_CORTEXA
|
||||
if (cpu_class == CPU_CLASS_CORTEXA)
|
||||
pmc_armv7_finalize(md);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
|
652
sys/dev/hwpmc/hwpmc_armv7.c
Normal file
652
sys/dev/hwpmc/hwpmc_armv7.c
Normal file
@ -0,0 +1,652 @@
|
||||
/*-
|
||||
* Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by SRI International and the University of
|
||||
* Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
|
||||
* ("CTSRD"), as part of the DARPA CRASH research programme.
|
||||
*
|
||||
* 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 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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/pmc.h>
|
||||
#include <sys/pmckern.h>
|
||||
|
||||
#include <machine/pmc_mdep.h>
|
||||
#include <machine/cpu.h>
|
||||
|
||||
#define CPU_ID_CORTEX_VER_MASK 0xff
|
||||
#define CPU_ID_CORTEX_VER_SHIFT 4
|
||||
|
||||
static int armv7_npmcs;
|
||||
|
||||
struct armv7_event_code_map {
|
||||
enum pmc_event pe_ev;
|
||||
uint8_t pe_code;
|
||||
};
|
||||
|
||||
const struct armv7_event_code_map armv7_event_codes[] = {
|
||||
{ PMC_EV_ARMV7_PMNC_SW_INCR, 0x00 },
|
||||
{ PMC_EV_ARMV7_L1_ICACHE_REFILL, 0x01 },
|
||||
{ PMC_EV_ARMV7_ITLB_REFILL, 0x02 },
|
||||
{ PMC_EV_ARMV7_L1_DCACHE_REFILL, 0x03 },
|
||||
{ PMC_EV_ARMV7_L1_DCACHE_ACCESS, 0x04 },
|
||||
{ PMC_EV_ARMV7_DTLB_REFILL, 0x05 },
|
||||
{ PMC_EV_ARMV7_MEM_READ, 0x06 },
|
||||
{ PMC_EV_ARMV7_MEM_WRITE, 0x07 },
|
||||
{ PMC_EV_ARMV7_INSTR_EXECUTED, 0x08 },
|
||||
{ PMC_EV_ARMV7_EXC_TAKEN, 0x09 },
|
||||
{ PMC_EV_ARMV7_EXC_EXECUTED, 0x0A },
|
||||
{ PMC_EV_ARMV7_CID_WRITE, 0x0B },
|
||||
{ PMC_EV_ARMV7_PC_WRITE, 0x0C },
|
||||
{ PMC_EV_ARMV7_PC_IMM_BRANCH, 0x0D },
|
||||
{ PMC_EV_ARMV7_PC_PROC_RETURN, 0x0E },
|
||||
{ PMC_EV_ARMV7_MEM_UNALIGNED_ACCESS, 0x0F },
|
||||
{ PMC_EV_ARMV7_PC_BRANCH_MIS_PRED, 0x10 },
|
||||
{ PMC_EV_ARMV7_CLOCK_CYCLES, 0x11 },
|
||||
{ PMC_EV_ARMV7_PC_BRANCH_PRED, 0x12 },
|
||||
{ PMC_EV_ARMV7_MEM_ACCESS, 0x13 },
|
||||
{ PMC_EV_ARMV7_L1_ICACHE_ACCESS, 0x14 },
|
||||
{ PMC_EV_ARMV7_L1_DCACHE_WB, 0x15 },
|
||||
{ PMC_EV_ARMV7_L2_CACHE_ACCESS, 0x16 },
|
||||
{ PMC_EV_ARMV7_L2_CACHE_REFILL, 0x17 },
|
||||
{ PMC_EV_ARMV7_L2_CACHE_WB, 0x18 },
|
||||
{ PMC_EV_ARMV7_BUS_ACCESS, 0x19 },
|
||||
{ PMC_EV_ARMV7_MEM_ERROR, 0x1A },
|
||||
{ PMC_EV_ARMV7_INSTR_SPEC, 0x1B },
|
||||
{ PMC_EV_ARMV7_TTBR_WRITE, 0x1C },
|
||||
{ PMC_EV_ARMV7_BUS_CYCLES, 0x1D },
|
||||
{ PMC_EV_ARMV7_CPU_CYCLES, 0xFF },
|
||||
};
|
||||
|
||||
const int armv7_event_codes_size =
|
||||
sizeof(armv7_event_codes) / sizeof(armv7_event_codes[0]);
|
||||
|
||||
/*
|
||||
* Per-processor information.
|
||||
*/
|
||||
struct armv7_cpu {
|
||||
struct pmc_hw *pc_armv7pmcs;
|
||||
int cortex_ver;
|
||||
};
|
||||
|
||||
static struct armv7_cpu **armv7_pcpu;
|
||||
|
||||
/*
|
||||
* Performance Monitor Control Register
|
||||
*/
|
||||
static __inline uint32_t
|
||||
armv7_pmnc_read(void)
|
||||
{
|
||||
uint32_t reg;
|
||||
|
||||
__asm __volatile("mrc p15, 0, %0, c9, c12, 0" : "=r" (reg));
|
||||
|
||||
return (reg);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
armv7_pmnc_write(uint32_t reg)
|
||||
{
|
||||
|
||||
__asm __volatile("mcr p15, 0, %0, c9, c12, 0" : : "r" (reg));
|
||||
}
|
||||
|
||||
/*
|
||||
* Clock Counter Register (PMCCNTR)
|
||||
* Counts processor clock cycles.
|
||||
*/
|
||||
static __inline uint32_t
|
||||
armv7_ccnt_read(void)
|
||||
{
|
||||
uint32_t reg;
|
||||
|
||||
__asm __volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (reg));
|
||||
|
||||
return (reg);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
armv7_ccnt_write(uint32_t reg)
|
||||
{
|
||||
|
||||
__asm __volatile("mcr p15, 0, %0, c9, c13, 0" : : "r" (reg));
|
||||
}
|
||||
|
||||
/*
|
||||
* Interrupt Enable Set Register
|
||||
*/
|
||||
static __inline void
|
||||
armv7_interrupt_enable(uint32_t pmc)
|
||||
{
|
||||
uint32_t reg;
|
||||
|
||||
reg = (1 << pmc);
|
||||
|
||||
__asm __volatile("mcr p15, 0, %0, c9, c14, 1" : : "r" (reg));
|
||||
}
|
||||
|
||||
/*
|
||||
* Interrupt Clear Set Register
|
||||
*/
|
||||
static __inline void
|
||||
armv7_interrupt_disable(uint32_t pmc)
|
||||
{
|
||||
uint32_t reg;
|
||||
|
||||
reg = (1 << pmc);
|
||||
|
||||
__asm __volatile("mcr p15, 0, %0, c9, c14, 2" : : "r" (reg));
|
||||
}
|
||||
|
||||
/*
|
||||
* Overflow Flag Register
|
||||
*/
|
||||
static __inline uint32_t
|
||||
armv7_flag_read(void)
|
||||
{
|
||||
uint32_t reg;
|
||||
|
||||
__asm __volatile("mrc p15, 0, %0, c9, c12, 3" : "=r" (reg));
|
||||
|
||||
return (reg);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
armv7_flag_write(uint32_t reg)
|
||||
{
|
||||
|
||||
__asm __volatile("mcr p15, 0, %0, c9, c12, 3" : : "r" (reg));
|
||||
}
|
||||
|
||||
/*
|
||||
* Event Selection Register
|
||||
*/
|
||||
static __inline void
|
||||
armv7_evtsel_write(uint32_t reg)
|
||||
{
|
||||
|
||||
__asm __volatile("mcr p15, 0, %0, c9, c13, 1" : : "r" (reg));
|
||||
}
|
||||
|
||||
/*
|
||||
* PMSELR
|
||||
*/
|
||||
static __inline void
|
||||
armv7_select_counter(unsigned int pmc)
|
||||
{
|
||||
|
||||
__asm __volatile("mcr p15, 0, %0, c9, c12, 5" : : "r" (pmc));
|
||||
}
|
||||
|
||||
/*
|
||||
* Counter Set Enable Register
|
||||
*/
|
||||
static __inline void
|
||||
armv7_counter_enable(unsigned int pmc)
|
||||
{
|
||||
uint32_t reg;
|
||||
|
||||
reg = (1 << pmc);
|
||||
|
||||
__asm __volatile("mcr p15, 0, %0, c9, c12, 1" : : "r" (reg));
|
||||
}
|
||||
|
||||
/*
|
||||
* Counter Clear Enable Register
|
||||
*/
|
||||
static __inline void
|
||||
armv7_counter_disable(unsigned int pmc)
|
||||
{
|
||||
uint32_t reg;
|
||||
|
||||
reg = (1 << pmc);
|
||||
|
||||
__asm __volatile("mcr p15, 0, %0, c9, c12, 2" : : "r" (reg));
|
||||
}
|
||||
|
||||
/*
|
||||
* Performance Count Register N
|
||||
*/
|
||||
static uint32_t
|
||||
armv7_pmcn_read(unsigned int pmc)
|
||||
{
|
||||
uint32_t reg = 0;
|
||||
|
||||
KASSERT(pmc < 4, ("[armv7,%d] illegal PMC number %d", __LINE__, pmc));
|
||||
|
||||
armv7_select_counter(pmc);
|
||||
__asm __volatile("mrc p15, 0, %0, c9, c13, 2" : "=r" (reg));
|
||||
|
||||
return (reg);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
armv7_pmcn_write(unsigned int pmc, uint32_t reg)
|
||||
{
|
||||
|
||||
KASSERT(pmc < 4, ("[armv7,%d] illegal PMC number %d", __LINE__, pmc));
|
||||
|
||||
armv7_select_counter(pmc);
|
||||
__asm __volatile("mcr p15, 0, %0, c9, c13, 2" : : "r" (reg));
|
||||
|
||||
return (reg);
|
||||
}
|
||||
|
||||
static int
|
||||
armv7_allocate_pmc(int cpu, int ri, struct pmc *pm,
|
||||
const struct pmc_op_pmcallocate *a)
|
||||
{
|
||||
uint32_t caps, config;
|
||||
struct armv7_cpu *pac;
|
||||
enum pmc_event pe;
|
||||
int i;
|
||||
|
||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
||||
("[armv7,%d] illegal CPU value %d", __LINE__, cpu));
|
||||
KASSERT(ri >= 0 && ri < armv7_npmcs,
|
||||
("[armv7,%d] illegal row index %d", __LINE__, ri));
|
||||
|
||||
pac = armv7_pcpu[cpu];
|
||||
|
||||
caps = a->pm_caps;
|
||||
if (a->pm_class != PMC_CLASS_ARMV7)
|
||||
return (EINVAL);
|
||||
pe = a->pm_ev;
|
||||
|
||||
for (i = 0; i < armv7_event_codes_size; i++) {
|
||||
if (armv7_event_codes[i].pe_ev == pe) {
|
||||
config = armv7_event_codes[i].pe_code;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == armv7_event_codes_size)
|
||||
return EINVAL;
|
||||
|
||||
pm->pm_md.pm_armv7.pm_armv7_evsel = config;
|
||||
|
||||
PMCDBG(MDP,ALL,2,"armv7-allocate ri=%d -> config=0x%x", ri, config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
armv7_read_pmc(int cpu, int ri, pmc_value_t *v)
|
||||
{
|
||||
pmc_value_t tmp;
|
||||
struct pmc *pm;
|
||||
|
||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
||||
("[armv7,%d] illegal CPU value %d", __LINE__, cpu));
|
||||
KASSERT(ri >= 0 && ri < armv7_npmcs,
|
||||
("[armv7,%d] illegal row index %d", __LINE__, ri));
|
||||
|
||||
pm = armv7_pcpu[cpu]->pc_armv7pmcs[ri].phw_pmc;
|
||||
|
||||
if (pm->pm_md.pm_armv7.pm_armv7_evsel == 0xFF)
|
||||
tmp = armv7_ccnt_read();
|
||||
else
|
||||
tmp = armv7_pmcn_read(ri);
|
||||
|
||||
PMCDBG(MDP,REA,2,"armv7-read id=%d -> %jd", ri, tmp);
|
||||
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
|
||||
*v = ARMV7_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp);
|
||||
else
|
||||
*v = tmp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
armv7_write_pmc(int cpu, int ri, pmc_value_t v)
|
||||
{
|
||||
struct pmc *pm;
|
||||
|
||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
||||
("[armv7,%d] illegal CPU value %d", __LINE__, cpu));
|
||||
KASSERT(ri >= 0 && ri < armv7_npmcs,
|
||||
("[armv7,%d] illegal row-index %d", __LINE__, ri));
|
||||
|
||||
pm = armv7_pcpu[cpu]->pc_armv7pmcs[ri].phw_pmc;
|
||||
|
||||
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
|
||||
v = ARMV7_RELOAD_COUNT_TO_PERFCTR_VALUE(v);
|
||||
|
||||
PMCDBG(MDP,WRI,1,"armv7-write cpu=%d ri=%d v=%jx", cpu, ri, v);
|
||||
|
||||
if (pm->pm_md.pm_armv7.pm_armv7_evsel == 0xFF)
|
||||
armv7_ccnt_write(v);
|
||||
else
|
||||
armv7_pmcn_write(ri, v);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
armv7_config_pmc(int cpu, int ri, struct pmc *pm)
|
||||
{
|
||||
struct pmc_hw *phw;
|
||||
|
||||
PMCDBG(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
|
||||
|
||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
||||
("[armv7,%d] illegal CPU value %d", __LINE__, cpu));
|
||||
KASSERT(ri >= 0 && ri < armv7_npmcs,
|
||||
("[armv7,%d] illegal row-index %d", __LINE__, ri));
|
||||
|
||||
phw = &armv7_pcpu[cpu]->pc_armv7pmcs[ri];
|
||||
|
||||
KASSERT(pm == NULL || phw->phw_pmc == NULL,
|
||||
("[armv7,%d] pm=%p phw->pm=%p hwpmc not unconfigured",
|
||||
__LINE__, pm, phw->phw_pmc));
|
||||
|
||||
phw->phw_pmc = pm;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
armv7_start_pmc(int cpu, int ri)
|
||||
{
|
||||
struct pmc_hw *phw;
|
||||
uint32_t config;
|
||||
struct pmc *pm;
|
||||
|
||||
phw = &armv7_pcpu[cpu]->pc_armv7pmcs[ri];
|
||||
pm = phw->phw_pmc;
|
||||
config = pm->pm_md.pm_armv7.pm_armv7_evsel;
|
||||
|
||||
/*
|
||||
* Configure the event selection.
|
||||
*/
|
||||
armv7_select_counter(ri);
|
||||
armv7_evtsel_write(config);
|
||||
|
||||
/*
|
||||
* Enable the PMC.
|
||||
*/
|
||||
armv7_interrupt_enable(ri);
|
||||
armv7_counter_enable(ri);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
armv7_stop_pmc(int cpu, int ri)
|
||||
{
|
||||
struct pmc_hw *phw;
|
||||
struct pmc *pm;
|
||||
|
||||
phw = &armv7_pcpu[cpu]->pc_armv7pmcs[ri];
|
||||
pm = phw->phw_pmc;
|
||||
|
||||
/*
|
||||
* Disable the PMCs.
|
||||
*/
|
||||
armv7_counter_disable(ri);
|
||||
armv7_interrupt_disable(ri);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
armv7_release_pmc(int cpu, int ri, struct pmc *pmc)
|
||||
{
|
||||
struct pmc_hw *phw;
|
||||
|
||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
||||
("[armv7,%d] illegal CPU value %d", __LINE__, cpu));
|
||||
KASSERT(ri >= 0 && ri < armv7_npmcs,
|
||||
("[armv7,%d] illegal row-index %d", __LINE__, ri));
|
||||
|
||||
phw = &armv7_pcpu[cpu]->pc_armv7pmcs[ri];
|
||||
KASSERT(phw->phw_pmc == NULL,
|
||||
("[armv7,%d] PHW pmc %p non-NULL", __LINE__, phw->phw_pmc));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
armv7_intr(int cpu, struct trapframe *tf)
|
||||
{
|
||||
struct armv7_cpu *pc;
|
||||
int retval, ri;
|
||||
struct pmc *pm;
|
||||
int error;
|
||||
int reg;
|
||||
|
||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
||||
("[armv7,%d] CPU %d out of range", __LINE__, cpu));
|
||||
|
||||
retval = 0;
|
||||
pc = armv7_pcpu[cpu];
|
||||
|
||||
for (ri = 0; ri < armv7_npmcs; ri++) {
|
||||
pm = armv7_pcpu[cpu]->pc_armv7pmcs[ri].phw_pmc;
|
||||
if (pm == NULL)
|
||||
continue;
|
||||
if (!PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
|
||||
continue;
|
||||
|
||||
/* Check if counter has overflowed */
|
||||
if (pm->pm_md.pm_armv7.pm_armv7_evsel == 0xFF)
|
||||
reg = (1 << 31);
|
||||
else
|
||||
reg = (1 << ri);
|
||||
|
||||
if ((armv7_flag_read() & reg) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Clear Overflow Flag */
|
||||
armv7_flag_write(reg);
|
||||
|
||||
retval = 1; /* Found an interrupting PMC. */
|
||||
if (pm->pm_state != PMC_STATE_RUNNING)
|
||||
continue;
|
||||
|
||||
error = pmc_process_interrupt(cpu, PMC_HR, pm, tf,
|
||||
TRAPF_USERMODE(tf));
|
||||
if (error)
|
||||
armv7_stop_pmc(cpu, ri);
|
||||
|
||||
/* Reload sampling count */
|
||||
armv7_write_pmc(cpu, ri, pm->pm_sc.pm_reloadcount);
|
||||
}
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
static int
|
||||
armv7_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
|
||||
{
|
||||
char armv7_name[PMC_NAME_MAX];
|
||||
struct pmc_hw *phw;
|
||||
int error;
|
||||
|
||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
||||
("[armv7,%d], illegal CPU %d", __LINE__, cpu));
|
||||
KASSERT(ri >= 0 && ri < armv7_npmcs,
|
||||
("[armv7,%d] row-index %d out of range", __LINE__, ri));
|
||||
|
||||
phw = &armv7_pcpu[cpu]->pc_armv7pmcs[ri];
|
||||
snprintf(armv7_name, sizeof(armv7_name), "ARMV7-%d", ri);
|
||||
if ((error = copystr(armv7_name, pi->pm_name, PMC_NAME_MAX,
|
||||
NULL)) != 0)
|
||||
return error;
|
||||
pi->pm_class = PMC_CLASS_ARMV7;
|
||||
if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
|
||||
pi->pm_enabled = TRUE;
|
||||
*ppmc = phw->phw_pmc;
|
||||
} else {
|
||||
pi->pm_enabled = FALSE;
|
||||
*ppmc = NULL;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
armv7_get_config(int cpu, int ri, struct pmc **ppm)
|
||||
{
|
||||
|
||||
*ppm = armv7_pcpu[cpu]->pc_armv7pmcs[ri].phw_pmc;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX don't know what we should do here.
|
||||
*/
|
||||
static int
|
||||
armv7_switch_in(struct pmc_cpu *pc, struct pmc_process *pp)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
armv7_switch_out(struct pmc_cpu *pc, struct pmc_process *pp)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
armv7_pcpu_init(struct pmc_mdep *md, int cpu)
|
||||
{
|
||||
struct armv7_cpu *pac;
|
||||
struct pmc_hw *phw;
|
||||
struct pmc_cpu *pc;
|
||||
uint32_t pmnc;
|
||||
int first_ri;
|
||||
int cpuid;
|
||||
int i;
|
||||
|
||||
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
|
||||
("[armv7,%d] wrong cpu number %d", __LINE__, cpu));
|
||||
PMCDBG(MDP,INI,1,"armv7-init cpu=%d", cpu);
|
||||
|
||||
armv7_pcpu[cpu] = pac = malloc(sizeof(struct armv7_cpu), M_PMC,
|
||||
M_WAITOK|M_ZERO);
|
||||
|
||||
cpuid = cpu_id();
|
||||
pac->cortex_ver = (cpuid >> CPU_ID_CORTEX_VER_SHIFT) & \
|
||||
CPU_ID_CORTEX_VER_MASK;
|
||||
|
||||
pac->pc_armv7pmcs = malloc(sizeof(struct pmc_hw) * armv7_npmcs,
|
||||
M_PMC, M_WAITOK|M_ZERO);
|
||||
pc = pmc_pcpu[cpu];
|
||||
first_ri = md->pmd_classdep[PMC_MDEP_CLASS_INDEX_ARMV7].pcd_ri;
|
||||
KASSERT(pc != NULL, ("[armv7,%d] NULL per-cpu pointer", __LINE__));
|
||||
|
||||
for (i = 0, phw = pac->pc_armv7pmcs; i < armv7_npmcs; i++, phw++) {
|
||||
phw->phw_state = PMC_PHW_FLAG_IS_ENABLED |
|
||||
PMC_PHW_CPU_TO_STATE(cpu) | PMC_PHW_INDEX_TO_STATE(i);
|
||||
phw->phw_pmc = NULL;
|
||||
pc->pc_hwpmcs[i + first_ri] = phw;
|
||||
}
|
||||
|
||||
/* Enable unit */
|
||||
pmnc = armv7_pmnc_read();
|
||||
pmnc |= ARMV7_PMNC_ENABLE;
|
||||
armv7_pmnc_write(pmnc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
armv7_pcpu_fini(struct pmc_mdep *md, int cpu)
|
||||
{
|
||||
uint32_t pmnc;
|
||||
|
||||
pmnc = armv7_pmnc_read();
|
||||
pmnc &= ~ARMV7_PMNC_ENABLE;
|
||||
armv7_pmnc_write(pmnc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct pmc_mdep *
|
||||
pmc_armv7_initialize()
|
||||
{
|
||||
struct pmc_mdep *pmc_mdep;
|
||||
struct pmc_classdep *pcd;
|
||||
int reg;
|
||||
|
||||
reg = armv7_pmnc_read();
|
||||
|
||||
armv7_npmcs = (reg >> ARMV7_PMNC_N_SHIFT) & \
|
||||
ARMV7_PMNC_N_MASK;
|
||||
|
||||
PMCDBG(MDP,INI,1,"armv7-init npmcs=%d", armv7_npmcs);
|
||||
|
||||
/*
|
||||
* Allocate space for pointers to PMC HW descriptors and for
|
||||
* the MDEP structure used by MI code.
|
||||
*/
|
||||
armv7_pcpu = malloc(sizeof(struct armv7_cpu *) * pmc_cpu_max(),
|
||||
M_PMC, M_WAITOK | M_ZERO);
|
||||
|
||||
/* Just one class */
|
||||
pmc_mdep = pmc_mdep_alloc(1);
|
||||
pmc_mdep->pmd_cputype = PMC_CPU_ARMV7;
|
||||
|
||||
pcd = &pmc_mdep->pmd_classdep[PMC_MDEP_CLASS_INDEX_ARMV7];
|
||||
pcd->pcd_caps = ARMV7_PMC_CAPS;
|
||||
pcd->pcd_class = PMC_CLASS_ARMV7;
|
||||
pcd->pcd_num = armv7_npmcs;
|
||||
pcd->pcd_ri = pmc_mdep->pmd_npmc;
|
||||
pcd->pcd_width = 32;
|
||||
|
||||
pcd->pcd_allocate_pmc = armv7_allocate_pmc;
|
||||
pcd->pcd_config_pmc = armv7_config_pmc;
|
||||
pcd->pcd_pcpu_fini = armv7_pcpu_fini;
|
||||
pcd->pcd_pcpu_init = armv7_pcpu_init;
|
||||
pcd->pcd_describe = armv7_describe;
|
||||
pcd->pcd_get_config = armv7_get_config;
|
||||
pcd->pcd_read_pmc = armv7_read_pmc;
|
||||
pcd->pcd_release_pmc = armv7_release_pmc;
|
||||
pcd->pcd_start_pmc = armv7_start_pmc;
|
||||
pcd->pcd_stop_pmc = armv7_stop_pmc;
|
||||
pcd->pcd_write_pmc = armv7_write_pmc;
|
||||
|
||||
pmc_mdep->pmd_intr = armv7_intr;
|
||||
pmc_mdep->pmd_switch_in = armv7_switch_in;
|
||||
pmc_mdep->pmd_switch_out = armv7_switch_out;
|
||||
|
||||
pmc_mdep->pmd_npmc += armv7_npmcs;
|
||||
|
||||
return (pmc_mdep);
|
||||
}
|
||||
|
||||
void
|
||||
pmc_armv7_finalize(struct pmc_mdep *md)
|
||||
{
|
||||
|
||||
}
|
61
sys/dev/hwpmc/hwpmc_armv7.h
Normal file
61
sys/dev/hwpmc/hwpmc_armv7.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*-
|
||||
* Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by SRI International and the University of
|
||||
* Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
|
||||
* ("CTSRD"), as part of the DARPA CRASH research programme.
|
||||
*
|
||||
* 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 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _DEV_HWPMC_ARMV7_H_
|
||||
#define _DEV_HWPMC_ARMV7_H_
|
||||
|
||||
#define ARMV7_PMC_CAPS (PMC_CAP_INTERRUPT | PMC_CAP_USER | \
|
||||
PMC_CAP_SYSTEM | PMC_CAP_EDGE | \
|
||||
PMC_CAP_THRESHOLD | PMC_CAP_READ | \
|
||||
PMC_CAP_WRITE | PMC_CAP_INVERT | \
|
||||
PMC_CAP_QUALIFIER)
|
||||
|
||||
#define ARMV7_PMNC_ENABLE (1 << 0) /* Enable all counters */
|
||||
#define ARMV7_PMNC_P (1 << 1) /* Reset all counters */
|
||||
#define ARMV7_PMNC_C (1 << 2) /* Cycle counter reset */
|
||||
#define ARMV7_PMNC_D (1 << 3) /* CCNT counts every 64th cpu cycle */
|
||||
#define ARMV7_PMNC_X (1 << 4) /* Export to ext. monitoring (ETM) */
|
||||
#define ARMV7_PMNC_DP (1 << 5) /* Disable CCNT if non-invasive debug*/
|
||||
#define ARMV7_PMNC_N_SHIFT 11 /* Number of counters implemented */
|
||||
#define ARMV7_PMNC_N_MASK 0x1f
|
||||
#define ARMV7_PMNC_MASK 0x3f /* Writable bits */
|
||||
|
||||
#define ARMV7_RELOAD_COUNT_TO_PERFCTR_VALUE(R) (-(R))
|
||||
#define ARMV7_PERFCTR_VALUE_TO_RELOAD_COUNT(P) (-(P))
|
||||
|
||||
#ifdef _KERNEL
|
||||
/* MD extension for 'struct pmc' */
|
||||
struct pmc_md_armv7_pmc {
|
||||
uint32_t pm_armv7_evsel;
|
||||
};
|
||||
#endif /* _KERNEL */
|
||||
#endif /* _DEV_HWPMC_ARMV7_H_ */
|
@ -4756,6 +4756,46 @@ __PMC_EV_ALIAS("IMPC_C0H_TRK_REQUEST.ALL", UCP_EVENT_84H_01H)
|
||||
#define PMC_EV_XSCALE_FIRST PMC_EV_XSCALE_IC_FETCH
|
||||
#define PMC_EV_XSCALE_LAST PMC_EV_XSCALE_DATA_BUS_TRANS
|
||||
|
||||
/*
|
||||
* ARMv7 Events
|
||||
*/
|
||||
|
||||
#define __PMC_EV_ARMV7() \
|
||||
__PMC_EV(ARMV7, PMNC_SW_INCR) \
|
||||
__PMC_EV(ARMV7, L1_ICACHE_REFILL) \
|
||||
__PMC_EV(ARMV7, ITLB_REFILL) \
|
||||
__PMC_EV(ARMV7, L1_DCACHE_REFILL) \
|
||||
__PMC_EV(ARMV7, L1_DCACHE_ACCESS) \
|
||||
__PMC_EV(ARMV7, DTLB_REFILL) \
|
||||
__PMC_EV(ARMV7, MEM_READ) \
|
||||
__PMC_EV(ARMV7, MEM_WRITE) \
|
||||
__PMC_EV(ARMV7, INSTR_EXECUTED) \
|
||||
__PMC_EV(ARMV7, EXC_TAKEN) \
|
||||
__PMC_EV(ARMV7, EXC_EXECUTED) \
|
||||
__PMC_EV(ARMV7, CID_WRITE) \
|
||||
__PMC_EV(ARMV7, PC_WRITE) \
|
||||
__PMC_EV(ARMV7, PC_IMM_BRANCH) \
|
||||
__PMC_EV(ARMV7, PC_PROC_RETURN) \
|
||||
__PMC_EV(ARMV7, MEM_UNALIGNED_ACCESS) \
|
||||
__PMC_EV(ARMV7, PC_BRANCH_MIS_PRED) \
|
||||
__PMC_EV(ARMV7, CLOCK_CYCLES) \
|
||||
__PMC_EV(ARMV7, PC_BRANCH_PRED) \
|
||||
__PMC_EV(ARMV7, MEM_ACCESS) \
|
||||
__PMC_EV(ARMV7, L1_ICACHE_ACCESS) \
|
||||
__PMC_EV(ARMV7, L1_DCACHE_WB) \
|
||||
__PMC_EV(ARMV7, L2_CACHE_ACCESS) \
|
||||
__PMC_EV(ARMV7, L2_CACHE_REFILL) \
|
||||
__PMC_EV(ARMV7, L2_CACHE_WB) \
|
||||
__PMC_EV(ARMV7, BUS_ACCESS) \
|
||||
__PMC_EV(ARMV7, MEM_ERROR) \
|
||||
__PMC_EV(ARMV7, INSTR_SPEC) \
|
||||
__PMC_EV(ARMV7, TTBR_WRITE) \
|
||||
__PMC_EV(ARMV7, BUS_CYCLES) \
|
||||
__PMC_EV(ARMV7, CPU_CYCLES)
|
||||
|
||||
#define PMC_EV_ARMV7_FIRST PMC_EV_ARMV7_PMNC_SW_INCR
|
||||
#define PMC_EV_ARMV7_LAST PMC_EV_ARMV7_CPU_CYCLES
|
||||
|
||||
/*
|
||||
* MIPS Events from "Programming the MIPS32 24K Core Family",
|
||||
* Document Number: MD00355 Revision 04.63 December 19, 2008
|
||||
@ -5219,7 +5259,8 @@ __PMC_EV_ALIAS("IMPC_C0H_TRK_REQUEST.ALL", UCP_EVENT_84H_01H)
|
||||
* 0x11080 0x0080 INTEL Pentium MMX events
|
||||
* 0x11100 0x0100 INTEL Pentium Pro/P-II/P-III/Pentium-M events
|
||||
* 0x11200 0x00FF INTEL XScale events
|
||||
* 0x11300 0x00FF MIPS 24K events
|
||||
* 0x11300 0x00FF MIPS 24K events
|
||||
* 0x14000 0x0100 ARMv7 events
|
||||
* 0x20000 0x1000 Software events
|
||||
*/
|
||||
#define __PMC_EVENTS() \
|
||||
@ -5253,6 +5294,8 @@ __PMC_EV_ALIAS("IMPC_C0H_TRK_REQUEST.ALL", UCP_EVENT_84H_01H)
|
||||
__PMC_EV_PPC7450() \
|
||||
__PMC_EV_BLOCK(PPC970, 0x13100) \
|
||||
__PMC_EV_PPC970() \
|
||||
__PMC_EV_BLOCK(ARMV7, 0x14000) \
|
||||
__PMC_EV_ARMV7() \
|
||||
|
||||
#define PMC_EVENT_FIRST PMC_EV_TSC_TSC
|
||||
#define PMC_EVENT_LAST PMC_EV_SOFT_LAST
|
||||
|
@ -2367,20 +2367,23 @@ skip_thunk:
|
||||
}
|
||||
VT_UNLOCK(vd);
|
||||
return (EINVAL);
|
||||
case VT_WAITACTIVE:
|
||||
case VT_WAITACTIVE: {
|
||||
unsigned int idx;
|
||||
|
||||
error = 0;
|
||||
|
||||
i = *(unsigned int *)data;
|
||||
if (i > VT_MAXWINDOWS)
|
||||
idx = *(unsigned int *)data;
|
||||
if (idx > VT_MAXWINDOWS)
|
||||
return (EINVAL);
|
||||
if (i != 0)
|
||||
vw = vd->vd_windows[i - 1];
|
||||
if (idx > 0)
|
||||
vw = vd->vd_windows[idx - 1];
|
||||
|
||||
VT_LOCK(vd);
|
||||
while (vd->vd_curwindow != vw && error == 0)
|
||||
error = cv_wait_sig(&vd->vd_winswitch, &vd->vd_lock);
|
||||
VT_UNLOCK(vd);
|
||||
return (error);
|
||||
}
|
||||
case VT_SETMODE: { /* set screen switcher mode */
|
||||
struct vt_mode *mode;
|
||||
struct proc *p1;
|
||||
|
@ -398,6 +398,7 @@ int tmpfs_alloc_vp(struct mount *, struct tmpfs_node *, int,
|
||||
void tmpfs_free_vp(struct vnode *);
|
||||
int tmpfs_alloc_file(struct vnode *, struct vnode **, struct vattr *,
|
||||
struct componentname *, char *);
|
||||
void tmpfs_check_mtime(struct vnode *);
|
||||
void tmpfs_dir_attach(struct vnode *, struct tmpfs_dirent *);
|
||||
void tmpfs_dir_detach(struct vnode *, struct tmpfs_dirent *);
|
||||
void tmpfs_dir_destroy(struct tmpfs_mount *, struct tmpfs_node *);
|
||||
|
@ -1415,6 +1415,31 @@ retry:
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
tmpfs_check_mtime(struct vnode *vp)
|
||||
{
|
||||
struct tmpfs_node *node;
|
||||
struct vm_object *obj;
|
||||
|
||||
ASSERT_VOP_ELOCKED(vp, "check_mtime");
|
||||
if (vp->v_type != VREG)
|
||||
return;
|
||||
node = VP_TO_TMPFS_NODE(vp);
|
||||
obj = vp->v_object;
|
||||
KASSERT((obj->flags & (OBJ_TMPFS_NODE | OBJ_TMPFS)) ==
|
||||
(OBJ_TMPFS_NODE | OBJ_TMPFS), ("non-tmpfs obj"));
|
||||
/* unlocked read */
|
||||
if ((obj->flags & OBJ_TMPFS_DIRTY) != 0) {
|
||||
VM_OBJECT_WLOCK(obj);
|
||||
if ((obj->flags & OBJ_TMPFS_DIRTY) != 0) {
|
||||
obj->flags &= ~OBJ_TMPFS_DIRTY;
|
||||
node = VP_TO_TMPFS_NODE(vp);
|
||||
node->tn_status |= TMPFS_NODE_MODIFIED;
|
||||
}
|
||||
VM_OBJECT_WUNLOCK(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Change flags of the given vnode.
|
||||
* Caller should execute tmpfs_update on vp after a successful execution.
|
||||
|
@ -33,10 +33,10 @@
|
||||
/*
|
||||
* Efficient memory file system.
|
||||
*
|
||||
* tmpfs is a file system that uses NetBSD's virtual memory sub-system
|
||||
* (the well-known UVM) to store file data and metadata in an efficient
|
||||
* way. This means that it does not follow the structure of an on-disk
|
||||
* file system because it simply does not need to. Instead, it uses
|
||||
* tmpfs is a file system that uses FreeBSD's virtual memory
|
||||
* sub-system to store file data and metadata in an efficient way.
|
||||
* This means that it does not follow the structure of an on-disk file
|
||||
* system because it simply does not need to. Instead, it uses
|
||||
* memory-specific data structures and algorithms to automatically
|
||||
* allocate and release resources.
|
||||
*/
|
||||
@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/proc.h>
|
||||
#include <sys/jail.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/sysctl.h>
|
||||
@ -418,11 +419,45 @@ tmpfs_statfs(struct mount *mp, struct statfs *sbp)
|
||||
static int
|
||||
tmpfs_sync(struct mount *mp, int waitfor)
|
||||
{
|
||||
struct vnode *vp, *mvp;
|
||||
struct vm_object *obj;
|
||||
|
||||
if (waitfor == MNT_SUSPEND) {
|
||||
MNT_ILOCK(mp);
|
||||
mp->mnt_kern_flag |= MNTK_SUSPEND2 | MNTK_SUSPENDED;
|
||||
MNT_IUNLOCK(mp);
|
||||
} else if (waitfor == MNT_LAZY) {
|
||||
/*
|
||||
* Handle lazy updates of mtime from writes to mmaped
|
||||
* regions. Use MNT_VNODE_FOREACH_ALL instead of
|
||||
* MNT_VNODE_FOREACH_ACTIVE, since unmap of the
|
||||
* tmpfs-backed vnode does not call vinactive(), due
|
||||
* to vm object type is OBJT_SWAP.
|
||||
*/
|
||||
MNT_VNODE_FOREACH_ALL(vp, mp, mvp) {
|
||||
if (vp->v_type != VREG) {
|
||||
VI_UNLOCK(vp);
|
||||
continue;
|
||||
}
|
||||
obj = vp->v_object;
|
||||
KASSERT((obj->flags & (OBJ_TMPFS_NODE | OBJ_TMPFS)) ==
|
||||
(OBJ_TMPFS_NODE | OBJ_TMPFS), ("non-tmpfs obj"));
|
||||
|
||||
/*
|
||||
* Unlocked read, avoid taking vnode lock if
|
||||
* not needed. Lost update will be handled on
|
||||
* the next call.
|
||||
*/
|
||||
if ((obj->flags & OBJ_TMPFS_DIRTY) == 0) {
|
||||
VI_UNLOCK(vp);
|
||||
continue;
|
||||
}
|
||||
if (vget(vp, LK_EXCLUSIVE | LK_RETRY | LK_INTERLOCK,
|
||||
curthread) != 0)
|
||||
continue;
|
||||
tmpfs_check_mtime(vp);
|
||||
vput(vp);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
@ -505,6 +505,7 @@ tmpfs_fsync(struct vop_fsync_args *v)
|
||||
|
||||
MPASS(VOP_ISLOCKED(vp));
|
||||
|
||||
tmpfs_check_mtime(vp);
|
||||
tmpfs_update(vp);
|
||||
|
||||
return 0;
|
||||
@ -1222,16 +1223,16 @@ tmpfs_readlink(struct vop_readlink_args *v)
|
||||
static int
|
||||
tmpfs_inactive(struct vop_inactive_args *v)
|
||||
{
|
||||
struct vnode *vp = v->a_vp;
|
||||
|
||||
struct vnode *vp;
|
||||
struct tmpfs_node *node;
|
||||
|
||||
vp = v->a_vp;
|
||||
node = VP_TO_TMPFS_NODE(vp);
|
||||
|
||||
if (node->tn_links == 0)
|
||||
vrecycle(vp);
|
||||
|
||||
return 0;
|
||||
else
|
||||
tmpfs_check_mtime(vp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -3649,6 +3649,9 @@ sctp_handle_stream_reset_response(struct sctp_tcb *stcb,
|
||||
/* huh ? */
|
||||
return (0);
|
||||
}
|
||||
if (ntohs(respin->ph.param_length) < sizeof(struct sctp_stream_reset_response_tsn)) {
|
||||
return (0);
|
||||
}
|
||||
if (action == SCTP_STREAM_RESET_RESULT_PERFORMED) {
|
||||
resp = (struct sctp_stream_reset_response_tsn *)respin;
|
||||
asoc->stream_reset_outstanding--;
|
||||
@ -4037,7 +4040,7 @@ __attribute__((noinline))
|
||||
sctp_handle_stream_reset(struct sctp_tcb *stcb, struct mbuf *m, int offset,
|
||||
struct sctp_chunkhdr *ch_req)
|
||||
{
|
||||
int chk_length, param_len, ptype;
|
||||
uint16_t remaining_length, param_len, ptype;
|
||||
struct sctp_paramhdr pstore;
|
||||
uint8_t cstore[SCTP_CHUNK_BUFFER_SIZE];
|
||||
uint32_t seq = 0;
|
||||
@ -4050,7 +4053,7 @@ __attribute__((noinline))
|
||||
int num_param = 0;
|
||||
|
||||
/* now it may be a reset or a reset-response */
|
||||
chk_length = ntohs(ch_req->chunk_length);
|
||||
remaining_length = ntohs(ch_req->chunk_length) - sizeof(struct sctp_chunkhdr);
|
||||
|
||||
/* setup for adding the response */
|
||||
sctp_alloc_a_chunk(stcb, chk);
|
||||
@ -4088,20 +4091,27 @@ strres_nochunk:
|
||||
ch->chunk_length = htons(chk->send_size);
|
||||
SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size);
|
||||
offset += sizeof(struct sctp_chunkhdr);
|
||||
while ((size_t)chk_length >= sizeof(struct sctp_stream_reset_tsn_request)) {
|
||||
while (remaining_length >= sizeof(struct sctp_paramhdr)) {
|
||||
ph = (struct sctp_paramhdr *)sctp_m_getptr(m, offset, sizeof(pstore), (uint8_t *) & pstore);
|
||||
if (ph == NULL)
|
||||
break;
|
||||
param_len = ntohs(ph->param_length);
|
||||
if (param_len < (int)sizeof(struct sctp_stream_reset_tsn_request)) {
|
||||
/* bad param */
|
||||
if (ph == NULL) {
|
||||
/* TSNH */
|
||||
break;
|
||||
}
|
||||
ph = (struct sctp_paramhdr *)sctp_m_getptr(m, offset, min(param_len, (int)sizeof(cstore)),
|
||||
param_len = ntohs(ph->param_length);
|
||||
if ((param_len > remaining_length) ||
|
||||
(param_len < (sizeof(struct sctp_paramhdr) + sizeof(uint32_t)))) {
|
||||
/* bad parameter length */
|
||||
break;
|
||||
}
|
||||
ph = (struct sctp_paramhdr *)sctp_m_getptr(m, offset, min(param_len, sizeof(cstore)),
|
||||
(uint8_t *) & cstore);
|
||||
if (ph == NULL) {
|
||||
/* TSNH */
|
||||
break;
|
||||
}
|
||||
ptype = ntohs(ph->param_type);
|
||||
num_param++;
|
||||
if (param_len > (int)sizeof(cstore)) {
|
||||
if (param_len > sizeof(cstore)) {
|
||||
trunc = 1;
|
||||
} else {
|
||||
trunc = 0;
|
||||
@ -4113,6 +4123,9 @@ strres_nochunk:
|
||||
if (ptype == SCTP_STR_RESET_OUT_REQUEST) {
|
||||
struct sctp_stream_reset_out_request *req_out;
|
||||
|
||||
if (param_len < sizeof(struct sctp_stream_reset_out_request)) {
|
||||
break;
|
||||
}
|
||||
req_out = (struct sctp_stream_reset_out_request *)ph;
|
||||
num_req++;
|
||||
if (stcb->asoc.stream_reset_outstanding) {
|
||||
@ -4126,12 +4139,18 @@ strres_nochunk:
|
||||
} else if (ptype == SCTP_STR_RESET_ADD_OUT_STREAMS) {
|
||||
struct sctp_stream_reset_add_strm *str_add;
|
||||
|
||||
if (param_len < sizeof(struct sctp_stream_reset_add_strm)) {
|
||||
break;
|
||||
}
|
||||
str_add = (struct sctp_stream_reset_add_strm *)ph;
|
||||
num_req++;
|
||||
sctp_handle_str_reset_add_strm(stcb, chk, str_add);
|
||||
} else if (ptype == SCTP_STR_RESET_ADD_IN_STREAMS) {
|
||||
struct sctp_stream_reset_add_strm *str_add;
|
||||
|
||||
if (param_len < sizeof(struct sctp_stream_reset_add_strm)) {
|
||||
break;
|
||||
}
|
||||
str_add = (struct sctp_stream_reset_add_strm *)ph;
|
||||
num_req++;
|
||||
sctp_handle_str_reset_add_out_strm(stcb, chk, str_add);
|
||||
@ -4156,6 +4175,9 @@ strres_nochunk:
|
||||
struct sctp_stream_reset_response *resp;
|
||||
uint32_t result;
|
||||
|
||||
if (param_len < sizeof(struct sctp_stream_reset_response)) {
|
||||
break;
|
||||
}
|
||||
resp = (struct sctp_stream_reset_response *)ph;
|
||||
seq = ntohl(resp->response_seq);
|
||||
result = ntohl(resp->result);
|
||||
@ -4167,7 +4189,11 @@ strres_nochunk:
|
||||
break;
|
||||
}
|
||||
offset += SCTP_SIZE32(param_len);
|
||||
chk_length -= SCTP_SIZE32(param_len);
|
||||
if (remaining_length >= SCTP_SIZE32(param_len)) {
|
||||
remaining_length -= SCTP_SIZE32(param_len);
|
||||
} else {
|
||||
remaining_length = 0;
|
||||
}
|
||||
}
|
||||
if (num_req == 0) {
|
||||
/* we have no response free the stuff */
|
||||
|
@ -1863,8 +1863,9 @@ flags_out:
|
||||
SCTP_CHECK_AND_CAST(av, optval, struct sctp_stream_value, *optsize);
|
||||
SCTP_FIND_STCB(inp, stcb, av->assoc_id);
|
||||
if (stcb) {
|
||||
if (stcb->asoc.ss_functions.sctp_ss_get_value(stcb, &stcb->asoc, &stcb->asoc.strmout[av->stream_id],
|
||||
&av->stream_value) < 0) {
|
||||
if ((av->stream_id >= stcb->asoc.streamoutcnt) ||
|
||||
(stcb->asoc.ss_functions.sctp_ss_get_value(stcb, &stcb->asoc, &stcb->asoc.strmout[av->stream_id],
|
||||
&av->stream_value) < 0)) {
|
||||
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
|
||||
error = EINVAL;
|
||||
} else {
|
||||
@ -4032,8 +4033,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
|
||||
SCTP_CHECK_AND_CAST(av, optval, struct sctp_stream_value, optsize);
|
||||
SCTP_FIND_STCB(inp, stcb, av->assoc_id);
|
||||
if (stcb) {
|
||||
if (stcb->asoc.ss_functions.sctp_ss_set_value(stcb, &stcb->asoc, &stcb->asoc.strmout[av->stream_id],
|
||||
av->stream_value) < 0) {
|
||||
if ((av->stream_id >= stcb->asoc.streamoutcnt) ||
|
||||
(stcb->asoc.ss_functions.sctp_ss_set_value(stcb, &stcb->asoc, &stcb->asoc.strmout[av->stream_id],
|
||||
av->stream_value) < 0)) {
|
||||
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
|
||||
error = EINVAL;
|
||||
}
|
||||
@ -4043,14 +4045,15 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
|
||||
SCTP_INP_RLOCK(inp);
|
||||
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
|
||||
SCTP_TCB_LOCK(stcb);
|
||||
stcb->asoc.ss_functions.sctp_ss_set_value(stcb,
|
||||
&stcb->asoc,
|
||||
&stcb->asoc.strmout[av->stream_id],
|
||||
av->stream_value);
|
||||
if (av->stream_id < stcb->asoc.streamoutcnt) {
|
||||
stcb->asoc.ss_functions.sctp_ss_set_value(stcb,
|
||||
&stcb->asoc,
|
||||
&stcb->asoc.strmout[av->stream_id],
|
||||
av->stream_value);
|
||||
}
|
||||
SCTP_TCB_UNLOCK(stcb);
|
||||
}
|
||||
SCTP_INP_RUNLOCK(inp);
|
||||
|
||||
} else {
|
||||
/*
|
||||
* Can't set stream value without
|
||||
|
@ -73,6 +73,7 @@
|
||||
#define __PMC_CPUS() \
|
||||
__PMC_CPU(AMD_K7, 0x00, "AMD K7") \
|
||||
__PMC_CPU(AMD_K8, 0x01, "AMD K8") \
|
||||
__PMC_CPU(ARMV7, 0x500, "ARMv7") \
|
||||
__PMC_CPU(INTEL_P5, 0x80, "Intel Pentium") \
|
||||
__PMC_CPU(INTEL_P6, 0x81, "Intel Pentium Pro") \
|
||||
__PMC_CPU(INTEL_CL, 0x82, "Intel Celeron") \
|
||||
@ -127,6 +128,7 @@ enum pmc_cputype {
|
||||
__PMC_CLASS(UCF) /* Intel Uncore fixed function */ \
|
||||
__PMC_CLASS(UCP) /* Intel Uncore programmable */ \
|
||||
__PMC_CLASS(XSCALE) /* Intel XScale counters */ \
|
||||
__PMC_CLASS(ARMV7) /* ARMv7 */ \
|
||||
__PMC_CLASS(MIPS24K) /* MIPS 24K */ \
|
||||
__PMC_CLASS(OCTEON) /* Cavium Octeon */ \
|
||||
__PMC_CLASS(PPC7450) /* Motorola MPC7450 class */ \
|
||||
|
@ -358,11 +358,13 @@ RetryFault:;
|
||||
(fault_flags & (VM_FAULT_CHANGE_WIRING | VM_FAULT_DIRTY)) == 0 &&
|
||||
/* avoid calling vm_object_set_writeable_dirty() */
|
||||
((prot & VM_PROT_WRITE) == 0 ||
|
||||
fs.first_object->type != OBJT_VNODE ||
|
||||
(fs.first_object->type != OBJT_VNODE &&
|
||||
(fs.first_object->flags & OBJ_TMPFS_NODE) == 0) ||
|
||||
(fs.first_object->flags & OBJ_MIGHTBEDIRTY) != 0)) {
|
||||
VM_OBJECT_RLOCK(fs.first_object);
|
||||
if ((prot & VM_PROT_WRITE) != 0 &&
|
||||
fs.first_object->type == OBJT_VNODE &&
|
||||
(fs.first_object->type == OBJT_VNODE ||
|
||||
(fs.first_object->flags & OBJ_TMPFS_NODE) != 0) &&
|
||||
(fs.first_object->flags & OBJ_MIGHTBEDIRTY) == 0)
|
||||
goto fast_failed;
|
||||
m = vm_page_lookup(fs.first_object, fs.first_pindex);
|
||||
|
@ -2199,8 +2199,13 @@ vm_object_set_writeable_dirty(vm_object_t object)
|
||||
{
|
||||
|
||||
VM_OBJECT_ASSERT_WLOCKED(object);
|
||||
if (object->type != OBJT_VNODE)
|
||||
if (object->type != OBJT_VNODE) {
|
||||
if ((object->flags & OBJ_TMPFS_NODE) != 0) {
|
||||
KASSERT(object->type == OBJT_SWAP, ("non-swap tmpfs"));
|
||||
vm_object_set_flag(object, OBJ_TMPFS_DIRTY);
|
||||
}
|
||||
return;
|
||||
}
|
||||
object->generation++;
|
||||
if ((object->flags & OBJ_MIGHTBEDIRTY) != 0)
|
||||
return;
|
||||
|
@ -187,6 +187,7 @@ struct vm_object {
|
||||
#define OBJ_PIPWNT 0x0040 /* paging in progress wanted */
|
||||
#define OBJ_MIGHTBEDIRTY 0x0100 /* object might be dirty, only for vnode */
|
||||
#define OBJ_TMPFS_NODE 0x0200 /* object belongs to tmpfs VREG node */
|
||||
#define OBJ_TMPFS_DIRTY 0x0400 /* dirty tmpfs obj */
|
||||
#define OBJ_COLORED 0x1000 /* pg_color is defined */
|
||||
#define OBJ_ONEMAPPING 0x2000 /* One USE (a single, non-forked) mapping flag */
|
||||
#define OBJ_DISCONNECTWNT 0x4000 /* disconnect from vnode wanted */
|
||||
|
@ -409,10 +409,10 @@ mf_fgets(SPACE *sp, enum e_spflag spflag)
|
||||
if (len >= (ssize_t)sizeof(tmpfname))
|
||||
errx(1, "%s: name too long", fname);
|
||||
unlink(tmpfname);
|
||||
if ((outfile = fopen(tmpfname, "w")) == NULL)
|
||||
err(1, "%s", fname);
|
||||
if (outfile != NULL && outfile != stdout)
|
||||
fclose(outfile);
|
||||
if ((outfile = fopen(tmpfname, "w")) == NULL)
|
||||
err(1, "%s", fname);
|
||||
fchown(fileno(outfile), sb.st_uid, sb.st_gid);
|
||||
fchmod(fileno(outfile), sb.st_mode & ALLPERMS);
|
||||
outfname = tmpfname;
|
||||
|
@ -182,7 +182,7 @@ expire_automounted(double expiration_time)
|
||||
{
|
||||
struct automounted_fs *af, *tmpaf;
|
||||
time_t now;
|
||||
double mounted_for, mounted_max = 0;
|
||||
double mounted_for, mounted_max = -1.0;
|
||||
int error;
|
||||
|
||||
now = time(NULL);
|
||||
@ -231,21 +231,28 @@ do_wait(int kq, double sleep_time)
|
||||
{
|
||||
struct timespec timeout;
|
||||
struct kevent unused;
|
||||
int error;
|
||||
int nevents;
|
||||
|
||||
assert(sleep_time > 0);
|
||||
timeout.tv_sec = sleep_time;
|
||||
timeout.tv_nsec = 0;
|
||||
if (sleep_time != -1.0) {
|
||||
assert(sleep_time > 0.0);
|
||||
timeout.tv_sec = sleep_time;
|
||||
timeout.tv_nsec = 0;
|
||||
|
||||
log_debugx("waiting for filesystem event for %.0f seconds", sleep_time);
|
||||
error = kevent(kq, NULL, 0, &unused, 1, &timeout);
|
||||
if (error < 0)
|
||||
log_debugx("waiting for filesystem event for %.0f seconds", sleep_time);
|
||||
nevents = kevent(kq, NULL, 0, &unused, 1, &timeout);
|
||||
} else {
|
||||
log_debugx("waiting for filesystem event");
|
||||
nevents = kevent(kq, NULL, 0, &unused, 1, NULL);
|
||||
}
|
||||
if (nevents < 0)
|
||||
log_err(1, "kevent");
|
||||
|
||||
if (error == 0)
|
||||
if (nevents == 0) {
|
||||
log_debugx("timeout reached");
|
||||
else
|
||||
assert(sleep_time > 0.0);
|
||||
} else {
|
||||
log_debugx("got filesystem event");
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
@ -324,7 +331,10 @@ main_autounmountd(int argc, char **argv)
|
||||
for (;;) {
|
||||
refresh_automounted();
|
||||
mounted_max = expire_automounted(expiration_time);
|
||||
if (mounted_max < expiration_time) {
|
||||
if (mounted_max == -1.0) {
|
||||
sleep_time = mounted_max;
|
||||
log_debugx("no filesystems to expire");
|
||||
} else if (mounted_max < expiration_time) {
|
||||
sleep_time = difftime(expiration_time, mounted_max);
|
||||
log_debugx("some filesystems expire in %.0f seconds",
|
||||
sleep_time);
|
||||
|
Loading…
x
Reference in New Issue
Block a user