All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH kernel] powerpc: Make vmalloc_to_phys() public
@ 2016-01-21  7:35 Alexey Kardashevskiy
  2016-01-25  5:46 ` [kernel] " Michael Ellerman
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Kardashevskiy @ 2016-01-21  7:35 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Alexey Kardashevskiy, Michael Ellerman, Paul Mackerras, linux-kernel

This makes vmalloc_to_phys() public as there will be another user
(in-kernel VFIO acceleration) for it soon.

As a part of future little optimization, this changes the helper to call
vmalloc_to_pfn() instead of vmalloc_to_page() as the size of the
struct page may not be power-of-two aligned which will make gcc use
multiply instructions instead of shifts.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---

A couple of notes:

1. real_vmalloc_addr() will be reworked later by Paul separately;

2. the optimization note it not valid at the moment as
vmalloc_to_pfn() calls vmalloc_to_page() which does the actual
search; these helpers functionality will be swapped later
(also, by Paul).

---
 arch/powerpc/include/asm/pgtable.h | 3 +++
 arch/powerpc/mm/pgtable.c          | 8 ++++++++
 arch/powerpc/perf/hv-24x7.c        | 8 --------
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
index ac9fb11..47897a3 100644
--- a/arch/powerpc/include/asm/pgtable.h
+++ b/arch/powerpc/include/asm/pgtable.h
@@ -78,6 +78,9 @@ static inline pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea,
 	}
 	return __find_linux_pte_or_hugepte(pgdir, ea, is_thp, shift);
 }
+
+unsigned long vmalloc_to_phys(void *vmalloc_addr);
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* _ASM_POWERPC_PGTABLE_H */
diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
index 83dfd79..de37ff4 100644
--- a/arch/powerpc/mm/pgtable.c
+++ b/arch/powerpc/mm/pgtable.c
@@ -243,3 +243,11 @@ void assert_pte_locked(struct mm_struct *mm, unsigned long addr)
 }
 #endif /* CONFIG_DEBUG_VM */
 
+unsigned long vmalloc_to_phys(void *va)
+{
+	unsigned long pfn = vmalloc_to_pfn(va);
+
+	BUG_ON(!pfn);
+	return __pa(pfn_to_kaddr(pfn)) + offset_in_page(va);
+}
+EXPORT_SYMBOL_GPL(vmalloc_to_phys);
diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index 9f9dfda..3b09ecf 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -493,14 +493,6 @@ static size_t event_to_attr_ct(struct hv_24x7_event_data *event)
 	}
 }
 
-static unsigned long vmalloc_to_phys(void *v)
-{
-	struct page *p = vmalloc_to_page(v);
-
-	BUG_ON(!p);
-	return page_to_phys(p) + offset_in_page(v);
-}
-
 /* */
 struct event_uniq {
 	struct rb_node node;
-- 
2.5.0.rc3

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

* Re: [kernel] powerpc: Make vmalloc_to_phys() public
  2016-01-21  7:35 [PATCH kernel] powerpc: Make vmalloc_to_phys() public Alexey Kardashevskiy
@ 2016-01-25  5:46 ` Michael Ellerman
  2016-01-25  6:21   ` Anshuman Khandual
  2016-01-25 10:06   ` Paul Mackerras
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Ellerman @ 2016-01-25  5:46 UTC (permalink / raw)
  To: Alexey Kardashevskiy, linuxppc-dev
  Cc: Alexey Kardashevskiy, Paul Mackerras, linux-kernel

On Thu, 2016-21-01 at 07:35:08 UTC, Alexey Kardashevskiy wrote:
> This makes vmalloc_to_phys() public as there will be another user
> (in-kernel VFIO acceleration) for it soon.
> 
> As a part of future little optimization, this changes the helper to call
> vmalloc_to_pfn() instead of vmalloc_to_page() as the size of the
> struct page may not be power-of-two aligned which will make gcc use
> multiply instructions instead of shifts.

You should also mention why you need to export it, presumably because whatever
new user you have in mind can be built as a module.

Acked-by: Michael Ellerman <mpe@ellerman.id.au>

cheers

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

* Re: [kernel] powerpc: Make vmalloc_to_phys() public
  2016-01-25  5:46 ` [kernel] " Michael Ellerman
@ 2016-01-25  6:21   ` Anshuman Khandual
  2016-01-25 10:06   ` Paul Mackerras
  1 sibling, 0 replies; 5+ messages in thread
From: Anshuman Khandual @ 2016-01-25  6:21 UTC (permalink / raw)
  To: Michael Ellerman, Alexey Kardashevskiy, linuxppc-dev
  Cc: Paul Mackerras, linux-kernel

On 01/25/2016 11:16 AM, Michael Ellerman wrote:
> On Thu, 2016-21-01 at 07:35:08 UTC, Alexey Kardashevskiy wrote:
>> > This makes vmalloc_to_phys() public as there will be another user
>> > (in-kernel VFIO acceleration) for it soon.
>> > 
>> > As a part of future little optimization, this changes the helper to call
>> > vmalloc_to_pfn() instead of vmalloc_to_page() as the size of the
>> > struct page may not be power-of-two aligned which will make gcc use
>> > multiply instructions instead of shifts.
> You should also mention why you need to export it, presumably because whatever
> new user you have in mind can be built as a module.

Unless the change specifically mentions about the use case, there
are a tons of static helper functions which can be exported to public
for module usage. Ideally this change should be part of the series
which actually needs the helper function to be available in public
not a stand alone one.

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

* Re: [kernel] powerpc: Make vmalloc_to_phys() public
  2016-01-25  5:46 ` [kernel] " Michael Ellerman
  2016-01-25  6:21   ` Anshuman Khandual
@ 2016-01-25 10:06   ` Paul Mackerras
  2016-01-27  3:19     ` Alexey Kardashevskiy
  1 sibling, 1 reply; 5+ messages in thread
From: Paul Mackerras @ 2016-01-25 10:06 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Alexey Kardashevskiy, linuxppc-dev, linux-kernel

On Mon, Jan 25, 2016 at 04:46:03PM +1100, Michael Ellerman wrote:
> On Thu, 2016-21-01 at 07:35:08 UTC, Alexey Kardashevskiy wrote:
> > This makes vmalloc_to_phys() public as there will be another user
> > (in-kernel VFIO acceleration) for it soon.
> > 
> > As a part of future little optimization, this changes the helper to call
> > vmalloc_to_pfn() instead of vmalloc_to_page() as the size of the
> > struct page may not be power-of-two aligned which will make gcc use
> > multiply instructions instead of shifts.
> 
> You should also mention why you need to export it, presumably because whatever
> new user you have in mind can be built as a module.

If I remember correctly, it's the *existing* user in hv-24x7.c that
needs the export.

Paul.

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

* Re: [kernel] powerpc: Make vmalloc_to_phys() public
  2016-01-25 10:06   ` Paul Mackerras
@ 2016-01-27  3:19     ` Alexey Kardashevskiy
  0 siblings, 0 replies; 5+ messages in thread
From: Alexey Kardashevskiy @ 2016-01-27  3:19 UTC (permalink / raw)
  To: Paul Mackerras, Michael Ellerman; +Cc: linuxppc-dev, linux-kernel

On 01/25/2016 09:06 PM, Paul Mackerras wrote:
> On Mon, Jan 25, 2016 at 04:46:03PM +1100, Michael Ellerman wrote:
>> On Thu, 2016-21-01 at 07:35:08 UTC, Alexey Kardashevskiy wrote:
>>> This makes vmalloc_to_phys() public as there will be another user
>>> (in-kernel VFIO acceleration) for it soon.
>>>
>>> As a part of future little optimization, this changes the helper to call
>>> vmalloc_to_pfn() instead of vmalloc_to_page() as the size of the
>>> struct page may not be power-of-two aligned which will make gcc use
>>> multiply instructions instead of shifts.
>>
>> You should also mention why you need to export it, presumably because whatever
>> new user you have in mind can be built as a module.
>
> If I remember correctly, it's the *existing* user in hv-24x7.c that
> needs the export.

No, CONFIG_HV_PERF_CTRS (which controls hv-24x7.c) is "bool" so today 
hv-24x7.c cannot compile as a module.

This exports the vmalloc_to_phys() symbol as a new user is going to be KVM 
which can compile as a module.


-- 
Alexey

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

end of thread, other threads:[~2016-01-27  3:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-21  7:35 [PATCH kernel] powerpc: Make vmalloc_to_phys() public Alexey Kardashevskiy
2016-01-25  5:46 ` [kernel] " Michael Ellerman
2016-01-25  6:21   ` Anshuman Khandual
2016-01-25 10:06   ` Paul Mackerras
2016-01-27  3:19     ` Alexey Kardashevskiy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.