momo zone

调核人的blog

关于scullv 的一些疑问

差不多关于设备文件中内存分配的问题就剩scullv了,这是最后一个。 在调试scullv时最大的一个问题是如果需要空间过大kernel 会报oops : dd if=~/pkg/VirtualBox-3.1-3.1.4_57640_openSUSE111-1.i586.rpm of=/dev/scullv0 Killed message:

Oct 23 22:49:09 linux-hm12 kernel: [15768.684678] BUG: unable to handle kernel paging request at f849e000
Oct 23 22:49:09 linux-hm12 kernel: [15768.684684] IP: [<c065cd1d>] iret_exc+0x7c1/0xa2d
Oct 23 22:49:09 linux-hm12 kernel: [15768.684693] *pdpt = 00000000009b7001 *pde = 0000000035bfa067 *pte = 0000000000000000
Oct 23 22:49:09 linux-hm12 kernel: [15768.684700] Oops: 0002 [#7] PREEMPT SMP
Oct 23 22:49:09 linux-hm12 kernel: [15768.684705] last sysfs file: /sys/devices/virtual/net/vboxnet0/statistics/collisions
Oct 23 22:49:09 linux-hm12 kernel: [15768.684710] Modules linked in: scullv scullc joydev st lp parport_pc ppdev parport af_packet binfmt_misc snd_pcm_oss snd_mixer_oss snd_seq w83627ehf hwmon_vid snd_seq_device coretemp vboxnetadp vboxnetflt vboxdrv mperf fuse loop dm_mod radeon ttm drm_kms_helper drm iwlagn firewire_ohci firewire_core arc4 ecb iwlcore rtl8187 snd_hda_codec_analog crc_itu_t 8139too ohci1394 skge 8139cp ieee1394 mac80211 snd_hda_intel snd_hda_codec eeprom_93cx6 iTCO_wdt snd_hwdep button pcspkr iTCO_vendor_support i2c_i801 snd_pcm sky2 snd_timer cfg80211 snd tpm_tis soundcore snd_page_alloc i2c_algo_bit tpm tpm_bios sr_mod cdrom rfkill intel_agp sg floppy edd reiserfs fan ata_generic thermal processor thermal_sys pata_jmicron [last unloaded: scullv]
Oct 23 22:49:09 linux-hm12 kernel: [15768.684775]
Oct 23 22:49:09 linux-hm12 kernel: [15768.684779] Pid: 10886, comm: dd Tainted: G      D     2.6.35.1-1-desktop #2 P5B-Deluxe/System Product Name
Oct 23 22:49:09 linux-hm12 kernel: [15768.684785] EIP: 0060:[<c065cd1d>] EFLAGS: 00010246 CPU: 1
Oct 23 22:49:09 linux-hm12 kernel: [15768.684789] EIP is at iret_exc+0x7c1/0xa2d
Oct 23 22:49:09 linux-hm12 kernel: [15768.684794] EAX: 00000000 EBX: 00000200 ECX: 00000200 EDX: 08059000
Oct 23 22:49:09 linux-hm12 kernel: [15768.684798] ESI: 08059000 EDI: f849e000 EBP: 00000000 ESP: c3bb7f20
Oct 23 22:49:09 linux-hm12 kernel: [15768.684802]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Oct 23 22:49:09 linux-hm12 kernel: [15768.684807] Process dd (pid: 10886, ti=c3bb6000 task=cdb5d8d0 task.ti=c3bb6000)
Oct 23 22:49:09 linux-hm12 kernel: [15768.684811] Stack:
Oct 23 22:49:09 linux-hm12 kernel: [15768.684814]  f849e000 00000200 ce01e000 00000200 ce01e018 fffffff2 f848c644 f848cde8
Oct 23 22:49:09 linux-hm12 kernel: [15768.684820] <0> 00000001 f244b458 c03b07ac 00001000 ef1bc3dc 00000000 00000200 08059000
Oct 23 22:49:09 linux-hm12 kernel: [15768.684828] <0> f24aeb80 cdad9100 00000200 08059000 f848c550 c0315fd0 c3bb7f9c 00000000
Oct 23 22:49:09 linux-hm12 kernel: [15768.684837] Call Trace:
Oct 23 22:49:09 linux-hm12 kernel: [15768.685127] Inexact backtrace:
Oct 23 22:49:09 linux-hm12 kernel: [15768.685127]
Oct 23 22:49:09 linux-hm12 kernel: [15768.685127]  [<f848c644>] ? scullv_write+0xf4/0x210 [scullv]
Oct 23 22:49:09 linux-hm12 kernel: [15768.685127]  [<c03b07ac>] ? security_file_permission+0xc/0x10
Oct 23 22:49:09 linux-hm12 kernel: [15768.685127]  [<f848c550>] ? scullv_write+0x0/0x210 [scullv]
Oct 23 22:49:09 linux-hm12 kernel: [15768.685127]  [<c0315fd0>] ? vfs_write+0xa0/0x190
Oct 23 22:49:10 linux-hm12 kernel: [15768.685127]  [<c0316a41>] ? sys_write+0x41/0x70
Oct 23 22:49:10 linux-hm12 kernel: [15768.685127]  [<c020318c>] ? sysenter_do_call+0x12/0x22
Oct 23 22:49:10 linux-hm12 kernel: [15768.685127] Code: e9 89 3c da ff 8d 0c 88 e9 3b 3d da ff 8d 0c 8b e9 73 3d da ff ba f2 ff ff ff e9 b9 3d da ff 01 e9 eb 04 8d 4c 8d 00 51 50 31 c0 <f3> aa 58 59 e9 56 3e da ff 8d 0c 88 51 50 31 c0 f3 aa 58 59 e9
Oct 23 22:49:10 linux-hm12 kernel: [15768.685127] EIP: [<c065cd1d>] iret_exc+0x7c1/0xa2d SS:ESP 0068:c3bb7f20
Oct 23 22:49:10 linux-hm12 kernel: [15768.685127] CR2: 00000000f849e000
Oct 23 22:49:10 linux-hm12 kernel: [15768.685127] —[ end trace ce27dbec989e1449 ]—
出现这个问题主要是因为高端内存空间不足:
localhost:~/ldd3/scullc # cat /proc/meminfo |grep Free
MemFree:          130180 kB
HighFree:          17696 kB #高端物理内存的剩余空间
LowFree:          112484 kB
SwapFree:        1052188 kB
HugePages_Free:        0
VmallocTotal:     122880 kB
VmallocUsed:       66956 kB #vmalloc 映射区占用
VmallocChunk:      36584 kB
默认的内核配置是仅仅分配少于128MB空间(Vmalloc_area)供物理高端内存(HIGH_MEM)映射,而这个内存映射区是在虚拟空间中的内核部分(1GB),所以这个高端内存映射区大小也是有限的。加内核参数可以更改这个Vmalloc_area的大小: vmalloc=256M .
这里说一下如何根据oops追踪代码:
看到[<f848c644>] ? scullv_write+0xf4/0x210 [scullv] 这样的就应该知道出错的指令在0xf4 然后用objdump -d -S scullv.ko > scullv.S 反编译+C源码对照很容易就定位出错位置。
Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: