how is the kernel boot-time param "printk.time" implemented?

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

 



  i'm betting i'm going to embarrass myself with this question, but
how is it that you have a boot-time kernel parameter "printk.time"
with which you can turn on and off printk timing information?

  as i read it, if you have a kernel source file, say "fubar.c", that
*can* be built as a module but you choose instead to build it directly
into the kernel image, then you still have access to that module's
parameters with "fubar.parmname=1" or whatever at boot time.  (this is
documented at the top of the file
Documentation/kernel-parameters.txt.)

  but if you examine the case with the boot-time parameter
printk.time, that feature is implemented in the source file
kernel/printk.c thusly:

...
#if defined(CONFIG_PRINTK_TIME)
static int printk_time = 1;
#else
static int printk_time = 0;
#endif
module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
...

  that looks perfectly reasonable, except that that source file isn't
set up to be selected as a module.  the corresponding Makefile reads:

obj-y     = sched.o fork.o exec_domain.o panic.o printk.o profile.o \
                                                 ^^^^^^^^

so that file is *always* compiled and built right into the kernel
image.  also, that source file has no module_init() or module_exit()
definitions, so i would have thought it simply can't behave as a
module or have module parameters.

  but, clearly, it can.  i can only guess that, somehow, the header
file include/linux/moduleparam.h is set up so that, if you define a
module parameter from a regular source file, that automatically
defines a module name by which to access that parameter, and the
module name will be the same as that of the source file.  hence, the
magical existence of "printk.time" at boot time.

  is that about right?  am i making any sense?

rday
--


========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
    Have classroom, will lecture.

http://crashcourse.ca                          Waterloo, Ontario, CANADA
========================================================================

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux