<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/mm/percpu.c, branch v3.2.38</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/mm/percpu.c?h=v3.2.38</id>
<link rel='self' href='https://git.amat.us/linux/atom/mm/percpu.c?h=v3.2.38'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2012-05-20T21:56:31Z</updated>
<entry>
<title>percpu: pcpu_embed_first_chunk() should free unused parts after all allocs are complete</title>
<updated>2012-05-20T21:56:31Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2012-04-27T15:42:53Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=8a2f7257ae6a7d1e1c87dd1ef146bd3e9c04e903'/>
<id>urn:sha1:8a2f7257ae6a7d1e1c87dd1ef146bd3e9c04e903</id>
<content type='text'>
commit 42b64281453249dac52861f9b97d18552a7ec62b upstream.

pcpu_embed_first_chunk() allocates memory for each node, copies percpu
data and frees unused portions of it before proceeding to the next
group.  This assumes that allocations for different nodes doesn't
overlap; however, depending on memory topology, the bootmem allocator
may end up allocating memory from a different node than the requested
one which may overlap with the portion freed from one of the previous
percpu areas.  This leads to percpu groups for different nodes
overlapping which is a serious bug.

This patch separates out copy &amp; partial free from the allocation loop
such that all allocations are complete before partial frees happen.

This also fixes overlapping frees which could happen on allocation
failure path - out_free_areas path frees whole groups but the groups
could have portions freed at that point.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Reported-by: "Pavel V. Panteleev" &lt;pp_84@mail.ru&gt;
Tested-by: "Pavel V. Panteleev" &lt;pp_84@mail.ru&gt;
LKML-Reference: &lt;E1SNhwY-0007ui-V7.pp_84-mail-ru@f220.mail.ru&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>percpu: fix per_cpu_ptr_to_phys() handling of non-page-aligned addresses</title>
<updated>2011-12-15T19:41:40Z</updated>
<author>
<name>Eugene Surovegin</name>
<email>ebs@ebshome.net</email>
</author>
<published>2011-12-15T19:25:59Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=9f57bd4d6dc69a4e3bf43044fa00fcd24dd363e3'/>
<id>urn:sha1:9f57bd4d6dc69a4e3bf43044fa00fcd24dd363e3</id>
<content type='text'>
per_cpu_ptr_to_phys() incorrectly rounds up its result for non-kmalloc
case to the page boundary, which is bogus for any non-page-aligned
address.

This affects the only in-tree user of this function - sysfs handler
for per-cpu 'crash_notes' physical address.  The trouble is that the
crash_notes per-cpu variable is not page-aligned:

crash_notes = 0xc08e8ed4
PER-CPU OFFSET VALUES:
 CPU 0: 3711f000
 CPU 1: 37129000
 CPU 2: 37133000
 CPU 3: 3713d000

So, the per-cpu addresses are:
 crash_notes on CPU 0: f7a07ed4 =&gt; phys 36b57ed4
 crash_notes on CPU 1: f7a11ed4 =&gt; phys 36b4ded4
 crash_notes on CPU 2: f7a1bed4 =&gt; phys 36b43ed4
 crash_notes on CPU 3: f7a25ed4 =&gt; phys 36b39ed4

However, /sys/devices/system/cpu/cpu*/crash_notes says:
 /sys/devices/system/cpu/cpu0/crash_notes: 36b57000
 /sys/devices/system/cpu/cpu1/crash_notes: 36b4d000
 /sys/devices/system/cpu/cpu2/crash_notes: 36b43000
 /sys/devices/system/cpu/cpu3/crash_notes: 36b39000

As you can see, all values are rounded down to a page
boundary. Consequently, this is where kexec sets up the NOTE segments,
and thus where the secondary kernel is looking for them. However, when
the first kernel crashes, it saves the notes to the unaligned
addresses, where they are not found.

Fix it by adding offset_in_page() to the translated page address.

-tj: Combined Eugene's and Petr's commit messages.

Signed-off-by: Eugene Surovegin &lt;ebs@ebshome.net&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Reported-by: Petr Tesarik &lt;ptesarik@suse.cz&gt;
Cc: stable@kernel.org
</content>
</entry>
<entry>
<title>percpu: explain why per_cpu_ptr_to_phys() is more complicated than necessary</title>
<updated>2011-11-23T16:20:53Z</updated>
<author>
<name>Dave Young</name>
<email>dyoung@redhat.com</email>
</author>
<published>2011-11-23T16:20:53Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=67589c71456b0346500629967292dea3802230b6'/>
<id>urn:sha1:67589c71456b0346500629967292dea3802230b6</id>
<content type='text'>
Add comments about current per_cpu_ptr_to_phys implementation to
explain why the logic is more complicated than necessary.

-tj: relocated comment into kerneldoc comment

Signed-off-by: Dave Young &lt;dyoung@redhat.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>percpu: fix chunk range calculation</title>
<updated>2011-11-22T16:09:46Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2011-11-18T18:55:35Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=a855b84c3d8c73220d4d3cd392a7bee7c83de70e'/>
<id>urn:sha1:a855b84c3d8c73220d4d3cd392a7bee7c83de70e</id>
<content type='text'>
Percpu allocator recorded the cpus which map to the first and last
units in pcpu_first/last_unit_cpu respectively and used them to
determine the address range of a chunk - e.g. it assumed that the
first unit has the lowest address in a chunk while the last unit has
the highest address.

This simply isn't true.  Groups in a chunk can have arbitrary positive
or negative offsets from the previous one and there is no guarantee
that the first unit occupies the lowest offset while the last one the
highest.

