linux - Is __init attribute used in loadable kernel modules? -


the description @ - http://www.tldp.org/ldp/lkmpg/2.4/html/x281.htm - page (as related answers on so, example answer here - __init , __exit macros usage built-in , loadable modules ) says

the __init macro causes init function discarded , memory freed once init function finishes built-in drivers, not loadable modules.

however, tried insert following module, in try call init functions __init attribute non-init function (f2()), , error kernel, indicating __init has effect on loadable modules well.

how , can find reliable information this?

my (above mentioned) program:

#include<linux/module.h> #include<linux/init.h>  static int __init f1(void){         printk(kern_alert "hello  \n");         return 0; }   static void __exit f2(void){         f1();         printk(kern_alert "bye n\n"); }  module_init(f1); module_exit(f2); 

error kernel:

    jul  8 08:15:51 localhost kernel: hello notice      jul  8 08:15:54 localhost kernel: [303032.948188] bug: unable handle kernel paging request @ f9b13000     jul  8 08:15:54 localhost kernel: [303032.949003] ip: [<f9b13000>] 0xf9b12fff     jul  8 08:15:54 localhost kernel: [303032.949003] *pdpt = 0000000000d3c001 *pde = 000000003100b067 *pte = 0000000000000000   jul  8 08:15:54 localhost kernel: [303032.949003] modules linked in: hello(pof-) tcp_lp lp wacom fuse bnep bluetooth ip6t_rpfilter ip6t_reject cfg80211 rfkill xt_conntrack ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw ip6table_filter ip6_tables iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security iptable_raw joydev snd_hda_codec_realtek snd_hda_intel snd_hda_codec snd_hwdep snd_seq snd_seq_device snd_pcm coretemp kvm itco_wdt itco_vendor_support ppdev r8169 mii snd_page_alloc snd_timer snd soundcore microcode serio_raw i2c_i801 lpc_ich mfd_core parport_pc parport acpi_cpufreq mperf binfmt_misc nfsd auth_rpcgss nfs_acl lockd sunrpc i915 ata_generic i2c_algo_bit pata_acpi drm_kms_helper drm i2c_core video [last unloaded: hello] jul  8 08:15:54 localhost kernel: [303032.949003] cpu: 1 pid: 11924 comm: rmmod tainted: pf          o 3.11.10-301.fc20.i686+pae #1 jul  8 08:15:54 localhost kernel: [303032.949003] hardware name:                  /dg41rq, bios rqg4110h.86a.0013.2009.1223.1136 12/23/2009 jul  8 08:15:54 localhost kernel: [303032.949003] task: d1bad780 ti: c33a4000 task.ti: c33a4000 jul  8 08:15:54 localhost kernel: [303032.949003] eip: 0060:[<f9b13000>] eflags: 00010282 cpu: 1 jul  8 08:15:54 localhost kernel: [303032.949003] eip @ 0xf9b13000 jul  8 08:15:54 localhost kernel: [303032.949003] eax: f9af6000 ebx: f9af8000 ecx: c0c77270 edx: 00000000 jul  8 08:15:54 localhost kernel: [303032.949003] esi: 00000000 edi: 00000000 ebp: c33a5f3c esp: c33a5f30 jul  8 08:15:54 localhost kernel: [303032.949003]  ds: 007b es: 007b fs: 00d8 gs: 00e0 ss: 0068 jul  8 08:15:54 localhost kernel: [303032.949003] cr0: 8005003b cr2: f9b13000 cr3: 10e7b000 cr4: 000407f0 jul  8 08:15:54 localhost kernel: [303032.949003] stack: jul  8 08:15:54 localhost kernel: [303032.949003]  f9af600b 00000000 00000000 c33a5fac c04b06a9 f4852ac0 c33a5f50 c057989d jul  8 08:15:54 localhost kernel: [303032.949003]  00000000 f9af8000 00000800 c33a5f50 6c6c6568 0000006f f4852ac0 f5312490 jul  8 08:15:54 localhost kernel: [303032.949003]  db5e7100 00000000 d1bad780 d1bada9c c33a5f88 c056160d c33a5f9c c046e9de jul  8 08:15:54 localhost kernel: [303032.949003] call trace: jul  8 08:15:54 localhost kernel: [303032.949003]  [<f9af600b>] ? f2+0xb/0x1000 [hello] jul  8 08:15:54 localhost kernel: [303032.949003]  [<c04b06a9>] sys_delete_module+0x149/0x2a0 jul  8 08:15:54 localhost kernel: [303032.949003]  [<c057989d>] ? mntput+0x1d/0x30 jul  8 08:15:54 localhost kernel: [303032.949003]  [<c056160d>] ? ____fput+0xd/0x10 jul  8 08:15:54 localhost kernel: [303032.949003]  [<c046e9de>] ? task_work_run+0x7e/0xb0 jul  8 08:15:54 localhost kernel: [303032.949003]  [<c099ff0d>] sysenter_do_call+0x12/0x28 jul  8 08:15:54 localhost kernel: [303032.949003] code:  bad eip value. jul  8 08:15:54 localhost kernel: [303032.949003] eip: [<f9b13000>] 0xf9b13000 ss:esp 0068:c33a5f30 jul  8 08:15:54 localhost kernel: [303032.949003] cr2: 00000000f9b13000 jul  8 08:15:54 localhost kernel: [303032.949003] ---[ end trace ca338922043618f4 ]--- jul  8 08:15:54 localhost kernel: bug: unable handle kernel paging request @ f9b13000 jul  8 08:15:54 localhost kernel: ip: [<f9b13000>] 0xf9b12fff jul  8 08:15:54 localhost kernel: *pdpt = 0000000000d3c001 *pde = 000000003100b067 *pte = 0000000000000000  

actually, __init attribute affects on loadable modules code.

probably, misprint in book refers.

btw, should warning sections mismatching when build given module.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

android - Pass an Serializable object in AIDL -