From: Cyrill Gorcunov <gorcunov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
To: Michael Kerrisk
<mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Andrew Morton
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
Pavel Emelyanov <xemul-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>,
linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"Eric W. Biederman"
<ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>,
"H. Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH 2/2] Add kcmp.2 manpage
Date: Wed, 29 Feb 2012 16:41:56 +0400 [thread overview]
Message-ID: <20120229124156.GD4796@moon> (raw)
In-Reply-To: <20120229123408.GC11326@moon>
On Wed, Feb 29, 2012 at 04:34:08PM +0400, Cyrill Gorcunov wrote:
> 1 and 2 should be swapped here, I'll update (this nit grow from text tossing,
> so don't pay attention on it).
>
Updated version below.
Cyrill
---
From: Cyrill Gorcunov <gorcunov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
Date: Wed, 29 Feb 2012 16:40:13 +0400
Subject: [PATCH 2/2] Add kcmp.2 manpage
NAME
kcmp - compare if two processes do share a particular kernel resource
SYNOPSIS
#define GNU SOURCE /* See feature test macros(7) */
#include <unistd.h>
#include <linux/kcmp.h>
#include <sys/syscall.h> /* For SYS xxx definitions */
int syscall( NR kcmp, pid1, pid2, type, idx1, idx2);
DESCRIPTION
kcmp() allows to find out if two processes identified by pid1
and pid2 do share kernel resources such as virtual memory, file
The comparison type is one of the following
KCMP FILE to compare two file descriptors specified by idx1 and idx2
KCMP VM to compare whether processes do share virtual memory
KCMP FILES to compare whether processes do share share the file descriptor table
KCMP FS to compare whether processes do share the file system information
KCMP SIGHAND to compare whether processes do share a signal handlers table
KCMP IO to compare whether processes do share I/O context
KCMP SYSVSEM to compare whether processes do share a single list of System V
semaphore undo values
RETURN VALUE
kcmp was designed to return values suitable for sorting. This is particularly
handy when one have to compare a large number
The return value is merely a result of simple arithmetic comparison of kernel
pointers (when kernel compares resources, it us
The easiest way to explain is to consider an example. Lets say v1 and v2
are the addresses of appropriate resources, then the return value is one
of the following
0 - v1 is equal to v2 , in other words we have a shared resource here
1 - v1 is less than v2
2 - v1 is greater than v2
3 - v1 is not equal to v2 , but ordering information is unavailble.
On error, -1 is returned, and errno is set appropriately.
CONFORMING TO
kcmp() is Linux specific and should not be used in programs intended to
be portable.
SEE ALSO
clone(2)
Signed-off-by: Cyrill Gorcunov <gorcunov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
CC: "Eric W. Biederman" <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
CC: "H. Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
CC: Pavel Emelyanov <xemul-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
---
man2/kcmp.2 | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 105 insertions(+), 0 deletions(-)
create mode 100644 man2/kcmp.2
diff --git a/man2/kcmp.2 b/man2/kcmp.2
new file mode 100644
index 0000000..de68109
--- /dev/null
+++ b/man2/kcmp.2
@@ -0,0 +1,105 @@
+.TH KCMP 2 2012-02-01 "Linux" "Linux Programmer's Manual"
+
+.SH NAME
+kcmp \- compare if two processes do share a particular kernel resource
+
+.SH SYNOPSIS
+.nf
+.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
+.B #include <unistd.h>
+.B #include <linux/kcmp.h>
+.BR "#include <sys/syscall.h> " "/* For SYS_xxx definitions */"
+
+.BI "int syscall(__NR_kcmp, pid1, pid2, type, idx1, idx2);"
+.fi
+
+.SH DESCRIPTION
+
+.BR kcmp ()
+allows to find out if two processes identified by
+.I pid1
+and
+.I pid2
+do share kernel resources such as virtual memory, file descriptors,
+file system etc.
+
+The comparison
+.I type
+is one of the following
+
+.BR KCMP_FILE
+to compare two file descriptors specified by
+.I idx1
+and
+.I idx2
+
+.BR KCMP_VM
+to compare whether processes do share virtual memory
+
+.BR KCMP_FILES
+to compare whether processes do share share the file descriptor table
+
+.BR KCMP_FS
+to compare whether processes do share the file system information
+
+.BR KCMP_SIGHAND
+to compare whether processes do share a signal handlers table
+
+.BR KCMP_IO
+to compare whether processes do share I/O context
+
+.BR KCMP_SYSVSEM
+to compare whether processes do share a single list of
+System V semaphore undo values
+
+.SH "RETURN VALUE"
+.B kcmp
+was designed to return values suitable for sorting.
+This is particularly handy when one have to compare
+a large number of file descriptors.
+
+The return value is merely a result of simple arithmetic comparison
+of kernel pointers (when kernel compares resources, it uses their
+memory addresses).
+
+The easiest way to explain is to consider an example.
+Lets say
+.I v1
+and
+.I v2
+are the addresses of appropriate resources, then the return value
+is one of the following
+
+.B 0
+\-
+.I v1
+is equal to
+.I v2
+, in other words we have a shared resource here
+
+.B 1
+\-
+.I v1
+is less than
+.I v2
+
+.B 2
+\-
+.I v1
+is greater than
+.I v2
+
+.B 3
+\-
+.I v1
+is not equal to
+.I v2
+, but ordering information is unavailble.
+
+On error, \-1 is returned, and errno is set appropriately.
+
+.SH "CONFORMING TO"
+.BR kcmp ()
+is Linux specific and should not be used in programs intended to be portable.
+.SH "SEE ALSO"
+.BR clone (2)
--
1.7.7.6
--
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
next prev parent reply other threads:[~2012-02-29 12:41 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-29 12:23 [PATCH 0/2] Update man pages for prctl and kcmp syscall Cyrill Gorcunov
2012-02-29 12:23 ` [PATCH 1/2] prctl: Add PR_SET_MM option description Cyrill Gorcunov
[not found] ` <1330518197-12825-2-git-send-email-gorcunov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2012-03-06 18:00 ` Michael Kerrisk (man-pages)
[not found] ` <CAKgNAkiOY-p7duD_wfed_Tk8T8SR5r1JCTa=0ne3-VQ30mQE-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-06 18:22 ` Cyrill Gorcunov
2012-03-06 19:52 ` Michael Kerrisk (man-pages)
[not found] ` <CAKgNAkjejoxs43UVgAR+YW7JZ1btCpMr+=K4jrZz=Ktv-TnS8w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-06 20:01 ` Cyrill Gorcunov
2012-03-06 20:07 ` Michael Kerrisk (man-pages)
2012-03-06 20:16 ` Cyrill Gorcunov
2012-04-15 3:48 ` Michael Kerrisk (man-pages)
[not found] ` <CAKgNAkgwapZXw5gR_sSGyfufybY52S4qD1MjPDKs+6tBcgFJUg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-04-15 6:54 ` Cyrill Gorcunov
2012-04-15 10:13 ` Michael Kerrisk (man-pages)
[not found] ` <CAKgNAkjMpjmKCD3oQa7qTeH5gXydDgMj5TjmKKtyXYzV9f--fA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-04-15 22:10 ` Cyrill Gorcunov
2012-02-29 12:23 ` [PATCH 2/2] Add kcmp.2 manpage Cyrill Gorcunov
[not found] ` <1330518197-12825-3-git-send-email-gorcunov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2012-02-29 12:34 ` Cyrill Gorcunov
2012-02-29 12:41 ` Cyrill Gorcunov [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-03-09 20:47 [PATCH 0/2] prctl.2 and kcmp.2 updated Cyrill Gorcunov
[not found] ` <1331326042-32558-1-git-send-email-gorcunov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2012-03-09 20:47 ` [PATCH 2/2] Add kcmp.2 manpage Cyrill Gorcunov
[not found] ` <1331326042-32558-3-git-send-email-gorcunov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2012-03-09 20:50 ` H. Peter Anvin
[not found] ` <4F5A6D09.3050704-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2012-03-09 21:03 ` Cyrill Gorcunov
2012-03-09 21:15 ` H. Peter Anvin
[not found] ` <4F5A72E9.5030802-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2012-03-09 21:18 ` Cyrill Gorcunov
2012-03-09 21:25 ` Cyrill Gorcunov
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=20120229124156.GD4796@moon \
--to=gorcunov-gefaqzzx7r8dnm+yrofe0a@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org \
--cc=hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=xemul-bzQdu9zFT3WakBO8gow8eQ@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).