Fix it by actually comparing unit offsets to determine cpus occupying
the lowest and highest offsets.  Also, rename pcu_first/last_unit_cpu
to pcpu_low/high_unit_cpu to avoid confusion.

The chunk address range is used to flush cache on vmalloc area
map/unmap and decide whether a given address is in the first chunk by
per_cpu_ptr_to_phys() and the bug was discovered by invalid
per_cpu_ptr_to_phys() translation for crash_note.

Kudos to Dave Young for tracking down the problem.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Reported-by: WANG Cong &lt;xiyou.wangcong@gmail.com&gt;
Reported-by: Dave Young &lt;dyoung@redhat.com&gt;
Tested-by: Dave Young &lt;dyoung@redhat.com&gt;
LKML-Reference: &lt;4EC21F67.10905@redhat.com&gt;
Cc: stable @kernel.org
</content>
</entry>
<entry>
<title>percpu: rename pcpu_mem_alloc to pcpu_mem_zalloc</title>
<updated>2011-11-22T16:09:41Z</updated>
<author>
<name>Bob Liu</name>
<email>lliubbo@gmail.com</email>
</author>
<published>2011-08-04T09:02:33Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=90459ce06f410b983540be56209c0abcbce23944'/>
<id>urn:sha1:90459ce06f410b983540be56209c0abcbce23944</id>
<content type='text'>
Currently pcpu_mem_alloc() is implemented always return zeroed memory.
So rename it to make user like pcpu_get_pages_and_bitmap() know don't
reinit it.

Signed-off-by: Bob Liu &lt;lliubbo@gmail.com&gt;
Reviewed-by: Pekka Enberg &lt;penberg@kernel.org&gt;
Reviewed-by: Michal Hocko &lt;mhocko@suse.cz&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>Merge branch 'for-2.6.40' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu</title>
<updated>2011-05-24T18:53:42Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2011-05-24T18:53:42Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=5129df03d0c44b2d5a5f9d7d52f3b079706b9a8f'/>
<id>urn:sha1:5129df03d0c44b2d5a5f9d7d52f3b079706b9a8f</id>
<content type='text'>
* 'for-2.6.40' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu:
  percpu: Unify input section names
  percpu: Avoid extra NOP in percpu_cmpxchg16b_double
  percpu: Cast away printk format warning
  percpu: Always align percpu output section to PAGE_SIZE

Fix up fairly trivial conflict in arch/x86/include/asm/percpu.h as per Tejun
</content>
</entry>
<entry>
<title>Merge branch 'fixes-2.6.39' into for-2.6.40</title>
<updated>2011-05-24T07:59:36Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2011-05-24T07:59:36Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=6988f20fe04e9ef3aea488cb8ab57fbeb78e12f0'/>
<id>urn:sha1:6988f20fe04e9ef3aea488cb8ab57fbeb78e12f0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Fix common misspellings</title>
<updated>2011-03-31T14:26:23Z</updated>
<author>
<name>Lucas De Marchi</name>
<email>lucas.demarchi@profusion.mobi</email>
</author>
<published>2011-03-31T01:57:33Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=25985edcedea6396277003854657b5f3cb31a628'/>
<id>urn:sha1:25985edcedea6396277003854657b5f3cb31a628</id>
<content type='text'>
Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi &lt;lucas.demarchi@profusion.mobi&gt;
</content>
</entry>
<entry>
<title>percpu: Cast away printk format warning</title>
<updated>2011-03-28T16:03:34Z</updated>
<author>
<name>Mike Frysinger</name>
<email>vapier@gentoo.org</email>
</author>
<published>2011-03-23T07:23:52Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=787e5b06a80e7fc9dc02d9b53a9d8d2ac63b7ace'/>
<id>urn:sha1:787e5b06a80e7fc9dc02d9b53a9d8d2ac63b7ace</id>
<content type='text'>
On 32-bit systems which don't happen to implicitly define or cast
VMALLOC_START and/or VMALLOC_END to long in their arch headers, the
printk in the percpu code will cause a warning to be emitted:

mm/percpu.c: In function 'pcpu_embed_first_chunk':
mm/percpu.c:1648: warning: format '%lx' expects type 'long unsigned int',
        but argument 3 has type 'unsigned int'

So add an explicit cast to unsigned long here.

Signed-off-by: Mike Frysinger &lt;vapier@gentoo.org&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>NOMMU: percpu should use is_vmalloc_addr().</title>
<updated>2011-03-28T11:53:29Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2011-03-28T11:53:29Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=eac522ef438f8ea173569fd0469371bc5d317947'/>
<id>urn:sha1:eac522ef438f8ea173569fd0469371bc5d317947</id>
<content type='text'>
per_cpu_ptr_to_phys() uses VMALLOC_START and VMALLOC_END to determine if an
address is in the vmalloc() region or not.  This is incorrect on NOMMU as
there is no real vmalloc() capability (vmalloc() is emulated by kmalloc()).

The correct way to do this is to use is_vmalloc_addr().  This encapsulates the
vmalloc() region test in MMU mode and just returns 0 in NOMMU mode.

On FRV in NOMMU mode, the percpu compilation fails without this patch:

mm/percpu.c: In function 'per_cpu_ptr_to_phys':
mm/percpu.c:1011: error: 'VMALLOC_START' undeclared (first use in this function)
mm/percpu.c:1011: error: (Each undeclared identifier is reported only once
mm/percpu.c:1011: error: for each function it appears in.)
mm/percpu.c:1012: error: 'VMALLOC_END' undeclared (first use in this function)
mm/percpu.c:1018: warning: control reaches end of non-void function

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
</content>
</entry>
</feed>
