<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/mm/percpu.c, branch v4.9</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v4.9</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.9'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2016-10-05T15:52:55Z</updated>
<entry>
<title>mm/percpu.c: fix potential memory leakage for pcpu_embed_first_chunk()</title>
<updated>2016-10-05T15:52:55Z</updated>
<author>
<name>zijun_hu</name>
<email>zijun_hu@htc.com</email>
</author>
<published>2016-10-05T13:30:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9b7396624a7b503220d85428654634b60762f2b0'/>
<id>urn:sha1:9b7396624a7b503220d85428654634b60762f2b0</id>
<content type='text'>
in order to ensure the percpu group areas within a chunk aren't
distributed too sparsely, pcpu_embed_first_chunk() goes to error handling
path when a chunk spans over 3/4 VMALLOC area, however, during the error
handling, it forget to free the memory allocated for all percpu groups by
going to label @out_free other than @out_free_areas.

it will cause memory leakage issue if the rare scene really happens, in
order to fix the issue, we check chunk spanned area immediately after
completing memory allocation for all percpu groups, we go to label
@out_free_areas to free the memory then return if the checking is failed.

in order to verify the approach, we dump all memory allocated then
enforce the jump then dump all memory freed, the result is okay after
checking whether we free all memory we allocate in this function.

BTW, The approach is chosen after thinking over the below scenes
 - we don't go to label @out_free directly to fix this issue since we
   maybe free several allocated memory blocks twice
 - the aim of jumping after pcpu_setup_first_chunk() is bypassing free
   usable memory other than handling error, moreover, the function does
   not return error code in any case, it either panics due to BUG_ON()
   or return 0.

Signed-off-by: zijun_hu &lt;zijun_hu@htc.com&gt;
Tested-by: zijun_hu &lt;zijun_hu@htc.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>mm/percpu.c: correct max_distance calculation for pcpu_embed_first_chunk()</title>
<updated>2016-10-05T15:52:54Z</updated>
<author>
<name>zijun_hu</name>
<email>zijun_hu@htc.com</email>
</author>
<published>2016-10-05T13:19:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=93c76b6b2faaad7bfbc0cda840763aa4819ef26e'/>
<id>urn:sha1:93c76b6b2faaad7bfbc0cda840763aa4819ef26e</id>
<content type='text'>
pcpu_embed_first_chunk() calculates the range a percpu chunk spans into
@max_distance and uses it to ensure that a chunk is not too big compared
to the total vmalloc area. However, during calculation, it used incorrect
top address by adding a unit size to the highest group's base address.

This can make the calculated max_distance slightly smaller than the actual
distance although given the scale of values involved the error is very
unlikely to have an actual impact.

Fix this issue by adding the group's size instead of a unit size.

BTW, The type of variable max_distance is changed from size_t to unsigned
long too based on below consideration:
 - type unsigned long usually have same width with IP core registers and
   can be applied at here very well
 - make @max_distance type consistent with the operand calculated against
   it such as @ai-&gt;groups[i].base_offset and macro VMALLOC_TOTAL
 - type unsigned long is more universal then size_t, size_t is type defined
   to unsigned int or unsigned long among various ARCHs usually

Signed-off-by: zijun_hu &lt;zijun_hu@htc.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>percpu: fix synchronization between synchronous map extension and chunk destruction</title>
<updated>2016-05-25T15:48:25Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2016-05-25T15:48:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6710e594f71ccaad8101bc64321152af7cd9ea28'/>
<id>urn:sha1:6710e594f71ccaad8101bc64321152af7cd9ea28</id>
<content type='text'>
For non-atomic allocations, pcpu_alloc() can try to extend the area
map synchronously after dropping pcpu_lock; however, the extension
wasn't synchronized against chunk destruction and the chunk might get
freed while extension is in progress.

This patch fixes the bug by putting most of non-atomic allocations
under pcpu_alloc_mutex to synchronize against pcpu_balance_work which
is responsible for async chunk management including destruction.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Reported-and-tested-by: Alexei Starovoitov &lt;alexei.starovoitov@gmail.com&gt;
Reported-by: Vlastimil Babka &lt;vbabka@suse.cz&gt;
Reported-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
Cc: stable@vger.kernel.org # v3.18+
Fixes: 1a4d76076cda ("percpu: implement asynchronous chunk population")
</content>
</entry>
<entry>
<title>percpu: fix synchronization between chunk-&gt;map_extend_work and chunk destruction</title>
<updated>2016-05-25T15:48:25Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2016-05-25T15:48:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4f996e234dad488e5d9ba0858bc1bae12eff82c3'/>
<id>urn:sha1:4f996e234dad488e5d9ba0858bc1bae12eff82c3</id>
<content type='text'>
Atomic allocations can trigger async map extensions which is serviced
by chunk-&gt;map_extend_work.  pcpu_balance_work which is responsible for
destroying idle chunks wasn't synchronizing properly against
chunk-&gt;map_extend_work and may end up freeing the chunk while the work
item is still in flight.

