* [RFC PATCH] powerpc/64s/radix: introduce option to disable broadcast tlbie
From: Nicholas Piggin @ 2019-07-31 12:32 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Aneesh Kumar K . V, Paul Mackerras, Nicholas Piggin
This is an initial hack of a quick option to disable use of the tlbie
instruction. This takes the simplest possible initial pass of just
replacing low level tlbie functions with IPIs. This means it's not as
performant as it could be if we spend some time optmizing it, but on
the other hand having a 1:1 replacement of tlbie is simple and can be
useful for comparisons so I think it's the right initial approach.
It's not entirely complete, doesn't deal with accelerators (reverts to
tlbie), not all the boot code is converted, kernel space invalidations
not converted, and KVM not converted, also radix only to start with. We
can start to add more cases if this will be useful.
Thanks,
Nick
---
arch/powerpc/mm/book3s64/radix_tlb.c | 149 +++++++++++++++++++++++++--
1 file changed, 140 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/mm/book3s64/radix_tlb.c b/arch/powerpc/mm/book3s64/radix_tlb.c
index 71f7fede2fa4..56ceecbd3d5c 100644
--- a/arch/powerpc/mm/book3s64/radix_tlb.c
+++ b/arch/powerpc/mm/book3s64/radix_tlb.c
@@ -11,6 +11,7 @@
#include <linux/mmu_context.h>
#include <linux/sched/mm.h>
+#include <asm/debugfs.h>
#include <asm/ppc-opcode.h>
#include <asm/tlb.h>
#include <asm/tlbflush.h>
@@ -285,6 +286,30 @@ static inline void _tlbie_pid(unsigned long pid, unsigned long ric)
asm volatile("eieio; tlbsync; ptesync": : :"memory");
}
+struct tlbiel_pid {
+ unsigned long pid;
+ unsigned long ric;
+};
+
+static void do_tlbiel_pid(void *info)
+{
+ struct tlbiel_pid *t = info;
+
+ if (t->ric == RIC_FLUSH_TLB)
+ _tlbiel_pid(t->pid, RIC_FLUSH_TLB);
+ else if (t->ric == RIC_FLUSH_PWC)
+ _tlbiel_pid(t->pid, RIC_FLUSH_PWC);
+ else
+ _tlbiel_pid(t->pid, RIC_FLUSH_ALL);
+}
+
+static inline void _tlbiel_pid_broadcast(const struct cpumask *cpus,
+ unsigned long pid, unsigned long ric)
+{
+ struct tlbiel_pid t = { .pid = pid, .ric = ric };
+ on_each_cpu_mask(cpus, do_tlbiel_pid, &t, 1);
+}
+
static inline void _tlbiel_lpid(unsigned long lpid, unsigned long ric)
{
int set;
@@ -420,6 +445,61 @@ static __always_inline void _tlbie_va(unsigned long va, unsigned long pid,
asm volatile("eieio; tlbsync; ptesync": : :"memory");
}
+struct tlbiel_va {
+ unsigned long pid;
+ unsigned long va;
+ unsigned long psize;
+ unsigned long ric;
+};
+
+static void do_tlbiel_va(void *info)
+{
+ struct tlbiel_va *t = info;
+
+ if (t->ric == RIC_FLUSH_TLB)
+ _tlbiel_va(t->va, t->pid, t->psize, RIC_FLUSH_TLB);
+ else if (t->ric == RIC_FLUSH_PWC)
+ _tlbiel_va(t->va, t->pid, t->psize, RIC_FLUSH_PWC);
+ else
+ _tlbiel_va(t->va, t->pid, t->psize, RIC_FLUSH_ALL);
+}
+
+static inline void _tlbiel_va_broadcast(const struct cpumask *cpus,
+ unsigned long va, unsigned long pid,
+ unsigned long psize, unsigned long ric)
+{
+ struct tlbiel_va t = { .va = va, .pid = pid, .psize = psize, .ric = ric };
+ on_each_cpu_mask(cpus, do_tlbiel_va, &t, 1);
+}
+
+struct tlbiel_va_range {
+ unsigned long pid;
+ unsigned long start;
+ unsigned long end;
+ unsigned long page_size;
+ unsigned long psize;
+ bool also_pwc;
+};
+
+static void do_tlbiel_va_range(void *info)
+{
+ struct tlbiel_va_range *t = info;
+
+ _tlbiel_va_range(t->start, t->end, t->pid, t->page_size,
+ t->psize, t->also_pwc);
+}
+
+static inline void _tlbiel_va_range_broadcast(const struct cpumask *cpus,
+ unsigned long start, unsigned long end,
+ unsigned long pid, unsigned long page_size,
+ unsigned long psize, bool also_pwc)
+{
+ struct tlbiel_va_range t = { .start = start, .end = end,
+ .pid = pid, .page_size = page_size,
+ .psize = psize, .also_pwc = also_pwc };
+ on_each_cpu_mask(cpus, do_tlbiel_va_range, &t, 1);
+}
+
static __always_inline void _tlbie_lpid_va(unsigned long va, unsigned long lpid,
unsigned long psize, unsigned long ric)
{
@@ -524,6 +604,12 @@ static bool mm_needs_flush_escalation(struct mm_struct *mm)
return false;
}
+static bool tlbie_enabled = true;
+static bool use_tlbie(void)
+{
+ return tlbie_enabled;
+}
+
#ifdef CONFIG_SMP
static void do_exit_flush_lazy_tlb(void *arg)
{
@@ -582,8 +668,10 @@ void radix__flush_tlb_mm(struct mm_struct *mm)
if (mm_needs_flush_escalation(mm))
_tlbie_pid(pid, RIC_FLUSH_ALL);
- else
+ else if (use_tlbie())
_tlbie_pid(pid, RIC_FLUSH_TLB);
+ else
+ _tlbiel_pid_broadcast(mm_cpumask(mm), pid, RIC_FLUSH_TLB);
} else {
local:
_tlbiel_pid(pid, RIC_FLUSH_TLB);
@@ -609,7 +697,10 @@ static void __flush_all_mm(struct mm_struct *mm, bool fullmm)
goto local;
}
}
- _tlbie_pid(pid, RIC_FLUSH_ALL);
+ if (mm_needs_flush_escalation(mm) || use_tlbie())
+ _tlbie_pid(pid, RIC_FLUSH_ALL);
+ else
+ _tlbiel_pid_broadcast(mm_cpumask(mm), pid, RIC_FLUSH_ALL);
} else {
local:
_tlbiel_pid(pid, RIC_FLUSH_ALL);
@@ -644,7 +735,11 @@ void radix__flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmaddr,
exit_flush_lazy_tlbs(mm);
goto local;
}
- _tlbie_va(vmaddr, pid, psize, RIC_FLUSH_TLB);
+ if (mm_needs_flush_escalation(mm) || use_tlbie())
+ _tlbie_va(vmaddr, pid, psize, RIC_FLUSH_TLB);
+ else
+ _tlbiel_va_broadcast(mm_cpumask(mm),
+ vmaddr, pid, psize, RIC_FLUSH_TLB);
} else {
local:
_tlbiel_va(vmaddr, pid, psize, RIC_FLUSH_TLB);
@@ -731,8 +826,11 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm,
} else {
if (mm_needs_flush_escalation(mm))
_tlbie_pid(pid, RIC_FLUSH_ALL);
- else
+ else if (use_tlbie())
_tlbie_pid(pid, RIC_FLUSH_TLB);
+ else
+ _tlbiel_pid_broadcast(mm_cpumask(mm),
+ pid, RIC_FLUSH_TLB);
}
} else {
bool hflush = flush_all_sizes;
@@ -757,8 +855,8 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm,
gflush = false;
}
- asm volatile("ptesync": : :"memory");
if (local) {
+ asm volatile("ptesync": : :"memory");
__tlbiel_va_range(start, end, pid, page_size, mmu_virtual_psize);
if (hflush)
__tlbiel_va_range(hstart, hend, pid,
@@ -767,7 +865,8 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm,
__tlbiel_va_range(gstart, gend, pid,
PUD_SIZE, MMU_PAGE_1G);
asm volatile("ptesync": : :"memory");
- } else {
+ } else if (use_tlbie()) {
+ asm volatile("ptesync": : :"memory");
__tlbie_va_range(start, end, pid, page_size, mmu_virtual_psize);
if (hflush)
__tlbie_va_range(hstart, hend, pid,
@@ -777,6 +876,15 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm,
PUD_SIZE, MMU_PAGE_1G);
fixup_tlbie();
asm volatile("eieio; tlbsync; ptesync": : :"memory");
+ } else {
+ _tlbiel_va_range_broadcast(mm_cpumask(mm),
+ start, end, pid, page_size, mmu_virtual_psize, false);
+ if (hflush)
+ _tlbiel_va_range_broadcast(mm_cpumask(mm),
+ hstart, hend, pid, PMD_SIZE, MMU_PAGE_2M, false);
+ if (gflush)
+ _tlbiel_va_range_broadcast(mm_cpumask(mm),
+ gstart, gend, pid, PUD_SIZE, MMU_PAGE_1G, false);
}
}
preempt_enable();
@@ -969,13 +1077,22 @@ static __always_inline void __radix__flush_tlb_range_psize(struct mm_struct *mm,
if (mm_needs_flush_escalation(mm))
also_pwc = true;
- _tlbie_pid(pid, also_pwc ? RIC_FLUSH_ALL : RIC_FLUSH_TLB);
+ if (use_tlbie())
+ _tlbie_pid(pid,
+ also_pwc ? RIC_FLUSH_ALL : RIC_FLUSH_TLB);
+ else
+ _tlbiel_pid_broadcast(mm_cpumask(mm), pid,
+ also_pwc ? RIC_FLUSH_ALL : RIC_FLUSH_TLB);
+
}
} else {
if (local)
_tlbiel_va_range(start, end, pid, page_size, psize, also_pwc);
- else
+ else if (mm_needs_flush_escalation(mm) || use_tlbie())
_tlbie_va_range(start, end, pid, page_size, psize, also_pwc);
+ else
+ _tlbiel_va_range_broadcast(mm_cpumask(mm),
+ start, end, pid, page_size, psize, also_pwc);
}
preempt_enable();
}
@@ -1017,7 +1134,11 @@ void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr)
exit_flush_lazy_tlbs(mm);
goto local;
}
- _tlbie_va_range(addr, end, pid, PAGE_SIZE, mmu_virtual_psize, true);
+ if (mm_needs_flush_escalation(mm) || use_tlbie())
+ _tlbie_va_range(addr, end, pid, PAGE_SIZE, mmu_virtual_psize, true);
+ else
+ _tlbiel_va_range_broadcast(mm_cpumask(mm),
+ addr, end, pid, PAGE_SIZE, mmu_virtual_psize, true);
} else {
local:
_tlbiel_va_range(addr, end, pid, PAGE_SIZE, mmu_virtual_psize, true);
@@ -1100,3 +1221,13 @@ extern void radix_kvm_prefetch_workaround(struct mm_struct *mm)
}
EXPORT_SYMBOL_GPL(radix_kvm_prefetch_workaround);
#endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
+
+static int __init radix_tlb_setup(void)
+{
+ debugfs_create_bool("tlbie_enabled", 0600,
+ powerpc_debugfs_root,
+ &tlbie_enabled);
+
+ return 0;
+}
+arch_initcall(radix_tlb_setup);
--
2.22.0
^ permalink raw reply related
* microblaze HAVE_MEMBLOCK_NODE_MAP dependency (was Re: [PATCH v2 0/5] mm: Enable CONFIG_NODES_SPAN_OTHER_NODES by default for NUMA)
From: Michal Hocko @ 2019-07-31 13:00 UTC (permalink / raw)
To: Mike Rapoport
Cc: Heiko Carstens, open list:MEMORY MANAGEMENT, Paul Mackerras,
H . Peter Anvin, sparclinux@vger.kernel.org, Alexander Duyck,
Will Deacon, linux-s390@vger.kernel.org, x86@kernel.org,
willy@infradead.org, Christian Borntraeger, Ingo Molnar,
Hoan Tran OS, Catalin Marinas, Open Source Submission,
Pavel Tatashin, Vasily Gorbik, Will Deacon, Borislav Petkov,
Thomas Gleixner, Vlastimil Babka, Oscar Salvador,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Andrew Morton,
linuxppc-dev@lists.ozlabs.org, David S . Miller
In-Reply-To: <20190731122631.GB14538@rapoport-lnx>
On Wed 31-07-19 15:26:32, Mike Rapoport wrote:
> On Wed, Jul 31, 2019 at 01:40:16PM +0200, Michal Hocko wrote:
> > On Wed 31-07-19 14:14:22, Mike Rapoport wrote:
> > > On Wed, Jul 31, 2019 at 10:03:09AM +0200, Michal Hocko wrote:
> > > > On Wed 31-07-19 09:24:21, Mike Rapoport wrote:
> > > > > [ sorry for a late reply too, somehow I missed this thread before ]
> > > > >
> > > > > On Tue, Jul 30, 2019 at 10:14:15AM +0200, Michal Hocko wrote:
> > > > > > [Sorry for a late reply]
> > > > > >
> > > > > > On Mon 15-07-19 17:55:07, Hoan Tran OS wrote:
> > > > > > > Hi,
> > > > > > >
> > > > > > > On 7/12/19 10:00 PM, Michal Hocko wrote:
> > > > > > [...]
> > > > > > > > Hmm, I thought this was selectable. But I am obviously wrong here.
> > > > > > > > Looking more closely, it seems that this is indeed only about
> > > > > > > > __early_pfn_to_nid and as such not something that should add a config
> > > > > > > > symbol. This should have been called out in the changelog though.
> > > > > > >
> > > > > > > Yes, do you have any other comments about my patch?
> > > > > >
> > > > > > Not really. Just make sure to explicitly state that
> > > > > > CONFIG_NODES_SPAN_OTHER_NODES is only about __early_pfn_to_nid and that
> > > > > > doesn't really deserve it's own config and can be pulled under NUMA.
> > > > > >
> > > > > > > > Also while at it, does HAVE_MEMBLOCK_NODE_MAP fall into a similar
> > > > > > > > bucket? Do we have any NUMA architecture that doesn't enable it?
> > > > > > > >
> > > > >
> > > > > HAVE_MEMBLOCK_NODE_MAP makes huge difference in node/zone initialization
> > > > > sequence so it's not only about a singe function.
> > > >
> > > > The question is whether we want to have this a config option or enable
> > > > it unconditionally for each NUMA system.
> > >
> > > We can make it 'default NUMA', but we can't drop it completely because
> > > microblaze uses sparse_memory_present_with_active_regions() which is
> > > unavailable when HAVE_MEMBLOCK_NODE_MAP=n.
> >
> > I suppose you mean that microblaze is using
> > sparse_memory_present_with_active_regions even without CONFIG_NUMA,
> > right?
>
> Yes.
>
> > I have to confess I do not understand that code. What is the deal
> > with setting node id there?
>
> The sparse_memory_present_with_active_regions() iterates over
> memblock.memory regions and uses the node id of each region as the
> parameter to memory_present(). The assumption here is that sometime before
> each region was assigned a proper non-negative node id.
>
> microblaze uses device tree for memory enumeration and the current FDT code
> does memblock_add() that implicitly sets nid in memblock.memory regions to -1.
>
> So in order to have proper node id passed to memory_present() microblaze
> has to call memblock_set_node() before it can use
> sparse_memory_present_with_active_regions().
I am sorry, but I still do not follow. Who is consuming that node id
information when NUMA=n. In other words why cannot we simply do
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index a015a951c8b7..3a47e8db8d1c 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -175,14 +175,9 @@ void __init setup_memory(void)
start_pfn = memblock_region_memory_base_pfn(reg);
end_pfn = memblock_region_memory_end_pfn(reg);
- memblock_set_node(start_pfn << PAGE_SHIFT,
- (end_pfn - start_pfn) << PAGE_SHIFT,
- &memblock.memory, 0);
+ memory_present(0, start_pfn << PAGE_SHIFT, end_pfn << PAGE_SHIFT);
}
- /* XXX need to clip this if using highmem? */
- sparse_memory_present_with_active_regions(0);
-
paging_init();
}
--
Michal Hocko
SUSE Labs
^ permalink raw reply related
* [Bug 204375] kernel 5.2.4 w. KASAN enabled fails to boot on a PowerMac G4 3,6 at very early stage
From: bugzilla-daemon @ 2019-07-31 13:11 UTC (permalink / raw)
To: linuxppc-dev
In-Reply-To: <bug-204375-206035@https.bugzilla.kernel.org/>
https://bugzilla.kernel.org/show_bug.cgi?id=204375
--- Comment #11 from Erhard F. (erhard_f@mailbox.org) ---
I opened bug #204397 with your output.
The G4 DP won't boot to a stage where I can get a dmesg, even if waiting for 10
minutes.
--
You are receiving this mail because:
You are watching the assignee of the bug.
^ permalink raw reply
* Re: [RFC PATCH] powerpc/64s/radix: introduce option to disable broadcast tlbie
From: Christophe Leroy @ 2019-07-31 13:56 UTC (permalink / raw)
To: Nicholas Piggin, linuxppc-dev; +Cc: Aneesh Kumar K . V, Paul Mackerras
In-Reply-To: <20190731123203.6370-1-npiggin@gmail.com>
Le 31/07/2019 à 14:32, Nicholas Piggin a écrit :
> This is an initial hack of a quick option to disable use of the tlbie
> instruction. This takes the simplest possible initial pass of just
> replacing low level tlbie functions with IPIs. This means it's not as
> performant as it could be if we spend some time optmizing it, but on
> the other hand having a 1:1 replacement of tlbie is simple and can be
> useful for comparisons so I think it's the right initial approach.
Can you explain why we want to optionnaly disable use of tlbie ?
Christophe
>
> It's not entirely complete, doesn't deal with accelerators (reverts to
> tlbie), not all the boot code is converted, kernel space invalidations
> not converted, and KVM not converted, also radix only to start with. We
> can start to add more cases if this will be useful.
>
> Thanks,
> Nick
> ---
> arch/powerpc/mm/book3s64/radix_tlb.c | 149 +++++++++++++++++++++++++--
> 1 file changed, 140 insertions(+), 9 deletions(-)
>
> diff --git a/arch/powerpc/mm/book3s64/radix_tlb.c b/arch/powerpc/mm/book3s64/radix_tlb.c
> index 71f7fede2fa4..56ceecbd3d5c 100644
> --- a/arch/powerpc/mm/book3s64/radix_tlb.c
> +++ b/arch/powerpc/mm/book3s64/radix_tlb.c
> @@ -11,6 +11,7 @@
> #include <linux/mmu_context.h>
> #include <linux/sched/mm.h>
>
> +#include <asm/debugfs.h>
> #include <asm/ppc-opcode.h>
> #include <asm/tlb.h>
> #include <asm/tlbflush.h>
> @@ -285,6 +286,30 @@ static inline void _tlbie_pid(unsigned long pid, unsigned long ric)
> asm volatile("eieio; tlbsync; ptesync": : :"memory");
> }
>
> +struct tlbiel_pid {
> + unsigned long pid;
> + unsigned long ric;
> +};
> +
> +static void do_tlbiel_pid(void *info)
> +{
> + struct tlbiel_pid *t = info;
> +
> + if (t->ric == RIC_FLUSH_TLB)
> + _tlbiel_pid(t->pid, RIC_FLUSH_TLB);
> + else if (t->ric == RIC_FLUSH_PWC)
> + _tlbiel_pid(t->pid, RIC_FLUSH_PWC);
> + else
> + _tlbiel_pid(t->pid, RIC_FLUSH_ALL);
> +}
> +
> +static inline void _tlbiel_pid_broadcast(const struct cpumask *cpus,
> + unsigned long pid, unsigned long ric)
> +{
> + struct tlbiel_pid t = { .pid = pid, .ric = ric };
> + on_each_cpu_mask(cpus, do_tlbiel_pid, &t, 1);
> +}
> +
> static inline void _tlbiel_lpid(unsigned long lpid, unsigned long ric)
> {
> int set;
> @@ -420,6 +445,61 @@ static __always_inline void _tlbie_va(unsigned long va, unsigned long pid,
> asm volatile("eieio; tlbsync; ptesync": : :"memory");
> }
>
> +struct tlbiel_va {
> + unsigned long pid;
> + unsigned long va;
> + unsigned long psize;
> + unsigned long ric;
> +};
> +
> +static void do_tlbiel_va(void *info)
> +{
> + struct tlbiel_va *t = info;
> +
> + if (t->ric == RIC_FLUSH_TLB)
> + _tlbiel_va(t->va, t->pid, t->psize, RIC_FLUSH_TLB);
> + else if (t->ric == RIC_FLUSH_PWC)
> + _tlbiel_va(t->va, t->pid, t->psize, RIC_FLUSH_PWC);
> + else
> + _tlbiel_va(t->va, t->pid, t->psize, RIC_FLUSH_ALL);
> +}
> +
> +static inline void _tlbiel_va_broadcast(const struct cpumask *cpus,
> + unsigned long va, unsigned long pid,
> + unsigned long psize, unsigned long ric)
> +{
> + struct tlbiel_va t = { .va = va, .pid = pid, .psize = psize, .ric = ric };
> + on_each_cpu_mask(cpus, do_tlbiel_va, &t, 1);
> +}
> +
> +struct tlbiel_va_range {
> + unsigned long pid;
> + unsigned long start;
> + unsigned long end;
> + unsigned long page_size;
> + unsigned long psize;
> + bool also_pwc;
> +};
> +
> +static void do_tlbiel_va_range(void *info)
> +{
> + struct tlbiel_va_range *t = info;
> +
> + _tlbiel_va_range(t->start, t->end, t->pid, t->page_size,
> + t->psize, t->also_pwc);
> +}
> +
> +static inline void _tlbiel_va_range_broadcast(const struct cpumask *cpus,
> + unsigned long start, unsigned long end,
> + unsigned long pid, unsigned long page_size,
> + unsigned long psize, bool also_pwc)
> +{
> + struct tlbiel_va_range t = { .start = start, .end = end,
> + .pid = pid, .page_size = page_size,
> + .psize = psize, .also_pwc = also_pwc };
> + on_each_cpu_mask(cpus, do_tlbiel_va_range, &t, 1);
> +}
> +
> static __always_inline void _tlbie_lpid_va(unsigned long va, unsigned long lpid,
> unsigned long psize, unsigned long ric)
> {
> @@ -524,6 +604,12 @@ static bool mm_needs_flush_escalation(struct mm_struct *mm)
> return false;
> }
>
> +static bool tlbie_enabled = true;
> +static bool use_tlbie(void)
> +{
> + return tlbie_enabled;
> +}
> +
> #ifdef CONFIG_SMP
> static void do_exit_flush_lazy_tlb(void *arg)
> {
> @@ -582,8 +668,10 @@ void radix__flush_tlb_mm(struct mm_struct *mm)
>
> if (mm_needs_flush_escalation(mm))
> _tlbie_pid(pid, RIC_FLUSH_ALL);
> - else
> + else if (use_tlbie())
> _tlbie_pid(pid, RIC_FLUSH_TLB);
> + else
> + _tlbiel_pid_broadcast(mm_cpumask(mm), pid, RIC_FLUSH_TLB);
> } else {
> local:
> _tlbiel_pid(pid, RIC_FLUSH_TLB);
> @@ -609,7 +697,10 @@ static void __flush_all_mm(struct mm_struct *mm, bool fullmm)
> goto local;
> }
> }
> - _tlbie_pid(pid, RIC_FLUSH_ALL);
> + if (mm_needs_flush_escalation(mm) || use_tlbie())
> + _tlbie_pid(pid, RIC_FLUSH_ALL);
> + else
> + _tlbiel_pid_broadcast(mm_cpumask(mm), pid, RIC_FLUSH_ALL);
> } else {
> local:
> _tlbiel_pid(pid, RIC_FLUSH_ALL);
> @@ -644,7 +735,11 @@ void radix__flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmaddr,
> exit_flush_lazy_tlbs(mm);
> goto local;
> }
> - _tlbie_va(vmaddr, pid, psize, RIC_FLUSH_TLB);
> + if (mm_needs_flush_escalation(mm) || use_tlbie())
> + _tlbie_va(vmaddr, pid, psize, RIC_FLUSH_TLB);
> + else
> + _tlbiel_va_broadcast(mm_cpumask(mm),
> + vmaddr, pid, psize, RIC_FLUSH_TLB);
> } else {
> local:
> _tlbiel_va(vmaddr, pid, psize, RIC_FLUSH_TLB);
> @@ -731,8 +826,11 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm,
> } else {
> if (mm_needs_flush_escalation(mm))
> _tlbie_pid(pid, RIC_FLUSH_ALL);
> - else
> + else if (use_tlbie())
> _tlbie_pid(pid, RIC_FLUSH_TLB);
> + else
> + _tlbiel_pid_broadcast(mm_cpumask(mm),
> + pid, RIC_FLUSH_TLB);
> }
> } else {
> bool hflush = flush_all_sizes;
> @@ -757,8 +855,8 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm,
> gflush = false;
> }
>
> - asm volatile("ptesync": : :"memory");
> if (local) {
> + asm volatile("ptesync": : :"memory");
> __tlbiel_va_range(start, end, pid, page_size, mmu_virtual_psize);
> if (hflush)
> __tlbiel_va_range(hstart, hend, pid,
> @@ -767,7 +865,8 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm,
> __tlbiel_va_range(gstart, gend, pid,
> PUD_SIZE, MMU_PAGE_1G);
> asm volatile("ptesync": : :"memory");
> - } else {
> + } else if (use_tlbie()) {
> + asm volatile("ptesync": : :"memory");
> __tlbie_va_range(start, end, pid, page_size, mmu_virtual_psize);
> if (hflush)
> __tlbie_va_range(hstart, hend, pid,
> @@ -777,6 +876,15 @@ static inline void __radix__flush_tlb_range(struct mm_struct *mm,
> PUD_SIZE, MMU_PAGE_1G);
> fixup_tlbie();
> asm volatile("eieio; tlbsync; ptesync": : :"memory");
> + } else {
> + _tlbiel_va_range_broadcast(mm_cpumask(mm),
> + start, end, pid, page_size, mmu_virtual_psize, false);
> + if (hflush)
> + _tlbiel_va_range_broadcast(mm_cpumask(mm),
> + hstart, hend, pid, PMD_SIZE, MMU_PAGE_2M, false);
> + if (gflush)
> + _tlbiel_va_range_broadcast(mm_cpumask(mm),
> + gstart, gend, pid, PUD_SIZE, MMU_PAGE_1G, false);
> }
> }
> preempt_enable();
> @@ -969,13 +1077,22 @@ static __always_inline void __radix__flush_tlb_range_psize(struct mm_struct *mm,
> if (mm_needs_flush_escalation(mm))
> also_pwc = true;
>
> - _tlbie_pid(pid, also_pwc ? RIC_FLUSH_ALL : RIC_FLUSH_TLB);
> + if (use_tlbie())
> + _tlbie_pid(pid,
> + also_pwc ? RIC_FLUSH_ALL : RIC_FLUSH_TLB);
> + else
> + _tlbiel_pid_broadcast(mm_cpumask(mm), pid,
> + also_pwc ? RIC_FLUSH_ALL : RIC_FLUSH_TLB);
> +
> }
> } else {
> if (local)
> _tlbiel_va_range(start, end, pid, page_size, psize, also_pwc);
> - else
> + else if (mm_needs_flush_escalation(mm) || use_tlbie())
> _tlbie_va_range(start, end, pid, page_size, psize, also_pwc);
> + else
> + _tlbiel_va_range_broadcast(mm_cpumask(mm),
> + start, end, pid, page_size, psize, also_pwc);
> }
> preempt_enable();
> }
> @@ -1017,7 +1134,11 @@ void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr)
> exit_flush_lazy_tlbs(mm);
> goto local;
> }
> - _tlbie_va_range(addr, end, pid, PAGE_SIZE, mmu_virtual_psize, true);
> + if (mm_needs_flush_escalation(mm) || use_tlbie())
> + _tlbie_va_range(addr, end, pid, PAGE_SIZE, mmu_virtual_psize, true);
> + else
> + _tlbiel_va_range_broadcast(mm_cpumask(mm),
> + addr, end, pid, PAGE_SIZE, mmu_virtual_psize, true);
> } else {
> local:
> _tlbiel_va_range(addr, end, pid, PAGE_SIZE, mmu_virtual_psize, true);
> @@ -1100,3 +1221,13 @@ extern void radix_kvm_prefetch_workaround(struct mm_struct *mm)
> }
> EXPORT_SYMBOL_GPL(radix_kvm_prefetch_workaround);
> #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
> +
> +static int __init radix_tlb_setup(void)
> +{
> + debugfs_create_bool("tlbie_enabled", 0600,
> + powerpc_debugfs_root,
> + &tlbie_enabled);
> +
> + return 0;
> +}
> +arch_initcall(radix_tlb_setup);
>
^ permalink raw reply
* Re: microblaze HAVE_MEMBLOCK_NODE_MAP dependency (was Re: [PATCH v2 0/5] mm: Enable CONFIG_NODES_SPAN_OTHER_NODES by default for NUMA)
From: Mike Rapoport @ 2019-07-31 14:21 UTC (permalink / raw)
To: Michal Hocko
Cc: Heiko Carstens, open list:MEMORY MANAGEMENT, Paul Mackerras,
H . Peter Anvin, sparclinux@vger.kernel.org, Alexander Duyck,
Will Deacon, linux-s390@vger.kernel.org, x86@kernel.org,
willy@infradead.org, Christian Borntraeger, Ingo Molnar,
Hoan Tran OS, Catalin Marinas, Open Source Submission,
Pavel Tatashin, Vasily Gorbik, Will Deacon, Borislav Petkov,
Thomas Gleixner, Vlastimil Babka, Oscar Salvador,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Andrew Morton,
linuxppc-dev@lists.ozlabs.org, David S . Miller
In-Reply-To: <20190731130037.GN9330@dhcp22.suse.cz>
On Wed, Jul 31, 2019 at 03:00:37PM +0200, Michal Hocko wrote:
> On Wed 31-07-19 15:26:32, Mike Rapoport wrote:
> > On Wed, Jul 31, 2019 at 01:40:16PM +0200, Michal Hocko wrote:
> > > On Wed 31-07-19 14:14:22, Mike Rapoport wrote:
> > > > On Wed, Jul 31, 2019 at 10:03:09AM +0200, Michal Hocko wrote:
> > > > > On Wed 31-07-19 09:24:21, Mike Rapoport wrote:
> > > > > > [ sorry for a late reply too, somehow I missed this thread before ]
> > > > > >
> > > > > > On Tue, Jul 30, 2019 at 10:14:15AM +0200, Michal Hocko wrote:
> > > > > > > [Sorry for a late reply]
> > > > > > >
> > > > > > > On Mon 15-07-19 17:55:07, Hoan Tran OS wrote:
> > > > > > > > Hi,
> > > > > > > >
> > > > > > > > On 7/12/19 10:00 PM, Michal Hocko wrote:
> > > > > > > [...]
> > > > > > > > > Hmm, I thought this was selectable. But I am obviously wrong here.
> > > > > > > > > Looking more closely, it seems that this is indeed only about
> > > > > > > > > __early_pfn_to_nid and as such not something that should add a config
> > > > > > > > > symbol. This should have been called out in the changelog though.
> > > > > > > >
> > > > > > > > Yes, do you have any other comments about my patch?
> > > > > > >
> > > > > > > Not really. Just make sure to explicitly state that
> > > > > > > CONFIG_NODES_SPAN_OTHER_NODES is only about __early_pfn_to_nid and that
> > > > > > > doesn't really deserve it's own config and can be pulled under NUMA.
> > > > > > >
> > > > > > > > > Also while at it, does HAVE_MEMBLOCK_NODE_MAP fall into a similar
> > > > > > > > > bucket? Do we have any NUMA architecture that doesn't enable it?
> > > > > > > > >
> > > > > >
> > > > > > HAVE_MEMBLOCK_NODE_MAP makes huge difference in node/zone initialization
> > > > > > sequence so it's not only about a singe function.
> > > > >
> > > > > The question is whether we want to have this a config option or enable
> > > > > it unconditionally for each NUMA system.
> > > >
> > > > We can make it 'default NUMA', but we can't drop it completely because
> > > > microblaze uses sparse_memory_present_with_active_regions() which is
> > > > unavailable when HAVE_MEMBLOCK_NODE_MAP=n.
> > >
> > > I suppose you mean that microblaze is using
> > > sparse_memory_present_with_active_regions even without CONFIG_NUMA,
> > > right?
> >
> > Yes.
> >
> > > I have to confess I do not understand that code. What is the deal
> > > with setting node id there?
> >
> > The sparse_memory_present_with_active_regions() iterates over
> > memblock.memory regions and uses the node id of each region as the
> > parameter to memory_present(). The assumption here is that sometime before
> > each region was assigned a proper non-negative node id.
> >
> > microblaze uses device tree for memory enumeration and the current FDT code
> > does memblock_add() that implicitly sets nid in memblock.memory regions to -1.
> >
> > So in order to have proper node id passed to memory_present() microblaze
> > has to call memblock_set_node() before it can use
> > sparse_memory_present_with_active_regions().
>
> I am sorry, but I still do not follow. Who is consuming that node id
> information when NUMA=n. In other words why cannot we simply do
We can, I think nobody cared to change it.
> diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
> index a015a951c8b7..3a47e8db8d1c 100644
> --- a/arch/microblaze/mm/init.c
> +++ b/arch/microblaze/mm/init.c
> @@ -175,14 +175,9 @@ void __init setup_memory(void)
>
> start_pfn = memblock_region_memory_base_pfn(reg);
> end_pfn = memblock_region_memory_end_pfn(reg);
> - memblock_set_node(start_pfn << PAGE_SHIFT,
> - (end_pfn - start_pfn) << PAGE_SHIFT,
> - &memblock.memory, 0);
> + memory_present(0, start_pfn << PAGE_SHIFT, end_pfn << PAGE_SHIFT);
memory_present() expects pfns, the shift is not needed.
> }
>
> - /* XXX need to clip this if using highmem? */
> - sparse_memory_present_with_active_regions(0);
> -
> paging_init();
> }
>
> --
> Michal Hocko
> SUSE Labs
--
Sincerely yours,
Mike.
^ permalink raw reply
* Re: microblaze HAVE_MEMBLOCK_NODE_MAP dependency (was Re: [PATCH v2 0/5] mm: Enable CONFIG_NODES_SPAN_OTHER_NODES by default for NUMA)
From: Michal Hocko @ 2019-07-31 14:41 UTC (permalink / raw)
To: Mike Rapoport
Cc: Heiko Carstens, open list:MEMORY MANAGEMENT, Paul Mackerras,
H . Peter Anvin, sparclinux@vger.kernel.org, Alexander Duyck,
Will Deacon, linux-s390@vger.kernel.org, x86@kernel.org,
willy@infradead.org, Christian Borntraeger, Ingo Molnar,
Hoan Tran OS, Catalin Marinas, Open Source Submission,
Pavel Tatashin, Vasily Gorbik, Will Deacon, Borislav Petkov,
Thomas Gleixner, Vlastimil Babka, Oscar Salvador,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Andrew Morton,
linuxppc-dev@lists.ozlabs.org, David S . Miller
In-Reply-To: <20190731142129.GA24998@rapoport-lnx>
On Wed 31-07-19 17:21:29, Mike Rapoport wrote:
> On Wed, Jul 31, 2019 at 03:00:37PM +0200, Michal Hocko wrote:
> > On Wed 31-07-19 15:26:32, Mike Rapoport wrote:
> > > On Wed, Jul 31, 2019 at 01:40:16PM +0200, Michal Hocko wrote:
> > > > On Wed 31-07-19 14:14:22, Mike Rapoport wrote:
> > > > > On Wed, Jul 31, 2019 at 10:03:09AM +0200, Michal Hocko wrote:
> > > > > > On Wed 31-07-19 09:24:21, Mike Rapoport wrote:
> > > > > > > [ sorry for a late reply too, somehow I missed this thread before ]
> > > > > > >
> > > > > > > On Tue, Jul 30, 2019 at 10:14:15AM +0200, Michal Hocko wrote:
> > > > > > > > [Sorry for a late reply]
> > > > > > > >
> > > > > > > > On Mon 15-07-19 17:55:07, Hoan Tran OS wrote:
> > > > > > > > > Hi,
> > > > > > > > >
> > > > > > > > > On 7/12/19 10:00 PM, Michal Hocko wrote:
> > > > > > > > [...]
> > > > > > > > > > Hmm, I thought this was selectable. But I am obviously wrong here.
> > > > > > > > > > Looking more closely, it seems that this is indeed only about
> > > > > > > > > > __early_pfn_to_nid and as such not something that should add a config
> > > > > > > > > > symbol. This should have been called out in the changelog though.
> > > > > > > > >
> > > > > > > > > Yes, do you have any other comments about my patch?
> > > > > > > >
> > > > > > > > Not really. Just make sure to explicitly state that
> > > > > > > > CONFIG_NODES_SPAN_OTHER_NODES is only about __early_pfn_to_nid and that
> > > > > > > > doesn't really deserve it's own config and can be pulled under NUMA.
> > > > > > > >
> > > > > > > > > > Also while at it, does HAVE_MEMBLOCK_NODE_MAP fall into a similar
> > > > > > > > > > bucket? Do we have any NUMA architecture that doesn't enable it?
> > > > > > > > > >
> > > > > > >
> > > > > > > HAVE_MEMBLOCK_NODE_MAP makes huge difference in node/zone initialization
> > > > > > > sequence so it's not only about a singe function.
> > > > > >
> > > > > > The question is whether we want to have this a config option or enable
> > > > > > it unconditionally for each NUMA system.
> > > > >
> > > > > We can make it 'default NUMA', but we can't drop it completely because
> > > > > microblaze uses sparse_memory_present_with_active_regions() which is
> > > > > unavailable when HAVE_MEMBLOCK_NODE_MAP=n.
> > > >
> > > > I suppose you mean that microblaze is using
> > > > sparse_memory_present_with_active_regions even without CONFIG_NUMA,
> > > > right?
> > >
> > > Yes.
> > >
> > > > I have to confess I do not understand that code. What is the deal
> > > > with setting node id there?
> > >
> > > The sparse_memory_present_with_active_regions() iterates over
> > > memblock.memory regions and uses the node id of each region as the
> > > parameter to memory_present(). The assumption here is that sometime before
> > > each region was assigned a proper non-negative node id.
> > >
> > > microblaze uses device tree for memory enumeration and the current FDT code
> > > does memblock_add() that implicitly sets nid in memblock.memory regions to -1.
> > >
> > > So in order to have proper node id passed to memory_present() microblaze
> > > has to call memblock_set_node() before it can use
> > > sparse_memory_present_with_active_regions().
> >
> > I am sorry, but I still do not follow. Who is consuming that node id
> > information when NUMA=n. In other words why cannot we simply do
>
> We can, I think nobody cared to change it.
It would be great if somebody with the actual HW could try it out.
I can throw a patch but I do not even have a cross compiler in my
toolbox.
>
> > diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
> > index a015a951c8b7..3a47e8db8d1c 100644
> > --- a/arch/microblaze/mm/init.c
> > +++ b/arch/microblaze/mm/init.c
> > @@ -175,14 +175,9 @@ void __init setup_memory(void)
> >
> > start_pfn = memblock_region_memory_base_pfn(reg);
> > end_pfn = memblock_region_memory_end_pfn(reg);
> > - memblock_set_node(start_pfn << PAGE_SHIFT,
> > - (end_pfn - start_pfn) << PAGE_SHIFT,
> > - &memblock.memory, 0);
> > + memory_present(0, start_pfn << PAGE_SHIFT, end_pfn << PAGE_SHIFT);
>
> memory_present() expects pfns, the shift is not needed.
Right.
--
Michal Hocko
SUSE Labs
^ permalink raw reply
* [PATCH v10 06/22] powerpc: mm: Add p?d_leaf() definitions
From: Steven Price @ 2019-07-31 15:45 UTC (permalink / raw)
To: linux-mm
Cc: Mark Rutland, Peter Zijlstra, Dave Hansen, Paul Mackerras,
H. Peter Anvin, Will Deacon, Liang, Kan, x86, Steven Price,
Ingo Molnar, Catalin Marinas, Arnd Bergmann, kvm-ppc,
Jérôme Glisse, Borislav Petkov, Andy Lutomirski,
Thomas Gleixner, linux-arm-kernel, Ard Biesheuvel, linux-kernel,
James Morse, Andrew Morton, linuxppc-dev
In-Reply-To: <20190731154603.41797-1-steven.price@arm.com>
walk_page_range() is going to be allowed to walk page tables other than
those of user space. For this it needs to know when it has reached a
'leaf' entry in the page tables. This information is provided by the
p?d_leaf() functions/macros.
For powerpc pmd_large() already exists and does what we want, so hoist
it out of the CONFIG_TRANSPARENT_HUGEPAGE condition and implement the
other levels. Macros are used to provide the generic p?d_leaf() names.
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: linuxppc-dev@lists.ozlabs.org
CC: kvm-ppc@vger.kernel.org
Signed-off-by: Steven Price <steven.price@arm.com>
---
arch/powerpc/include/asm/book3s/64/pgtable.h | 30 ++++++++++++++------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 8308f32e9782..84270666355c 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -921,6 +921,12 @@ static inline int pud_present(pud_t pud)
return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PRESENT));
}
+#define pud_leaf pud_large
+static inline int pud_large(pud_t pud)
+{
+ return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
+}
+
extern struct page *pud_page(pud_t pud);
extern struct page *pmd_page(pmd_t pmd);
static inline pte_t pud_pte(pud_t pud)
@@ -964,6 +970,12 @@ static inline int pgd_present(pgd_t pgd)
return !!(pgd_raw(pgd) & cpu_to_be64(_PAGE_PRESENT));
}
+#define pgd_leaf pgd_large
+static inline int pgd_large(pgd_t pgd)
+{
+ return !!(pgd_raw(pgd) & cpu_to_be64(_PAGE_PTE));
+}
+
static inline pte_t pgd_pte(pgd_t pgd)
{
return __pte_raw(pgd_raw(pgd));
@@ -1131,6 +1143,15 @@ static inline bool pmd_access_permitted(pmd_t pmd, bool write)
return pte_access_permitted(pmd_pte(pmd), write);
}
+#define pmd_leaf pmd_large
+/*
+ * returns true for pmd migration entries, THP, devmap, hugetlb
+ */
+static inline int pmd_large(pmd_t pmd)
+{
+ return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
+}
+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
extern pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot);
extern pmd_t mk_pmd(struct page *page, pgprot_t pgprot);
@@ -1157,15 +1178,6 @@ pmd_hugepage_update(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp,
return hash__pmd_hugepage_update(mm, addr, pmdp, clr, set);
}
-/*
- * returns true for pmd migration entries, THP, devmap, hugetlb
- * But compile time dependent on THP config
- */
-static inline int pmd_large(pmd_t pmd)
-{
- return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
-}
-
static inline pmd_t pmd_mknotpresent(pmd_t pmd)
{
return __pmd(pmd_val(pmd) & ~_PAGE_PRESENT);
--
2.20.1
^ permalink raw reply related
* Re: microblaze HAVE_MEMBLOCK_NODE_MAP dependency (was Re: [PATCH v2 0/5] mm: Enable CONFIG_NODES_SPAN_OTHER_NODES by default for NUMA)
From: Mike Rapoport @ 2019-07-31 17:15 UTC (permalink / raw)
To: Michal Hocko
Cc: Heiko Carstens, open list:MEMORY MANAGEMENT, Paul Mackerras,
H . Peter Anvin, sparclinux@vger.kernel.org, Alexander Duyck,
Will Deacon, linux-s390@vger.kernel.org, x86@kernel.org,
willy@infradead.org, Christian Borntraeger, Ingo Molnar,
Hoan Tran OS, Catalin Marinas, Open Source Submission,
Pavel Tatashin, Vasily Gorbik, Will Deacon, Borislav Petkov,
Thomas Gleixner, Vlastimil Babka, Oscar Salvador,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Andrew Morton,
linuxppc-dev@lists.ozlabs.org, David S . Miller
In-Reply-To: <20190731144114.GY9330@dhcp22.suse.cz>
On Wed, Jul 31, 2019 at 04:41:14PM +0200, Michal Hocko wrote:
> On Wed 31-07-19 17:21:29, Mike Rapoport wrote:
> > On Wed, Jul 31, 2019 at 03:00:37PM +0200, Michal Hocko wrote:
> > >
> > > I am sorry, but I still do not follow. Who is consuming that node id
> > > information when NUMA=n. In other words why cannot we simply do
> >
> > We can, I think nobody cared to change it.
>
> It would be great if somebody with the actual HW could try it out.
> I can throw a patch but I do not even have a cross compiler in my
> toolbox.
Well, it compiles :)
> > > diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
> > > index a015a951c8b7..3a47e8db8d1c 100644
> > > --- a/arch/microblaze/mm/init.c
> > > +++ b/arch/microblaze/mm/init.c
> > > @@ -175,14 +175,9 @@ void __init setup_memory(void)
> > >
> > > start_pfn = memblock_region_memory_base_pfn(reg);
> > > end_pfn = memblock_region_memory_end_pfn(reg);
> > > - memblock_set_node(start_pfn << PAGE_SHIFT,
> > > - (end_pfn - start_pfn) << PAGE_SHIFT,
> > > - &memblock.memory, 0);
> > > + memory_present(0, start_pfn << PAGE_SHIFT, end_pfn << PAGE_SHIFT);
> >
> > memory_present() expects pfns, the shift is not needed.
>
> Right.
>
> --
> Michal Hocko
> SUSE Labs
>
--
Sincerely yours,
Mike.
^ permalink raw reply
* Re: microblaze HAVE_MEMBLOCK_NODE_MAP dependency (was Re: [PATCH v2 0/5] mm: Enable CONFIG_NODES_SPAN_OTHER_NODES by default for NUMA)
From: Randy Dunlap @ 2019-07-31 17:45 UTC (permalink / raw)
To: Mike Rapoport, Michal Hocko
Cc: Heiko Carstens, open list:MEMORY MANAGEMENT, Paul Mackerras,
H . Peter Anvin, sparclinux@vger.kernel.org, Alexander Duyck,
Will Deacon, linux-s390@vger.kernel.org, x86@kernel.org,
willy@infradead.org, Christian Borntraeger, Ingo Molnar,
Hoan Tran OS, Catalin Marinas, Open Source Submission,
Pavel Tatashin, Vasily Gorbik, Will Deacon, Borislav Petkov,
Thomas Gleixner, Vlastimil Babka, Oscar Salvador,
linux-arm-kernel@lists.infradead.org, Michal Simek,
linux-kernel@vger.kernel.org, Andrew Morton,
linuxppc-dev@lists.ozlabs.org, David S . Miller
In-Reply-To: <20190731171510.GB24998@rapoport-lnx>
On 7/31/19 10:15 AM, Mike Rapoport wrote:
> On Wed, Jul 31, 2019 at 04:41:14PM +0200, Michal Hocko wrote:
>> On Wed 31-07-19 17:21:29, Mike Rapoport wrote:
>>> On Wed, Jul 31, 2019 at 03:00:37PM +0200, Michal Hocko wrote:
>>>>
>>>> I am sorry, but I still do not follow. Who is consuming that node id
>>>> information when NUMA=n. In other words why cannot we simply do
>>>
>>> We can, I think nobody cared to change it.
>>
>> It would be great if somebody with the actual HW could try it out.
>> I can throw a patch but I do not even have a cross compiler in my
>> toolbox.
>
> Well, it compiles :)
Adding Michal Simek <monstr@monstr.eu>.
It's not clear that the MICROBLAZE maintainer is still supporting MICROBLAZE.
>>>> diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
>>>> index a015a951c8b7..3a47e8db8d1c 100644
>>>> --- a/arch/microblaze/mm/init.c
>>>> +++ b/arch/microblaze/mm/init.c
>>>> @@ -175,14 +175,9 @@ void __init setup_memory(void)
>>>>
>>>> start_pfn = memblock_region_memory_base_pfn(reg);
>>>> end_pfn = memblock_region_memory_end_pfn(reg);
>>>> - memblock_set_node(start_pfn << PAGE_SHIFT,
>>>> - (end_pfn - start_pfn) << PAGE_SHIFT,
>>>> - &memblock.memory, 0);
>>>> + memory_present(0, start_pfn << PAGE_SHIFT, end_pfn << PAGE_SHIFT);
>>>
>>> memory_present() expects pfns, the shift is not needed.
>>
>> Right.
>>
>> --
>> Michal Hocko
>> SUSE Labs
--
~Randy
^ permalink raw reply
* Re: [PATCH] hwrng: Use device-managed registration API
From: Ludovic Desroches @ 2019-07-31 12:01 UTC (permalink / raw)
To: Chuhong Yuan
Cc: Alexandre Belloni, Deepak Saxena, Herbert Xu, Arnd Bergmann,
Greg Kroah-Hartman, Łukasz Stelmach, Nicolas Ferre,
Krzysztof Kozlowski, Patrice Chotard, linux-samsung-soc,
Kukjin Kim, Paul Mackerras, Matt Mackall, linux-kernel,
linuxppc-dev, linux-arm-kernel, linux-crypto
In-Reply-To: <20190725080155.19875-1-hslester96@gmail.com>
On Thu, Jul 25, 2019 at 04:01:55PM +0800, Chuhong Yuan wrote:
> External E-Mail
>
>
> Use devm_hwrng_register to simplify the implementation.
> Manual unregistration and some remove functions can be
> removed now.
>
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
> ---
> drivers/char/hw_random/atmel-rng.c | 3 +--
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Thanks
> drivers/char/hw_random/cavium-rng-vf.c | 11 +----------
> drivers/char/hw_random/exynos-trng.c | 3 +--
> drivers/char/hw_random/n2-drv.c | 4 +---
> drivers/char/hw_random/nomadik-rng.c | 3 +--
> drivers/char/hw_random/omap-rng.c | 3 +--
> drivers/char/hw_random/powernv-rng.c | 10 +---------
> drivers/char/hw_random/st-rng.c | 4 +---
> drivers/char/hw_random/xgene-rng.c | 4 +---
> 9 files changed, 9 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/char/hw_random/atmel-rng.c b/drivers/char/hw_random/atmel-rng.c
> index 433426242b87..e55705745d5e 100644
> --- a/drivers/char/hw_random/atmel-rng.c
> +++ b/drivers/char/hw_random/atmel-rng.c
> @@ -86,7 +86,7 @@ static int atmel_trng_probe(struct platform_device *pdev)
> trng->rng.name = pdev->name;
> trng->rng.read = atmel_trng_read;
>
> - ret = hwrng_register(&trng->rng);
> + ret = devm_hwrng_register(&pdev->dev, &trng->rng);
> if (ret)
> goto err_register;
>
> @@ -103,7 +103,6 @@ static int atmel_trng_remove(struct platform_device *pdev)
> {
> struct atmel_trng *trng = platform_get_drvdata(pdev);
>
> - hwrng_unregister(&trng->rng);
>
> atmel_trng_disable(trng);
> clk_disable_unprepare(trng->clk);
> diff --git a/drivers/char/hw_random/cavium-rng-vf.c b/drivers/char/hw_random/cavium-rng-vf.c
> index 2d1352b67168..3de4a6a443ef 100644
> --- a/drivers/char/hw_random/cavium-rng-vf.c
> +++ b/drivers/char/hw_random/cavium-rng-vf.c
> @@ -67,7 +67,7 @@ static int cavium_rng_probe_vf(struct pci_dev *pdev,
>
> pci_set_drvdata(pdev, rng);
>
> - ret = hwrng_register(&rng->ops);
> + ret = devm_hwrng_register(&pdev->dev, &rng->ops);
> if (ret) {
> dev_err(&pdev->dev, "Error registering device as HWRNG.\n");
> return ret;
> @@ -76,14 +76,6 @@ static int cavium_rng_probe_vf(struct pci_dev *pdev,
> return 0;
> }
>
> -/* Remove the VF */
> -static void cavium_rng_remove_vf(struct pci_dev *pdev)
> -{
> - struct cavium_rng *rng;
> -
> - rng = pci_get_drvdata(pdev);
> - hwrng_unregister(&rng->ops);
> -}
>
> static const struct pci_device_id cavium_rng_vf_id_table[] = {
> { PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, 0xa033), 0, 0, 0},
> @@ -95,7 +87,6 @@ static struct pci_driver cavium_rng_vf_driver = {
> .name = "cavium_rng_vf",
> .id_table = cavium_rng_vf_id_table,
> .probe = cavium_rng_probe_vf,
> - .remove = cavium_rng_remove_vf,
> };
> module_pci_driver(cavium_rng_vf_driver);
>
> diff --git a/drivers/char/hw_random/exynos-trng.c b/drivers/char/hw_random/exynos-trng.c
> index 94235761955c..b4b52ab23b6b 100644
> --- a/drivers/char/hw_random/exynos-trng.c
> +++ b/drivers/char/hw_random/exynos-trng.c
> @@ -153,7 +153,7 @@ static int exynos_trng_probe(struct platform_device *pdev)
> goto err_clock;
> }
>
> - ret = hwrng_register(&trng->rng);
> + ret = devm_hwrng_register(&pdev->dev, &trng->rng);
> if (ret) {
> dev_err(&pdev->dev, "Could not register hwrng device.\n");
> goto err_register;
> @@ -179,7 +179,6 @@ static int exynos_trng_remove(struct platform_device *pdev)
> {
> struct exynos_trng_dev *trng = platform_get_drvdata(pdev);
>
> - hwrng_unregister(&trng->rng);
> clk_disable_unprepare(trng->clk);
>
> pm_runtime_put_sync(&pdev->dev);
> diff --git a/drivers/char/hw_random/n2-drv.c b/drivers/char/hw_random/n2-drv.c
> index d4cab105796f..2d256b3470db 100644
> --- a/drivers/char/hw_random/n2-drv.c
> +++ b/drivers/char/hw_random/n2-drv.c
> @@ -768,7 +768,7 @@ static int n2rng_probe(struct platform_device *op)
> np->hwrng.data_read = n2rng_data_read;
> np->hwrng.priv = (unsigned long) np;
>
> - err = hwrng_register(&np->hwrng);
> + err = devm_hwrng_register(&pdev->dev, &np->hwrng);
> if (err)
> goto out_hvapi_unregister;
>
> @@ -793,8 +793,6 @@ static int n2rng_remove(struct platform_device *op)
>
> cancel_delayed_work_sync(&np->work);
>
> - hwrng_unregister(&np->hwrng);
> -
> sun4v_hvapi_unregister(HV_GRP_RNG);
>
> return 0;
> diff --git a/drivers/char/hw_random/nomadik-rng.c b/drivers/char/hw_random/nomadik-rng.c
> index fc0f6b0cb80d..74ed29f42e4f 100644
> --- a/drivers/char/hw_random/nomadik-rng.c
> +++ b/drivers/char/hw_random/nomadik-rng.c
> @@ -57,7 +57,7 @@ static int nmk_rng_probe(struct amba_device *dev, const struct amba_id *id)
> if (!base)
> goto out_release;
> nmk_rng.priv = (unsigned long)base;
> - ret = hwrng_register(&nmk_rng);
> + ret = devm_hwrng_register(&dev->dev, &nmk_rng);
> if (ret)
> goto out_release;
> return 0;
> @@ -71,7 +71,6 @@ static int nmk_rng_probe(struct amba_device *dev, const struct amba_id *id)
>
> static int nmk_rng_remove(struct amba_device *dev)
> {
> - hwrng_unregister(&nmk_rng);
> amba_release_regions(dev);
> clk_disable(rng_clk);
> return 0;
> diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c
> index e9b6ac61fb7f..b27f39688b5e 100644
> --- a/drivers/char/hw_random/omap-rng.c
> +++ b/drivers/char/hw_random/omap-rng.c
> @@ -500,7 +500,7 @@ static int omap_rng_probe(struct platform_device *pdev)
> if (ret)
> goto err_register;
>
> - ret = hwrng_register(&priv->rng);
> + ret = devm_hwrng_register(&pdev->dev, &priv->rng);
> if (ret)
> goto err_register;
>
> @@ -525,7 +525,6 @@ static int omap_rng_remove(struct platform_device *pdev)
> {
> struct omap_rng_dev *priv = platform_get_drvdata(pdev);
>
> - hwrng_unregister(&priv->rng);
>
> priv->pdata->cleanup(priv);
>
> diff --git a/drivers/char/hw_random/powernv-rng.c b/drivers/char/hw_random/powernv-rng.c
> index f2e8272e276a..8da1d7917bdc 100644
> --- a/drivers/char/hw_random/powernv-rng.c
> +++ b/drivers/char/hw_random/powernv-rng.c
> @@ -33,18 +33,11 @@ static struct hwrng powernv_hwrng = {
> .read = powernv_rng_read,
> };
>
> -static int powernv_rng_remove(struct platform_device *pdev)
> -{
> - hwrng_unregister(&powernv_hwrng);
> -
> - return 0;
> -}
> -
> static int powernv_rng_probe(struct platform_device *pdev)
> {
> int rc;
>
> - rc = hwrng_register(&powernv_hwrng);
> + rc = devm_hwrng_register(&pdev->dev, &powernv_hwrng);
> if (rc) {
> /* We only register one device, ignore any others */
> if (rc == -EEXIST)
> @@ -70,7 +63,6 @@ static struct platform_driver powernv_rng_driver = {
> .of_match_table = powernv_rng_match,
> },
> .probe = powernv_rng_probe,
> - .remove = powernv_rng_remove,
> };
> module_platform_driver(powernv_rng_driver);
>
> diff --git a/drivers/char/hw_random/st-rng.c b/drivers/char/hw_random/st-rng.c
> index bd6a98b3479b..863448360a7d 100644
> --- a/drivers/char/hw_random/st-rng.c
> +++ b/drivers/char/hw_random/st-rng.c
> @@ -102,7 +102,7 @@ static int st_rng_probe(struct platform_device *pdev)
>
> dev_set_drvdata(&pdev->dev, ddata);
>
> - ret = hwrng_register(&ddata->ops);
> + ret = devm_hwrng_register(&pdev->dev, &ddata->ops);
> if (ret) {
> dev_err(&pdev->dev, "Failed to register HW RNG\n");
> clk_disable_unprepare(clk);
> @@ -118,8 +118,6 @@ static int st_rng_remove(struct platform_device *pdev)
> {
> struct st_rng_data *ddata = dev_get_drvdata(&pdev->dev);
>
> - hwrng_unregister(&ddata->ops);
> -
> clk_disable_unprepare(ddata->clk);
>
> return 0;
> diff --git a/drivers/char/hw_random/xgene-rng.c b/drivers/char/hw_random/xgene-rng.c
> index 8c6f9f63da5e..7e568db87ae2 100644
> --- a/drivers/char/hw_random/xgene-rng.c
> +++ b/drivers/char/hw_random/xgene-rng.c
> @@ -361,7 +361,7 @@ static int xgene_rng_probe(struct platform_device *pdev)
>
> xgene_rng_func.priv = (unsigned long) ctx;
>
> - rc = hwrng_register(&xgene_rng_func);
> + rc = devm_hwrng_register(&pdev->dev, &xgene_rng_func);
> if (rc) {
> dev_err(&pdev->dev, "RNG registering failed error %d\n", rc);
> if (!IS_ERR(ctx->clk))
> @@ -375,7 +375,6 @@ static int xgene_rng_probe(struct platform_device *pdev)
> rc);
> if (!IS_ERR(ctx->clk))
> clk_disable_unprepare(ctx->clk);
> - hwrng_unregister(&xgene_rng_func);
> return rc;
> }
>
> @@ -392,7 +391,6 @@ static int xgene_rng_remove(struct platform_device *pdev)
> dev_err(&pdev->dev, "RNG init wakeup failed error %d\n", rc);
> if (!IS_ERR(ctx->clk))
> clk_disable_unprepare(ctx->clk);
> - hwrng_unregister(&xgene_rng_func);
>
> return rc;
> }
> --
> 2.20.1
>
>
^ permalink raw reply
* [PATCH 6/8] dma-direct: turn ARCH_ZONE_DMA_BITS into a variable
From: Nicolas Saenz Julienne @ 2019-07-31 15:47 UTC (permalink / raw)
To: catalin.marinas, hch, wahrenst, marc.zyngier, Robin Murphy,
linux-arm-kernel, devicetree, iommu, linux-mm, Marek Szyprowski
Cc: phill, linux-s390, f.fainelli, Vasily Gorbik, mbrugger,
frowand.list, linuxppc-dev, Heiko Carstens, linux-kernel, eric,
robh+dt, Paul Mackerras, linux-rpi-kernel, akpm, will,
Christian Borntraeger, nsaenzjulienne
In-Reply-To: <20190731154752.16557-1-nsaenzjulienne@suse.de>
Some architectures, notably arm64, are interested in tweaking this
depending on their runtime dma addressing limitations.
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
arch/powerpc/include/asm/page.h | 9 ---------
arch/powerpc/mm/mem.c | 14 ++++++++++++--
arch/s390/include/asm/page.h | 2 --
arch/s390/mm/init.c | 1 +
include/linux/dma-direct.h | 2 ++
kernel/dma/direct.c | 8 +++-----
6 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
index 0d52f57fca04..73668a21ae78 100644
--- a/arch/powerpc/include/asm/page.h
+++ b/arch/powerpc/include/asm/page.h
@@ -319,13 +319,4 @@ struct vm_area_struct;
#endif /* __ASSEMBLY__ */
#include <asm/slice.h>
-/*
- * Allow 30-bit DMA for very limited Broadcom wifi chips on many powerbooks.
- */
-#ifdef CONFIG_PPC32
-#define ARCH_ZONE_DMA_BITS 30
-#else
-#define ARCH_ZONE_DMA_BITS 31
-#endif
-
#endif /* _ASM_POWERPC_PAGE_H */
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 9191a66b3bc5..3792a998ca02 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -31,6 +31,7 @@
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/memremap.h>
+#include <linux/dma-direct.h>
#include <asm/pgalloc.h>
#include <asm/prom.h>
@@ -201,7 +202,7 @@ static int __init mark_nonram_nosave(void)
* everything else. GFP_DMA32 page allocations automatically fall back to
* ZONE_DMA.
*
- * By using 31-bit unconditionally, we can exploit ARCH_ZONE_DMA_BITS to
+ * By using 31-bit unconditionally, we can exploit arch_zone_dma_bits to
* inform the generic DMA mapping code. 32-bit only devices (if not handled
* by an IOMMU anyway) will take a first dip into ZONE_NORMAL and get
* otherwise served by ZONE_DMA.
@@ -237,9 +238,18 @@ void __init paging_init(void)
printk(KERN_DEBUG "Memory hole size: %ldMB\n",
(long int)((top_of_ram - total_ram) >> 20));
+ /*
+ * Allow 30-bit DMA for very limited Broadcom wifi chips on many
+ * powerbooks.
+ */
+ if (IS_ENABLED(CONFIG_PPC32))
+ arch_zone_dma_bits = 30;
+ else
+ arch_zone_dma_bits = 31;
+
#ifdef CONFIG_ZONE_DMA
max_zone_pfns[ZONE_DMA] = min(max_low_pfn,
- 1UL << (ARCH_ZONE_DMA_BITS - PAGE_SHIFT));
+ 1UL << (arch_zone_dma_bits - PAGE_SHIFT));
#endif
max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
#ifdef CONFIG_HIGHMEM
diff --git a/arch/s390/include/asm/page.h b/arch/s390/include/asm/page.h
index 823578c6b9e2..a4d38092530a 100644
--- a/arch/s390/include/asm/page.h
+++ b/arch/s390/include/asm/page.h
@@ -177,8 +177,6 @@ static inline int devmem_is_allowed(unsigned long pfn)
#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \
VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
-#define ARCH_ZONE_DMA_BITS 31
-
#include <asm-generic/memory_model.h>
#include <asm-generic/getorder.h>
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 20340a03ad90..07d93955d3e4 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -118,6 +118,7 @@ void __init paging_init(void)
sparse_memory_present_with_active_regions(MAX_NUMNODES);
sparse_init();
+ arch_zone_dma_bits = 31;
memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
max_zone_pfns[ZONE_DMA] = PFN_DOWN(MAX_DMA_ADDRESS);
max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
index adf993a3bd58..a1b353b77858 100644
--- a/include/linux/dma-direct.h
+++ b/include/linux/dma-direct.h
@@ -5,6 +5,8 @@
#include <linux/dma-mapping.h>
#include <linux/mem_encrypt.h>
+extern unsigned int arch_zone_dma_bits;
+
#ifdef CONFIG_ARCH_HAS_PHYS_TO_DMA
#include <asm/dma-direct.h>
#else
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 59bdceea3737..40dfc9b4ee4c 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -19,9 +19,7 @@
* Most architectures use ZONE_DMA for the first 16 Megabytes, but
* some use it for entirely different regions:
*/
-#ifndef ARCH_ZONE_DMA_BITS
-#define ARCH_ZONE_DMA_BITS 24
-#endif
+unsigned int arch_zone_dma_bits __ro_after_init = 24;
static void report_addr(struct device *dev, dma_addr_t dma_addr, size_t size)
{
@@ -72,7 +70,7 @@ static gfp_t __dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask,
* Note that GFP_DMA32 and GFP_DMA are no ops without the corresponding
* zones.
*/
- if (*phys_mask <= DMA_BIT_MASK(ARCH_ZONE_DMA_BITS))
+ if (*phys_mask <= DMA_BIT_MASK(arch_zone_dma_bits))
return GFP_DMA;
if (*phys_mask <= DMA_BIT_MASK(32))
return GFP_DMA32;
@@ -387,7 +385,7 @@ int dma_direct_supported(struct device *dev, u64 mask)
u64 min_mask;
if (IS_ENABLED(CONFIG_ZONE_DMA))
- min_mask = DMA_BIT_MASK(ARCH_ZONE_DMA_BITS);
+ min_mask = DMA_BIT_MASK(arch_zone_dma_bits);
else
min_mask = DMA_BIT_MASK(32);
--
2.22.0
^ permalink raw reply related
* [PATCH 0/8] Raspberry Pi 4 DMA addressing support
From: Nicolas Saenz Julienne @ 2019-07-31 15:47 UTC (permalink / raw)
To: catalin.marinas, hch, wahrenst, marc.zyngier, Robin Murphy,
linux-arm-kernel, devicetree, iommu, linux-mm
Cc: phill, linux-s390, f.fainelli, mbrugger, frowand.list,
linuxppc-dev, linux-kernel, eric, robh+dt, linux-rpi-kernel, akpm,
will, nsaenzjulienne, m.szyprowski
Hi all,
this series attempts to address some issues we found while bringing up
the new Raspberry Pi 4 in arm64 and it's intended to serve as a follow
up of this discussion:
https://lkml.org/lkml/2019/7/17/476
The new Raspberry Pi 4 has up to 4GB of memory but most peripherals can
only address the first GB: their DMA address range is
0xc0000000-0xfc000000 which is aliased to the first GB of physical
memory 0x00000000-0x3c000000. Note that only some peripherals have these
limitations: the ARM cores, PCIe, V3D, GENET, and 40-bit DMA channels
have a wider view of the address space.
Part of this is solved in arm32 by setting up the machine specific
'.dma_zone_size = SZ_1G', which takes care of the allocating the
coherent memory area at the right spot. Yet no buffer bouncing (needed
for dma streaming) is available at the moment, but that's a story for
another series.
Unfortunately there is no such thing as '.dma_zone_size' in arm64 also
only ZONE_DMA32 is created which is interpreted by dma-direct and the
arm64 code as if all peripherals where be able to address the first 4GB
of memory.
In the light of this, the series implements the following changes:
- Add code that parses the device-tree in oder to find the SoC's common
DMA area.
- Create a ZONE_DMA whenever that area is needed and add the rest of the
lower 4 GB of memory to ZONE_DMA32*.
- Create the CMA area in a place suitable for all peripherals.
- Inform dma-direct of the new runtime calculated min_mask*.
That's all.
Regards,
Nicolas
* These solutions where already discussed on the previous RFC (see link
above).
---
Nicolas Saenz Julienne (8):
arm64: mm: use arm64_dma_phys_limit instead of calling
max_zone_dma_phys()
arm64: rename variables used to calculate ZONE_DMA32's size
of/fdt: add function to get the SoC wide DMA addressable memory size
arm64: re-introduce max_zone_dma_phys()
arm64: use ZONE_DMA on DMA addressing limited devices
dma-direct: turn ARCH_ZONE_DMA_BITS into a variable
arm64: update arch_zone_dma_bits to fine tune dma-direct min mask
mm: comment arm64's usage of 'enum zone_type'
arch/arm64/Kconfig | 4 ++
arch/arm64/mm/init.c | 78 ++++++++++++++++++++++++++-------
arch/powerpc/include/asm/page.h | 9 ----
arch/powerpc/mm/mem.c | 14 +++++-
arch/s390/include/asm/page.h | 2 -
arch/s390/mm/init.c | 1 +
drivers/of/fdt.c | 72 ++++++++++++++++++++++++++++++
include/linux/dma-direct.h | 2 +
include/linux/mmzone.h | 21 ++++-----
include/linux/of_fdt.h | 2 +
kernel/dma/direct.c | 8 ++--
11 files changed, 168 insertions(+), 45 deletions(-)
--
2.22.0
^ permalink raw reply
* Re: [RFC PATCH] powerpc/64s/radix: introduce option to disable broadcast tlbie
From: Nicholas Piggin @ 2019-07-31 23:05 UTC (permalink / raw)
To: Christophe Leroy, linuxppc-dev; +Cc: Aneesh Kumar K . V, Paul Mackerras
In-Reply-To: <188d2d1d-a254-d00c-eee4-dd71e01b443f@c-s.fr>
Christophe Leroy's on July 31, 2019 11:56 pm:
>
>
> Le 31/07/2019 à 14:32, Nicholas Piggin a écrit :
>> This is an initial hack of a quick option to disable use of the tlbie
>> instruction. This takes the simplest possible initial pass of just
>> replacing low level tlbie functions with IPIs. This means it's not as
>> performant as it could be if we spend some time optmizing it, but on
>> the other hand having a 1:1 replacement of tlbie is simple and can be
>> useful for comparisons so I think it's the right initial approach.
>
> Can you explain why we want to optionnaly disable use of tlbie ?
It's something we've wanted to have more control of for a while.
One is for testing performance, especially on large systems it is not
always best to use tlbie. For example if you have threaded apps that
only run on a few CPUs (e.g., process * thread hybrid process model
server).
There is also concern about coherent accelerators may have high
latency to respond to tlbie, which can block the resource for others.
And we did have a hardware errata with early POWER9 it would have
been nice to disable it until the kernel could be updated with the
workaround.
Thanks,
Nick
^ permalink raw reply
* Re: [PATCH] powerpc: Support CMDLINE_EXTEND
From: Chris Packham @ 2019-08-01 0:14 UTC (permalink / raw)
To: christophe.leroy@c-s.fr, paulus@samba.org, mpe@ellerman.id.au,
benh@kernel.crashing.org
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
In-Reply-To: <32ae09e8-0d32-4266-aa37-d5a34cb4e707@c-s.fr>
On Wed, 2019-07-31 at 09:23 +0200, Christophe Leroy wrote:
>
> Le 30/07/2019 à 23:10, Chris Packham a écrit :
> >
> > Hi Christophe,
> >
> > On Tue, 2019-07-30 at 09:02 +0200, Christophe Leroy wrote:
> > >
> > >
> > > Le 24/07/2019 à 07:33, Chris Packham a écrit :
> > > >
> > > >
> > > > Device tree aware platforms can make use of CMDLINE_EXTEND to
> > > > extend the
> > > > kernel command line provided by the bootloader. This is
> > > > particularly
> > > > useful to set parameters for built-in modules that would
> > > > otherwise
> > > > be
> > > > done at module insertion. Add support for this in the powerpc
> > > > architecture.
> > > >
> > > > Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz
> > > > >
> > > > ---
> > > > arch/powerpc/Kconfig | 12 ++++++++++++
> > > I think you also have to implement some stuff in
> > > early_cmdline_parse()
> > > in arch/powerpc/kernel/prom_init.c
> > I my case I didn't need to since the generic code
> > in drivers/of/fdt.c
> > did what I need. For early options or platforms that don't use a
> > device
> > tree then I can see why I'd need the update to update to prom_init.
> >
> > >
> > >
> > > Maybe look at https://patchwork.ozlabs.org/patch/1074126/
> > >
> > Do you mind if I take this and fold it into a v2 of my patch? Any
> > particular reason it didn't get picked up in April?
> Sure, take it, I don't mind.
>
> Two reasons it was not picked up in April I believe:
> - It was part of a larger series
> (https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=10051
> 8)
> and was intended to challenge the series proposed by Daniel
> (https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=98106
> )
> but nothing happened.
> - It was conflicting with the ongoing changes for implementing KASAN.
>
> What you will have to do is to define prom_strlcat() in the same
> spirit
> as https://patchwork.ozlabs.org/patch/1091621/ by copying it from
> lib/string.c and
Is it OK to use BUG_ON in prom_init? If I copy it verbatim then the
code from lib/string.c has a BUG_ON. I could probably change that to
if(x) return -1 if BUG_ON is not appropriate.
> I think you'll be able to drop prom_strlcpy() as that
> function what only used there.
I think I need to keep prom_strlcpy to handle the CMDLINE_FORCE case.
>
> Christophe
>
> >
> >
> > >
> > > Christophe
> > >
> > > >
> > > >
> > > > 1 file changed, 12 insertions(+)
> > > >
> > > > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> > > > index d8dcd8820369..cd9b3974aa36 100644
> > > > --- a/arch/powerpc/Kconfig
> > > > +++ b/arch/powerpc/Kconfig
> > > > @@ -851,6 +851,11 @@ config CMDLINE
> > > > some command-line options at build time by
> > > > entering
> > > > them here. In
> > > > most cases you will need to specify the root
> > > > device
> > > > here.
> > > >
> > > > +choice
> > > > + prompt "Kernel command line type" if CMDLINE != ""
> > > > + default CMDLINE_FORCE
> > > > + depends on CMDLINE_BOOL
> > > > +
> > > > config CMDLINE_FORCE
> > > > bool "Always use the default kernel command string"
> > > > depends on CMDLINE_BOOL
> > > > @@ -860,6 +865,13 @@ config CMDLINE_FORCE
> > > > This is useful if you cannot or don't want to
> > > > change
> > > > the
> > > > command-line options your boot loader passes to
> > > > the
> > > > kernel.
> > > >
> > > > +config CMDLINE_EXTEND
> > > > + bool "Extend bootloader kernel arguments"
> > > > + help
> > > > + The command-line arguments provided by the boot
> > > > loader
> > > > will be
> > > > + appended to the default kernel command string.
> > > > +endchoice
> > > > +
> > > > config EXTRA_TARGETS
> > > > string "Additional default image types"
> > > > help
^ permalink raw reply
* [PATCH v2] powerpc: Support CMDLINE_EXTEND
From: Chris Packham @ 2019-08-01 2:12 UTC (permalink / raw)
To: benh, paulus, mpe, christophe.leroy, malat
Cc: Chris Packham, linuxppc-dev, linux-kernel
Bring powerpc in line with other architectures that support extending or
overriding the bootloader provided command line.
The current behaviour is most like CMDLINE_FROM_BOOTLOADER where the
bootloader command line is preferred but the kernel config can provide a
fallback so CMDLINE_FROM_BOOTLOADER is the default. CMDLINE_EXTEND can
be used to append the CMDLINE from the kernel config to the one provided
by the bootloader.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
While I'm at it does anyone think it's worth getting rid of the default CMDLINE
value if CMDLINE_BOOL and maybe CMDLINE_BOOL? Every defconfig in the kernel
that sets CMDLINE_BOOL=y also sets CMDLINE to something other than
"console=ttyS0,9600 console=tty0 root=/dev/sda2". Removing CMDLINE_BOOL and
unconditionally setting the default value of CMDLINE to "" would clean up the
Kconfig even more.
Changes in v2:
- incorporate ideas from Christope's patch https://patchwork.ozlabs.org/patch/1074126/
arch/powerpc/Kconfig | 20 +++++++++++++++++++-
arch/powerpc/kernel/prom_init.c | 26 +++++++++++++++++++++++++-
2 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 77f6ebf97113..d413fe1b4058 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -852,15 +852,33 @@ config CMDLINE
some command-line options at build time by entering them here. In
most cases you will need to specify the root device here.
+choice
+ prompt "Kernel command line type" if CMDLINE != ""
+ default CMDLINE_FROM_BOOTLOADER
+
+config CMDLINE_FROM_BOOTLOADER
+ bool "Use bootloader kernel arguments if available"
+ help
+ Uses the command-line options passed by the boot loader. If
+ the boot loader doesn't provide any, the default kernel command
+ string provided in CMDLINE will be used.
+
+config CMDLINE_EXTEND
+ bool "Extend bootloader kernel arguments"
+ help
+ The command-line arguments provided by the boot loader will be
+ appended to the default kernel command string.
+
config CMDLINE_FORCE
bool "Always use the default kernel command string"
- depends on CMDLINE_BOOL
help
Always use the default kernel command string, even if the boot
loader passes other arguments to the kernel.
This is useful if you cannot or don't want to change the
command-line options your boot loader passes to the kernel.
+endchoice
+
config EXTRA_TARGETS
string "Additional default image types"
help
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 514707ef6779..df29f141dbd2 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -310,6 +310,25 @@ static size_t __init prom_strlcpy(char *dest, const char *src, size_t size)
return ret;
}
+static size_t __init prom_strlcat(char *dest, const char *src, size_t count)
+{
+ size_t dsize = prom_strlen(dest);
+ size_t len = prom_strlen(src);
+ size_t res = dsize + len;
+
+ /* This would be a bug */
+ BUG_ON(dsize >= count);
+
+ dest += dsize;
+ count -= dsize;
+ if (len >= count)
+ len = count-1;
+ memcpy(dest, src, len);
+ dest[len] = 0;
+ return res;
+
+}
+
#ifdef CONFIG_PPC_PSERIES
static int __init prom_strtobool(const char *s, bool *res)
{
@@ -761,8 +780,13 @@ static void __init early_cmdline_parse(void)
p = prom_cmd_line;
if ((long)prom.chosen > 0)
l = prom_getprop(prom.chosen, "bootargs", p, COMMAND_LINE_SIZE-1);
- if (IS_ENABLED(CONFIG_CMDLINE_BOOL) && (l <= 0 || p[0] == '\0')) /* dbl check */
+
+ if (IS_ENABLED(CONFIG_CMDLINE_FORCE) || l <= 0 || p[0] == '\0')
prom_strlcpy(prom_cmd_line, CONFIG_CMDLINE, sizeof(prom_cmd_line));
+ else if (IS_ENABLED(CONFIG_CMDLINE_EXTEND))
+ prom_strlcat(prom_cmd_line, " " CONFIG_CMDLINE,
+ sizeof(prom_cmd_line));
+
prom_printf("command line: %s\n", prom_cmd_line);
#ifdef CONFIG_PPC64
--
2.22.0
^ permalink raw reply related
* Re: [PATCH 1/3] powerpc/spinlocks: Refactor SHARED_PROCESSOR
From: Andrew Donnellan @ 2019-08-01 3:20 UTC (permalink / raw)
To: Christopher M. Riedl, linuxppc-dev
In-Reply-To: <20190728125438.1550-2-cmr@informatik.wtf>
On 28/7/19 10:54 pm, Christopher M. Riedl wrote:
> Determining if a processor is in shared processor mode is not a constant
> so don't hide it behind a #define.
>
> Signed-off-by: Christopher M. Riedl <cmr@informatik.wtf>
This seems aesthetically more right.
Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
> ---
> arch/powerpc/include/asm/spinlock.h | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
> index a47f827bc5f1..8631b0b4e109 100644
> --- a/arch/powerpc/include/asm/spinlock.h
> +++ b/arch/powerpc/include/asm/spinlock.h
> @@ -101,15 +101,24 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)
>
> #if defined(CONFIG_PPC_SPLPAR)
> /* We only yield to the hypervisor if we are in shared processor mode */
> -#define SHARED_PROCESSOR (lppaca_shared_proc(local_paca->lppaca_ptr))
> extern void __spin_yield(arch_spinlock_t *lock);
> extern void __rw_yield(arch_rwlock_t *lock);
> #else /* SPLPAR */
> #define __spin_yield(x) barrier()
> #define __rw_yield(x) barrier()
> -#define SHARED_PROCESSOR 0
> #endif
>
> +static inline bool is_shared_processor(void)
> +{
> +/* Only server processors have an lppaca struct */
> +#ifdef CONFIG_PPC_BOOK3S
> + return (IS_ENABLED(CONFIG_PPC_SPLPAR) &&
> + lppaca_shared_proc(local_paca->lppaca_ptr));
> +#else
> + return false;
> +#endif
> +}
> +
> static inline void arch_spin_lock(arch_spinlock_t *lock)
> {
> while (1) {
> @@ -117,7 +126,7 @@ static inline void arch_spin_lock(arch_spinlock_t *lock)
> break;
> do {
> HMT_low();
> - if (SHARED_PROCESSOR)
> + if (is_shared_processor())
> __spin_yield(lock);
> } while (unlikely(lock->slock != 0));
> HMT_medium();
> @@ -136,7 +145,7 @@ void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
> local_irq_restore(flags);
> do {
> HMT_low();
> - if (SHARED_PROCESSOR)
> + if (is_shared_processor())
> __spin_yield(lock);
> } while (unlikely(lock->slock != 0));
> HMT_medium();
> @@ -226,7 +235,7 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
> break;
> do {
> HMT_low();
> - if (SHARED_PROCESSOR)
> + if (is_shared_processor())
> __rw_yield(rw);
> } while (unlikely(rw->lock < 0));
> HMT_medium();
> @@ -240,7 +249,7 @@ static inline void arch_write_lock(arch_rwlock_t *rw)
> break;
> do {
> HMT_low();
> - if (SHARED_PROCESSOR)
> + if (is_shared_processor())
> __rw_yield(rw);
> } while (unlikely(rw->lock != 0));
> HMT_medium();
>
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
^ permalink raw reply
* Re: [PATCH 2/3] powerpc/spinlocks: Rename SPLPAR-only spinlocks
From: Andrew Donnellan @ 2019-08-01 3:27 UTC (permalink / raw)
To: Christopher M. Riedl, linuxppc-dev
In-Reply-To: <20190728125438.1550-3-cmr@informatik.wtf>
On 28/7/19 10:54 pm, Christopher M. Riedl wrote:
> The __rw_yield and __spin_yield locks only pertain to SPLPAR mode.
> Rename them to make this relationship obvious.
>
> Signed-off-by: Christopher M. Riedl <cmr@informatik.wtf>
Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
> ---
> arch/powerpc/include/asm/spinlock.h | 6 ++++--
> arch/powerpc/lib/locks.c | 6 +++---
> 2 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
> index 8631b0b4e109..1e7721176f39 100644
> --- a/arch/powerpc/include/asm/spinlock.h
> +++ b/arch/powerpc/include/asm/spinlock.h
> @@ -101,8 +101,10 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)
>
> #if defined(CONFIG_PPC_SPLPAR)
> /* We only yield to the hypervisor if we are in shared processor mode */
> -extern void __spin_yield(arch_spinlock_t *lock);
> -extern void __rw_yield(arch_rwlock_t *lock);
> +void splpar_spin_yield(arch_spinlock_t *lock);
> +void splpar_rw_yield(arch_rwlock_t *lock);
> +#define __spin_yield(x) splpar_spin_yield(x)
> +#define __rw_yield(x) splpar_rw_yield(x)
> #else /* SPLPAR */
> #define __spin_yield(x) barrier()
> #define __rw_yield(x) barrier()
> diff --git a/arch/powerpc/lib/locks.c b/arch/powerpc/lib/locks.c
> index 6550b9e5ce5f..6440d5943c00 100644
> --- a/arch/powerpc/lib/locks.c
> +++ b/arch/powerpc/lib/locks.c
> @@ -18,7 +18,7 @@
> #include <asm/hvcall.h>
> #include <asm/smp.h>
>
> -void __spin_yield(arch_spinlock_t *lock)
> +void splpar_spin_yield(arch_spinlock_t *lock)
> {
> unsigned int lock_value, holder_cpu, yield_count;
>
> @@ -36,14 +36,14 @@ void __spin_yield(arch_spinlock_t *lock)
> plpar_hcall_norets(H_CONFER,
> get_hard_smp_processor_id(holder_cpu), yield_count);
> }
> -EXPORT_SYMBOL_GPL(__spin_yield);
> +EXPORT_SYMBOL_GPL(splpar_spin_yield);
>
> /*
> * Waiting for a read lock or a write lock on a rwlock...
> * This turns out to be the same for read and write locks, since
> * we only know the holder if it is write-locked.
> */
> -void __rw_yield(arch_rwlock_t *rw)
> +void splpar_rw_yield(arch_rwlock_t *rw)
> {
> int lock_value;
> unsigned int holder_cpu, yield_count;
>
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
^ permalink raw reply
* Re: [PATCH 3/3] powerpc/spinlock: Fix oops in shared-processor spinlocks
From: Andrew Donnellan @ 2019-08-01 3:33 UTC (permalink / raw)
To: Christopher M. Riedl, linuxppc-dev
In-Reply-To: <20190728125438.1550-4-cmr@informatik.wtf>
On 28/7/19 10:54 pm, Christopher M. Riedl wrote:
> Booting w/ ppc64le_defconfig + CONFIG_PREEMPT results in the attached
> kernel trace due to calling shared-processor spinlocks while not running
> in an SPLPAR. Previously, the out-of-line spinlocks implementations were
> selected based on CONFIG_PPC_SPLPAR at compile time without a runtime
> shared-processor LPAR check.
>
> To fix, call the actual spinlock implementations from a set of common
> functions, spin_yield() and rw_yield(), which check for shared-processor
> LPAR during runtime and select the appropriate lock implementation.
>
> [ 0.430878] BUG: Kernel NULL pointer dereference at 0x00000100
> [ 0.431991] Faulting instruction address: 0xc000000000097f88
> [ 0.432934] Oops: Kernel access of bad area, sig: 7 [#1]
> [ 0.433448] LE PAGE_SIZE=64K MMU=Radix MMU=Hash PREEMPT SMP NR_CPUS=2048 NUMA PowerNV
> [ 0.434479] Modules linked in:
> [ 0.435055] CPU: 0 PID: 2 Comm: kthreadd Not tainted 5.2.0-rc6-00491-g249155c20f9b #28
> [ 0.435730] NIP: c000000000097f88 LR: c000000000c07a88 CTR: c00000000015ca10
> [ 0.436383] REGS: c0000000727079f0 TRAP: 0300 Not tainted (5.2.0-rc6-00491-g249155c20f9b)
> [ 0.437004] MSR: 9000000002009033 <SF,HV,VEC,EE,ME,IR,DR,RI,LE> CR: 84000424 XER: 20040000
> [ 0.437874] CFAR: c000000000c07a84 DAR: 0000000000000100 DSISR: 00080000 IRQMASK: 1
> [ 0.437874] GPR00: c000000000c07a88 c000000072707c80 c000000001546300 c00000007be38a80
> [ 0.437874] GPR04: c0000000726f0c00 0000000000000002 c00000007279c980 0000000000000100
> [ 0.437874] GPR08: c000000001581b78 0000000080000001 0000000000000008 c00000007279c9b0
> [ 0.437874] GPR12: 0000000000000000 c000000001730000 c000000000142558 0000000000000000
> [ 0.437874] GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
> [ 0.437874] GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
> [ 0.437874] GPR24: c00000007be38a80 c000000000c002f4 0000000000000000 0000000000000000
> [ 0.437874] GPR28: c000000072221a00 c0000000726c2600 c00000007be38a80 c00000007be38a80
> [ 0.443992] NIP [c000000000097f88] __spin_yield+0x48/0xa0
> [ 0.444523] LR [c000000000c07a88] __raw_spin_lock+0xb8/0xc0
> [ 0.445080] Call Trace:
> [ 0.445670] [c000000072707c80] [c000000072221a00] 0xc000000072221a00 (unreliable)
> [ 0.446425] [c000000072707cb0] [c000000000bffb0c] __schedule+0xbc/0x850
> [ 0.447078] [c000000072707d70] [c000000000c002f4] schedule+0x54/0x130
> [ 0.447694] [c000000072707da0] [c0000000001427dc] kthreadd+0x28c/0x2b0
> [ 0.448389] [c000000072707e20] [c00000000000c1cc] ret_from_kernel_thread+0x5c/0x70
> [ 0.449143] Instruction dump:
> [ 0.449821] 4d9e0020 552a043e 210a07ff 79080fe0 0b080000 3d020004 3908b878 794a1f24
> [ 0.450587] e8e80000 7ce7502a e8e70000 38e70100 <7ca03c2c> 70a70001 78a50020 4d820020
> [ 0.452808] ---[ end trace 474d6b2b8fc5cb7e ]---
>
> Signed-off-by: Christopher M. Riedl <cmr@informatik.wtf>
This should probably head to stable?
> ---
> arch/powerpc/include/asm/spinlock.h | 36 ++++++++++++++++++++---------
> 1 file changed, 25 insertions(+), 11 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
> index 1e7721176f39..8161809c6be1 100644
> --- a/arch/powerpc/include/asm/spinlock.h
> +++ b/arch/powerpc/include/asm/spinlock.h
> @@ -103,11 +103,9 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)
> /* We only yield to the hypervisor if we are in shared processor mode */
> void splpar_spin_yield(arch_spinlock_t *lock);
> void splpar_rw_yield(arch_rwlock_t *lock);
> -#define __spin_yield(x) splpar_spin_yield(x)
> -#define __rw_yield(x) splpar_rw_yield(x)
> #else /* SPLPAR */
> -#define __spin_yield(x) barrier()
> -#define __rw_yield(x) barrier()
> +#define splpar_spin_yield(lock)
> +#define splpar_rw_yield(lock)
I prefer using #ifdef on the function definition and declaring an
alternative function with an empty body for the !SPLPAR case, seeing an
empty #define just feels a bit weird
> #endif
>
> static inline bool is_shared_processor(void)
> @@ -121,6 +119,22 @@ static inline bool is_shared_processor(void)
> #endif
> }
>
> +static inline void spin_yield(arch_spinlock_t *lock)
> +{
> + if (is_shared_processor())
> + splpar_spin_yield(lock);
> + else
> + barrier();
> +}
> +
> +static inline void rw_yield(arch_rwlock_t *lock)
> +{
> + if (is_shared_processor())
> + splpar_rw_yield(lock);
> + else
> + barrier();
> +}
> +
> static inline void arch_spin_lock(arch_spinlock_t *lock)
> {
> while (1) {
> @@ -129,7 +143,7 @@ static inline void arch_spin_lock(arch_spinlock_t *lock)
> do {
> HMT_low();
> if (is_shared_processor())
> - __spin_yield(lock);
> + spin_yield(lock);
> } while (unlikely(lock->slock != 0));
> HMT_medium();
> }
> @@ -148,7 +162,7 @@ void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
> do {
> HMT_low();
> if (is_shared_processor())
> - __spin_yield(lock);
> + spin_yield(lock);
> } while (unlikely(lock->slock != 0));
> HMT_medium();
> local_irq_restore(flags_dis);
> @@ -238,7 +252,7 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
> do {
> HMT_low();
> if (is_shared_processor())
> - __rw_yield(rw);
> + rw_yield(rw);
> } while (unlikely(rw->lock < 0));
> HMT_medium();
> }
> @@ -252,7 +266,7 @@ static inline void arch_write_lock(arch_rwlock_t *rw)
> do {
> HMT_low();
> if (is_shared_processor())
> - __rw_yield(rw);
> + rw_yield(rw);
> } while (unlikely(rw->lock != 0));
> HMT_medium();
> }
> @@ -292,9 +306,9 @@ static inline void arch_write_unlock(arch_rwlock_t *rw)
> rw->lock = 0;
> }
>
> -#define arch_spin_relax(lock) __spin_yield(lock)
> -#define arch_read_relax(lock) __rw_yield(lock)
> -#define arch_write_relax(lock) __rw_yield(lock)
> +#define arch_spin_relax(lock) spin_yield(lock)
> +#define arch_read_relax(lock) rw_yield(lock)
> +#define arch_write_relax(lock) rw_yield(lock)
>
> /* See include/linux/spinlock.h */
> #define smp_mb__after_spinlock() smp_mb()
>
--
Andrew Donnellan OzLabs, ADL Canberra
ajd@linux.ibm.com IBM Australia Limited
^ permalink raw reply
* [PATCH] powerpc/configs: Add debug config fragment
From: Andrew Donnellan @ 2019-08-01 4:58 UTC (permalink / raw)
To: linuxppc-dev
Add a debug config fragment that we can use to put useful debug options
into.
Currently we only define a target for powernv[_be]_debug_defconfig, and the
only option included is to enable debugfs SCOM access.
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
---
arch/powerpc/Makefile | 8 ++++++++
arch/powerpc/configs/debug.config | 1 +
2 files changed, 9 insertions(+)
create mode 100644 arch/powerpc/configs/debug.config
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index c345b79414a9..aff022592d89 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -331,6 +331,14 @@ PHONY += powernv_be_defconfig
powernv_be_defconfig:
$(call merge_into_defconfig,powernv_defconfig,be)
+PHONY += powernv_be_debug_defconfig
+powernv_be_debug_defconfig:
+ $(call merge_into_defconfig,powernv_defconfig,be debug)
+
+PHONY += powernv_debug_defconfig
+powernv_debug_defconfig:
+ $(call merge_into_defconfig,powernv_defconfig,debug)
+
PHONY += mpc85xx_defconfig
mpc85xx_defconfig:
$(call merge_into_defconfig,mpc85xx_basic_defconfig,\
diff --git a/arch/powerpc/configs/debug.config b/arch/powerpc/configs/debug.config
new file mode 100644
index 000000000000..a14ae1f20d60
--- /dev/null
+++ b/arch/powerpc/configs/debug.config
@@ -0,0 +1 @@
+CONFIG_SCOM_DEBUGFS=y
--
2.20.1
^ permalink raw reply related
* [PATCH] powerpc/powernv: Print helpful message when cores guarded
From: Joel Stanley @ 2019-08-01 5:16 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev
Often the firmware will guard out cores after a crash. This often
undesirable, and is not immediately noticeable.
This adds an informative message when a CPU device tree nodes are marked
bad in the device tree.
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
Tested on qemu 4.1 with this patch applied:
https://ozlabs.org/~joel/uta2019/0001-TESTING-mark-every-second-core-as-guarded.patch
This will show no cores guarded:
qemu-system-ppc64 -M powernv8 -nographic -smp 1,cores=1,threads=1 -kernel zImage.epapr
This will show three:
qemu-system-ppc64 -M powernv8 -nographic -smp 7,cores=7,threads=1 -kernel zImage.epapr
arch/powerpc/platforms/powernv/setup.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
index a5e52f9eed3c..7107583d0c6b 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -129,6 +129,28 @@ static void pnv_setup_rfi_flush(void)
setup_count_cache_flush();
}
+static void __init pnv_check_guarded_cores(void)
+{
+ struct device_node *dn;
+ int bad_count = 0;
+
+ for_each_node_by_type(dn, "cpu") {
+ if (of_property_match_string(dn, "status", "bad") >= 0)
+ bad_count++;
+ };
+
+ if (bad_count) {
+ pr_cont(" __ \n");
+ pr_cont(" / \\ _______________ \n");
+ pr_cont(" | | / \\ \n");
+ pr_cont(" @ @ | WARNING! | \n");
+ pr_cont(" || || | It looks like | \n");
+ pr_cont(" || || <--| you have %*d | \n", 3, bad_count);
+ pr_cont(" |\\_/| | guarded cores | \n");
+ pr_cont(" \\___/ \\_______________/ \n\n");
+ }
+}
+
static void __init pnv_setup_arch(void)
{
set_arch_panic_timeout(10, ARCH_PANIC_TIMEOUT);
@@ -149,6 +171,8 @@ static void __init pnv_setup_arch(void)
/* Enable NAP mode */
powersave_nap = 1;
+ pnv_check_guarded_cores();
+
/* XXX PMCS */
}
--
2.20.1
^ permalink raw reply related
* [Bug 204375] kernel 5.2.4 w. KASAN enabled fails to boot on a PowerMac G4 3,6 at very early stage
From: bugzilla-daemon @ 2019-08-01 5:36 UTC (permalink / raw)
To: linuxppc-dev
In-Reply-To: <bug-204375-206035@https.bugzilla.kernel.org/>
https://bugzilla.kernel.org/show_bug.cgi?id=204375
--- Comment #12 from Christophe Leroy (christophe.leroy@c-s.fr) ---
On my side under QEMU, deactivating KASAN on lib/mpi significantly reduces boot
time.
For that, just add the following on top of lib/mpi/Makefile:
KASAN_SANITIZE := n
--
You are receiving this mail because:
You are watching the assignee of the bug.
^ permalink raw reply
* Re: [PATCH v2] powerpc: Support CMDLINE_EXTEND
From: Christophe Leroy @ 2019-08-01 6:14 UTC (permalink / raw)
To: Chris Packham, benh, paulus, mpe, malat; +Cc: linuxppc-dev, linux-kernel
In-Reply-To: <20190801021206.26799-1-chris.packham@alliedtelesis.co.nz>
Le 01/08/2019 à 04:12, Chris Packham a écrit :
> Bring powerpc in line with other architectures that support extending or
> overriding the bootloader provided command line.
>
> The current behaviour is most like CMDLINE_FROM_BOOTLOADER where the
> bootloader command line is preferred but the kernel config can provide a
> fallback so CMDLINE_FROM_BOOTLOADER is the default. CMDLINE_EXTEND can
> be used to append the CMDLINE from the kernel config to the one provided
> by the bootloader.
>
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
> While I'm at it does anyone think it's worth getting rid of the default CMDLINE
> value if CMDLINE_BOOL and maybe CMDLINE_BOOL? Every defconfig in the kernel
> that sets CMDLINE_BOOL=y also sets CMDLINE to something other than
> "console=ttyS0,9600 console=tty0 root=/dev/sda2". Removing CMDLINE_BOOL and
> unconditionally setting the default value of CMDLINE to "" would clean up the
> Kconfig even more.
Note
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cbe46bd4f5104552b612505b73d366f66efc2341
which is already a step forward.
I guess that default is for users selecting this option manually to get
a first sensitive CMDLINE. But is it really worth it ?
>
> Changes in v2:
> - incorporate ideas from Christope's patch https://patchwork.ozlabs.org/patch/1074126/
>
> arch/powerpc/Kconfig | 20 +++++++++++++++++++-
> arch/powerpc/kernel/prom_init.c | 26 +++++++++++++++++++++++++-
> 2 files changed, 44 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 77f6ebf97113..d413fe1b4058 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -852,15 +852,33 @@ config CMDLINE
> some command-line options at build time by entering them here. In
> most cases you will need to specify the root device here.
>
> +choice
> + prompt "Kernel command line type" if CMDLINE != ""
> + default CMDLINE_FROM_BOOTLOADER
> +
> +config CMDLINE_FROM_BOOTLOADER
> + bool "Use bootloader kernel arguments if available"
> + help
> + Uses the command-line options passed by the boot loader. If
> + the boot loader doesn't provide any, the default kernel command
> + string provided in CMDLINE will be used.
> +
> +config CMDLINE_EXTEND
> + bool "Extend bootloader kernel arguments"
> + help
> + The command-line arguments provided by the boot loader will be
> + appended to the default kernel command string.
> +
> config CMDLINE_FORCE
> bool "Always use the default kernel command string"
> - depends on CMDLINE_BOOL
> help
> Always use the default kernel command string, even if the boot
> loader passes other arguments to the kernel.
> This is useful if you cannot or don't want to change the
> command-line options your boot loader passes to the kernel.
>
> +endchoice
> +
> config EXTRA_TARGETS
> string "Additional default image types"
> help
> diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
> index 514707ef6779..df29f141dbd2 100644
> --- a/arch/powerpc/kernel/prom_init.c
> +++ b/arch/powerpc/kernel/prom_init.c
> @@ -310,6 +310,25 @@ static size_t __init prom_strlcpy(char *dest, const char *src, size_t size)
> return ret;
> }
>
> +static size_t __init prom_strlcat(char *dest, const char *src, size_t count)
> +{
> + size_t dsize = prom_strlen(dest);
> + size_t len = prom_strlen(src);
> + size_t res = dsize + len;
> +
> + /* This would be a bug */
> + BUG_ON(dsize >= count);
Has you pointed in another mail, BUG_ON() should be avoided here.
I guess if the destination is already full, just return count:
if (dsize >= count)
return count;
> +
> + dest += dsize;
> + count -= dsize;
> + if (len >= count)
> + len = count-1;
> + memcpy(dest, src, len);
> + dest[len] = 0;
> + return res;
> +
> +}
> +
> #ifdef CONFIG_PPC_PSERIES
> static int __init prom_strtobool(const char *s, bool *res)
> {
> @@ -761,8 +780,13 @@ static void __init early_cmdline_parse(void)
> p = prom_cmd_line;
> if ((long)prom.chosen > 0)
> l = prom_getprop(prom.chosen, "bootargs", p, COMMAND_LINE_SIZE-1);
The above is pointless in case CONFIG_CMDLINE_FORCE is selected.
> - if (IS_ENABLED(CONFIG_CMDLINE_BOOL) && (l <= 0 || p[0] == '\0')) /* dbl check */
> +
> + if (IS_ENABLED(CONFIG_CMDLINE_FORCE) || l <= 0 || p[0] == '\0')
> prom_strlcpy(prom_cmd_line, CONFIG_CMDLINE, sizeof(prom_cmd_line));
If we can ensure that prom_cmd_line remains empty when
CONFIG_CMDLINE_FORCE is selected (see above comment), then
prom_strlcat() can be used in lieu of prom_strlcpy()
> + else if (IS_ENABLED(CONFIG_CMDLINE_EXTEND))
> + prom_strlcat(prom_cmd_line, " " CONFIG_CMDLINE,
> + sizeof(prom_cmd_line));
> +
> prom_printf("command line: %s\n", prom_cmd_line);
>
> #ifdef CONFIG_PPC64
>
Christophe
^ permalink raw reply
* [PATCH 0/2] powerpc/xive: 2 small tweaks in 'xive_irq_bitmap_add()'
From: Christophe JAILLET @ 2019-08-01 8:31 UTC (permalink / raw)
To: benh, paulus, mpe, allison, tglx, clg, groug
Cc: kernel-janitors, Christophe JAILLET, linuxppc-dev, linux-kernel
The first patch uses GFP_KERNEL instead of GFP_ATOMIC.
The 2nd adds a check for memory allocation failure.
Christophe JAILLET (2):
powerpc/xive: Use GFP_KERNEL instead of GFP_ATOMIC in
'xive_irq_bitmap_add()'
powerpc/xive: Add a check for memory allocation failure
arch/powerpc/sysdev/xive/spapr.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
--
2.20.1
^ permalink raw reply
* [PATCH 1/2] powerpc/xive: Use GFP_KERNEL instead of GFP_ATOMIC in 'xive_irq_bitmap_add()'
From: Christophe JAILLET @ 2019-08-01 8:32 UTC (permalink / raw)
To: benh, paulus, mpe, allison, tglx, clg, groug
Cc: kernel-janitors, Christophe JAILLET, linuxppc-dev, linux-kernel
In-Reply-To: <cover.1564647619.git.christophe.jaillet@wanadoo.fr>
There is no need to use GFP_ATOMIC here. GFP_KERNEL should be enough.
GFP_KERNEL is also already used for another allocation just a few lines
below.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
arch/powerpc/sysdev/xive/spapr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/sysdev/xive/spapr.c b/arch/powerpc/sysdev/xive/spapr.c
index 8ef9cf4ebb1c..b4f5eb9e0f82 100644
--- a/arch/powerpc/sysdev/xive/spapr.c
+++ b/arch/powerpc/sysdev/xive/spapr.c
@@ -45,7 +45,7 @@ static int xive_irq_bitmap_add(int base, int count)
{
struct xive_irq_bitmap *xibm;
- xibm = kzalloc(sizeof(*xibm), GFP_ATOMIC);
+ xibm = kzalloc(sizeof(*xibm), GFP_KERNEL);
if (!xibm)
return -ENOMEM;
--
2.20.1
^ permalink raw reply related
* [PATCH 2/2] powerpc/xive: Add a check for memory allocation failure
From: Christophe JAILLET @ 2019-08-01 8:32 UTC (permalink / raw)
To: benh, paulus, mpe, allison, tglx, clg, groug
Cc: kernel-janitors, Christophe JAILLET, linuxppc-dev, linux-kernel
In-Reply-To: <cover.1564647619.git.christophe.jaillet@wanadoo.fr>
The result of this kzalloc is not checked. Add a check and corresponding
error handling code.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Note that 'xive_irq_bitmap_add()' failures are not handled in
'xive_spapr_init()'
I guess that it is not really an issue. This function is _init, so if a
memory allocation occures here, it is likely that the system will
already be in bad shape.
Anyway, the check added here would at least keep the data linked in
'xive_irq_bitmaps' usable.
---
arch/powerpc/sysdev/xive/spapr.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/powerpc/sysdev/xive/spapr.c b/arch/powerpc/sysdev/xive/spapr.c
index b4f5eb9e0f82..52198131c75e 100644
--- a/arch/powerpc/sysdev/xive/spapr.c
+++ b/arch/powerpc/sysdev/xive/spapr.c
@@ -53,6 +53,10 @@ static int xive_irq_bitmap_add(int base, int count)
xibm->base = base;
xibm->count = count;
xibm->bitmap = kzalloc(xibm->count, GFP_KERNEL);
+ if (!xibm->bitmap) {
+ kfree(xibm);
+ return -ENOMEM;
+ }
list_add(&xibm->list, &xive_irq_bitmaps);
pr_info("Using IRQ range [%x-%x]", xibm->base,
--
2.20.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox