OSDN Git Service

LDP: Update original to LDP v3.68
[linuxjm/LDP_man-pages.git] / original / man2 / swapon.2
index 63d1c9b..e4c67d2 100644 (file)
@@ -1,7 +1,6 @@
-.\" Hey Emacs! This file is -*- nroff -*- source.
-.\"
 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
 .\"
+.\" %%%LICENSE_START(VERBATIM)
 .\" Permission is granted to make and distribute verbatim copies of this
 .\" manual provided the copyright notice and this permission notice are
 .\" preserved on all copies.
@@ -21,6 +20,7 @@
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
 .\"
 .\" Modified by Michael Haardt <michael@moria.de>
 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
 .\" 2007-06-22 Ivana Varekova <varekova@redhat.com>, mtk
 .\"     Update text describing limit on number of swap files.
 .\"
-.TH SWAPON 2 2007-06-22 "Linux" "Linux Programmer's Manual"
+.TH SWAPON 2 2014-05-28 "Linux" "Linux Programmer's Manual"
 .SH NAME
 swapon, swapoff \- start/stop swapping to file/device
 .SH SYNOPSIS
 .B #include <unistd.h>
 .br
-.B #include <asm/page.h>     /* to find PAGE_SIZE */
-.br
 .B #include <sys/swap.h>
 .sp
 .BI "int swapon(const char *" path ", int " swapflags );
@@ -55,15 +53,12 @@ sets the swap area to the file or block device specified by
 stops swapping to the file or block device specified by
 .IR path .
 .PP
+If the
+.B SWAP_FLAG_PREFER
+flag is specified in the
 .BR swapon ()
-takes a
-.I swapflags
-argument.
-If
 .I swapflags
-has the
-.B SWAP_FLAG_PREFER
-bit turned on, the new swap area will have a higher priority than default.
+argument, the new swap area will have a higher priority than default.
 The priority is encoded within
 .I swapflags
 as:
@@ -72,7 +67,18 @@ as:
 .I "    (prio << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK"
 .br
 .PP
-These functions may only be used by a privileged process (one having the
+If the
+.B SWAP_FLAG_DISCARD
+flag is specified in the
+.BR swapon ()
+.I swapflags
+argument, freed swap pages will be discarded before they are reused,
+if the swap device supports the discard or trim operation.
+(This may improve performance on some Solid State Devices,
+but often it does not.)
+See also NOTES.
+.PP
+These functions may be used only by a privileged process (one having the
 .B CAP_SYS_ADMIN
 capability).
 .SS Priority
@@ -97,7 +103,7 @@ pages are allocated on a round-robin basis between them.
 .PP
 As of Linux 1.3.6, the kernel usually follows these rules,
 but there are exceptions.
-.SH "RETURN VALUE"
+.SH RETURN VALUE
 On success, zero is returned.
 On error, \-1 is returned, and
 .I errno
@@ -115,11 +121,19 @@ is already being used as a swap area.
 The file
 .I path
 exists, but refers neither to a regular file nor to a block device;
-or, for
-.BR swapon (),
-the indicated path does not contain a valid swap signature or
-resides on an in-memory file system like tmpfs; or, for
-.BR swapoff (),
+.TP
+.B EINVAL
+.RB ( swapon ())
+The indicated path does not contain a valid swap signature or
+resides on an in-memory filesystem such as tmpfs.
+.TP
+.BR EINVAL " (since Linux 3.4)"
+.RB ( swapon ())
+An invalid flag value was specified in
+.IR flags .
+.TP
+.B EINVAL
+.RB ( swapoff ())
 .I path
 is not currently a swap area.
 .TP
@@ -140,7 +154,7 @@ The caller does not have the
 capability.
 Alternatively, the maximum number of swap files are already in use;
 see NOTES below.
-.SH "CONFORMING TO"
+.SH CONFORMING TO
 These functions are Linux-specific and should not be used in programs
 intended to be portable.
 The second
@@ -165,7 +179,31 @@ option
 .BR mbind (2)
 and
 .BR migrate_pages (2)).
-.SH "SEE ALSO"
+Since kernel 2.6.32, the limit is further decreased by 1
+if the kernel is built with the
+.B CONFIG_MEMORY_FAILURE
+option.
+
+Discard of swap pages was introduced in kernel 2.6.29,
+then made conditional
+on the
+.B SWAP_FLAG_DISCARD
+flag in kernel 2.6.36,
+.\" To be precise: 2.6.35.5
+which still discards the
+entire swap area when
+.BR swapon ()
+is called, even if that flag bit is not set.
+.SH SEE ALSO
 .BR mkswap (8),
 .BR swapoff (8),
 .BR swapon (8)
+.SH COLOPHON
+This page is part of release 3.68 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.