This patch fixes the bug by rolling async map extension operations
into pcpu_balance_work.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Reported-and-tested-by: Alexei Starovoitov &lt;alexei.starovoitov@gmail.com&gt;
Reported-by: Vlastimil Babka &lt;vbabka@suse.cz&gt;
Reported-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
Cc: stable@vger.kernel.org # v3.18+
Fixes: 9c824b6a172c ("percpu: make sure chunk-&gt;map array has available space")
</content>
</entry>
<entry>
<title>mm: percpu: use pr_fmt to prefix output</title>
<updated>2016-03-17T22:09:34Z</updated>
<author>
<name>Joe Perches</name>
<email>joe@perches.com</email>
</author>
<published>2016-03-17T21:19:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=870d4b12ad15d21c5db67b373bdc2f62cfe2ec64'/>
<id>urn:sha1:870d4b12ad15d21c5db67b373bdc2f62cfe2ec64</id>
<content type='text'>
Use the normal mechanism to make the logging output consistently
"percpu:" instead of a mix of "PERCPU:" and "percpu:"

Signed-off-by: Joe Perches &lt;joe@perches.com&gt;
Acked-by: Tejun Heo &lt;tj@kernel.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>mm: convert printk(KERN_&lt;LEVEL&gt; to pr_&lt;level&gt;</title>
<updated>2016-03-17T22:09:34Z</updated>
<author>
<name>Joe Perches</name>
<email>joe@perches.com</email>
</author>
<published>2016-03-17T21:19:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1170532bb49f9468aedabdc1d5a560e2521a2bcc'/>
<id>urn:sha1:1170532bb49f9468aedabdc1d5a560e2521a2bcc</id>
<content type='text'>
Most of the mm subsystem uses pr_&lt;level&gt; so make it consistent.

Miscellanea:

 - Realign arguments
 - Add missing newline to format
 - kmemleak-test.c has a "kmemleak: " prefix added to the
   "Kmemleak testing" logging message via pr_fmt

Signed-off-by: Joe Perches &lt;joe@perches.com&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;	[percpu]
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>mm: coalesce split strings</title>
<updated>2016-03-17T22:09:34Z</updated>
<author>
<name>Joe Perches</name>
<email>joe@perches.com</email>
</author>
<published>2016-03-17T21:19:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=756a025f00091918d9d09ca3229defb160b409c0'/>
<id>urn:sha1:756a025f00091918d9d09ca3229defb160b409c0</id>
<content type='text'>
Kernel style prefers a single string over split strings when the string is
'user-visible'.

Miscellanea:

 - Add a missing newline
 - Realign arguments

Signed-off-by: Joe Perches &lt;joe@perches.com&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;	[percpu]
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>mm: convert pr_warning to pr_warn</title>
<updated>2016-03-17T22:09:34Z</updated>
<author>
<name>Joe Perches</name>
<email>joe@perches.com</email>
</author>
<published>2016-03-17T21:19:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=598d80914e84fa79580850530f5d4a50a99bf4f5'/>
<id>urn:sha1:598d80914e84fa79580850530f5d4a50a99bf4f5</id>
<content type='text'>
There are a mixture of pr_warning and pr_warn uses in mm.  Use pr_warn
consistently.

Miscellanea:

 - Coalesce formats
 - Realign arguments

Signed-off-by: Joe Perches &lt;joe@perches.com&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;	[percpu]
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>tree wide: use kvfree() than conditional kfree()/vfree()</title>
<updated>2016-01-23T01:02:18Z</updated>
<author>
<name>Tetsuo Handa</name>
<email>penguin-kernel@i-love.sakura.ne.jp</email>
</author>
<published>2016-01-22T23:11:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1d5cfdb076288df5eb95545a547a39905e95c930'/>
<id>urn:sha1:1d5cfdb076288df5eb95545a547a39905e95c930</id>
<content type='text'>
There are many locations that do

  if (memory_was_allocated_by_vmalloc)
    vfree(ptr);
  else
    kfree(ptr);

but kvfree() can handle both kmalloc()ed memory and vmalloc()ed memory
using is_vmalloc_addr().  Unless callers have special reasons, we can
replace this branch with kvfree().  Please check and reply if you found
problems.

Signed-off-by: Tetsuo Handa &lt;penguin-kernel@I-love.SAKURA.ne.jp&gt;
Acked-by: Michal Hocko &lt;mhocko@suse.com&gt;
Acked-by: Jan Kara &lt;jack@suse.com&gt;
Acked-by: Russell King &lt;rmk+kernel@arm.linux.org.uk&gt;
Reviewed-by: Andreas Dilger &lt;andreas.dilger@intel.com&gt;
Acked-by: "Rafael J. Wysocki" &lt;rjw@rjwysocki.net&gt;
Acked-by: David Rientjes &lt;rientjes@google.com&gt;
Cc: "Luck, Tony" &lt;tony.luck@intel.com&gt;
Cc: Oleg Drokin &lt;oleg.drokin@intel.com&gt;
Cc: Boris Petkov &lt;bp@suse.de&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>mm/percpu: use offset_in_page macro</title>
<updated>2015-11-06T03:34:48Z</updated>
<author>
<name>Alexander Kuleshov</name>
<email>kuleshovmail@gmail.com</email>
</author>
<published>2015-11-06T02:46:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f09f1243ca2d5d297881bf2c2148d9ab35314314'/>
<id>urn:sha1:f09f1243ca2d5d297881bf2c2148d9ab35314314</id>
<content type='text'>
linux/mm.h provides offset_in_page() macro.  Let's use already predefined
macro instead of (addr &amp; ~PAGE_MASK).

Signed-off-by: Alexander Kuleshov &lt;kuleshovmail@gmail.com&gt;
Acked-by: Tejun Heo &lt;tj@kernel.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>
</feed>
