summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/sys
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-08-21 09:39:55 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-09-21 10:29:40 +0200
commit2df56dbd60bb5d925d2ce0ddbdefdbe6107ea783 (patch)
treebd7bad558534db4a1f400bc38a2c9aa7ea4f411e /freebsd/sys/sys
parentUpdate to FreeBSD head 2018-02-01 (diff)
downloadrtems-libbsd-2df56dbd60bb5d925d2ce0ddbdefdbe6107ea783.tar.bz2
Update to FreeBSD head 2018-04-01
Git mirror commit 8dfb1ccc26d1cea7e2529303003ff61f9f1784c4. Update #3472.
Diffstat (limited to 'freebsd/sys/sys')
-rw-r--r--freebsd/sys/sys/aio.h2
-rw-r--r--freebsd/sys/sys/buf.h9
-rw-r--r--freebsd/sys/sys/bufobj.h2
-rw-r--r--freebsd/sys/sys/bus.h1
-rw-r--r--freebsd/sys/sys/bus_dma.h2
-rw-r--r--freebsd/sys/sys/callout.h1
-rw-r--r--freebsd/sys/sys/disk.h161
-rw-r--r--freebsd/sys/sys/domainset.h38
-rw-r--r--freebsd/sys/sys/kernel.h8
-rw-r--r--freebsd/sys/sys/ktr_class.h2
-rwxr-xr-xfreebsd/sys/sys/linker_set.h13
-rw-r--r--freebsd/sys/sys/lockstat.h8
-rw-r--r--freebsd/sys/sys/module.h2
-rw-r--r--freebsd/sys/sys/mutex.h2
-rw-r--r--freebsd/sys/sys/priv.h3
-rw-r--r--freebsd/sys/sys/proc.h9
-rw-r--r--freebsd/sys/sys/random.h8
-rw-r--r--freebsd/sys/sys/refcount.h31
-rw-r--r--freebsd/sys/sys/seq.h58
-rw-r--r--freebsd/sys/sys/sysproto.h7
-rw-r--r--freebsd/sys/sys/systm.h11
-rw-r--r--freebsd/sys/sys/vmmeter.h80
22 files changed, 348 insertions, 110 deletions
diff --git a/freebsd/sys/sys/aio.h b/freebsd/sys/sys/aio.h
index 2843042b..4963e986 100644
--- a/freebsd/sys/sys/aio.h
+++ b/freebsd/sys/sys/aio.h
@@ -55,7 +55,7 @@
#ifndef __rtems__
/*
- * Maximum number of allowed LIO operations
+ * Maximum number of operations in a single lio_listio call
*/
#define AIO_LISTIO_MAX 16
#endif /* __rtems__ */
diff --git a/freebsd/sys/sys/buf.h b/freebsd/sys/sys/buf.h
index 77acac5b..c9b2eeae 100644
--- a/freebsd/sys/sys/buf.h
+++ b/freebsd/sys/sys/buf.h
@@ -112,7 +112,9 @@ struct buf {
off_t b_offset; /* Offset into file. */
TAILQ_ENTRY(buf) b_bobufs; /* (V) Buffer's associated vnode. */
uint32_t b_vflags; /* (V) BV_* flags */
- unsigned short b_qindex; /* (Q) buffer queue index */
+ uint8_t b_qindex; /* (Q) buffer queue index */
+ uint8_t b_domain; /* (Q) buf domain this resides in */
+ uint16_t b_subqueue; /* (Q) per-cpu q if any */
uint32_t b_flags; /* B_* flags. */
b_xflags_t b_xflags; /* extra flags */
struct lock b_lock; /* Buffer lock */
@@ -217,7 +219,7 @@ struct buf {
#define B_DONE 0x00000200 /* I/O completed. */
#define B_EINTR 0x00000400 /* I/O was interrupted */
#define B_NOREUSE 0x00000800 /* Contents not reused once released. */
-#define B_00001000 0x00001000 /* Available flag. */
+#define B_REUSE 0x00001000 /* Contents reused, second chance. */
#define B_INVAL 0x00002000 /* Does not contain valid info. */
#define B_BARRIER 0x00004000 /* Write this and all preceding first. */
#define B_NOCACHE 0x00008000 /* Do not cache block after use. */
@@ -241,7 +243,7 @@ struct buf {
#define PRINT_BUF_FLAGS "\20\40remfree\37cluster\36vmio\35ram\34managed" \
"\33paging\32infreecnt\31nocopy\30b23\27relbuf\26b21\25b20" \
"\24b19\23b18\22clusterok\21malloc\20nocache\17b14\16inval" \
- "\15b12\14noreuse\13eintr\12done\11b8\10delwri" \
+ "\15reuse\14noreuse\13eintr\12done\11b8\10delwri" \
"\7validsuspwrt\6cache\5deferred\4direct\3async\2needcommit\1age"
/*
@@ -542,7 +544,6 @@ struct buf *geteblk(int, int);
int bufwait(struct buf *);
int bufwrite(struct buf *);
void bufdone(struct buf *);
-void bufdone_finish(struct buf *);
void bd_speedup(void);
int cluster_read(struct vnode *, u_quad_t, daddr_t, long,
diff --git a/freebsd/sys/sys/bufobj.h b/freebsd/sys/sys/bufobj.h
index fb3f0873..b02d4276 100644
--- a/freebsd/sys/sys/bufobj.h
+++ b/freebsd/sys/sys/bufobj.h
@@ -106,6 +106,7 @@ struct bufobj {
struct bufv bo_dirty; /* i Dirty buffers */
long bo_numoutput; /* i Writes in progress */
u_int bo_flag; /* i Flags */
+ int bo_domain; /* - Clean queue affinity */
int bo_bsize; /* - Block size for i/o */
};
@@ -126,6 +127,7 @@ struct bufobj {
#define ASSERT_BO_LOCKED(bo) rw_assert(BO_LOCKPTR((bo)), RA_LOCKED)
#define ASSERT_BO_UNLOCKED(bo) rw_assert(BO_LOCKPTR((bo)), RA_UNLOCKED)
+void bufobj_init(struct bufobj *bo, void *private);
void bufobj_wdrop(struct bufobj *bo);
void bufobj_wref(struct bufobj *bo);
void bufobj_wrefl(struct bufobj *bo);
diff --git a/freebsd/sys/sys/bus.h b/freebsd/sys/sys/bus.h
index 7a3f6b1a..d1d6bbb9 100644
--- a/freebsd/sys/sys/bus.h
+++ b/freebsd/sys/sys/bus.h
@@ -702,6 +702,7 @@ void bus_data_generation_update(void);
#define BUS_PASS_INTERRUPT 40 /* Interrupt controllers. */
#define BUS_PASS_TIMER 50 /* Timers and clocks. */
#define BUS_PASS_SCHEDULER 60 /* Start scheduler. */
+#define BUS_PASS_SUPPORTDEV 100000 /* Drivers which support DEFAULT drivers. */
#define BUS_PASS_DEFAULT __INT_MAX /* Everything else. */
#define BUS_PASS_ORDER_FIRST 0
diff --git a/freebsd/sys/sys/bus_dma.h b/freebsd/sys/sys/bus_dma.h
index 2bf46ca8..eb2bc42d 100644
--- a/freebsd/sys/sys/bus_dma.h
+++ b/freebsd/sys/sys/bus_dma.h
@@ -178,7 +178,7 @@ int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
/*
* Set the memory domain to be used for allocations.
- *
+ *
* Automatic for PCI devices. Must be set prior to creating maps or
* allocating memory.
*/
diff --git a/freebsd/sys/sys/callout.h b/freebsd/sys/sys/callout.h
index a0b45d98..e5e5df85 100644
--- a/freebsd/sys/sys/callout.h
+++ b/freebsd/sys/sys/callout.h
@@ -62,6 +62,7 @@
#define C_HARDCLOCK 0x0100 /* align to hardclock() calls */
#define C_ABSOLUTE 0x0200 /* event time is absolute. */
#define C_PRECALC 0x0400 /* event time is pre-calculated. */
+#define C_CATCH 0x0800 /* catch signals, used by pause_sbt(9) */
struct callout_handle {
struct callout *callout;
diff --git a/freebsd/sys/sys/disk.h b/freebsd/sys/sys/disk.h
new file mode 100644
index 00000000..020626e2
--- /dev/null
+++ b/freebsd/sys/sys/disk.h
@@ -0,0 +1,161 @@
+/*-
+ * SPDX-License-Identifier: Beerware
+ *
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ *
+ * $FreeBSD$
+ *
+ */
+
+#ifndef _SYS_DISK_H_
+#define _SYS_DISK_H_
+
+#include <sys/ioccom.h>
+#include <sys/kerneldump.h>
+#include <sys/types.h>
+#include <sys/disk_zone.h>
+
+#ifdef _KERNEL
+
+#ifndef _SYS_CONF_H_
+#include <sys/conf.h> /* XXX: temporary to avoid breakage */
+#endif
+
+void disk_err(struct bio *bp, const char *what, int blkdone, int nl);
+
+#endif
+
+#define DIOCGSECTORSIZE _IOR('d', 128, u_int)
+ /*
+ * Get the sector size of the device in bytes. The sector size is the
+ * smallest unit of data which can be transferred from this device.
+ * Usually this is a power of 2 but it might not be (i.e. CDROM audio).
+ */
+
+#define DIOCGMEDIASIZE _IOR('d', 129, off_t) /* Get media size in bytes */
+ /*
+ * Get the size of the entire device in bytes. This should be a
+ * multiple of the sector size.
+ */
+
+#define DIOCGFWSECTORS _IOR('d', 130, u_int) /* Get firmware's sectorcount */
+ /*
+ * Get the firmware's notion of number of sectors per track. This
+ * value is mostly used for compatibility with various ill designed
+ * disk label formats. Don't use it unless you have to.
+ */
+
+#define DIOCGFWHEADS _IOR('d', 131, u_int) /* Get firmware's headcount */
+ /*
+ * Get the firmwares notion of number of heads per cylinder. This
+ * value is mostly used for compatibility with various ill designed
+ * disk label formats. Don't use it unless you have to.
+ */
+
+#define DIOCSKERNELDUMP_FREEBSD11 _IOW('d', 133, u_int)
+ /*
+ * Enable/Disable (the argument is boolean) the device for kernel
+ * core dumps.
+ */
+
+#define DIOCGFRONTSTUFF _IOR('d', 134, off_t)
+ /*
+ * Many disk formats have some amount of space reserved at the
+ * start of the disk to hold bootblocks, various disklabels and
+ * similar stuff. This ioctl returns the number of such bytes
+ * which may apply to the device.
+ */
+
+#define DIOCGFLUSH _IO('d', 135) /* Flush write cache */
+ /*
+ * Flush write cache of the device.
+ */
+
+#define DIOCGDELETE _IOW('d', 136, off_t[2]) /* Delete data */
+ /*
+ * Mark data on the device as unused.
+ */
+
+#define DISK_IDENT_SIZE 256
+#define DIOCGIDENT _IOR('d', 137, char[DISK_IDENT_SIZE])
+ /*-
+ * Get the ident of the given provider. Ident is (most of the time)
+ * a uniqe and fixed provider's identifier. Ident's properties are as
+ * follow:
+ * - ident value is preserved between reboots,
+ * - provider can be detached/attached and ident is preserved,
+ * - provider's name can change - ident can't,
+ * - ident value should not be based on on-disk metadata; in other
+ * words copying whole data from one disk to another should not
+ * yield the same ident for the other disk,
+ * - there could be more than one provider with the same ident, but
+ * only if they point at exactly the same physical storage, this is
+ * the case for multipathing for example,
+ * - GEOM classes that consumes single providers and provide single
+ * providers, like geli, gbde, should just attach class name to the
+ * ident of the underlying provider,
+ * - ident is an ASCII string (is printable),
+ * - ident is optional and applications can't relay on its presence.
+ */
+
+#define DIOCGPROVIDERNAME _IOR('d', 138, char[MAXPATHLEN])
+ /*
+ * Store the provider name, given a device path, in a buffer. The buffer
+ * must be at least MAXPATHLEN bytes long.
+ */
+
+#define DIOCGSTRIPESIZE _IOR('d', 139, off_t) /* Get stripe size in bytes */
+ /*
+ * Get the size of the device's optimal access block in bytes.
+ * This should be a multiple of the sector size.
+ */
+
+#define DIOCGSTRIPEOFFSET _IOR('d', 140, off_t) /* Get stripe offset in bytes */
+ /*
+ * Get the offset of the first device's optimal access block in bytes.
+ * This should be a multiple of the sector size.
+ */
+
+#define DIOCGPHYSPATH _IOR('d', 141, char[MAXPATHLEN])
+ /*
+ * Get a string defining the physical path for a given provider.
+ * This has similar rules to ident, but is intended to uniquely
+ * identify the physical location of the device, not the current
+ * occupant of that location.
+ */
+
+struct diocgattr_arg {
+ char name[64];
+ int len;
+ union {
+ char str[DISK_IDENT_SIZE];
+ off_t off;
+ int i;
+ uint16_t u16;
+ } value;
+};
+#define DIOCGATTR _IOWR('d', 142, struct diocgattr_arg)
+
+#define DIOCZONECMD _IOWR('d', 143, struct disk_zone_args)
+
+#ifndef __rtems__
+struct diocskerneldump_arg {
+ uint8_t kda_enable;
+ uint8_t kda_compression;
+ uint8_t kda_encryption;
+ uint8_t kda_key[KERNELDUMP_KEY_MAX_SIZE];
+ uint32_t kda_encryptedkeysize;
+ uint8_t *kda_encryptedkey;
+};
+#define DIOCSKERNELDUMP _IOW('d', 144, struct diocskerneldump_arg)
+ /*
+ * Enable/Disable the device for kernel core dumps.
+ */
+#endif /* __rtems__ */
+
+#endif /* _SYS_DISK_H_ */
diff --git a/freebsd/sys/sys/domainset.h b/freebsd/sys/sys/domainset.h
index 6580e1ed..81375ed0 100644
--- a/freebsd/sys/sys/domainset.h
+++ b/freebsd/sys/sys/domainset.h
@@ -28,8 +28,8 @@
* $FreeBSD$
*/
-#ifndef _SYS_DOMAINSETSET_H_
-#define _SYS_DOMAINSETSET_H_
+#ifndef _SYS_DOMAINSET_H_
+#define _SYS_DOMAINSET_H_
#include <sys/_domainset.h>
@@ -38,7 +38,11 @@
#define _NDOMAINSETBITS _BITSET_BITS
#define _NDOMAINSETWORDS __bitset_words(DOMAINSET_SETSIZE)
-#define DOMAINSETSETBUFSIZ ((2 + sizeof(long) * 2) * _NDOMAINSETWORDS)
+#define DOMAINSETBUFSIZ \
+ (((2 + sizeof(long) * 2) * _NDOMAINSETWORDS) + \
+ sizeof("::") + sizeof(__XSTRING(DOMAINSET_POLICY_MAX)) + \
+ sizeof(__XSTRING(MAXMEMDOM)))
+
#define DOMAINSET_CLR(n, p) BIT_CLR(DOMAINSET_SETSIZE, n, p)
#define DOMAINSET_COPY(f, t) BIT_COPY(DOMAINSET_SETSIZE, f, t)
@@ -73,23 +77,37 @@
#define DOMAINSET_POLICY_ROUNDROBIN 1
#define DOMAINSET_POLICY_FIRSTTOUCH 2
#define DOMAINSET_POLICY_PREFER 3
-#define DOMAINSET_POLICY_MAX DOMAINSET_POLICY_PREFER
+#define DOMAINSET_POLICY_INTERLEAVE 4
+#define DOMAINSET_POLICY_MAX DOMAINSET_POLICY_INTERLEAVE
#ifdef _KERNEL
-#include <sys/queue.h>
-LIST_HEAD(domainlist, domainset);
+#if MAXMEMDOM < 256
+typedef uint8_t domainid_t;
+#else
+typedef uint16_t domainid_t;
+#endif
struct domainset {
LIST_ENTRY(domainset) ds_link;
domainset_t ds_mask; /* allowed domains. */
uint16_t ds_policy; /* Policy type. */
- int16_t ds_prefer; /* Preferred domain or -1. */
- uint16_t ds_cnt; /* popcnt from above. */
- uint16_t ds_max; /* Maximum domain in set. */
+ domainid_t ds_prefer; /* Preferred domain or -1. */
+ domainid_t ds_cnt; /* popcnt from above. */
+ domainid_t ds_order[MAXMEMDOM]; /* nth domain table. */
};
void domainset_zero(void);
+/*
+ * Add a domainset to the system based on a key initializing policy, prefer,
+ * and mask. Do not create and directly use domainset structures. The
+ * returned value will not match the key pointer.
+ */
+struct domainset *domainset_create(const struct domainset *);
+#ifdef _SYS_SYSCTL_H_
+int sysctl_handle_domainset(SYSCTL_HANDLER_ARGS);
+#endif
+
#else
__BEGIN_DECLS
int cpuset_getdomain(cpulevel_t, cpuwhich_t, id_t, size_t, domainset_t *,
@@ -99,4 +117,4 @@ int cpuset_setdomain(cpulevel_t, cpuwhich_t, id_t, size_t,
__END_DECLS
#endif
-#endif /* !_SYS_DOMAINSETSET_H_ */
+#endif /* !_SYS_DOMAINSET_H_ */
diff --git a/freebsd/sys/sys/kernel.h b/freebsd/sys/sys/kernel.h
index 81ceca04..42a37604 100644
--- a/freebsd/sys/sys/kernel.h
+++ b/freebsd/sys/sys/kernel.h
@@ -270,7 +270,7 @@ sysinit_tslog_shim(const void * data)
sysinit_tslog_shim, \
&uniquifier ## _sys_init_tslog \
}; \
- DATA_SET(sysinit_set,uniquifier ## _sys_init)
+ DATA_WSET(sysinit_set,uniquifier ## _sys_init)
#else
#ifndef __rtems__
#define C_SYSINIT(uniquifier, subsystem, order, func, ident) \
@@ -280,7 +280,7 @@ sysinit_tslog_shim(const void * data)
func, \
(ident) \
}; \
- DATA_SET(sysinit_set,uniquifier ## _sys_init)
+ DATA_WSET(sysinit_set,uniquifier ## _sys_init)
#else /* __rtems__ */
#define SYSINIT_ENTRY_NAME(uniquifier) \
_bsd_ ## uniquifier ## _sys_init
@@ -293,7 +293,7 @@ sysinit_tslog_shim(const void * data)
func, \
(ident) \
}; \
- RWDATA_SET(sysinit_set,SYSINIT_ENTRY_NAME(uniquifier))
+ DATA_WSET(sysinit_set,SYSINIT_ENTRY_NAME(uniquifier))
#define SYSINIT_REFERENCE(uniquifier) \
extern struct sysinit SYSINIT_ENTRY_NAME(uniquifier); \
static struct sysinit const * const \
@@ -323,7 +323,7 @@ sysinit_tslog_shim(const void * data)
func, \
(ident) \
}; \
- DATA_SET(sysuninit_set,uniquifier ## _sys_uninit)
+ DATA_WSET(sysuninit_set,uniquifier ## _sys_uninit)
#else /* __rtems__ */
#define C_SYSUNINIT(uniquifier, subsystem, order, func, ident)
#endif /* __rtems__ */
diff --git a/freebsd/sys/sys/ktr_class.h b/freebsd/sys/sys/ktr_class.h
index 9190ce27..32d905d2 100644
--- a/freebsd/sys/sys/ktr_class.h
+++ b/freebsd/sys/sys/ktr_class.h
@@ -65,7 +65,7 @@
#define KTR_VM 0x00100000 /* The virtual memory system */
#define KTR_INET 0x00200000 /* IPv4 stack */
#define KTR_RUNQ 0x00400000 /* Run queue */
-#define KTR_CONTENTION 0x00800000 /* Lock contention */
+#define KTR_SPARE5 0x00800000
#define KTR_UMA 0x01000000 /* UMA slab allocator */
#define KTR_CALLOUT 0x02000000 /* Callouts and timeouts */
#define KTR_GEOM 0x04000000 /* GEOM I/O events */
diff --git a/freebsd/sys/sys/linker_set.h b/freebsd/sys/sys/linker_set.h
index 7e33c93f..e10be24c 100755
--- a/freebsd/sys/sys/linker_set.h
+++ b/freebsd/sys/sys/linker_set.h
@@ -60,12 +60,13 @@
*/
#ifdef __GNUCLIKE___SECTION
#ifndef __rtems__
-#define __MAKE_SET(set, sym) \
+#define __MAKE_SET_QV(set, sym, qv) \
__GLOBL(__CONCAT(__start_set_,set)); \
__GLOBL(__CONCAT(__stop_set_,set)); \
- static void const * __MAKE_SET_CONST \
+ static void const * qv \
__set_##set##_sym_##sym __section("set_" #set) \
__used = &(sym)
+#define __MAKE_SET(set, sym) __MAKE_SET_QV(set, sym, __MAKE_SET_CONST)
#else /* __rtems__ */
#define RTEMS_BSD_DEFINE_SET(set, type) \
type const __CONCAT(_bsd__start_set_,set)[0] \
@@ -114,12 +115,14 @@
*/
#define TEXT_SET(set, sym) __MAKE_SET(set, sym)
#define DATA_SET(set, sym) __MAKE_SET(set, sym)
+#ifndef __rtems__
+#define DATA_WSET(set, sym) __MAKE_SET_QV(set, sym, )
+#else /* __rtems__ */
+#define DATA_WSET(set, sym) __MAKE_RWSET(set, sym)
+#endif /* __rtems__ */
#define BSS_SET(set, sym) __MAKE_SET(set, sym)
#define ABS_SET(set, sym) __MAKE_SET(set, sym)
#define SET_ENTRY(set, sym) __MAKE_SET(set, sym)
-#ifdef __rtems__
-#define RWDATA_SET(set, sym) __MAKE_RWSET(set, sym)
-#endif /* __rtems__ */
/*
* Initialize before referring to a given linker set.
diff --git a/freebsd/sys/sys/lockstat.h b/freebsd/sys/sys/lockstat.h
index 50747e89..6167a7d1 100644
--- a/freebsd/sys/sys/lockstat.h
+++ b/freebsd/sys/sys/lockstat.h
@@ -109,12 +109,7 @@ extern volatile int lockstat_enabled;
LOCKSTAT_RECORD1(probe, lp, a); \
} while (0)
-#ifndef LOCK_PROFILING
#define LOCKSTAT_PROFILE_ENABLED(probe) __predict_false(lockstat_enabled)
-#define LOCKSTAT_OOL_PROFILE_ENABLED(probe) LOCKSTAT_PROFILE_ENABLED(probe)
-#else
-#define LOCKSTAT_OOL_PROFILE_ENABLED(probe) 1
-#endif
struct lock_object;
uint64_t lockstat_nsecs(struct lock_object *);
@@ -139,10 +134,7 @@ uint64_t lockstat_nsecs(struct lock_object *);
#define LOCKSTAT_PROFILE_RELEASE_RWLOCK(probe, lp, a) \
LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp)
-#ifndef LOCK_PROFILING
#define LOCKSTAT_PROFILE_ENABLED(probe) 0
-#endif
-#define LOCKSTAT_OOL_PROFILE_ENABLED(probe) 1
#endif /* !KDTRACE_HOOKS */
diff --git a/freebsd/sys/sys/module.h b/freebsd/sys/sys/module.h
index eb8b03d8..c3f8dc3c 100644
--- a/freebsd/sys/sys/module.h
+++ b/freebsd/sys/sys/module.h
@@ -201,7 +201,7 @@ struct mod_pnp_match_info
* D pointer to a string to human readable description for device
* P A pointer that should be ignored
* E EISA PNP Identifier (in binary, but bus publishes string)
- * K Key for whole table. pnp_name=value. must be last, if present.
+ * T Key for whole table. pnp_name=value. must be last, if present.
*
* The pnp_name "#" is reserved for other fields that should be ignored.
* Otherwise pnp_name must match the name from the parent device's pnpinfo
diff --git a/freebsd/sys/sys/mutex.h b/freebsd/sys/sys/mutex.h
index 52587064..e15de1ae 100644
--- a/freebsd/sys/sys/mutex.h
+++ b/freebsd/sys/sys/mutex.h
@@ -133,6 +133,8 @@ int __mtx_trylock_spin_flags(volatile uintptr_t *c, int opts,
const char *file, int line);
void __mtx_unlock_spin_flags(volatile uintptr_t *c, int opts,
const char *file, int line);
+void mtx_spin_wait_unlocked(struct mtx *m);
+
#else /* __rtems__ */
void mtx_init(struct mtx *m, const char *name, const char *type, int opts);
void mtx_destroy(struct mtx *m);
diff --git a/freebsd/sys/sys/priv.h b/freebsd/sys/sys/priv.h
index 52f1dbd2..55453f5a 100644
--- a/freebsd/sys/sys/priv.h
+++ b/freebsd/sys/sys/priv.h
@@ -344,7 +344,8 @@
#define PRIV_NET_SETIFDESCR 418 /* Set interface description. */
#define PRIV_NET_SETIFFIB 419 /* Set interface fib. */
#define PRIV_NET_VXLAN 420 /* Administer vxlan. */
-#define PRIV_NET_SETVLANPCP 421 /* Set VLAN priority. */
+#define PRIV_NET_SETLANPCP 421 /* Set LAN priority. */
+#define PRIV_NET_SETVLANPCP PRIV_NET_SETLANPCP /* Alias Set VLAN priority */
/*
* 802.11-related privileges.
diff --git a/freebsd/sys/sys/proc.h b/freebsd/sys/sys/proc.h
index ab292769..cef3ae2e 100644
--- a/freebsd/sys/sys/proc.h
+++ b/freebsd/sys/sys/proc.h
@@ -67,7 +67,7 @@
#include <sys/ucontext.h>
#include <sys/ucred.h>
#include <sys/types.h>
-#include <sys/domainset.h>
+#include <sys/_domainset.h>
#include <machine/proc.h> /* Machine-dependent proc substruct. */
#ifdef _KERNEL
@@ -328,6 +328,7 @@ struct thread {
void *td_su; /* (k) FFS SU private */
sbintime_t td_sleeptimo; /* (t) Sleep timeout. */
int td_rtcgen; /* (s) rtc_generation of abs. sleep */
+ size_t td_vslock_sz; /* (k) amount of vslock-ed space */
#define td_endzero td_sigmask
/* Copied during fork1() or create_thread(). */
@@ -420,7 +421,11 @@ do { \
} while (0)
#define TD_LOCKS_INC(td) ((td)->td_locks++)
-#define TD_LOCKS_DEC(td) ((td)->td_locks--)
+#define TD_LOCKS_DEC(td) do { \
+ KASSERT(SCHEDULER_STOPPED_TD(td) || (td)->td_locks > 0, \
+ ("thread %p owns no locks", (td))); \
+ (td)->td_locks--; \
+} while (0)
#else
#define THREAD_LOCKPTR_ASSERT(td, lock)
diff --git a/freebsd/sys/sys/random.h b/freebsd/sys/sys/random.h
index 78acaf9d..69d377f5 100644
--- a/freebsd/sys/sys/random.h
+++ b/freebsd/sys/sys/random.h
@@ -31,10 +31,10 @@
#ifndef _SYS_RANDOM_H_
#define _SYS_RANDOM_H_
-#ifdef _KERNEL
-
#include <sys/types.h>
+#ifdef _KERNEL
+
#if !defined(KLD_MODULE)
#if defined(RANDOM_LOADABLE) && defined(RANDOM_YARROW)
#error "Cannot define both RANDOM_LOADABLE and RANDOM_YARROW"
@@ -137,4 +137,8 @@ void random_harvest_deregister_source(enum random_entropy_source);
#endif /* _KERNEL */
+#define GRND_NONBLOCK 0x1
+#define GRND_RANDOM 0x2
+ssize_t getrandom(void *buf, size_t buflen, unsigned int flags);
+
#endif /* _SYS_RANDOM_H_ */
diff --git a/freebsd/sys/sys/refcount.h b/freebsd/sys/sys/refcount.h
index e6b26ce4..040584ff 100644
--- a/freebsd/sys/sys/refcount.h
+++ b/freebsd/sys/sys/refcount.h
@@ -76,4 +76,35 @@ refcount_release(volatile u_int *count)
return (1);
}
+/*
+ * A temporary hack until refcount_* APIs are sorted out.
+ */
+static __inline int
+refcount_acquire_if_not_zero(volatile u_int *count)
+{
+ u_int old;
+
+ old = *count;
+ for (;;) {
+ if (old == 0)
+ return (0);
+ if (atomic_fcmpset_int(count, &old, old + 1))
+ return (1);
+ }
+}
+
+static __inline int
+refcount_release_if_not_last(volatile u_int *count)
+{
+ u_int old;
+
+ old = *count;
+ for (;;) {
+ if (old == 1)
+ return (0);
+ if (atomic_fcmpset_int(count, &old, old - 1))
+ return (1);
+ }
+}
+
#endif /* ! __SYS_REFCOUNT_H__ */
diff --git a/freebsd/sys/sys/seq.h b/freebsd/sys/sys/seq.h
index 405e3466..c5f00bcb 100644
--- a/freebsd/sys/sys/seq.h
+++ b/freebsd/sys/sys/seq.h
@@ -41,26 +41,52 @@ typedef uint32_t seq_t;
#ifdef _KERNEL
/*
- * Typical usage:
+ * seq allows readers and writers to work with a consistent snapshot. Modifying
+ * operations must be enclosed within a transaction delineated by
+ * seq_write_beg/seq_write_end. The trick works by having the writer increment
+ * the sequence number twice, at the beginning and end of the transaction.
+ * The reader detects that the sequence number has not changed between its start
+ * and end, and that the sequence number is even, to validate consistency.
+ *
+ * Some fencing (both hard fencing and compiler barriers) may be needed,
+ * depending on the cpu. Modern AMD cpus provide strong enough guarantees to not
+ * require any fencing by the reader or writer.
+ *
+ * Example usage:
*
* writers:
- * lock_exclusive(&obj->lock);
- * seq_write_begin(&obj->seq);
- * .....
- * seq_write_end(&obj->seq);
- * unlock_exclusive(&obj->unlock);
+ * lock_exclusive(&obj->lock);
+ * seq_write_begin(&obj->seq);
+ * obj->var1 = ...;
+ * obj->var2 = ...;
+ * seq_write_end(&obj->seq);
+ * unlock_exclusive(&obj->lock);
*
* readers:
- * obj_t lobj;
- * seq_t seq;
+ * int var1, var2;
+ * seq_t seq;
+ *
+ * for (;;) {
+ * seq = seq_read(&obj->seq);
+ * var1 = obj->var1;
+ * var2 = obj->var2;
+ * if (seq_consistent(&obj->seq, seq))
+ * break;
+ * }
+ * .....
+ *
+ * Writers may not block or sleep in any way.
+ *
+ * There are 2 minor caveats in this implementation:
+ *
+ * 1. There is no guarantee of progress. That is, a large number of writers can
+ * interfere with the execution of the readers and cause the code to live-lock
+ * in a loop trying to acquire a consistent snapshot.
*
- * for (;;) {
- * seq = seq_read(&gobj->seq);
- * lobj = gobj;
- * if (seq_consistent(&gobj->seq, seq))
- * break;
- * }
- * foo(lobj);
+ * 2. If the reader loops long enough, the counter may overflow and eventually
+ * wrap back to its initial value, fooling the reader into accepting the
+ * snapshot. Given that this needs 4 billion transactional writes across a
+ * single contended reader, it is unlikely to ever happen.
*/
/* A hack to get MPASS macro */
@@ -79,6 +105,7 @@ static __inline void
seq_write_begin(seq_t *seqp)
{
+ critical_enter();
MPASS(!seq_in_modify(*seqp));
*seqp += 1;
atomic_thread_fence_rel();
@@ -90,6 +117,7 @@ seq_write_end(seq_t *seqp)
atomic_store_rel_32(seqp, *seqp + 1);
MPASS(!seq_in_modify(*seqp));
+ critical_exit();
}
static __inline seq_t
diff --git a/freebsd/sys/sys/sysproto.h b/freebsd/sys/sys/sysproto.h
index 9148a395..f70d820c 100644
--- a/freebsd/sys/sys/sysproto.h
+++ b/freebsd/sys/sys/sysproto.h
@@ -1815,6 +1815,11 @@ struct cpuset_setdomain_args {
char mask_l_[PADL_(domainset_t *)]; domainset_t * mask; char mask_r_[PADR_(domainset_t *)];
char policy_l_[PADL_(int)]; int policy; char policy_r_[PADR_(int)];
};
+struct getrandom_args {
+ char buf_l_[PADL_(void *)]; void * buf; char buf_r_[PADR_(void *)];
+ char buflen_l_[PADL_(size_t)]; size_t buflen; char buflen_r_[PADR_(size_t)];
+ char flags_l_[PADL_(unsigned int)]; unsigned int flags; char flags_r_[PADR_(unsigned int)];
+};
int nosys(struct thread *, struct nosys_args *);
void sys_sys_exit(struct thread *, struct sys_exit_args *);
int sys_fork(struct thread *, struct fork_args *);
@@ -2195,6 +2200,7 @@ int sys_mknodat(struct thread *, struct mknodat_args *);
int sys_kevent(struct thread *, struct kevent_args *);
int sys_cpuset_getdomain(struct thread *, struct cpuset_getdomain_args *);
int sys_cpuset_setdomain(struct thread *, struct cpuset_setdomain_args *);
+int sys_getrandom(struct thread *, struct getrandom_args *);
#ifdef COMPAT_43
@@ -3087,6 +3093,7 @@ int freebsd11_mknodat(struct thread *, struct freebsd11_mknodat_args *);
#define SYS_AUE_kevent AUE_KEVENT
#define SYS_AUE_cpuset_getdomain AUE_NULL
#define SYS_AUE_cpuset_setdomain AUE_NULL
+#define SYS_AUE_getrandom AUE_NULL
#endif /* __rtems__ */
#undef PAD_
diff --git a/freebsd/sys/sys/systm.h b/freebsd/sys/sys/systm.h
index 2dfe959b..98efffd0 100644
--- a/freebsd/sys/sys/systm.h
+++ b/freebsd/sys/sys/systm.h
@@ -354,14 +354,15 @@ int copystr(const void * _Nonnull __restrict kfaddr,
int copyinstr(const void * __restrict udaddr,
void * _Nonnull __restrict kaddr, size_t len,
size_t * __restrict lencopied);
-int copyin(const void * _Nonnull __restrict udaddr,
+int copyin(const void * __restrict udaddr,
void * _Nonnull __restrict kaddr, size_t len);
-int copyin_nofault(const void * _Nonnull __restrict udaddr,
+int copyin_nofault(const void * __restrict udaddr,
void * _Nonnull __restrict kaddr, size_t len);
int copyout(const void * _Nonnull __restrict kaddr,
- void * _Nonnull __restrict udaddr, size_t len);
+ void * __restrict udaddr, size_t len);
int copyout_nofault(const void * _Nonnull __restrict kaddr,
- void * _Nonnull __restrict udaddr, size_t len);
+ void * __restrict udaddr, size_t len);
+
#else /* __rtems__ */
static inline int
copyinstr(const void * __restrict udaddr, void * __restrict kaddr,
@@ -557,6 +558,8 @@ int pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr,
#endif /* __rtems__ */
#define pause(wmesg, timo) \
pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK)
+#define pause_sig(wmesg, timo) \
+ pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK | C_CATCH)
#define tsleep(chan, pri, wmesg, timo) \
_sleep((chan), NULL, (pri), (wmesg), tick_sbt * (timo), \
0, C_HARDCLOCK)
diff --git a/freebsd/sys/sys/vmmeter.h b/freebsd/sys/sys/vmmeter.h
index 901604ae..408cd862 100644
--- a/freebsd/sys/sys/vmmeter.h
+++ b/freebsd/sys/sys/vmmeter.h
@@ -125,6 +125,7 @@ struct vmmeter {
counter_u64_t v_vforkpages; /* (p) pages affected by vfork() */
counter_u64_t v_rforkpages; /* (p) pages affected by rfork() */
counter_u64_t v_kthreadpages; /* (p) ... and by kernel fork() */
+ counter_u64_t v_wire_count; /* (p) pages wired down */
#define VM_METER_NCOUNTERS \
(offsetof(struct vmmeter, v_page_size) / sizeof(counter_u64_t))
/*
@@ -139,24 +140,43 @@ struct vmmeter {
u_int v_pageout_free_min; /* (c) min pages reserved for kernel */
u_int v_interrupt_free_min; /* (c) reserved pages for int code */
u_int v_free_severe; /* (c) severe page depletion point */
- u_int v_wire_count VMMETER_ALIGNED; /* (a) pages wired down */
- u_int v_active_count VMMETER_ALIGNED; /* (a) pages active */
- u_int v_inactive_count VMMETER_ALIGNED; /* (a) pages inactive */
- u_int v_laundry_count VMMETER_ALIGNED; /* (a) pages eligible for
- laundering */
- u_int v_free_count VMMETER_ALIGNED; /* (f) pages free */
};
#endif /* _KERNEL || _WANT_VMMETER */
#ifdef _KERNEL
+#include <sys/domainset.h>
+
extern struct vmmeter vm_cnt;
-extern u_int vm_pageout_wakeup_thresh;
+extern domainset_t vm_min_domains;
+extern domainset_t vm_severe_domains;
#define VM_CNT_ADD(var, x) counter_u64_add(vm_cnt.var, x)
#define VM_CNT_INC(var) VM_CNT_ADD(var, 1)
#define VM_CNT_FETCH(var) counter_u64_fetch(vm_cnt.var)
+static inline void
+vm_wire_add(int cnt)
+{
+
+ VM_CNT_ADD(v_wire_count, cnt);
+}
+
+static inline void
+vm_wire_sub(int cnt)
+{
+
+ VM_CNT_ADD(v_wire_count, -cnt);
+}
+
+u_int vm_free_count(void);
+static inline u_int
+vm_wire_count(void)
+{
+
+ return (VM_CNT_FETCH(v_wire_count));
+}
+
/*
* Return TRUE if we are under our severe low-free-pages threshold
*
@@ -167,7 +187,7 @@ static inline int
vm_page_count_severe(void)
{
- return (vm_cnt.v_free_severe > vm_cnt.v_free_count);
+ return (!DOMAINSET_EMPTY(&vm_severe_domains));
}
/*
@@ -183,50 +203,8 @@ static inline int
vm_page_count_min(void)
{
- return (vm_cnt.v_free_min > vm_cnt.v_free_count);
-}
-
-/*
- * Return TRUE if we have not reached our free page target during
- * free page recovery operations.
- */
-static inline int
-vm_page_count_target(void)
-{
-
- return (vm_cnt.v_free_target > vm_cnt.v_free_count);
+ return (!DOMAINSET_EMPTY(&vm_min_domains));
}
-/*
- * Return the number of pages we need to free-up or cache
- * A positive number indicates that we do not have enough free pages.
- */
-static inline int
-vm_paging_target(void)
-{
-
- return (vm_cnt.v_free_target - vm_cnt.v_free_count);
-}
-
-/*
- * Returns TRUE if the pagedaemon needs to be woken up.
- */
-static inline int
-vm_paging_needed(u_int free_count)
-{
-
- return (free_count < vm_pageout_wakeup_thresh);
-}
-
-/*
- * Return the number of pages we need to launder.
- * A positive number indicates that we have a shortfall of clean pages.
- */
-static inline int
-vm_laundry_target(void)
-{
-
- return (vm_paging_target());
-}
#endif /* _KERNEL */
#endif /* _SYS_VMMETER_H_ */