13757 Commits

Author SHA1 Message Date
mav
a76136eb76 MFC r280850:
Periodically wake up threads waiting for vmem(9) resources, so they could
ask for resource reclamation again.

This is kind of dirty hack, but as last resort this is better then stuck
indefinitely because of KVA fragmentation, waiting until some random event
free something sufficient.  OpenSolaris also has this hack in its vmem(9).
2015-04-13 09:17:57 +00:00
kib
a891e427f4 MFC r281094:
Restore proper error from oshmctl(2), broken by r280323.
2015-04-07 07:10:44 +00:00
kib
d1c2847dcd MFC r281071:
Remove useless initialization.
2015-04-07 07:08:35 +00:00
kib
a66c389283 MFC r280797:
Make debug.vmem_check a tunable.  It is useful to set it early.
2015-04-04 08:06:13 +00:00
kib
cfab2455d5 MFC r280323:
Somewhat modernize the SysV shm code.

MFC r280325 (by cognet):
Fix warning for !MAC case.
2015-04-04 07:59:07 +00:00
kib
34687e7dea MFC r278697 (by alc):
Preset the object's color, or alignment, to maximize superpage usage.
2015-04-04 07:56:04 +00:00
kib
7b4777f74a MFC r258056 (by alc):
Eliminate the gratuitous use of mmap(2) flags from the implementation
of kern_shmat().  Use a simpler approach to determine whether to pass
VMFS_NO_SPACE or VMFS_OPTIMAL_SPACE to vm_map_find().
2015-04-04 07:52:12 +00:00
jhb
b09b758bf2 MFC 276724:
On some Intel CPUs with a P-state but not C-state invariant TSC the TSC
may also halt in C2 and not just C3 (it seems that in some cases the BIOS
advertises its C3 state as a C2 state in _CST).  Just play it safe and
disable both C2 and C3 states if a user forces the use of the TSC as the
timecounter on such CPUs.

PR:		192316
2015-04-02 01:02:42 +00:00
jhb
ea3f65c3bf MFC 278761:
Include OBJT_PHYS VM objects in ELF core dumps. In particular this
includes the shared page allowing debuggers to use the signal trampoline
code to identify signal frames in core dumps.
2015-04-01 19:48:19 +00:00
jhb
065ed54942 MFC 278760:
Add two new counters for vnode life cycle events:
- vfs.recycles counts the number of vnodes forcefully recycled to avoid
  exceeding kern.maxvnodes.
- vfs.vnodes_created counts the number of vnodes created by successful
  calls to getnewvnode().
2015-03-31 15:37:24 +00:00
ian
17ca262c02 MFC r279361, r279395, r279396:
Allow the kern.osrelease and kern.osreldate sysctl values to be set in a
  jail's creation parameters.  This allows the kernel version to be reliably
  spoofed within the jail whether examined directly with sysctl or
  indirectly with the uname -r and -K options.

  Export the new osreldate and osrelease jail parms in jail_get(2).

  Fix line wrap.
2015-03-25 20:57:54 +00:00
hselasky
f07b924bdc MFC r280345:
Fix for out of order device destruction notifications when using the
delist_dev() function. In addition to this change:
- add a proper description of this function
- add a proper witness assert inside this function
- switch a nearby line to use the "cdp" pointer instead of cdev2priv()
2015-03-25 13:01:51 +00:00
kib
48a0d48fb5 MFC r279390:
Change umtx_lock to be the sleepable mutex.
2015-03-21 01:39:44 +00:00
rwatson
6102a34d38 Merge r263233 from HEAD to stable/10:
Update kernel inclusions of capability.h to use capsicum.h instead; some
  further refinement is required as some device drivers intended to be
  portable over FreeBSD versions rely on __FreeBSD_version to decide whether
  to include capability.h.

Sponsored by:	Google, Inc.
2015-03-19 13:37:36 +00:00
kib
df6775dbed MFC r272566:
Convert -1 from sbuf_bcat() to ENOMEM.
2015-03-12 16:05:52 +00:00
scottl
565f091b88 MFC r271889, 272799, 272800, 274976
This brings in bus_get_domain() and the related reporting via devinfo,
dmesg, and sysctl.

Obtained from:	adrian, jhb
Sponsored by:	Netflix, Inc.
2015-03-12 07:07:41 +00:00
jhb
ab52664711 MFC 277712:
Change the default VFS timestamp precision from seconds to microseconds.
2015-03-10 14:18:26 +00:00
kib
06a96cf2f5 MFC r279362:
The VNASSERT in vflush() FORCECLOSE case is trying to panic early to
prevent errors from yanking devices out from under filesystems.  Only
care about special vnodes on devfs, special nodes on other kinds of
filesystems do not have special properties.
2015-03-06 09:22:05 +00:00
kib
efbc02bc53 MFC r279283:
When failing to claim ownership of a umtx_pi, restore the umutex owner
to its previous, unowned state.
2015-03-04 09:31:10 +00:00
kib
17814a5b03 MFC r279282:
When unlocking a contested PI pthread mutex, if the queue of waiters
is empty, look up the umtx_pi and disown it if the current thread owns it.
2015-03-04 09:29:25 +00:00
ae
4cbe57cef8 MFC r279206:
In some cases soreceive_dgram() can return no data, but has control
  message. This can happen when application is sending packets too big
  for the path MTU and recvmsg() will return zero (indicating no data)
  but there will be a cmsghdr with cmsg_type set to IPV6_PATHMTU.
  Remove KASSERT() which does NULL pointer dereference in such case.
  Also call m_freem() only when m isn't NULL.

MFC r279209:
  soreceive_generic() still has similar KASSERT(), therefore instead of
  remove KASSERT(), change it to check mbuf isn't NULL.

PR:		197882
Sponsored by:	Yandex LLC
2015-03-02 07:51:14 +00:00
ngie
b4b5cbeab3 MFC r278891:
Add the mnt_lockref field to the ddb(4) 'show mount' command

Differential Revision: https://reviews.freebsd.org/D1688
Submitted by: Conrad Meyer <conrad.meyer@isilon.com>
Sponsored by: EMC / Isilon Storage Division
2015-03-01 21:03:34 +00:00
kib
61abcd4fb5 MFC r278963:
If malloc() sleeps, Giant is dropped.  Recheck for another thread
doing our work.

Remove unneeded check for failed M_WAITOK allocation.
2015-02-25 09:19:26 +00:00
kib
9534a4a472 MFC r278523:
In mountd, silence a race with the parallel unmount.
2015-02-24 01:46:43 +00:00
jhb
4ee9c49971 MFC 274817,274878,276801,276840,278976:
Improve support for XSAVE with debuggers.
- Dump an NT_X86_XSTATE note if XSAVE is in use. This note is designed
  to match what Linux does in that 1) it dumps the entire XSAVE area
  including the fxsave state, and 2) it stashes a copy of the current
  xsave mask in the unused padding between the fxsave state and the
  xstate header at the same location used by Linux.
- Teach readelf() to recognize NT_X86_XSTATE notes.
- Change PT_GET/SETXSTATE to take the entire XSAVE state instead of
  only the extra portion. This avoids having to always make two
  ptrace() calls to get or set the full XSAVE state.
- Add a PT_GET_XSTATE_INFO which returns the length of the current
  XSTATE save area (so the size of the buffer needed for PT_GETXSTATE)
  and the current XSAVE mask (%xcr0).
2015-02-23 18:38:41 +00:00
markj
f19f98c27b MFC r278983:
Free the zlib stream once the CTF section is decompressed.

MFC r278984:
Remove unnecessary checks for a NULL return value from malloc.

MFC r279089:
Let vn_rdwr() check for short reads.
2015-02-23 01:24:10 +00:00
kib
e17da454ea MFC r278795:
Reparenting done by debugger attach can leave reaper without direct
children.  Handle the situation instead asserting that it is
impossible.
2015-02-18 08:10:13 +00:00
kib
4ebc3c5038 MFC r278794:
Return with the process locked.
2015-02-18 08:08:09 +00:00
rrs
a7664682b1 MFC of r278469, r278623
278469:
This fixes two conditions that can incur when migration
is being done in the callout code and harmonizes the macro
use.:
1) The callout_active() will lie. Basically if a migration
   is occuring and the callout is about to expire and the
   migration has been deferred, the callout_active will no
   longer return true until after the migration. This confuses
   and breaks callers that are doing callout_init(&c, 1); such
   as TCP.
2) The migration code had a bug in it where when migrating, if
   a two calls to callout_reset came in and they both collided with
   the callout on the wheel about to run, then the second call to
   callout_reset would corrupt the list the callout wheel uses
   putting the callout thread into a endless loop.
3) Per imp, I have fixed all the macro occurance in the code that
   were for the most part being ignored.

278623:

This fixes a bug I in-advertantly inserted when I updated the callout
code in my last commit. The cc_exec_next is used to track the next
when a direct call is being made from callout. It is *never* used
in the in-direct method. When macro-izing I made it so that it
would separate out direct/vs/non-direct. This is incorrect and can
cause panics as Peter Holm has found for me (Thanks so much Peter for
all your help in this). What this change does is restore that behavior
but also get rid of the cc_next from the array and instead make it
be part of the base callout structure. This way no one else will get
confused since we will never use it for non-direct.

Sponsored by:	Netflix Inc.
2015-02-15 13:24:32 +00:00
sbruno
ea2d650270 MFC 272315 272757 274091 274902
for real this time

r272315
Explicitly return None for negative event indices.  Prior to this,
eventat(-1) would return the next-to-last event causing the back button
to cycle back to the end of an event source instead of stopping at the
start.

r272757
Add schedgraph traces for callout handlers.  Specifically, a callwheel logs
a running event each time it executes a callout function.  The event
includes the function pointer, argument, and whether or not it was run from
hardware interrupt context.  The callwheel is marked idle when each handler
completes.  This effectively logs the duration of each callout routine in
the graph.

r274091
Bind Ctrl-Q as a global hotkey to exit.  Bind Ctrl-W as a hotkey to close
dialogs.

r274902
Add a new thread state "spinning" to schedgraph and add tracepoints at the
start and stop of spinning waits in lock primitives.

Reviewed by:	jhb
2015-02-13 19:06:22 +00:00
sbruno
2da30ef0ce Revert r278650. Definite layer 8 bug.
Submitted by:	dhw and Thomas Mueller <tmueller@sysgo.com>
2015-02-13 18:45:44 +00:00
ian
7a36a698cb MFC r277025: Fix an off-by-one in ppsratecheck(). 2015-02-13 18:10:06 +00:00
sbruno
538802789a MFC 272315 272757 274091 274902
r272315
Explicitly return None for negative event indices.  Prior to this,
eventat(-1) would return the next-to-last event causing the back button
to cycle back to the end of an event source instead of stopping at the
start.

r272757
Add schedgraph traces for callout handlers.  Specifically, a callwheel logs
a running event each time it executes a callout function.  The event
includes the function pointer, argument, and whether or not it was run from
hardware interrupt context.  The callwheel is marked idle when each handler
completes.  This effectively logs the duration of each callout routine in
the graph.

r274091
Bind Ctrl-Q as a global hotkey to exit.  Bind Ctrl-W as a hotkey to close
dialogs.

r274902
Add a new thread state "spinning" to schedgraph and add tracepoints at the
start and stop of spinning waits in lock primitives.

Reviewed by:	jhb
2015-02-13 00:29:57 +00:00
kib
a85afe0d7d MFC r278209:
Add ddb command 'show clocksource'.
2015-02-11 09:12:10 +00:00
jhb
9809511c44 MFC 273800:
Rework virtual machine hypervisor detection.
- Move the existing code to x86/x86/identcpu.c since it is x86-specific.
- If the CPUID2_HV flag is set, assume a hypervisor is present and query
  the 0x40000000 leaf to determine the hypervisor vendor ID.  Export the
  vendor ID and the highest supported hypervisor CPUID leaf via
  hv_vendor[] and hv_high variables, respectively.  The hv_vendor[]
  array is also exported via the hw.hv_vendor sysctl.
- Merge the VMWare detection code from tsc.c into the new probe in
  identcpu.c.  Add a VM_GUEST_VMWARE to identify vmware and use that in
  the TSC code to identify VMWare.
2015-02-10 16:34:42 +00:00
kib
b02e8ddcdf MFC r277970:
Check for the cycle in the chain of dependency for priority-inheritance
mutexes.
2015-02-07 08:35:18 +00:00
jhb
b2ec547430 MFC 275808:
Check for SS_NBIO in so->so_state instead of sb->sb_flags in
soreceive_stream().
2015-02-06 15:53:13 +00:00
kib
d00b9ac996 MFC r278145:
Fix use after free in pipe_dtor().
2015-02-06 09:02:10 +00:00
hselasky
34369aa374 MFC r277179, r277199 and r277391:
Add a kernel function to delist our kernel character devices, so that
the device name can be re-used right away in case we are destroying
the character devices in the background.
2015-02-05 20:49:13 +00:00
jamie
c6bc15d7ab MFC r277855:
Add allow.mount.fdescfs jail flag.

PR:		192951
Submitted by:	ruben@verweg.com
2015-01-31 17:35:53 +00:00
kib
53cbeb6d49 MFC r277322:
Add procctl(2) PROC_TRACE_CTL command to enable or disable debugger
attachment to the process.
2015-01-25 13:15:12 +00:00
kib
9ddc339f8b MFC r277321:
Make SIGSTOP working for sleeps done while waiting for fifo readers or
writers in open(2), when the fifo is located on an NFS mount.
2015-01-25 13:09:53 +00:00
delphij
f72184af7f MFC r276904:
Improve style and fix a possible use-after-free case introduced in r268384
by reinitializing the 'freestate' pointer after freeing the memory.

Obtained from:	HardenedBSD (71fab80c5dd3034b71a29a61064625018671bbeb)
PR:		194525
Submitted by:	Oliver Pinter <oliver.pinter@hardenedbsd.org>
2015-01-24 00:27:50 +00:00
kib
2247a66996 MFC r277236:
For sigaction(2), ignore possible garbage in sa_flags for sa_handler
== SIG_DFL or SIG_IGN.
2015-01-22 09:07:02 +00:00
kib
44ff2e7b62 MFC r277055:
Revert r263475: TDP_DEVMEMIO no longer needed.
2015-01-19 11:07:29 +00:00
dchagin
af01cd2f74 MFC r276906:
Allow clock_getcpuclockid() on the CPU-time clock for zombie process.
Posix does not prohibit this.
2015-01-17 06:18:45 +00:00
jamie
fe94e6fed3 MFC r277158:
Don't set prison's pr_ip4s or pr_ip6s to -1.

PR:		196474
2015-01-17 01:16:03 +00:00
hselasky
f17550e390 MFC r276532 and r276626:
The "cnputs_mtx" mutex must be allowed to recurse. Debug prints and/or
witness printouts in the console driver clients can cause this mutex
to recurse by calls to "printf()" from witness for example. In
particular this can happen if "debug.witness.skipspin=0" is set in the
boot environment.
2015-01-11 12:17:27 +00:00
dchagin
f5dd178d9f Regen for r276955 (__getcwd path bug). 2015-01-11 07:04:18 +00:00
dchagin
4f4ad9e7dd MFC r276564, r276654:
Cast *path to silence clang -Wpointer-sign warning.

Indeed, instead of hiding the kern___getcwd() bug by bogus cast
in r276564, change path type to char * (pathnames are always char *).
And remove bogus casts of malloc().
kern___getcwd() internally doesn't actually use or support u_char *
paths, except to copy them to a normal char * path.

These changes are not visible to libc as libc/gen/getcwd.c misdeclares
__getcwd() as taking a plain char * path.

While here remove _SYS_SYSPROTO_H_ for __getcwd() syscall as
we always have sysproto.h.
2015-01-11 07:02:03 +00:00