LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 06-28-2009, 04:48 AM   #1
kuru
LQ Newbie
 
Registered: Oct 2004
Location: korea
Posts: 11

Rep: Reputation: 0
smp_processor_id() internal


If I follow the smp_processor_id(), I reach at per_cpu__cpu_number. However, I can not find when the per_cpu__cpu_number is set

Please let me know.
Thank you for your reading.
 
Old 06-28-2009, 11:12 PM   #2
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 71
I think it's in the /boot/System.map file. But your question is not very clear to me...
 
Old 06-29-2009, 06:09 AM   #3
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
I think the OP means where in the running of the kernel is this value set (this is not at all obvious since it is given a value through preprocessor stringification). The answer is, at least for x86(_64) systems, in arch/x86/kernel/setup_percpu.c, line 491:
Code:
                per_cpu(cpu_number, cpu) = cpu;
What looks like a function is actually a macro which assigns to the variable with identifier per_cpu__cpu_number, through some magic on lines 28-29 of the same file as well as in include/linux/percpu-defs.h and elsewhere.
 
Old 06-29-2009, 10:24 PM   #4
kuru
LQ Newbie
 
Registered: Oct 2004
Location: korea
Posts: 11

Original Poster
Rep: Reputation: 0
First of all, thank you for your answers and I'm sorry for not to mention about my working environment. My working environment is like below:
- Linux kernel 2.6.29
- x86, 32bit machine with 2 processors

I have seen that code and feel strange because of below code.
Code:
// arch/x86/kernel/smpboot.c
void __init native_smp_prepare_boot_cpu(void)
{
	int me = smp_boot_processor_id();
	init_gdt(me);
	...
}

// arch/x86/kernel/smpcommon.c
__cpuinit void init_gdt(int cpu)
{
	...
	per_cpu(cpu_number, cpu) = cpu;
}
As you see, 'me' is per_cpu__cpu_number. In init_gdt() it sets the per_cpu__cpu_number to the 'me' again.
 
Old 06-30-2009, 02:19 PM   #5
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Quote:
Originally Posted by kuru View Post
As you see, 'me' is per_cpu__cpu_number. In init_gdt() it sets the per_cpu__cpu_number to the 'me' again.
Yes, you are correct. There may have been a few reasons for this (perhaps there was a difference in smp_processor_id, which gets the cpu_number after temporarily disabling preemption, or maybe the init_gdt function was needed elsewhere to set the cpu_number).

This, however, is irrelevant since the offending code has already been removed. Moreover, the entire function init_gdt() is now gone.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy an internal hard drive as backup? Restore an internal drive? Peufelon Linux - Hardware 2 06-15-2008 03:28 PM
Did you know that they know your internal ip? alan_ri Linux - Security 18 12-31-2007 07:56 PM
internal modem fatal_err0r Red Hat 1 05-03-2006 03:46 PM
Able to connect to internal IP only dwai Linux - Networking 2 09-07-2005 01:03 PM
Installation of internal HP DAT 40i DDS internal tape drive netkepala Linux - Hardware 3 11-08-2004 12:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 09:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration