Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.