public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [GIT PULL] percpu fixes for 2.6.31-rc8
@ 2009-09-01 12:51 Tejun Heo
  2009-09-01 12:56 ` Tejun Heo
  0 siblings, 1 reply; 4+ messages in thread
From: Tejun Heo @ 2009-09-01 12:51 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Linux Kernel, David Miller, Meelis Roos

Hello, Linus.

Please consider pulling from the following percpu fixes tree.

 git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu.git for-linus

This branch contains one critical fix for sparc64.  Dynamic percpu
allocator in 2.6.31 tree still assumed that cpu0 always exists which
is not true on certain sparc64 machines.  This leads to malfunction in
the allocator leading to unmapping of used area and then oops.  This
was reported in the following thread.

 http://thread.gmane.org/gmane.linux.ports.sparc/12138

Using raw_smp_processor_id() instead of 0 in two places fixes the
problem.  Devel branch had both (sans raw_ prefix) but the first one
was no longer necessary and dropped.  Both chunk->page[] array and
vmalloc area back pointing which the fix touches are always done for
all possible cpus in unison and what changes is percpu now uses
raw_smp_processor_id() to use any possible one of the cpus instead of
explicit 0.  Given that the changes have been in linux-next for some
time now, I believe these changes to be quite safe.

Thanks.
---
  Tejun Heo (1):
        percpu: don't assume existence of cpu0

 mm/percpu.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/mm/percpu.c b/mm/percpu.c
index 5fe3784..3311c89 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -197,7 +197,12 @@ static unsigned long pcpu_chunk_addr(struct pcpu_chunk *chunk,
 static bool pcpu_chunk_page_occupied(struct pcpu_chunk *chunk,
 				     int page_idx)
 {
-	return *pcpu_chunk_pagep(chunk, 0, page_idx) != NULL;
+	/*
+	 * Any possible cpu id can be used here, so there's no need to
+	 * worry about preemption or cpu hotplug.
+	 */
+	return *pcpu_chunk_pagep(chunk, raw_smp_processor_id(),
+				 page_idx) != NULL;
 }

 /* set the pointer to a chunk in a page struct */
@@ -297,6 +302,14 @@ static struct pcpu_chunk *pcpu_chunk_addr_search(void *addr)
 		return pcpu_first_chunk;
 	}

+	/*
+	 * The address is relative to unit0 which might be unused and
+	 * thus unmapped.  Offset the address to the unit space of the
+	 * current processor before looking it up in the vmalloc
+	 * space.  Note that any possible cpu id can be used here, so
+	 * there's no need to worry about preemption or cpu hotplug.
+	 */
+	addr += raw_smp_processor_id() * pcpu_unit_size;
 	return pcpu_get_page_chunk(vmalloc_to_page(addr));
 }


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [GIT PULL] percpu fixes for 2.6.31-rc8
  2009-09-01 12:51 [GIT PULL] percpu fixes for 2.6.31-rc8 Tejun Heo
@ 2009-09-01 12:56 ` Tejun Heo
  2009-09-05 21:23   ` Linus Torvalds
  0 siblings, 1 reply; 4+ messages in thread
From: Tejun Heo @ 2009-09-01 12:56 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Linux Kernel, David Miller, Meelis Roos

Tejun Heo wrote:
> Hello, Linus.
> 
> Please consider pulling from the following percpu fixes tree.
> 
>  git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu.git for-linus

Ummm... one question.  The above tree is on top of the previous
for-linus fixes tree.  It pulls in to the current #master alright but
it would still be a merge instead of a fast-forward.  Would it be
better to prep fixes tree on top of the current #master so that it
results in fast-forward?  If that's the case, please let me know or
just cherry pick the top commit.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [GIT PULL] percpu fixes for 2.6.31-rc8
  2009-09-01 12:56 ` Tejun Heo
@ 2009-09-05 21:23   ` Linus Torvalds
  2009-09-05 21:44     ` Tejun Heo
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Torvalds @ 2009-09-05 21:23 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Linux Kernel, David Miller, Meelis Roos



On Tue, 1 Sep 2009, Tejun Heo wrote:
> 
> Ummm... one question.  The above tree is on top of the previous
> for-linus fixes tree.  It pulls in to the current #master alright but
> it would still be a merge instead of a fast-forward.  Would it be
> better to prep fixes tree on top of the current #master so that it
> results in fast-forward?  If that's the case, please let me know or
> just cherry pick the top commit.

No, I actually prefer people to avoid rebasing unless they have some real 
reason for it. My pulls almost always end up being merges anyway, since I 
pull from several people, so even if you were to have rebased, it would 
_not_ have been a fast-forward for me, since I'd in the meantime have 
pulled from others anyway.

			Linus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [GIT PULL] percpu fixes for 2.6.31-rc8
  2009-09-05 21:23   ` Linus Torvalds
@ 2009-09-05 21:44     ` Tejun Heo
  0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2009-09-05 21:44 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Linux Kernel, David Miller, Meelis Roos

Hello, Linus.

Linus Torvalds wrote:
> On Tue, 1 Sep 2009, Tejun Heo wrote:
>> Ummm... one question.  The above tree is on top of the previous
>> for-linus fixes tree.  It pulls in to the current #master alright but
>> it would still be a merge instead of a fast-forward.  Would it be
>> better to prep fixes tree on top of the current #master so that it
>> results in fast-forward?  If that's the case, please let me know or
>> just cherry pick the top commit.
> 
> No, I actually prefer people to avoid rebasing unless they have some real 
> reason for it. My pulls almost always end up being merges anyway, since I 
> pull from several people, so even if you were to have rebased, it would 
> _not_ have been a fast-forward for me, since I'd in the meantime have 
> pulled from others anyway.

Alright, thanks for the explanation.  Will do as advised.

-- 
tejun

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-09-05 21:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-01 12:51 [GIT PULL] percpu fixes for 2.6.31-rc8 Tejun Heo
2009-09-01 12:56 ` Tejun Heo
2009-09-05 21:23   ` Linus Torvalds
2009-09-05 21:44     ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox