Re: [PATCH 19/25] Docs: kernel-hacking: CPU id on [0,NR_CPUS)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 4, 2010 at 00:09, Randy Dunlap <rdunlap@xxxxxxxxxxxx> wrote:
> the half-open interval part isn't necessarily better IMO.

How about this for an entirely new patch:

diff --git a/Documentation/DocBook/kernel-hacking.tmpl b/Documentation/DocBook/kernel-hacking.tmpl
index 511f2f3..2fb8191 100644
--- a/Documentation/DocBook/kernel-hacking.tmpl
+++ b/Documentation/DocBook/kernel-hacking.tmpl
@@ -811,19 +811,31 @@ printk(KERN_INFO "my ip: %pI4\n", &amp;ipaddress);
 
   <sect1 id="routines-processorids">
    <title><function>{get,put}_cpu()</function>/<function>smp_processor_id()</function>
-    <filename class="headerfile">include/asm/smp.h</filename></title>
+    <filename class="headerfile">include/linux/smp.h</filename>
+    <filename class="headerfile">include/linux/threads.h</filename>
+   </title>
+
+   <para>
+    The constant <symbol>NR_CPUS</symbol> provides the maximum number of CPUS
+    that the kernel can support at one time. In general, the value of this
+    constant is provided during kernel build configuration via the
+    <symbol>CONFIG_NR_CPUS</symbol> configuration variable.
+   </para>
    
    <para>
-    <function>get_cpu()</function> disables preemption (so you won't
-    suddenly get moved to another CPU) and returns as the current
-    CPU id a number on the half-open interval [0,<symbol>NR_CPUS</symbol>);
-    subsequently returned CPU ids are not necessarily contiguous.  You return
-    it again with <function>put_cpu()</function> when you are done.
+    <function>get_cpu()</function> disables preemption on the local CPU
+    (so you won't suddenly get moved to another CPU) and then returns
+    the local CPU id as a number ranging from 0 up to (but not including)
+    <symbol>NR_CPUS</symbol>; subsequently returned CPU ids are not
+    necessarily contiguous. When you're done with the local CPU, return
+    it to the scheduling system using <function>put_cpu()</function>.
    </para>
+
    <para>
     If you know you cannot be preempted by another task (ie. you are
-    in interrupt context, or have preemption disabled) you can use
-    smp_processor_id().
+    in interrupt context, or have preemption disabled) you can avoid
+    unnecessary overhead by using <function>smp_processor_id()</function>
+    to get the local CPU id number.
    </para>
   </sect1>
 
> (yes, I know what it means.)

To everyone on the list: Must there be a fear of intellectual
ridicule? This is supposed to be fun cooperation for solving
puzzles.

--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux