linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCCH percpu: add cpunum param in per_cpu_ptr_to_phys
@ 2011-11-15  8:36 Dave Young
  2011-11-15 14:49 ` Tejun Heo
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Young @ 2011-11-15  8:36 UTC (permalink / raw)
  To: gregkh, tj, cl, linux-kernel, linux-mm

per_cpu_ptr_to_phys iterate all cpu to get the phy addr
let's leave the caller to pass the cpu number to it.

Actually in the only one user show_crash_notes,
cpunum is provided already before calling this. 

Signed-off-by: Dave Young <dyoung@redhat.com>
---
 drivers/base/cpu.c     |    2 +-
 include/linux/percpu.h |    2 +-
 mm/percpu.c            |   29 ++++-------------------------
 3 files changed, 6 insertions(+), 27 deletions(-)

--- linux-2.6.orig/drivers/base/cpu.c	2011-09-20 12:39:36.000000000 +0800
+++ linux-2.6/drivers/base/cpu.c	2011-11-15 14:52:42.742852411 +0800
@@ -125,7 +125,7 @@ static ssize_t show_crash_notes(struct s
 	 * boot up and this data does not change there after. Hence this
 	 * operation should be safe. No locking required.
 	 */
-	addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpunum));
+	addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpunum), cpunum);
 	rc = sprintf(buf, "%Lx\n", addr);
 	return rc;
 }
--- linux-2.6.orig/include/linux/percpu.h	2011-11-15 11:06:18.000000000 +0800
+++ linux-2.6/include/linux/percpu.h	2011-11-15 14:53:28.352605321 +0800
@@ -160,7 +160,7 @@ extern void __init percpu_init_late(void
 
 extern void __percpu *__alloc_percpu(size_t size, size_t align);
 extern void free_percpu(void __percpu *__pdata);
-extern phys_addr_t per_cpu_ptr_to_phys(void *addr);
+extern phys_addr_t per_cpu_ptr_to_phys(void *addr, int cpunum);
 
 #define alloc_percpu(type)	\
 	(typeof(type) __percpu *)__alloc_percpu(sizeof(type), __alignof__(type))
--- linux-2.6.orig/mm/percpu.c	2011-11-15 11:06:19.000000000 +0800
+++ linux-2.6/mm/percpu.c	2011-11-15 14:59:56.927166899 +0800
@@ -971,6 +971,7 @@ bool is_kernel_percpu_address(unsigned l
 /**
  * per_cpu_ptr_to_phys - convert translated percpu address to physical address
  * @addr: the address to be converted to physical address
+ * @cpunum: the cpu number of percpu address
  *
  * Given @addr which is dereferenceable address obtained via one of
  * percpu access macros, this function translates it into its physical
@@ -980,34 +981,12 @@ bool is_kernel_percpu_address(unsigned l
  * RETURNS:
  * The physical address for @addr.
  */
-phys_addr_t per_cpu_ptr_to_phys(void *addr)
+phys_addr_t per_cpu_ptr_to_phys(void *addr, int cpunum)
 {
 	void __percpu *base = __addr_to_pcpu_ptr(pcpu_base_addr);
-	bool in_first_chunk = false;
-	unsigned long first_start, first_end;
-	unsigned int cpu;
+	void *start = per_cpu_ptr(base, cpunum);
 
-	/*
-	 * The following test on first_start/end isn't strictly
-	 * necessary but will speed up lookups of addresses which
-	 * aren't in the first chunk.
-	 */
-	first_start = pcpu_chunk_addr(pcpu_first_chunk, pcpu_first_unit_cpu, 0);
-	first_end = pcpu_chunk_addr(pcpu_first_chunk, pcpu_last_unit_cpu,
-				    pcpu_unit_pages);
-	if ((unsigned long)addr >= first_start &&
-	    (unsigned long)addr < first_end) {
-		for_each_possible_cpu(cpu) {
-			void *start = per_cpu_ptr(base, cpu);
-
-			if (addr >= start && addr < start + pcpu_unit_size) {
-				in_first_chunk = true;
-				break;
-			}
-		}
-	}
-
-	if (in_first_chunk) {
+	if (addr >= start && addr < start + pcpu_unit_size) {
 		if (!is_vmalloc_addr(addr))
 			return __pa(addr);
 		else

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCCH percpu: add cpunum param in per_cpu_ptr_to_phys
  2011-11-15  8:36 [PATCCH percpu: add cpunum param in per_cpu_ptr_to_phys Dave Young
@ 2011-11-15 14:49 ` Tejun Heo
  2011-11-16  1:15   ` Dave Young
  0 siblings, 1 reply; 4+ messages in thread
From: Tejun Heo @ 2011-11-15 14:49 UTC (permalink / raw)
  To: Dave Young; +Cc: gregkh, cl, linux-kernel, linux-mm

On Tue, Nov 15, 2011 at 04:36:46PM +0800, Dave Young wrote:
> per_cpu_ptr_to_phys iterate all cpu to get the phy addr
> let's leave the caller to pass the cpu number to it.
> 
> Actually in the only one user show_crash_notes,
> cpunum is provided already before calling this. 
> 
> Signed-off-by: Dave Young <dyoung@redhat.com>

Does this matter?  If it's not a performance critical path, I'd rather
keep the generic funtionality.

Thanks.

-- 
tejun

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCCH percpu: add cpunum param in per_cpu_ptr_to_phys
  2011-11-15 14:49 ` Tejun Heo
@ 2011-11-16  1:15   ` Dave Young
  2011-11-16  1:25     ` Tejun Heo
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Young @ 2011-11-16  1:15 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Dave Young, gregkh, cl, linux-kernel, linux-mm

On Tue, Nov 15, 2011 at 10:49 PM, Tejun Heo <tj@kernel.org> wrote:
> On Tue, Nov 15, 2011 at 04:36:46PM +0800, Dave Young wrote:
>> per_cpu_ptr_to_phys iterate all cpu to get the phy addr
>> let's leave the caller to pass the cpu number to it.
>>
>> Actually in the only one user show_crash_notes,
>> cpunum is provided already before calling this.
>>
>> Signed-off-by: Dave Young <dyoung@redhat.com>
>
> Does this matter?  If it's not a performance critical path, I'd rather
> keep the generic funtionality.

Hi, why not? the code is redundant, it's an improvement of the code, isn't it?
Also, kernel code size will be smaller.

>
> Thanks.
>
> --
> tejun
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>



-- 
Regards
Dave

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCCH percpu: add cpunum param in per_cpu_ptr_to_phys
  2011-11-16  1:15   ` Dave Young
@ 2011-11-16  1:25     ` Tejun Heo
  0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2011-11-16  1:25 UTC (permalink / raw)
  To: Dave Young; +Cc: Dave Young, gregkh, cl, linux-kernel, linux-mm

Hello,

On Tue, Nov 15, 2011 at 5:15 PM, Dave Young <hidave.darkstar@gmail.com> wrote:
>> Does this matter?  If it's not a performance critical path, I'd rather
>> keep the generic funtionality.
>
> Hi, why not? the code is redundant, it's an improvement of the code, isn't it?
> Also, kernel code size will be smaller.

(scratching head...) Ummm... I'm not sure whether it's an improvement
or not. The contest is between loss of currently unused functionality
and meaningless optimization. I vote for status quo.

Thanks.

-- 
tejun

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2011-11-16  1:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-15  8:36 [PATCCH percpu: add cpunum param in per_cpu_ptr_to_phys Dave Young
2011-11-15 14:49 ` Tejun Heo
2011-11-16  1:15   ` Dave Young
2011-11-16  1:25     ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).