<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/kernel/resource.c, branch v3.10</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.10</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.10'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2013-04-29T22:54:40Z</updated>
<entry>
<title>mem hotunplug: fix kfree() of bootmem memory</title>
<updated>2013-04-29T22:54:40Z</updated>
<author>
<name>Yasuaki Ishimatsu</name>
<email>isimatu.yasuaki@jp.fujitsu.com</email>
</author>
<published>2013-04-29T22:08:56Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=ebff7d8f270d045338d9f4796014f4db429a17f9'/>
<id>urn:sha1:ebff7d8f270d045338d9f4796014f4db429a17f9</id>
<content type='text'>
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  [&lt;ffffffff811c41d2&gt;] kfree+0x232/0x240
   RSP &lt;ffff88084678d968&gt;

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 &lt;isimatu.yasuaki@jp.fujitsu.com&gt;
Reviewed-by: Toshi Kani &lt;toshi.kani@hp.com&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: Ram Pai &lt;linuxram@us.ibm.com&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>resource: add release_mem_region_adjustable()</title>
<updated>2013-04-29T22:54:37Z</updated>
<author>
<name>Toshi Kani</name>
<email>toshi.kani@hp.com</email>
</author>
<published>2013-04-29T22:08:19Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=825f787bb49676083b97c1de1f8f2f8f26b5c908'/>
<id>urn:sha1:825f787bb49676083b97c1de1f8f2f8f26b5c908</id>
<content type='text'>
Add release_mem_region_adjustable(), which releases a requested region
from a currently busy memory resource.  This interface adjusts the
matched memory resource accordingly even if the requested region does
not match exactly but still fits into.

This new interface is intended for memory hot-delete.  During bootup,
memory resources are inserted from the boot descriptor table, such as
EFI Memory Table and e820.  Each memory resource entry usually covers
the whole contigous memory range.  Memory hot-delete request, on the
other hand, may target to a particular range of memory resource, and its
size can be much smaller than the whole contiguous memory.  Since the
existing release interfaces like __release_region() require a requested
region to be exactly matched to a resource entry, they do not allow a
partial resource to be released.

This new interface is restrictive (i.e.  release under certain
conditions), which is consistent with other release interfaces,
__release_region() and __release_resource().  Additional release
conditions, such as an overlapping region to a resource entry, can be
supported after they are confirmed as valid cases.

There is no change to the existing interfaces since their restriction is
valid for I/O resources.

[akpm@linux-foundation.org: use GFP_ATOMIC under write_lock()]
[akpm@linux-foundation.org: switch back to GFP_KERNEL, less buggily]
[akpm@linux-foundation.org: remove unneeded and wrong kfree(), per Toshi]
Signed-off-by: Toshi Kani &lt;toshi.kani@hp.com&gt;
Reviewed-by : Yasuaki Ishimatsu &lt;isimatu.yasuaki@jp.fujitsu.com&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Reviewed-by: Ram Pai &lt;linuxram@us.ibm.com&gt;
Cc: T Makphaibulchoke &lt;tmac@hp.com&gt;
Cc: Wen Congyang &lt;wency@cn.fujitsu.com&gt;
Cc: Tang Chen &lt;tangchen@cn.fujitsu.com&gt;
Cc: Jiang Liu &lt;jiang.liu@huawei.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>resource: add __adjust_resource() for internal use</title>
<updated>2013-04-29T22:54:37Z</updated>
<author>
<name>Toshi Kani</name>
<email>toshi.kani@hp.com</email>
</author>
<published>2013-04-29T22:08:17Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=ae8e3a915aef5af5ace5936c56f05f0b1502ded1'/>
<id>urn:sha1:ae8e3a915aef5af5ace5936c56f05f0b1502ded1</id>
<content type='text'>
Add __adjust_resource(), which is called by adjust_resource() internally
after the resource_lock is held.  There is no interface change to
adjust_resource().  This change allows other functions to call
__adjust_resource() internally while the resource_lock is held.

Signed-off-by: Toshi Kani &lt;toshi.kani@hp.com&gt;
Reviewed-by: Yasuaki Ishimatsu &lt;isimatu.yasuaki@jp.fujitsu.com&gt;
Acked-by: David Rientjes &lt;rientjes@google.com&gt;
Cc: Ram Pai &lt;linuxram@us.ibm.com&gt;
Cc: T Makphaibulchoke &lt;tmac@hp.com&gt;
Cc: Wen Congyang &lt;wency@cn.fujitsu.com&gt;
Cc: Tang Chen &lt;tangchen@cn.fujitsu.com&gt;
Cc: Jiang Liu &lt;jiang.liu@huawei.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>kernel/resource.c: fix stack overflow in __reserve_region_with_split()</title>
<updated>2012-10-05T18:05:31Z</updated>
<author>
<name>T Makphaibulchoke</name>
<email>tmac@hp.com</email>
</author>
<published>2012-10-05T00:16:55Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4965f5667f36a95b41cda6638875bc992bd7d18b'/>
<id>urn:sha1:4965f5667f36a95b41cda6638875bc992bd7d18b</id>
<content type='text'>
Using a recursive call add a non-conflicting region in
__reserve_region_with_split() could result in a stack overflow in the case
that the recursive calls are too deep.  Convert the recursive calls to an
iterative loop to avoid the problem.

Tested on a machine containing 135 regions.  The kernel no longer panicked
with stack overflow.

Also tested with code arbitrarily adding regions with no conflict,
embedding two consecutive conflicts and embedding two non-consecutive
conflicts.

Signed-off-by: T Makphaibulchoke &lt;tmac@hp.com&gt;
Reviewed-by: Ram Pai &lt;linuxram@us.ibm.com&gt;
Cc: Paul Gortmaker &lt;paul.gortmaker@gmail.com&gt;
Cc: Wei Yang &lt;weiyang@linux.vnet.ibm.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>resource: make sure requested range is included in the root range</title>
<updated>2012-07-31T00:25:21Z</updated>
<author>
<name>Octavian Purdila</name>
<email>octavian.purdila@intel.com</email>
</author>
<published>2012-07-30T21:42:58Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=65fed8f6f23070b56d0ed3841173ddd410130a89'/>
<id>urn:sha1:65fed8f6f23070b56d0ed3841173ddd410130a89</id>
<content type='text'>
When the requested range is outside of the root range the logic in
__reserve_region_with_split will cause an infinite recursion which will
overflow the stack as seen in the warning bellow.

This particular stack overflow was caused by requesting the
(100000000-107ffffff) range while the root range was (0-ffffffff).  In
this case __request_resource would return the whole root range as
conflict range (i.e.  0-ffffffff).  Then, the logic in
__reserve_region_with_split would continue the recursion requesting the
new range as (conflict-&gt;end+1, end) which incidentally in this case
equals the originally requested range.

This patch aborts looking for an usable range when the request does not
intersect with the root range.  When the request partially overlaps with
the root range, it ajust the request to fall in the root range and then
continues with the new request.

When the request is modified or aborted errors and a stack trace are
logged to allow catching the errors in the upper layers.

[    5.968374] WARNING: at kernel/sched.c:4129 sub_preempt_count+0x63/0x89()
[    5.975150] Modules linked in:
[    5.978184] Pid: 1, comm: swapper Not tainted 3.0.22-mid27-00004-gb72c817 #46
[    5.985324] Call Trace:
[    5.987759]  [&lt;c1039dfc&gt;] ? console_unlock+0x17b/0x18d
[    5.992891]  [&lt;c1039620&gt;] warn_slowpath_common+0x48/0x5d
[    5.998194]  [&lt;c1031758&gt;] ? sub_preempt_count+0x63/0x89
[    6.003412]  [&lt;c1039644&gt;] warn_slowpath_null+0xf/0x13
[    6.008453]  [&lt;c1031758&gt;] sub_preempt_count+0x63/0x89
[    6.013499]  [&lt;c14d60c4&gt;] _raw_spin_unlock+0x27/0x3f
[    6.018453]  [&lt;c10c6349&gt;] add_partial+0x36/0x3b
[    6.022973]  [&lt;c10c7c0a&gt;] deactivate_slab+0x96/0xb4
[    6.027842]  [&lt;c14cf9d9&gt;] __slab_alloc.isra.54.constprop.63+0x204/0x241
[    6.034456]  [&lt;c103f78f&gt;] ? kzalloc.constprop.5+0x29/0x38
[    6.039842]  [&lt;c103f78f&gt;] ? kzalloc.constprop.5+0x29/0x38
[    6.045232]  [&lt;c10c7dc9&gt;] kmem_cache_alloc_trace+0x51/0xb0
[    6.050710]  [&lt;c103f78f&gt;] ? kzalloc.constprop.5+0x29/0x38
[    6.056100]  [&lt;c103f78f&gt;] kzalloc.constprop.5+0x29/0x38
[    6.061320]  [&lt;c17b45e9&gt;] __reserve_region_with_split+0x1c/0xd1
[    6.067230]  [&lt;c17b4693&gt;] __reserve_region_with_split+0xc6/0xd1
...
[    7.179057]  [&lt;c17b4693&gt;] __reserve_region_with_split+0xc6/0xd1
[    7.184970]  [&lt;c17b4779&gt;] reserve_region_with_split+0x30/0x42
[    7.190709]  [&lt;c17a8ebf&gt;] e820_reserve_resources_late+0xd1/0xe9
[    7.196623]  [&lt;c17c9526&gt;] pcibios_resource_survey+0x23/0x2a
[    7.202184]  [&lt;c17cad8a&gt;] pcibios_init+0x23/0x35
[    7.206789]  [&lt;c17ca574&gt;] pci_subsys_init+0x3f/0x44
[    7.211659]  [&lt;c1002088&gt;] do_one_initcall+0x72/0x122
[    7.216615]  [&lt;c17ca535&gt;] ? pci_legacy_init+0x3d/0x3d
[    7.221659]  [&lt;c17a27ff&gt;] kernel_init+0xa6/0x118
[    7.226265]  [&lt;c17a2759&gt;] ? start_kernel+0x334/0x334
[    7.231223]  [&lt;c14d7482&gt;] kernel_thread_helper+0x6/0x10

Signed-off-by: Octavian Purdila &lt;octavian.purdila@intel.com&gt;
Signed-off-by: Ram Pai &lt;linuxram@us.ibm.com&gt;
Cc: Jesse Barnes &lt;jbarnes@virtuousgeek.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>resources: allow adjust_resource() for resources with no parent</title>
<updated>2012-06-13T21:42:22Z</updated>
<author>
<name>Yinghai Lu</name>
<email>yinghai@kernel.org</email>
</author>
<published>2012-05-18T01:51:11Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=82ec90eac304e81b1389175b4dded7abecc678ef'/>
<id>urn:sha1:82ec90eac304e81b1389175b4dded7abecc678ef</id>
<content type='text'>
If a resource has no parent, allow its start/end to be set arbitrarily
as long as any children are still contained within the new range.

[bhelgaas: changelog]
Signed-off-by: Yinghai Lu &lt;yinghai@kernel.org&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;</content>
</entry>
<entry>
<title>kernel/resource.c: correct the comment of allocate_resource()</title>
<updated>2012-06-01T00:49:26Z</updated>
<author>
<name>Wei Yang</name>
<email>weiyang@linux.vnet.ibm.com</email>
</author>
<published>2012-05-31T23:26:05Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=ee5e5683d8ac3fec876cb6c26792212f773d5898'/>
<id>urn:sha1:ee5e5683d8ac3fec876cb6c26792212f773d5898</id>
<content type='text'>
In the comment of allocate_resource(), the explanation of parameter max
and min is not correct.

Actually, these two parameters are used to specify the range of the
resource that will be allocated, not the min/max size that will be
allocated.

Signed-off-by: Wei Yang &lt;weiyang@linux.vnet.ibm.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>kernel/resource.c: move EXPORT_SYMBOL right after definition</title>
<updated>2012-02-03T22:37:07Z</updated>
<author>
<name>Cong Wang</name>
<email>xiyou.wangcong@gmail.com</email>
</author>
<published>2012-02-03T13:42:39Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=241057486646dd42278538218376c79aae2c359f'/>
<id>urn:sha1:241057486646dd42278538218376c79aae2c359f</id>
<content type='text'>
EXPORT_SYMBOL(adjust_resource) should be right after adjust_resource().

Signed-off-by: WANG Cong &lt;xiyou.wangcong@gmail.com&gt;
Signed-off-by: Jiri Kosina &lt;jkosina@suse.cz&gt;
</content>
</entry>
<entry>
<title>kernel: Map most files to use export.h instead of module.h</title>
<updated>2011-10-31T13:20:12Z</updated>
<author>
<name>Paul Gortmaker</name>
<email>paul.gortmaker@windriver.com</email>
</author>
<published>2011-05-23T18:51:41Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=9984de1a5a8a96275fcab818f7419af5a3c86e71'/>
<id>urn:sha1:9984de1a5a8a96275fcab818f7419af5a3c86e71</id>
<content type='text'>
The changed files were only including linux/module.h for the
EXPORT_SYMBOL infrastructure, and nothing else.  Revector them
onto the isolated export header for faster compile times.

Nothing to see here but a whole lot of instances of:

  -#include &lt;linux/module.h&gt;
  +#include &lt;linux/export.h&gt;

This commit is only changing the kernel dir; next targets
will probably be mm, fs, the arch dirs, etc.

Signed-off-by: Paul Gortmaker &lt;paul.gortmaker@windriver.com&gt;
</content>
</entry>
<entry>
<title>Resource: fix wrong resource window calculation</title>
<updated>2011-09-30T03:04:34Z</updated>
<author>
<name>Ram Pai</name>
<email>linuxram@us.ibm.com</email>
</author>
<published>2011-09-22T07:48:58Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=47ea91b4052d9e94b9dca5d7a3d947fbebd07ba9'/>
<id>urn:sha1:47ea91b4052d9e94b9dca5d7a3d947fbebd07ba9</id>
<content type='text'>
__find_resource() incorrectly returns a resource window which overlaps
an existing allocated window.  This happens when the parent's
resource-window spans 0x00000000 to 0xffffffff and is entirely allocated
to all its children resource-windows.

__find_resource() looks for gaps in resource allocation among the
children resource windows.  When it encounters the last child window it
blindly tries the range next to one allocated to the last child.  Since
the last child's window ends at 0xffffffff the calculation overflows,
leading the algorithm to believe that any window in the range 0x0000000
to 0xfffffff is available for allocation.  This leads to a conflicting
window allocation.

Michal Ludvig reported this issue seen on his platform.  The following
patch fixes the problem and has been verified by Michal.  I believe this
bug has been there for ages.  It got exposed by git commit 2bbc6942273b
("PCI : ability to relocate assigned pci-resources")

Signed-off-by: Ram Pai &lt;linuxram@us.ibm.com&gt;
Tested-by: Michal Ludvig &lt;mludvig@logix.net.nz&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
