Re: How to write a kernel patch to expose a kernel-level function?
- From: Tauno Voipio <tauno.voipio@xxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 07:29:59 GMT
hzmonte@xxxxxxxxxxx wrote:
http://altlinux.org/index.php?module=sisyphus&package=cpuid
Thx but no, it is not what I want. This package displays the CPU spec like who the manufacturer is and what model it is, etc. What I want, and what smp_processor_id() returns, is which logical processor the calling thread is running on. Is CPU0, CPU1, or CPU2, for example?
In both cases you need a piece of kernel code, a patch or a kernel module
So my question is How to write a kernel patch? Is it as simple as adding a statement in the source like "EXPORT TO USER-SPACE smp_processor_id"? Any pointer to how to do it? Ay more concrete guideline?
The kernel runs in a private address space compared to the user code. You cannot use the kernel internal address for anything in user code, and it's not allowed to even look at the contents of the address.
For details, get the books
Understanding the Linux Kernel
and
Linux Device Drivers
and read and understand them before attempting own kernel coding.
Both books are published by O'Reilly.
IMHO, creating a /proc file is the easiest way of reading the identifier.
A different story is that the result is probably invalid at the time your user code gets it. There is no guarantee that the process is running on the reported processor anymore.
--
Tauno Voipio tauno voipio (at) iki fi
.
- Follow-Ups:
- References:
- How to write a kernel patch to expose a kernel-level function?
- From: hzmonte
- Re: How to write a kernel patch to expose a kernel-level function?
- From: Tauno Voipio
- Re: How to write a kernel patch to expose a kernel-level function?
- From: hzmonte
- How to write a kernel patch to expose a kernel-level function?
- Prev by Date: Re: /home out of space
- Next by Date: Re: How to write a kernel patch to expose a kernel-level function?
- Previous by thread: Re: How to write a kernel patch to expose a kernel-level function?
- Next by thread: Re: How to write a kernel patch to expose a kernel-level function?
- Index(es):
Relevant Pages
|