linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anton Vorontsov <anton.vorontsov-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Mel Gorman <mgorman-l3A5Bk7waGM@public.gmane.org>
Cc: Pekka Enberg <penberg-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Leonid Moiseichuk
	<leonid.moiseichuk-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>,
	KOSAKI Motohiro
	<kosaki.motohiro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Minchan Kim <minchan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Bartlomiej Zolnierkiewicz
	<b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
	John Stultz <john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linaro-kernel-cunTk1MwBs8s++Sfvej+rw@public.gmane.org,
	patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	kernel-team-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org,
	linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [RFC 3/3] man-pages: Add man page for vmpressure_fd(2)
Date: Wed, 7 Nov 2012 03:01:52 -0800	[thread overview]
Message-ID: <20121107110152.GC30462@lizard> (raw)
In-Reply-To: <20121107105348.GA25549@lizard>

VMPRESSURE_FD(2)        Linux Programmer's Manual       VMPRESSURE_FD(2)

NAME
       vmpressure_fd - Linux virtual memory pressure notifications

SYNOPSIS
       #define _GNU_SOURCE
       #include <unistd.h>
       #include <sys/syscall.h>
       #include <asm/unistd.h>
       #include <linux/types.h>
       #include <linux/vmpressure.h>

       int vmpressure_fd(struct vmpressure_config *config)
       {
            config->size = sizeof(*config);
            return syscall(__NR_vmpressure_fd, config);
       }

DESCRIPTION
       This  system  call creates a new file descriptor that can be used
       with blocking (e.g.  read(2)) and/or polling (e.g.  poll(2)) rou-
       tines to get notified about system's memory pressure.

       Upon  these  notifications,  userland programs can cooperate with
       the kernel, achieving better system's memory management.

   Memory pressure levels
       There are currently three memory pressure levels, each  level  is
       defined via vmpressure_level enumeration, and correspond to these
       constants:

       VMPRESSURE_LOW
              The system is reclaiming memory for new allocations. Moni-
              toring reclaiming activity might be useful for maintaining
              overall system's cache level.

       VMPRESSURE_MEDIUM
              The system is experiencing medium memory  pressure,  there
              might  be  some  mild  swapping activity. Upon this event,
              applications may decide to free any resources that can  be
              easily reconstructed or re-read from a disk.

       VMPRESSURE_OOM
              The  system  is  actively thrashing, it is about to out of
              memory (OOM) or even the in-kernel OOM killer  is  on  its
              way  to  trigger. Applications should do whatever they can
              to help the system. See proc(5) for more information about
              OOM killer and its configuration options.

       Note that the behaviour of some levels can be tuned through the
       sysctl(5)      mechanism.      See      /usr/src/linux/Documenta-
       tion/sysctl/vm.txt for various vmpressure_*  tunables  and  their
       meanings.

   Configuration
       vmpressure_fd(2) accepts vmpressure_config structure to configure
       the notifications:

       struct vmpressure_config {
            __u32 size;
            __u32 threshold;
       };

       size is a part of ABI  versioning  and  must  be  initialized  to
       sizeof(struct vmpressure_config).

       threshold  is  used to setup a minimal value of the pressure upon
       which the events will be delivered by the kernel  (for  algebraic
       comparisons,   it   is  defined  that  VMPRESSURE_LOW  <  VMPRES-
       SURE_MEDIUM < VMPRESSURE_OOM, but applications should not put any
       meaning into the absolute values.)

   Events
       Upon  a  notification,  application  must  read  out events using
       read(2) system call.  The events are delivered using the  follow-
       ing structure:

       struct vmpressure_event {
            __u32 pressure;
       };

       The pressure shows the most recent system's pressure level.

RETURN VALUE
       On  success,  vmpressure_fd()  returns  a new file descriptor. On
       error, a negative value is returned and errno is set to  indicate
       the error.

ERRORS
       vmpressure_fd() can fail with errors similar to open(2).

       In addition, the following errors are possible:

       EINVAL The  failure  means  that  an improperly initalized config
              structure has been passed to the call.

       EFAULT The failure means that the kernel was unable to  read  the
              configuration  structure, that is, config parameter points
              to an inaccessible memory.

VERSIONS
       The system call is available on Linux since kernel  3.8.  Library
       support is yet not provided by any glibc version.

CONFORMING TO
       The system call is Linux-specific.

EXAMPLE
       Examples can be found in /usr/src/linux/tools/testing/vmpressure/
       directory.

SEE ALSO
       poll(2), read(2), proc(5), sysctl(5), vmstat(8)

Linux                          2012-10-16               VMPRESSURE_FD(2)

Signed-off-by: Anton Vorontsov <anton.vorontsov-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 man2/vmpressure_fd.2 | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 163 insertions(+)
 create mode 100644 man2/vmpressure_fd.2

diff --git a/man2/vmpressure_fd.2 b/man2/vmpressure_fd.2
new file mode 100644
index 0000000..eaf07d4
--- /dev/null
+++ b/man2/vmpressure_fd.2
@@ -0,0 +1,163 @@
+.\" Copyright (C) 2008 Michael Kerrisk <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
+.\" Copyright (C) 2012 Linaro Ltd.
+.\" 		       Anton Vorontsov <anton.vorontsov-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
+.\"
+.\" Based on ideas from:
+.\" KOSAKI Motohiro, Leonid Moiseichuk, Mel Gorman, Minchan Kim and Pekka
+.\" Enberg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public License
+.\" along with this program; if not, write to the Free Software
+.\" Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+.\" MA  02111-1307  USA
+.\"
+.TH VMPRESSURE_FD 2 2012-10-16 Linux "Linux Programmer's Manual"
+.SH NAME
+vmpressure_fd \- Linux virtual memory pressure notifications
+.SH SYNOPSIS
+.nf
+.B #define _GNU_SOURCE
+.B #include <unistd.h>
+.B #include <sys/syscall.h>
+.B #include <asm/unistd.h>
+.B #include <linux/types.h>
+.B #include <linux/vmpressure.h>
+.\" TODO: libc wrapper
+
+.BI "int vmpressure_fd(struct vmpressure_config *"config )
+.B
+{
+.B
+	config->size = sizeof(*config);
+.B
+	return syscall(__NR_vmpressure_fd, config);
+.B
+}
+.fi
+.SH DESCRIPTION
+This system call creates a new file descriptor that can be used with
+blocking (e.g.
+.BR read (2))
+and/or polling (e.g.
+.BR poll (2))
+routines to get notified about system's memory pressure.
+
+Upon these notifications, userland programs can cooperate with the kernel,
+achieving better system's memory management.
+.SS Memory pressure levels
+There are currently three memory pressure levels, each level is defined
+via
+.IR vmpressure_level " enumeration,"
+and correspond to these constants:
+.TP
+.B VMPRESSURE_LOW
+The system is reclaiming memory for new allocations. Monitoring reclaiming
+activity might be useful for maintaining overall system's cache level.
+.TP
+.B VMPRESSURE_MEDIUM
+The system is experiencing medium memory pressure, there might be some
+mild swapping activity. Upon this event, applications may decide to free
+any resources that can be easily reconstructed or re-read from a disk.
+.TP
+.B VMPRESSURE_OOM
+The system is actively thrashing, it is about to out of memory (OOM) or
+even the in-kernel OOM killer is on its way to trigger. Applications
+should do whatever they can to help the system. See
+.BR proc (5)
+for more information about OOM killer and its configuration options.
+.TP 0
+Note that the behaviour of some levels can be tuned through the
+.BR sysctl (5)
+mechanism. See
+.I /usr/src/linux/Documentation/sysctl/vm.txt
+for various
+.I vmpressure_*
+tunables and their meanings.
+.SS Configuration
+.BR vmpressure_fd (2)
+accepts
+.I vmpressure_config
+structure to configure the notifications:
+
+.nf
+struct vmpressure_config {
+	__u32 size;
+	__u32 threshold;
+};
+.fi
+
+.I size
+is a part of ABI versioning and must be initialized to
+.IR "sizeof(struct vmpressure_config)" .
+
+.I threshold
+is used to setup a minimal value of the pressure upon which the events
+will be delivered by the kernel (for algebraic comparisons, it is defined
+that
+.BR VMPRESSURE_LOW " <"
+.BR VMPRESSURE_MEDIUM " <"
+.BR VMPRESSURE_OOM ,
+but applications should not put any meaning into the absolute values.)
+.SS Events
+Upon a notification, application must read out events using
+.BR read (2)
+system call.
+The events are delivered using the following structure:
+
+.nf
+struct vmpressure_event {
+	__u32 pressure;
+};
+.fi
+
+The
+.I pressure
+shows the most recent system's pressure level.
+.SH "RETURN VALUE"
+On success,
+.BR vmpressure_fd ()
+returns a new file descriptor. On error, a negative value is returned and
+.I errno
+is set to indicate the error.
+.SH ERRORS
+.BR vmpressure_fd ()
+can fail with errors similar to
+.BR open (2).
+
+In addition, the following errors are possible:
+.TP
+.B EINVAL
+The failure means that an improperly initalized
+.I config
+structure has been passed to the call.
+.TP
+.B EFAULT
+The failure means that the kernel was unable to read the configuration
+structure, that is,
+.I config
+parameter points to an inaccessible memory.
+.SH VERSIONS
+The system call is available on Linux since kernel 3.8. Library support is
+yet not provided by any glibc version.
+.SH CONFORMING TO
+The system call is Linux-specific.
+.SH EXAMPLE
+Examples can be found in
+.I /usr/src/linux/tools/testing/vmpressure/
+directory.
+.SH "SEE ALSO"
+.BR poll (2),
+.BR read (2),
+.BR proc (5),
+.BR sysctl (5),
+.BR vmstat (8)
-- 
1.8.0
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2012-11-07 11:01 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-07 10:53 [RFC v3 0/3] vmpressure_fd: Linux VM pressure notifications Anton Vorontsov
2012-11-07 11:01 ` [RFC 1/3] mm: Add " Anton Vorontsov
2012-11-08 17:01   ` Mel Gorman
     [not found]     ` <20121108170124.GB8218-l3A5Bk7waGM@public.gmane.org>
2012-11-08 17:14       ` Kirill A. Shutemov
2012-11-13 18:38   ` Jonathan Corbet
2012-11-07 11:01 ` [RFC 2/3] tools/testing: Add vmpressure-test utility Anton Vorontsov
2012-11-07 11:01 ` Anton Vorontsov [this message]
2012-11-07 14:19   ` [RFC 3/3] man-pages: Add man page for vmpressure_fd(2) Rik van Riel
2012-11-20  5:52   ` Andrew Morton
     [not found]     ` <20121119215211.6370ac3b.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2012-11-20  6:24       ` Anton Vorontsov
2012-11-20 18:12         ` David Rientjes
     [not found]           ` <alpine.DEB.2.00.1211201004390.4200-X6Q0R45D7oAcqpCFd4KODRPsWskHk0ljAL8bYrjMMd8@public.gmane.org>
2012-11-21 15:01             ` Mel Gorman
2012-11-21 19:39               ` Andrew Morton
2012-11-22  8:52                 ` Pekka Enberg
2012-11-07 11:21 ` [RFC v3 0/3] vmpressure_fd: Linux VM pressure notifications Kirill A. Shutemov
2012-11-07 11:43   ` Anton Vorontsov
2012-11-07 12:11     ` Kirill A. Shutemov
     [not found]       ` <20121107121110.GA32402-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
2012-11-07 12:28         ` Anton Vorontsov
     [not found]   ` <20121107112136.GA31715-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
2012-11-07 11:28     ` Pekka Enberg
     [not found]       ` <CAOJsxLHY+3ZzGuGX=4o1pLfhRqjkKaEMyhX0ejB5nVrDvOWXNA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-11-07 11:43         ` Kirill A. Shutemov
     [not found]           ` <20121107114321.GA32265-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
2012-11-15  3:21             ` David Rientjes
     [not found]               ` <alpine.DEB.2.00.1211141910050.14414-X6Q0R45D7oAcqpCFd4KODRPsWskHk0ljAL8bYrjMMd8@public.gmane.org>
2012-11-15  3:39                 ` Anton Vorontsov
2012-11-15  3:59                   ` David Rientjes
     [not found]                     ` <alpine.DEB.2.00.1211141946370.14414-X6Q0R45D7oAcqpCFd4KODRPsWskHk0ljAL8bYrjMMd8@public.gmane.org>
2012-11-15  7:34                       ` Anton Vorontsov
     [not found]                         ` <20121115073420.GA19036-SAfYLu58TvsAzdhXFe8piDcLetGT9WKNKwcig+XE9tjR7s880joybQ@public.gmane.org>
2012-11-15  8:11                           ` David Rientjes
2012-11-15  8:52                             ` Anton Vorontsov
2012-11-15 21:25                               ` David Rientjes
     [not found]                                 ` <alpine.DEB.2.00.1211151303510.27188-X6Q0R45D7oAcqpCFd4KODRPsWskHk0ljAL8bYrjMMd8@public.gmane.org>
2012-11-16  9:33                                   ` Glauber Costa
     [not found]                                     ` <50A60873.3000607-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-11-16 20:04                                       ` David Rientjes
2012-11-16 21:12                                         ` Glauber Costa
2012-11-16 21:57                                           ` David Rientjes
2012-11-17  1:21                                             ` Anton Vorontsov
2012-11-18 22:53                                               ` David Rientjes
     [not found]                                               ` <20121117012114.GA22910-SAfYLu58TvubUOgZnPAKMoC2/QZ1MJnMKwcig+XE9tjR7s880joybQ@public.gmane.org>
2012-11-19 14:00                                                 ` Glauber Costa
     [not found]                                             ` <alpine.DEB.2.00.1211161349420.17853-X6Q0R45D7oAcqpCFd4KODRPsWskHk0ljAL8bYrjMMd8@public.gmane.org>
2012-11-19 13:57                                               ` Glauber Costa
2012-11-20 18:02                                                 ` David Rientjes
     [not found]                                                   ` <alpine.DEB.2.00.1211200950120.4200-X6Q0R45D7oAcqpCFd4KODRPsWskHk0ljAL8bYrjMMd8@public.gmane.org>
2012-11-21  9:30                                                     ` Kirill A. Shutemov
2012-11-21 11:32                                                       ` leonid.moiseichuk
2012-11-21 11:54                                                         ` Glauber Costa
2012-11-21 13:48                                                           ` leonid.moiseichuk
2012-11-26 21:35                                                   ` Michal Hocko
2012-11-19 14:19                                               ` Glauber Costa
     [not found]                                                 ` <50AA3FEF.2070100-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-11-20 18:23                                                   ` David Rientjes
     [not found]                                                     ` <alpine.DEB.2.00.1211201013460.4200-X6Q0R45D7oAcqpCFd4KODRPsWskHk0ljAL8bYrjMMd8@public.gmane.org>
2012-11-21  8:27                                                       ` Glauber Costa
2012-11-21  8:46                                                         ` Anton Vorontsov
2012-11-21  9:25                                                           ` Glauber Costa
2012-11-07 17:20     ` Greg Thelen
     [not found]       ` <xr93liedfhy4.fsf-aSPv4SP+Du0KgorLzL7FmE7CuiCeIGUxQQ4Iyu8u01E@public.gmane.org>
2012-11-07 20:52         ` Pekka Enberg
2012-11-07 11:30 ` Pekka Enberg
     [not found]   ` <CAOJsxLFz+Zi=A0uyuNMj411ngjwpstakNY3fEWy6tW_h4whr7w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-11-07 11:31     ` Pekka Enberg
2012-11-07 12:06     ` Anton Vorontsov
2012-11-09  8:32 ` Luiz Capitulino
2012-11-09  9:04   ` Anton Vorontsov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121107110152.GC30462@lizard \
    --to=anton.vorontsov-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
    --cc=b.zolnierkie-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=kernel-team-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org \
    --cc=kosaki.motohiro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=leonid.moiseichuk-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org \
    --cc=linaro-kernel-cunTk1MwBs8s++Sfvej+rw@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
    --cc=mgorman-l3A5Bk7waGM@public.gmane.org \
    --cc=minchan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=penberg-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).