public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Kerrisk <mtk.manpages-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
To: Andi Kleen <andi-Vw/NltI1exuRpAAqCnN02g@public.gmane.org>
Cc: lkml <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: getcpu(2) man page
Date: Wed, 02 Jul 2008 21:06:03 +0200	[thread overview]
Message-ID: <486BD19B.7040302@gmail.com> (raw)

Hi Andi,

Long ago, when I ran out of time, things stalled on incorporating a getcpu.2 man page that you
wrote ino man-pages.  There were still some open questions that I wanted to get sorted before
releasing the page.  Could you take a look at the FIXME(ak)s below please?

Cheers,

Michael

.\" This man page is Copyright (C) 2006 Andi Kleen <ak-h9bWGtP8wOw@public.gmane.org>.
.\" Permission is granted to distribute possibly modified copies
.\" of this page provided the header is included verbatim,
.\" and in case of nontrivial modification author and date
.\" of the modification is added to the header.
.TH getcpu 2 2008-06-02 "Linux" "Linux Programmer's Manual"
.SH NAME
getcpu \- determine CPU and NUMA node on which the calling thread is running
.SH SYNOPSIS
.nf
.B #include <linux/getcpu.h>
.sp
.BI "int getcpu(unsigned *" cpu ", unsigned *" node \
", struct getcpu_cache *" tcache );
.fi
.SH DESCRIPTION
.BR getcpu ()
identifies the processor and node on which the calling
thread or process is currently
running and writes them into the integers pointed to by the
.I cpu
and
.I node
arguments.
The processor is a unique small integer identifying a CPU.
The node is a unique small identifier identifying a NUMA node.
When either
.I cpu
or
.I node
is NULL nothing is written to the respective pointer.
.I tcache
is a pointer to a
.I struct getcpu_cache.
The caller should put the cache into a thread
local variable if the process is multithreaded because the cache
cannot be shared between different threads.
.I tcache
can be NULL.
If it is not NULL
.BR getcpu ()
will use it to speed up operation.
The information inside the cache is private to the system call
and should not be accessed by the user program.
The information placed in the cache can change between kernel releases.

.\" FIXME(ak) If the following formulation is correct, I think it would
.\" be better to substitute it instead of the next sentence:
.\"     The information placed in \fIcpu\fP is only guaranteed to be
.\"     current at the time of the call: ...
This information is only a hint: unless the CPU affinity
has been fixed using
.BR sched_setaffinity (2),
the kernel might change the CPU at any time.
(Normally this does not happen
because the scheduler tries to minimize movements between CPUs to
keep caches hot, but it is possible.)
.\" FIXME(ak) Can you explain what you mean in the next sentence when
.\" you say "recover"
The caller has to properly recover from the case when
.I cpu
and
.I node
are not the current CPU and node anymore.
.\" FIXME(ak) In the following, what precisely do you mean by "advisory"?
.\" It is not really clear to me whether you mean the information
.\" may not be "true", or whether you are just reiterating the point that
.\" the CPU/node might already have changed by the time the call returns.
All information returned by
.I getcpu(2)
is just advisory and not a guarantee.

When no cache is specified
.BR getcpu ()
will be slower, but always retrieve the current state.
With a cache
.\" FIXME(ak) what does the phrase "but might query the current state
.\" only during a short implementation specific interval" mean?
it will be faster, but might query the current state only during
a short implementation specific interval.

Linux makes a best effort to make this call as fast possible. The
intention of
.I getcpu(2)
is to allow programs to make optimizations with per-CPU data
or for NUMA optimization.
.SH VERSIONS
.BR getcpu (2)
was added in 2.6.19 for x86_64 and i386.
.SH SEE ALSO
.BR mbind (2),
.BR set_mempolicy (2),
.BR sched_setaffinity (2)


--
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

             reply	other threads:[~2008-07-02 19:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-02 19:06 Michael Kerrisk [this message]
     [not found] ` <486BD19B.7040302-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-07-02 19:57   ` getcpu(2) man page Andi Kleen
2008-07-03 12:33     ` Michael Kerrisk
     [not found]       ` <cfd18e0f0807030533q714f4e17w640580a60c300cbd-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-08  8:45         ` Michael Kerrisk

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=486BD19B.7040302@gmail.com \
    --to=mtk.manpages-gm/ye1e23mwn+bqq9rbeug@public.gmane.org \
    --cc=andi-Vw/NltI1exuRpAAqCnN02g@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@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