Commit ebff7d8
mem hotunplug: fix kfree() of bootmem memory
When hot removing memory presented at boot time, following messages are shown:
kernel BUG at mm/slub.c:3409!
invalid opcode: 0000 [#1] SMP
Modules linked in: ebtable_nat ebtables xt_CHECKSUM iptable_mangle bridge stp llc ipmi_devintf ipmi_msghandler sunrpc ipt_REJECT nf_conntrack_ipv4 nf_defrag_ipv4 iptable_filter ip_tables ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 xt_state nf_conntrack ip6table_filter ip6_tables binfmt_misc vfat fat dm_mirror dm_region_hash dm_log dm_mod vhost_net macvtap macvlan tun uinput iTCO_wdt iTCO_vendor_support coretemp kvm_intel kvm crc32c_intel ghash_clmulni_intel microcode pcspkr sg i2c_i801 lpc_ich mfd_core igb i2c_algo_bit i2c_core e1000e ptp pps_core tpm_infineon ioatdma dca sr_mod cdrom sd_mod crc_t10dif usb_storage megaraid_sas lpfc scsi_transport_fc scsi_tgt scsi_mod
CPU 0
Pid: 5091, comm: kworker/0:2 Tainted: G W 3.9.0-rc6+ #15
RIP: kfree+0x232/0x240
Process kworker/0:2 (pid: 5091, threadinfo ffff88084678c000, task ffff88083928ca80)
Call Trace:
__release_region+0xd4/0xe0
__remove_pages+0x52/0x110
arch_remove_memory+0x89/0xd0
remove_memory+0xc4/0x100
acpi_memory_device_remove+0x6d/0xb1
acpi_device_remove+0x89/0xab
__device_release_driver+0x7c/0xf0
device_release_driver+0x2f/0x50
acpi_bus_device_detach+0x6c/0x70
acpi_ns_walk_namespace+0x11a/0x250
acpi_walk_namespace+0xee/0x137
acpi_bus_trim+0x33/0x7a
acpi_bus_hot_remove_device+0xc4/0x1a1
acpi_os_execute_deferred+0x27/0x34
process_one_work+0x1f7/0x590
worker_thread+0x11a/0x370
kthread+0xee/0x100
ret_from_fork+0x7c/0xb0
RIP [<ffffffff811c41d2>] kfree+0x232/0x240
RSP <ffff88084678d968>
The reason why the messages are shown is to release a resource
structure, allocated by bootmem, by kfree(). So when we release a
resource structure, we should check whether it is allocated by bootmem
or not.
But even if we know a resource structure is allocated by bootmem, we
cannot release it since SLxB cannot treat it. So for reusing a resource
structure, this patch remembers it by using bootmem_resource as follows:
When releasing a resource structure by free_resource(), free_resource()
checks whether the resource structure is allocated by bootmem or not.
If it is allocated by bootmem, free_resource() adds it to
bootmem_resource. If it is not allocated by bootmem, free_resource()
release it by kfree().
And when getting a new resource structure by get_resource(),
get_resource() checks whether bootmem_resource has released resource
structures or not. If there is a released resource structure,
get_resource() returns it. If there is not a releaed resource
structure, get_resource() returns new resource structure allocated by
kzalloc().
[akpm@linux-foundation.org: s/get_resource/alloc_resource/]
Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Reviewed-by: Toshi Kani <toshi.kani@hp.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Ram Pai <linuxram@us.ibm.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>1 parent 9ca24e2 commit ebff7d8
1 file changed
+55
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
53 | 62 | | |
54 | 63 | | |
55 | 64 | | |
| |||
151 | 160 | | |
152 | 161 | | |
153 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
154 | 197 | | |
155 | 198 | | |
156 | 199 | | |
| |||
771 | 814 | | |
772 | 815 | | |
773 | 816 | | |
774 | | - | |
| 817 | + | |
775 | 818 | | |
776 | 819 | | |
777 | 820 | | |
| |||
796 | 839 | | |
797 | 840 | | |
798 | 841 | | |
799 | | - | |
| 842 | + | |
800 | 843 | | |
801 | 844 | | |
802 | 845 | | |
| |||
806 | 849 | | |
807 | 850 | | |
808 | 851 | | |
809 | | - | |
810 | | - | |
| 852 | + | |
811 | 853 | | |
812 | | - | |
| 854 | + | |
813 | 855 | | |
814 | 856 | | |
815 | 857 | | |
| |||
899 | 941 | | |
900 | 942 | | |
901 | 943 | | |
902 | | - | |
| 944 | + | |
903 | 945 | | |
904 | 946 | | |
905 | 947 | | |
| |||
933 | 975 | | |
934 | 976 | | |
935 | 977 | | |
936 | | - | |
| 978 | + | |
937 | 979 | | |
938 | 980 | | |
939 | 981 | | |
| |||
967 | 1009 | | |
968 | 1010 | | |
969 | 1011 | | |
970 | | - | |
| 1012 | + | |
971 | 1013 | | |
972 | 1014 | | |
973 | 1015 | | |
| |||
1007 | 1049 | | |
1008 | 1050 | | |
1009 | 1051 | | |
1010 | | - | |
| 1052 | + | |
1011 | 1053 | | |
1012 | 1054 | | |
1013 | 1055 | | |
| |||
1055 | 1097 | | |
1056 | 1098 | | |
1057 | 1099 | | |
1058 | | - | |
1059 | | - | |
| 1100 | + | |
| 1101 | + | |
1060 | 1102 | | |
1061 | 1103 | | |
1062 | 1104 | | |
| |||
1083 | 1125 | | |
1084 | 1126 | | |
1085 | 1127 | | |
1086 | | - | |
| 1128 | + | |
1087 | 1129 | | |
1088 | 1130 | | |
1089 | 1131 | | |
| |||
1119 | 1161 | | |
1120 | 1162 | | |
1121 | 1163 | | |
1122 | | - | |
| 1164 | + | |
1123 | 1165 | | |
1124 | 1166 | | |
1125 | 1167 | | |
| |||
0 commit comments