Commit Graph

2038 Commits

Author SHA1 Message Date
Andriy Gapon
58e103da6e define Maxmem for ia64, the only platform that didn't have it
This is a direct commit to stable/10 as the platform was removed
in the newer branches.

Maxmem is required for compiling fwohci(4) on ia64 since commit
r310081, MFC of r277511.
It was easier to add Maxmem than to make a special case for ia64
in fwohci.

Reported by:	jhb, gjb
Discussed with:	kib, jhb
2016-12-24 13:28:39 +00:00
Kenneth D. Merry
c05cd4c0c4 MFC r291716, r291724, r291741, r291742
In addition to those revisions, add this change to a file that is not in
head:

sys/ia64/include/bus.h:
  	Guard kernel-only parts of the ia64 machine/bus.h header with
  	#ifdef _KERNEL.

  	This allows userland programs to include <machine/bus.h> to get the
  	definition of bus_addr_t and bus_size_t.

  ------------------------------------------------------------------------
  r291716 | ken | 2015-12-03 15:54:55 -0500 (Thu, 03 Dec 2015) | 257 lines

  Add asynchronous command support to the pass(4) driver, and the new
  camdd(8) utility.

  CCBs may be queued to the driver via the new CAMIOQUEUE ioctl, and
  completed CCBs may be retrieved via the CAMIOGET ioctl.  User
  processes can use poll(2) or kevent(2) to get notification when
  I/O has completed.

  While the existing CAMIOCOMMAND blocking ioctl interface only
  supports user virtual data pointers in a CCB (generally only
  one per CCB), the new CAMIOQUEUE ioctl supports user virtual and
  physical address pointers, as well as user virtual and physical
  scatter/gather lists.  This allows user applications to have more
  flexibility in their data handling operations.

  Kernel memory for data transferred via the queued interface is
  allocated from the zone allocator in MAXPHYS sized chunks, and user
  data is copied in and out.  This is likely faster than the
  vmapbuf()/vunmapbuf() method used by the CAMIOCOMMAND ioctl in
  configurations with many processors (there are more TLB shootdowns
  caused by the mapping/unmapping operation) but may not be as fast
  as running with unmapped I/O.

  The new memory handling model for user requests also allows
  applications to send CCBs with request sizes that are larger than
  MAXPHYS.  The pass(4) driver now limits queued requests to the I/O
  size listed by the SIM driver in the maxio field in the Path
  Inquiry (XPT_PATH_INQ) CCB.

  There are some things things would be good to add:

  1. Come up with a way to do unmapped I/O on multiple buffers.
     Currently the unmapped I/O interface operates on a struct bio,
     which includes only one address and length.  It would be nice
     to be able to send an unmapped scatter/gather list down to
     busdma.  This would allow eliminating the copy we currently do
     for data.

  2. Add an ioctl to list currently outstanding CCBs in the various
     queues.

  3. Add an ioctl to cancel a request, or use the XPT_ABORT CCB to do
     that.

  4. Test physical address support.  Virtual pointers and scatter
     gather lists have been tested, but I have not yet tested
     physical addresses or scatter/gather lists.

  5. Investigate multiple queue support.  At the moment there is one
     queue of commands per pass(4) device.  If multiple processes
     open the device, they will submit I/O into the same queue and
     get events for the same completions.  This is probably the right
     model for most applications, but it is something that could be
     changed later on.

  Also, add a new utility, camdd(8) that uses the asynchronous pass(4)
  driver interface.

  This utility is intended to be a basic data transfer/copy utility,
  a simple benchmark utility, and an example of how to use the
  asynchronous pass(4) interface.

  It can copy data to and from pass(4) devices using any target queue
  depth, starting offset and blocksize for the input and ouptut devices.
  It currently only supports SCSI devices, but could be easily extended
  to support ATA devices.

  It can also copy data to and from regular files, block devices, tape
  devices, pipes, stdin, and stdout.  It does not support queueing
  multiple commands to any of those targets, since it uses the standard
  read(2)/write(2)/writev(2)/readv(2) system calls.

  The I/O is done by two threads, one for the reader and one for the
  writer.  The reader thread sends completed read requests to the
  writer thread in strictly sequential order, even if they complete
  out of order.  That could be modified later on for random I/O patterns
  or slightly out of order I/O.

  camdd(8) uses kqueue(2)/kevent(2) to get I/O completion events from
  the pass(4) driver and also to send request notifications internally.

  For pass(4) devcies, camdd(8) uses a single buffer (CAM_DATA_VADDR)
  per CAM CCB on the reading side, and a scatter/gather list
  (CAM_DATA_SG) on the writing side.  In addition to testing both
  interfaces, this makes any potential reblocking of I/O easier.  No
  data is copied between the reader and the writer, but rather the
  reader's buffers are split into multiple I/O requests or combined
  into a single I/O request depending on the input and output blocksize.

  For the file I/O path, camdd(8) also uses a single buffer (read(2),
  write(2), pread(2) or pwrite(2)) on reads, and a scatter/gather list
  (readv(2), writev(2), preadv(2), pwritev(2)) on writes.

  Things that would be nice to do for camdd(8) eventually:

  1.  Add support for I/O pattern generation.  Patterns like all
      zeros, all ones, LBA-based patterns, random patterns, etc. Right
      Now you can always use /dev/zero, /dev/random, etc.

  2.  Add support for a "sink" mode, so we do only reads with no
      writes.  Right now, you can use /dev/null.

  3.  Add support for automatic queue depth probing, so that we can
      figure out the right queue depth on the input and output side
      for maximum throughput.  At the moment it defaults to 6.

  4.  Add support for SATA device passthrough I/O.

  5.  Add support for random LBAs and/or lengths on the input and
      output sides.

  6.  Track average per-I/O latency and busy time.  The busy time
      and latency could also feed in to the automatic queue depth
      determination.

  sys/cam/scsi/scsi_pass.h:
  	Define two new ioctls, CAMIOQUEUE and CAMIOGET, that queue
  	and fetch asynchronous CAM CCBs respectively.

  	Although these ioctls do not have a declared argument, they
  	both take a union ccb pointer.  If we declare a size here,
  	the ioctl code in sys/kern/sys_generic.c will malloc and free
  	a buffer for either the CCB or the CCB pointer (depending on
  	how it is declared).  Since we have to keep a copy of the
  	CCB (which is fairly large) anyway, having the ioctl malloc
  	and free a CCB for each call is wasteful.

  sys/cam/scsi/scsi_pass.c:
  	Add asynchronous CCB support.

  	Add two new ioctls, CAMIOQUEUE and CAMIOGET.

  	CAMIOQUEUE adds a CCB to the incoming queue.  The CCB is
  	executed immediately (and moved to the active queue) if it
  	is an immediate CCB, but otherwise it will be executed
  	in passstart() when a CCB is available from the transport layer.

  	When CCBs are completed (because they are immediate or
  	passdone() if they are queued), they are put on the done
  	queue.

  	If we get the final close on the device before all pending
  	I/O is complete, all active I/O is moved to the abandoned
  	queue and we increment the peripheral reference count so
  	that the peripheral driver instance doesn't go away before
  	all pending I/O is done.

  	The new passcreatezone() function is called on the first
  	call to the CAMIOQUEUE ioctl on a given device to allocate
  	the UMA zones for I/O requests and S/G list buffers.  This
  	may be good to move off to a taskqueue at some point.
  	The new passmemsetup() function allocates memory and
  	scatter/gather lists to hold the user's data, and copies
  	in any data that needs to be written.  For virtual pointers
  	(CAM_DATA_VADDR), the kernel buffer is malloced from the
  	new pass(4) driver malloc bucket.  For virtual
  	scatter/gather lists (CAM_DATA_SG), buffers are allocated
  	from a new per-pass(9) UMA zone in MAXPHYS-sized chunks.
  	Physical pointers are passed in unchanged.  We have support
  	for up to 16 scatter/gather segments (for the user and
  	kernel S/G lists) in the default struct pass_io_req, so
  	requests with longer S/G lists require an extra kernel malloc.

  	The new passcopysglist() function copies a user scatter/gather
  	list to a kernel scatter/gather list.  The number of elements
  	in each list may be different, but (obviously) the amount of data
  	stored has to be identical.

  	The new passmemdone() function copies data out for the
  	CAM_DATA_VADDR and CAM_DATA_SG cases.

  	The new passiocleanup() function restores data pointers in
  	user CCBs and frees memory.

  	Add new functions to support kqueue(2)/kevent(2):

  	passreadfilt() tells kevent whether or not the done
  	queue is empty.

  	passkqfilter() adds a knote to our list.

  	passreadfiltdetach() removes a knote from our list.

  	Add a new function, passpoll(), for poll(2)/select(2)
  	to use.

  	Add devstat(9) support for the queued CCB path.

  sys/cam/ata/ata_da.c:
  	Add support for the BIO_VLIST bio type.

  sys/cam/cam_ccb.h:
  	Add a new enumeration for the xflags field in the CCB header.
  	(This doesn't change the CCB header, just adds an enumeration to
  	use.)

  sys/cam/cam_xpt.c:
  	Add a new function, xpt_setup_ccb_flags(), that allows specifying
  	CCB flags.

  sys/cam/cam_xpt.h:
  	Add a prototype for xpt_setup_ccb_flags().

  sys/cam/scsi/scsi_da.c:
  	Add support for BIO_VLIST.

  sys/dev/md/md.c:
  	Add BIO_VLIST support to md(4).

  sys/geom/geom_disk.c:
  	Add BIO_VLIST support to the GEOM disk class.  Re-factor the I/O size
  	limiting code in g_disk_start() a bit.

  sys/kern/subr_bus_dma.c:
  	Change _bus_dmamap_load_vlist() to take a starting offset and
  	length.

  	Add a new function, _bus_dmamap_load_pages(), that will load a list
  	of physical pages starting at an offset.

  	Update _bus_dmamap_load_bio() to allow loading BIO_VLIST bios.
  	Allow unmapped I/O to start at an offset.

  sys/kern/subr_uio.c:
  	Add two new functions, physcopyin_vlist() and physcopyout_vlist().

  sys/pc98/include/bus.h:
  	Guard kernel-only parts of the pc98 machine/bus.h header with
  	#ifdef _KERNEL.

  	This allows userland programs to include <machine/bus.h> to get the
  	definition of bus_addr_t and bus_size_t.

  sys/sys/bio.h:
  	Add a new bio flag, BIO_VLIST.

  sys/sys/uio.h:
  	Add prototypes for physcopyin_vlist() and physcopyout_vlist().

  share/man/man4/pass.4:
  	Document the CAMIOQUEUE and CAMIOGET ioctls.

  usr.sbin/Makefile:
  	Add camdd.

  usr.sbin/camdd/Makefile:
  	Add a makefile for camdd(8).

  usr.sbin/camdd/camdd.8:
  	Man page for camdd(8).

  usr.sbin/camdd/camdd.c:
  	The new camdd(8) utility.

  Sponsored by:	Spectra Logic

  ------------------------------------------------------------------------
  r291724 | ken | 2015-12-03 17:07:01 -0500 (Thu, 03 Dec 2015) | 6 lines

  Fix typos in the camdd(8) usage() function output caused by an error in
  my diff filter script.

  Sponsored by:	Spectra Logic

  ------------------------------------------------------------------------
  r291741 | ken | 2015-12-03 22:38:35 -0500 (Thu, 03 Dec 2015) | 10 lines

  Fix g_disk_vlist_limit() to work properly with deletes.

  Add a new bp argument to g_disk_maxsegs(), and add a new function,
  g_disk_maxsize() tha will properly determine the maximum I/O size for a
  delete or non-delete bio.

  Submitted by:	will
  Sponsored by:	Spectra Logic

  ------------------------------------------------------------------------
  ------------------------------------------------------------------------
  r291742 | ken | 2015-12-03 22:44:12 -0500 (Thu, 03 Dec 2015) | 5 lines

  Fix a style issue in g_disk_limit().

  Noticed by:	bdrewery

  ------------------------------------------------------------------------

Sponsored by:	Spectra Logic
2015-12-16 19:01:14 +00:00
Konstantin Belousov
3360246dbb MFC r288000:
Add support for weak symbols to the kernel linkers.
2015-09-27 01:33:43 +00:00
Ryan Stone
71d7f73ac9 MFC r280957
Fix integer truncation bug in malloc(9)

  A couple of internal functions used by malloc(9) and uma truncated
  a size_t down to an int.  This could cause any number of issues
  (e.g. indefinite sleeps, memory corruption) if any kernel
  subsystem tried to allocate 2GB or more through malloc.  zfs would
  attempt such an allocation when run on a system with 2TB or more
  of RAM.
2015-09-17 23:31:44 +00:00
John Baldwin
df0a3be9eb MFC 281266:
Move the 32-bit compatible procfs types from freebsd32.h to <sys/procfs.h>
and export them to userland.
- Define __HAVE_REG32 on platforms that define a reg32 structure and check
  for this in <sys/procfs.h> to control when to export prstatus32, etc.
- Add prstatus32_t and prpsinfo32_t typedefs for the 32-bit structures.
  libbfd looks for these types, and having them fixes 'gcore' in gdb of a
  32-bit process on a 64-bit platform.
- Use the structure definitions from <sys/procfs.h> in gcore's elf32 core
  dump code instead of duplicating the definitions.
2015-06-02 14:54:53 +00:00
Hans Petter Selasky
440008368e MFC r282120:
The add_bounce_page() function can be called when loading physical
pages which pass a NULL virtual address. If the BUS_DMA_KEEP_PG_OFFSET
flag is set, use the physical address to compute the page offset
instead. The physical address should always be valid when adding
bounce pages and should contain the same page offset like the virtual
address.

Submitted by:	Svatopluk Kraus <onwahe@gmail.com>
Reviewed by:	jhb@
2015-05-05 19:47:17 +00:00
Peter Wemm
7fa6e52ec2 Repair ia64 build after r278347 - remove const from set_mcontext 2015-02-08 22:17:20 +00:00
Konstantin Belousov
a3434e0588 Merge the fueword(9) and casueword(9). In particular,
MFC r273783:
Add fueword(9) and casueword(9) functions.
MFC note: ia64 is handled like arm, with NO_FUEWORD define.

MFC r273784:
Replace some calls to fuword() by fueword() with proper error checking.

MFC r273785:
Convert kern_umtx.c to use fueword() and casueword().
MFC note: the sys__umtx_lock and sys__umtx_unlock syscalls are not
converted, they are removed from HEAD, and not used.  The do_sem2*()
family is not yet merged to stable/10, corresponding chunk will be
merged after do_sem2* are committed.

MFC r273788 (by jkim):
Actually install casuword(9) to fix build.

MFC r273911:
Add type qualifier volatile to the base (userspace) address argument
of fuword(9) and suword(9).
2014-11-18 12:53:32 +00:00
Marcel Moolenaar
ac417171e4 Make sure all memory updates are made visible before we let go
of the thread in cpu_switch(). It's otherwise possible that on
another CPU the thread continues from stale context data.

Note that this is prominent on newer CPUs, like the Montecito,
that really take advantage of the weak memory ordering. First
generation Itanium 2 is not that aggressive and does not need
this.

This is a direct commit to stable/10.

Approved by:	re@ (gjb)
2014-09-22 20:10:45 +00:00
Marcel Moolenaar
84eea2ba7c Fix previous commit: unbreak build of libkvm by including sys/systm.h
only when _KERNEL is defined.

Approved by:	re@ (implicit)
2014-09-07 21:40:14 +00:00
Marcel Moolenaar
e31ece45b7 Fix the PCPU access macros. It was found that the PCPU pointer, when
held in register r13, is used outside the bounds of critical_enter()
and critical_exit() by virtue of optimizations performed by the
compiler. The net effect being that address computations of fields
in the PCPU structure could be relative to the PCPU structure of the
CPU on which the address computation was performed and not related
to the CPU that executes the actual load or store operation.
The typical failure mode being that the per-CPU cache of UMA got
corrupted due to accesses from other CPUs.

Adding more volatile decorating to the register expression does not
help. The thinking being that volatile is assumed to work on memory
references and not register references. Thus, the fix is to perform
the address computation using a volatile inline assembly statement.

Additionally, since the reference is fundamentally non-atomic on ia64
by virtue of have a distinct address computation followed by the
actual load or store operation, it is required to wrap the entire
PCPU access in a critical section.

With PCPU_GET and friends requiring curthread now that they're in a
critical section, low-level use of these macros in functions like
cpu_switch() is not possible anymore. Consequently, a second order
set of changes is needed to avoid using PCPU_GET and friends where
curthread is either not set yet, or in the process of being changed.
In those cases, explicit dereferencing of pcpup is needed. In those
cases it is also possible to do that.

This is a direct commit to stable/10.

Approved by:	re@ (marius)
2014-09-06 22:17:54 +00:00
Konstantin Belousov
7676b49b19 Fix a leak of the wired pages when unwiring of the PROT_NONE-mapped
wired region.  Rework the handling of unwire to do the it in batch,
both at pmap and object level.

All commits below are by alc.

MFC r268327:
Introduce pmap_unwire().

MFC r268591:
Implement pmap_unwire() for powerpc.

MFC r268776:
Implement pmap_unwire() for arm.

MFC r268806:
pmap_unwire(9) man page.

MFC r269134:
When unwiring a region of an address space, do not assume that the
underlying physical pages are mapped by the pmap.  This fixes a leak
of the wired pages on the unwiring of the region mapped with no access
allowed.

MFC r269339:
In the implementation of the new function pmap_unwire(), the call to
MOEA64_PVO_TO_PTE() must be performed before any changes are made to the
PVO. Otherwise, MOEA64_PVO_TO_PTE() will panic.

MFC r269365:
Correct a long-standing problem in moea{,64}_pvo_enter() that was revealed
by the combination of r268591 and r269134: When we attempt to add the
wired attribute to an existing mapping, moea{,64}_pvo_enter() do nothing.
(They only set the wired attribute on newly created mappings.)

MFC r269433:
Handle wiring failures in vm_map_wire() with the new functions
pmap_unwire() and vm_object_unwire().
Retire vm_fault_{un,}wire(), since they are no longer used.

MFC r269438:
Rewrite a loop in vm_map_wire() so that gcc doesn't think that the variable
"rv" is uninitialized.

MFC r269485:
Retire pmap_change_wiring().

Reviewed by:	alc
2014-09-01 07:58:15 +00:00
Alan Cox
ffeeeaeca2 Update an assertion to reflect the changes made in r270439. This is a
direct commit to stable/10 because ia64 is no longer supported by HEAD.

Reported by:	marcel
Sponsored by:	EMC / Isilon Storage Division
2014-08-30 03:41:47 +00:00
Marcel Moolenaar
3407d17c78 Make sure the psr field in the trapframe (which holds the value of cr.ipsr)
is properly synthesized for the EPC syscall. Properly synthesized in this
case means that the bank number (BN bitfield) is set to 1. This is needed
because the move-from-PSR instruction does copy all bits! In this case
the BN bitfield was not copied.

While normally this is not a problem, because when we leave the kernel via
the EPC syscall path again, we don't actually care about the BN bitfield.
We restore PSR with a move-to-PSR instruction, which also doesn't cover
the BN bitfield.

There is however a scenario where we enter the kernel via the EPC syscall
path and leave the kernel via the exception/interrupt path. That path
uses the RFI (Return-From-Interrupt) instruction and it restores all bits.
What happens in that case is that we don't properly switch to register
bank 1 and any exception/interrupt that happens while running in bank 0
clobbers the process' (or kernel's) banked registers. This is because the
CPU switches to bank 0 on an exception/interrupt so that there are 16
general registers available for constructing a trapframe and saving the
context. Consequently: normal code should always use register bank 1.

This bug has been present since 2003 (11 years) and has been the cause
for many "unexplained" kernel panics. It says something about how often
we hit this problem on the one hand and how tricky it was to find it.

Many thanks to: clusteradm@ for enabling me to track this down!
2014-08-25 15:15:59 +00:00
Konstantin Belousov
c8f7f2683d Merge the changes to pmap_enter(9) for sleep-less operation (requested
by flag).  The ia64 pmap.c changes are direct commit, since ia64 is
removed on head.

MFC r269368 (by alc):
Retire PVO_EXECUTABLE.

MFC r269728:
Change pmap_enter(9) interface to take flags parameter and superpage
mapping size (currently unused).

MFC r269759 (by alc):
Update the text of a KASSERT() to reflect the changes in r269728.

MFC r269822 (by alc):
Change {_,}pmap_allocpte() so that they look for the flag
PMAP_ENTER_NOSLEEP instead of M_NOWAIT/M_WAITOK when deciding whether
to sleep on page table page allocation.

MFC r270151 (by alc):
Replace KASSERT that no PV list locks are held with a conditional
unlock.

Reviewed by:	alc
Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation
2014-08-24 07:53:15 +00:00
Ed Maste
9445b3fea2 MFC r263815, r263872:
Move ia64 efi.h to sys in preparation for amd64 UEFI support

    Prototypes specific to ia64 have been left in this file for now, under
    __ia64__, rather than moving them to a new header under sys/ia64.
    I anticipate that (some of) the corresponding functions will be shared
    by the amd64, arm64, i386, and ia64 architectures, and we can adjust
    this as EFI support on other than ia64 continues to develop.

  Fix missed efi.h header change in r263815

Sponsored by:	The FreeBSD Foundation
2014-08-21 19:51:07 +00:00
Warner Losh
15f7a618a2 MFC r263749,267146:
>r267146 | imp | 2014-06-05 22:08:55 -0600 (Thu, 05 Jun 2014) | 4 lines
>Restore comments accidentally removed.

>r263749 | imp | 2014-03-25 16:08:31 -0600 (Tue, 25 Mar 2014) | 18 lines
>Rather than require a makeoptions DEBUG to get debug correct,
>add it in kern.mk, but only if we're using clang. While this
>option is supported by both clang and gcc, in the future there
>may be changes to clang which change the defaults that require
>a tweak to build our kernel such that other tools in our tree
>will work. Set a good example by forcing -gdwarf-2 only for
>clang builds, and only if the user hasn't specified another
>dwarf level already. Update UPDATING to reflect the changed
>state of affairs. This also keeps us from having to update
>all the ARM kernels to add this, and also keeps us from
>in the future having to update all the MIPS kernels and is
>one less place the user will have to know to do something
>special for clang and one less thing developers will need
>to do when moving an architecture to clang.
2014-07-17 22:31:46 +00:00
Marcel Moolenaar
4459e8e1be MFC r263380 & r268185: Add KTR events for the PMAP interface functions. 2014-07-02 23:57:55 +00:00
Marcel Moolenaar
1506f02b0e MFC r263323: Fix and improve exception tracing. 2014-07-02 23:47:43 +00:00
Marcel Moolenaar
b11cb99bcd MFC r263254: Move the implementation of kdb_cpu_trap() from <machine/kdb.h>
to machdep.c.
2014-07-02 23:37:14 +00:00
Marcel Moolenaar
8199ea8b33 MFC r263253: Don't use the ITC as the faulting address for external
interrupts.
2014-07-02 23:33:07 +00:00
Marcel Moolenaar
212663f300 MFC r263248 & r263257: In intr_event_handle() we already save and set
td_intr_frame, so don't do it also in ia64_handle_intr().
2014-07-02 23:23:18 +00:00
Marcel Moolenaar
3312c89297 MFC r262726: When reading physical memory, make sure to access it using
the right memory attributes.
2014-07-02 23:12:56 +00:00
Marcel Moolenaar
0791ee4a2e MFC r259959 & r260009: Add prototypical support for minidumps. 2014-07-02 23:05:57 +00:00
Marcel Moolenaar
4047216aac MFC r257484: Change PAL_PTCE_INFO related variables. 2014-07-02 22:19:59 +00:00
Marcel Moolenaar
d8839710bd MFC r257477: Purge the translation cache of APs before we unleash them. 2014-07-02 22:06:31 +00:00
Marcel Moolenaar
15bb1145d7 MFC 257475: Respect the kern.smp.disabled tunable. 2014-07-02 21:53:34 +00:00
Ian Lepore
6f3e3bd718 MFC 263301
In kernel config files, it is supposed to be 'options<space><tab>' not
  'options<tab><tab>', per long standing (but recently not so strictly
  enforced) convention.
2014-05-17 17:34:37 +00:00
Ian Lepore
edf8a8003c MFC 263036, 263059: delete advertising clause in licenses, renumber. 2014-05-17 13:59:11 +00:00
Ian Lepore
b86b7c41c9 MFC r257854 (discussed with alc@)
As of r257209, all architectures have defined
  VM_KMEM_SIZE_SCALE.  In other words, every architecture is now
  auto-sizing the kmem arena.  This revision changes kmeminit() so
  that the definition of VM_KMEM_SIZE_SCALE becomes mandatory and
  the definition of VM_KMEM_SIZE becomes optional.

  Replace or eliminate all existing definitions of VM_KMEM_SIZE.
  With auto-sizing enabled, VM_KMEM_SIZE effectively became an
  alternate spelling for VM_KMEM_SIZE_MIN on most architectures.
  Use VM_KMEM_SIZE_MIN for clarity.
2014-05-16 01:30:30 +00:00
Scott Long
b181a6ec32 Merge r264984
Retire smp_active.  It was racey and caused demonstrated problems with
the cpufreq code.  Replace its use with smp_started.  There's at least
one userland tool that still looks at the kern.smp.active sysctl, so
preserve it but point it to smp_started as well.

Obtained from:	Netflix, Inc.
2014-05-07 20:28:27 +00:00
Kenneth D. Merry
086c85adfd MFC the mpr(4) driver for LSI's 12Gb SAS cards.
This includes r265236, r265237, r265241 and r265261:

  ------------------------------------------------------------------------
  r265236 | ken | 2014-05-02 14:25:09 -0600 (Fri, 02 May 2014) | 51 lines

  Bring in the mpr(4) driver for LSI's MPT3 12Gb SAS controllers.

  This is derived from the mps(4) driver, but it supports only the 12Gb
  IT and IR hardware including the SAS 3004, SAS 3008 and SAS 3108.

  Some notes about this driver:
   o The 12Gb hardware can do "FastPath" I/O, and that capability is included in
     this driver.

   o WarpDrive functionality has been removed, since it isn't supported in
     the 12Gb driver interface.

   o The Scatter/Gather list handling code is significantly different between
     the 6Gb and 12Gb hardware.  The 12Gb boards support IEEE Scatter/Gather
     lists.

  Thanks to LSI for developing and testing this driver for FreeBSD.

  share/man/man4/mpr.4:
  	mpr(4) man page.

  sys/dev/mpr/*:
  	mpr(4) driver files.

  sys/modules/Makefile,
  sys/modules/mpr/Makefile:
  	Add a module Makefile for the mpr(4) driver.

  sys/conf/files:
  	Add the mpr(4) driver.

  sys/amd64/conf/GENERIC,
  sys/i386/conf/GENERIC,
  sys/mips/conf/OCTEON1,
  sys/sparc64/conf/GENERIC:
  	Add the mpr(4) driver to all config files that currently
  	have the mps(4) driver.

  sys/ia64/conf/GENERIC:
  	Add the mps(4) and mpr(4) drivers to the ia64 GENERIC
  	config file.

  sys/i386/conf/XEN:
  	Exclude the mpr module from building here.

  Submitted by:	Steve McConnell <Stephen.McConnell@lsi.com>
  Tested by:	Chris Reeves <chrisr@spectralogic.com>
  Sponsored by:	LSI, Spectra Logic
  Relnotes:	LSI 12Gb SAS driver mpr(4) added

  ------------------------------------------------------------------------
  ------------------------------------------------------------------------
  r265237 | ken | 2014-05-02 14:36:20 -0600 (Fri, 02 May 2014) | 8 lines

  Add the mpr(4) man page to the man4 Makefile.

  This should have been included in r265236.

  Submitted by:	Steve McConnell <Stephen.McConnell@lsi.com>
  MFC after:	3 days
  Sponsored by:	LSI, Spectra Logic

  ------------------------------------------------------------------------
  ------------------------------------------------------------------------
  r265241 | brueffer | 2014-05-02 15:14:28 -0600 (Fri, 02 May 2014) | 2 lines

  Use our standard SYNOPSIS wording; perform some cleanup while here.

  ------------------------------------------------------------------------
  ------------------------------------------------------------------------
  r265261 | brueffer | 2014-05-03 05:15:28 -0600 (Sat, 03 May 2014) | 2 lines

  Add a missing colon.

  ------------------------------------------------------------------------

Submitted by:	Steve McConnell <Stephen.McConnell@lsi.com>
Tested by:	Chris Reeves <chrisr@spectralogic.com>
Sponsored by:	LSI, Spectra Logic
Relnotes:	LSI 12Gb SAS driver mpr(4) added
2014-05-05 20:35:35 +00:00
Tijl Coosemans
13fee2c7c3 MFC r263998:
Rename __wchar_t so it no longer conflicts with __wchar_t from clang 3.4
-fms-extensions.
2014-04-15 09:41:52 +00:00
Marcel Moolenaar
fa7a699e5b MFC r260175:
Implement atomic_swap_<type>.
2014-02-16 23:08:21 +00:00
Marcel Moolenaar
9cef742ef3 MFC r260914:
In pmap_set_pte(), make sure to enforce ordering by inserting a memory fence.
2014-02-16 22:12:13 +00:00
Marcel Moolenaar
51e69d9039 MFC r260666:
In the nested TLB fault handler, for a direct-mapped address, make
sure to clear the lower 12 bits.
2014-02-16 22:01:44 +00:00
Marcel Moolenaar
13bccfa298 MFC r259244:
Allow pmap_remove_pages() to be called for physical maps not
associated with the current thread.
2014-02-16 20:26:22 +00:00
Marcel Moolenaar
5b6df298be MFC r257910:
Don't enable interrupts before we call sched_throw().
2014-02-16 19:20:13 +00:00
Marcel Moolenaar
46da14ecc5 MFC r257487:
Use LOG2_ID_PAGE_SIZE again for the identity mapping in regions 6 & 7.
2014-02-16 19:12:50 +00:00
Konstantin Belousov
45ff09c9fb MFC r257228:
Add bus_dmamap_load_ma() function to load map with the array of
vm_pages.
2013-12-17 13:38:21 +00:00
Glen Barber
66bb89fc08 - Remove debugging from GENERIC* kernel configurations
- Enable MALLOC_PRODUCTION
- Default dumpdev=NO
- Remove UPDATING entry regarding debugging features
- Bump __FreeBSD_version to 1000500

Approved by:	re (implicit)
Sponsored by:	The FreeBSD Foundation
2013-10-10 17:59:44 +00:00
Alan Cox
deb179bb4c The pmap function pmap_clear_reference() is no longer used. Remove it.
pmap_clear_reference() has had exactly one caller in the kernel for
several years, more precisely, since FreeBSD 8.  Now, that call no
longer exists.

Approved by:	re (kib)
Sponsored by:	EMC / Isilon Storage Division
2013-09-20 04:30:18 +00:00
John Baldwin
edb572a38c Add a mmap flag (MAP_32BIT) on 64-bit platforms to request that a mapping use
an address in the first 2GB of the process's address space.  This flag should
have the same semantics as the same flag on Linux.

To facilitate this, add a new parameter to vm_map_find() that specifies an
optional maximum virtual address.  While here, fix several callers of
vm_map_find() to use a VMFS_* constant for the findspace argument instead of
TRUE and FALSE.

Reviewed by:	alc
Approved by:	re (kib)
2013-09-09 18:11:59 +00:00
Gleb Smirnoff
e16477e8d9 On those machines, where sf_bufs do not represent any real object, make
sf_buf_alloc()/sf_buf_free() inlines, to save two calls to an absolutely
empty functions.

Reviewed by:	alc, kib, scottl
Sponsored by:	Nginx, Inc.
Sponsored by:	Netflix
2013-09-06 05:37:49 +00:00
Alan Cox
51321f7c31 Significantly reduce the cost, i.e., run time, of calls to madvise(...,
MADV_DONTNEED) and madvise(..., MADV_FREE).  Specifically, introduce a new
pmap function, pmap_advise(), that operates on a range of virtual addresses
within the specified pmap, allowing for a more efficient implementation of
MADV_DONTNEED and MADV_FREE.  Previously, the implementation of
MADV_DONTNEED and MADV_FREE relied on per-page pmap operations, such as
pmap_clear_reference().  Intuitively, the problem with this implementation
is that the pmap-level locks are acquired and released and the page table
traversed repeatedly, once for each resident page in the range
that was specified to madvise(2).  A more subtle flaw with the previous
implementation is that pmap_clear_reference() would clear the reference bit
on all mappings to the specified page, not just the mapping in the range
specified to madvise(2).

Since our malloc(3) makes heavy use of madvise(2), this change can have a
measureable impact.  For example, the system time for completing a parallel
"buildworld" on a 6-core amd64 machine was reduced by about 1.5% to 2.0%.

Note: This change only contains pmap_advise() implementations for a subset
of our supported architectures.  I will commit implementations for the
remaining architectures after further testing.  For now, a stub function is
sufficient because of the advisory nature of pmap_advise().

Discussed with: jeff, jhb, kib
Tested by:      pho (i386), marcel (ia64)
Sponsored by:   EMC / Isilon Storage Division
2013-08-29 15:49:05 +00:00
Konstantin Belousov
e68c64f0ba Revert r254501. Instead, reuse the type stability of the struct pmap
which is the part of struct vmspace, allocated from UMA_ZONE_NOFREE
zone.  Initialize the pmap lock in the vmspace zone init function, and
remove pmap lock initialization and destruction from pmap_pinit() and
pmap_release().

Suggested and reviewed by:	alc (previous version)
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
2013-08-22 18:12:24 +00:00
Pawel Jakub Dawidek
417ffc66fa Add process descriptors support to the GENERIC kernel. It is already being
used by the tools in base systems and with sandboxing more and more tools
the usage should only increase.

Submitted by:	Mariusz Zaborski <oshogbo@FreeBSD.org>
Sponsored by:	Google Summer of Code 2013
MFC after:	1 month
2013-08-18 10:21:29 +00:00
Jung-uk Kim
3bd12ca8f1 Tidy up global locks for ACPICA. There is no functional change. 2013-08-13 21:34:03 +00:00
Attilio Rao
c7aebda8a1 The soft and hard busy mechanism rely on the vm object lock to work.
Unify the 2 concept into a real, minimal, sxlock where the shared
acquisition represent the soft busy and the exclusive acquisition
represent the hard busy.
The old VPO_WANTED mechanism becames the hard-path for this new lock
and it becomes per-page rather than per-object.
The vm_object lock becames an interlock for this functionality:
it can be held in both read or write mode.
However, if the vm_object lock is held in read mode while acquiring
or releasing the busy state, the thread owner cannot make any
assumption on the busy state unless it is also busying it.

Also:
- Add a new flag to directly shared busy pages while vm_page_alloc
  and vm_page_grab are being executed.  This will be very helpful
  once these functions happen under a read object lock.
- Move the swapping sleep into its own per-object flag

The KPI is heavilly changed this is why the version is bumped.
It is very likely that some VM ports users will need to change
their own code.

Sponsored by:	EMC / Isilon storage division
Discussed with:	alc
Reviewed by:	jeff, kib
Tested by:	gavin, bapt (older version)
Tested by:	pho, scottl
2013-08-09 11:11:11 +00:00
Andriy Gapon
9ba0691bdd follow up to r254051
- update powerpc/GENERIC64 as well, suggested by mdf
- update comments so that they make sense after the change, suggested by
  jhb

X-MFC after:	never (change specific to head)
2013-08-09 08:11:09 +00:00