LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [V2, 3/4] powerpc/mm/hash64: Store the slot information at the right offset.
From: Michael Ellerman @ 2018-02-14  5:43 UTC (permalink / raw)
  To: Aneesh Kumar K.V, benh, paulus, Ram Pai; +Cc: linuxppc-dev, Aneesh Kumar K.V
In-Reply-To: <20180211150009.21297-3-aneesh.kumar@linux.vnet.ibm.com>

On Sun, 2018-02-11 at 15:00:08 UTC, "Aneesh Kumar K.V" wrote:
> The hugetlb pte entries are at the PMD and PUD level. Use the right offset
> for them to get the second half of the table.
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> Reviewed-by: Ram Pai <linuxram@us.ibm.com>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/ff31e105464d8c8c97301964682702

cheers

^ permalink raw reply

* Re: [1/1] powerpc/pseries: Enable RAS hotplug events late
From: Michael Ellerman @ 2018-02-14  5:43 UTC (permalink / raw)
  To: Sam Bobroff, linuxppc-dev
In-Reply-To: <b3202827b5f22e9a7e8f145f83140698911641f7.1518394650.git.sam.bobroff@au1.ibm.com>

On Mon, 2018-02-12 at 00:19:29 UTC, Sam Bobroff wrote:
> Currently if the kernel receives a memory hot-unplug event early
> enough, it may get stuck in an infinite loop in
> dissolve_free_huge_pages(). This appears as a stall just after:
> 
> pseries-hotplug-mem: Attempting to hot-remove XX LMB(s) at YYYYYYYY
> 
> It appears to be caused by "minimum_order" being uninitialized, due to
> init_ras_IRQ() executing before hugetlb_init().
> 
> To correct this, extract the part of init_ras_IRQ() that enables
> hotplug event processing and place it in the machine_late_initcall
> phase, which is guaranteed to be after hugetlb_init() is called.
> 
> Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
> Acked-by: Balbir Singh <bsingharora@gmail.com>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/c9dccf1d074a67d36c510845f66398

cheers

^ permalink raw reply

* Re: [1/2] powerpc/kdump: Add missing optional dummy functions
From: Michael Ellerman @ 2018-02-14  5:43 UTC (permalink / raw)
  To: Guenter Roeck, Benjamin Herrenschmidt
  Cc: linux-kernel, Nicholas Piggin, Paul Mackerras, linuxppc-dev,
	Guenter Roeck
In-Reply-To: <1518474848-3158-1-git-send-email-linux@roeck-us.net>

On Mon, 2018-02-12 at 22:34:07 UTC, Guenter Roeck wrote:
> If KEXEC_CORE is not enabled, PowerNV builds fail as follows.
> 
> arch/powerpc/platforms/powernv/smp.c: In function 'pnv_smp_cpu_kill_self':
> arch/powerpc/platforms/powernv/smp.c:236:4: error:
> 	implicit declaration of function 'crash_ipi_callback'
> 
> Add dummy function calls, similar to kdump_in_progress(), to solve the
> problem.
> 
> Fixes: 4145f358644b ("powernv/kdump: Fix cases where the kdump kernel ...")
> Cc: Balbir Singh <bsingharora@gmail.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> Acked-by: Balbir Singh <bsingharora@gmail.com>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/910961754572a2f4c83ad7e610d180

cheers

^ permalink raw reply

* Re: selftests/powerpc: Fix: use ucontext_t instead of struct ucontext
From: Michael Ellerman @ 2018-02-14  5:43 UTC (permalink / raw)
  To: Harish, linuxppc-dev; +Cc: Harish
In-Reply-To: <1518503575-19021-1-git-send-email-harish@linux.vnet.ibm.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 664 bytes --]

On Tue, 2018-02-13 at 06:32:55 UTC, Harish wrote:
> With glibc 2.26 'struct ucontext' is removed to improve POSIX
> compliance, which breaks powerpc/alignment_handler selftest.
> Fix the test by using ucontext_t. Tested on ppc, works with older
> glibc versions as well.
> 
> Fixes the following:
> alignment_handler.c: In function ‘sighandler’:
> alignment_handler.c:68:5: error: dereferencing pointer to incomplete type ‘struct ucontext’
>   ucp->uc_mcontext.gp_regs[PT_NIP] += 4;
>      ^~
> 
> Signed-off-by: Harish <harish@linux.vnet.ibm.com>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/ecdf06e1ea5376bba03c155751f686

cheers

^ permalink raw reply

* Re: [2/2] powerpc/pseries: Declare optional dummy function for find_and_online_cpu_nid
From: Michael Ellerman @ 2018-02-14  5:43 UTC (permalink / raw)
  To: Guenter Roeck, Benjamin Herrenschmidt
  Cc: linux-kernel, Michael Bringmann, Paul Mackerras, Nathan Fontenot,
	linuxppc-dev, Guenter Roeck
In-Reply-To: <1518474848-3158-2-git-send-email-linux@roeck-us.net>

On Mon, 2018-02-12 at 22:34:08 UTC, Guenter Roeck wrote:
> Commit e67e02a544e9 ("powerpc/pseries: Fix cpu hotplug crash with
> memoryless nodes") adds an unconditional call to find_and_online_cpu_nid(),
> which is only declared if CONFIG_PPC_SPLPAR is enabled. This results in
> the following build error if this is not the case.
> 
> arch/powerpc/platforms/pseries/hotplug-cpu.o: In function `dlpar_online_cpu':
> arch/powerpc/platforms/pseries/hotplug-cpu.c:369:
> 			undefined reference to `.find_and_online_cpu_nid'
> 
> Follow the guideline provided by similar functions and provide a dummy
> function if CONFIG_PPC_SPLPAR is not enabled. This also moves the external
> function declaration into an include file where it should be.
> 
> Fixes: e67e02a544e9 ("powerpc/pseries: Fix cpu hotplug crash with ...")
> Cc: Michael Bringmann <mwb@linux.vnet.ibm.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/82343484a2d4c97a03bfd81303b549

cheers

^ permalink raw reply

* Re: [V3] powerpc/mm/hash64: memset the pagetable pages on allocation.
From: Michael Ellerman @ 2018-02-14  5:43 UTC (permalink / raw)
  To: Aneesh Kumar K.V, benh, paulus, Ram Pai; +Cc: linuxppc-dev, Aneesh Kumar K.V
In-Reply-To: <20180213110933.5491-1-aneesh.kumar@linux.vnet.ibm.com>

On Tue, 2018-02-13 at 11:09:33 UTC, "Aneesh Kumar K.V" wrote:
> On powerpc we allocate page table pages from slab cache of different sizes. For
> now we have a constructor that zero out the objects when we allocate then for
> the first time. We expect the objects to be zeroed out when we free the the
> object back to slab cache. This happens in the unmap path. For hugetlb pages
> we call huge_pte_get_and_clear to do that. With the current configuration of
> page table size, both pud and pgd level tables get allocated from the same slab
> cache. At the pud level, we use the second half of the table to store the slot
> information. But never clear that when unmapping. When such an freed object get
> allocated at pgd level, we will have part of the page table page not initlaized
> correctly. This result in kernel crash
> 
> Simplify this by calling the object initialization after kmem_cache_alloc
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/fc5c2f4a55a2c258e12013cdf287cf

cheers

^ permalink raw reply

* Re: [PATCH] powerpc/xive: use hw CPU ids when configuring the CPU queues
From: Michael Ellerman @ 2018-02-14  5:55 UTC (permalink / raw)
  To: Cédric Le Goater, linuxppc-dev; +Cc: Benjamin Herrenschmidt, stable
In-Reply-To: <592440b1-5943-2315-c477-598900c79521@kaod.org>

C=C3=A9dric Le Goater <clg@kaod.org> writes:

> On 02/13/2018 10:18 AM, Michael Ellerman wrote:
>> C=C3=A9dric Le Goater <clg@kaod.org> writes:
>>=20
>>> The CPU event notification queues on sPAPR should be configured using
>>> a hardware CPU identifier.
>>>
>>> The problem did not show up on the Power Hypervisor because pHyp
>>> supports 8 threads per core which keeps CPU number contiguous. This is
>>> not the case on all sPAPR virtual machines, some use SMT=3D1.
>>>
>>> Also improve error logging by adding the CPU number.
>>>
>>> Signed-off-by: C=C3=A9dric Le Goater <clg@kaod.org>
>>> ---
>>>
>>>  I think we should send this one to stable also.
>>=20
>> Fixes: eac1e731b59e ("powerpc/xive: guest exploitation of the XIVE inter=
rupt controller")
>
> yes.
>
>> Cc: stable@vger.kernel.org # v4.14+
>
> yes. I just added the Cc:. I am not sure that will work with=20
> patchwork though.

They don't accept patches that way.

I'll add the tags and commit it.

cheers

^ permalink raw reply

* Re: 4.16-rc1 virtual machine crash on boot
From: Cyril Bur @ 2018-02-14  6:15 UTC (permalink / raw)
  To: Tyrel Datwyler, linuxppc-dev@ozlabs.org, Nathan Fontenot,
	Michael Ellerman
In-Reply-To: <f8cfacb1-8675-c8f0-4147-d0ba74717488@linux.vnet.ibm.com>

On Tue, 2018-02-13 at 21:12 -0800, Tyrel Datwyler wrote:
> On 02/13/2018 05:20 PM, Cyril Bur wrote:
> > Hello all,
> 
> Does reverting commit 02ef6dd8109b581343ebeb1c4c973513682535d6 alleviate the issue?
> 

Hi Tyrel,

No it doesn't. Same backtrace.

> -Tyrel
> 
> > 
> > I'm seeing this crash trying to boot a KVM virtual machine. This kernel
> > was compiled with pseries_le_defconfig and run using the following qemu
> > commandline:
> > 
> > qemu-system-ppc64 -enable-kvm -cpu POWER8 -smp 4 -m 4G -M pseries
> > -nographic -vga none -drive file=vm.raw,if=virtio,format=raw -drive
> > file=mkvmconf2xeO,if=virtio,format=raw -netdev type=user,id=net0
> > -device virtio-net-pci,netdev=net0 -kernel vmlinux_tscr -append
> > 'root=/dev/vdb1 rw cloud-init=disabled'
> > 
> > qemu-system-ppc64 --version
> > QEMU emulator version 2.5.0 (Debian 1:2.5+dfsg-5ubuntu10.16), Copyright
> > (c) 2003-2008 Fabrice Bellard
> > 
> > 
> > Key type dns_resolver registered
> > Unable to handle kernel paging request for data at address 0x00000010
> > Faulting instruction address: 0xc0000000018f2bbc
> > Oops: Kernel access of bad area, sig: 11 [#1]
> > LE SMP NR_CPUS=2048 NUMA pSeries
> > CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.16.0-rc1v4.16-rc1 #8
> > NIP:  c0000000018f2bbc LR: c0000000018f2bb4 CTR: 0000000000000000
> > REGS: c0000000fea838d0 TRAP: 0380   Not tainted  (4.16.0-rc1v4.16-rc1)
> > MSR:  8000000002009033 <SF,VEC,EE,ME,IR,DR,RI,LE>  CR: 84000248  XER:
> > 20000000
> > CFAR: c0000000019591a0 SOFTE: 0 
> > GPR00: c0000000018f2bb4 c0000000fea83b50 c000000001bd8400
> > 0000000000000000 
> > GPR04: c0000000fea83b70 0000000000000000 000000000000002f
> > 0000000000000022 
> > GPR08: 0000000000000000 c0000000022a3e90 0000000000000000
> > 0000000000000220 
> > GPR12: 0000000000000000 c00000000fb40980 c00000000000d698
> > 0000000000000000 
> > GPR16: 0000000000000000 0000000000000000 0000000000000000
> > 0000000000000000 
> > GPR20: 0000000000000000 0000000000000000 0000000000000000
> > 0000000000000000 
> > GPR24: 0000000000000000 c0000000018b9248 c0000000018e36d8
> > c0000000019738a8 
> > GPR28: 0000000000000007 c0000000fffffc68 c0000000fea83bf0
> > 0000000000000010 
> > NIP [c0000000018f2bbc] read_drconf_v1_cell+0x50/0x9c
> > LR [c0000000018f2bb4] read_drconf_v1_cell+0x48/0x9c
> > Call Trace:
> > [c0000000fea83b50] [c0000000018f2bb4] read_drconf_v1_cell+0x48/0x9c
> > (unreliable)
> > [c0000000fea83b90] [c0000000018f305c] drmem_init+0x13c/0x2ec
> > [c0000000fea83c40] [c0000000018e4288] do_one_initcall+0xdc/0x1ac
> > [c0000000fea83d00] [c0000000018e45d4] kernel_init_freeable+0x27c/0x358
> > [c0000000fea83dc0] [c00000000000d6bc] kernel_init+0x2c/0x160
> > [c0000000fea83e30] [c00000000000bc20] ret_from_kernel_thread+0x5c/0xbc
> > Instruction dump:
> > 7c7f1b78 60000000 60000000 7c240b78 3d22ffdc 3929f0a4 e95e0000
> > e8690002 
> > f9440021 4806657d 60000000 e9210020 <f87f0000> 39090004 39490010
> > f9010020 
> > ---[ end trace bd9f49f482d30e03 ]---
> > 
> > Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
> > 
> > WARNING: CPU: 1 PID: 1 at drivers/tty/vt/vt.c:3883
> > do_unblank_screen+0x1f0/0x270
> > CPU: 1 PID: 1 Comm: swapper/0 Tainted: G      D          4.16.0-
> > rc1v4.16-rc1 #8
> > NIP:  c0000000009aa800 LR: c0000000009aa63c CTR: c00000000148f5f0
> > REGS: c0000000fea832c0 TRAP: 0700   Tainted:
> > G      D           (4.16.0-rc1v4.16-rc1)
> > MSR:  8000000002029033 <SF,VEC,EE,ME,IR,DR,RI,LE>  CR: 28002222  XER:
> > 20000000
> > CFAR: c0000000009aa658 SOFTE: 1 
> > GPR00: c0000000009aa63c c0000000fea83540 c000000001bd8400
> > 0000000000000000 
> > GPR04: 0000000000000001 c0000000fb0c200e 0000000000001dd7
> > c0000000fea834d0 
> > GPR08: 00000000fe430000 0000000000000000 0000000000000000
> > 0000000000000001 
> > GPR12: 0000000028002428 c00000000fb40980 c00000000000d698
> > 0000000000000000 
> > GPR16: 0000000000000000 0000000000000000 0000000000000000
> > 0000000000000000 
> > GPR20: 0000000000000000 0000000000000000 0000000000000000
> > 0000000000000000 
> > GPR24: c0000000fea40000 c0000000feadf910 c000000001a4a7a8
> > c000000001cc4ea0 
> > GPR28: c00000000173f4f0 c000000001cc4ec8 0000000000000000
> > 0000000000000000 
> > NIP [c0000000009aa800] do_unblank_screen+0x1f0/0x270
> > LR [c0000000009aa63c] do_unblank_screen+0x2c/0x270
> > Call Trace:
> > [c0000000fea83540] [c0000000009aa63c] do_unblank_screen+0x2c/0x270
> > (unreliable)
> > [c0000000fea835b0] [c0000000008a2a70] bust_spinlocks+0x40/0x80
> > [c0000000fea835d0] [c0000000000da90c] panic+0x1b8/0x32c
> > [c0000000fea83670] [c0000000000e1bd4] do_exit+0xcb4/0xcc0
> > [c0000000fea83730] [c0000000000275fc] die+0x29c/0x450
> > [c0000000fea837c0] [c000000000053f88] bad_page_fault+0xe8/0x160
> > [c0000000fea83830] [c000000000028a90] slb_miss_bad_addr+0x40/0x90
> > [c0000000fea83860] [c000000000008b08] bad_addr_slb+0x158/0x160
> > --- interrupt: 380 at read_drconf_v1_cell+0x50/0x9c
> >     LR = read_drconf_v1_cell+0x48/0x9c
> > [c0000000fea83b90] [c0000000018f305c] drmem_init+0x13c/0x2ec
> > [c0000000fea83c40] [c0000000018e4288] do_one_initcall+0xdc/0x1ac
> > [c0000000fea83d00] [c0000000018e45d4] kernel_init_freeable+0x27c/0x358
> > [c0000000fea83dc0] [c00000000000d6bc] kernel_init+0x2c/0x160
> > [c0000000fea83e30] [c00000000000bc20] ret_from_kernel_thread+0x5c/0xbc
> > Instruction dump:
> > 3c62ffbf 38840001 7c8407b4 38639ca8 4b7ae0ed 60000000 38210070
> > e8010010 
> > ebc1fff0 ebe1fff8 7c0803a6 4e800020 <0fe00000> 4bfffe58 60000000
> > 60420000 
> > ---[ end trace bd9f49f482d30e04 ]---
> > Rebooting in 10 seconds..
> > 
> 
> 

^ permalink raw reply

* Re: [bug report] ocxl: Add AFU interrupt support
From: Dan Carpenter @ 2018-02-14  7:29 UTC (permalink / raw)
  To: Frederic Barrat; +Cc: linuxppc-dev
In-Reply-To: <dc0b4b1c-b3f5-bc4e-1f96-96055fecd77d@linux.vnet.ibm.com>

On Tue, Feb 13, 2018 at 08:29:26PM +0100, Frederic Barrat wrote:
> Hi,
> 
> Thanks for the report. I'll fix the first issue. The 2nd is already on its
> way to upstream:
> https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id=dedab7f0d3137441a97fe7cf9b9ca5
> 
> (though we still have a useless cast in there; will fix as well).
> 
> May I ask what static checker you're using?
> 

These are Smatch warnings.

regards,
dan carpenter

^ permalink raw reply

* Re: samples/seccomp/ broken when cross compiling s390, ppc allyesconfig
From: Michal Hocko @ 2018-02-14  9:20 UTC (permalink / raw)
  To: Kees Cook; +Cc: Michael Ellerman, Will Drewry, linux-s390, PowerPC, LKML
In-Reply-To: <CAGXu5jJZROQMxzxu+Dp3mVMktSg-oTB6pqk7fUyM_6_2oa9c_A@mail.gmail.com>

On Tue 13-02-18 13:27:30, Kees Cook wrote:
> On Tue, Feb 13, 2018 at 2:32 AM, Michal Hocko <mhocko@kernel.org> wrote:
> > On Tue 13-02-18 21:16:55, Michael Ellerman wrote:
> >> Kees Cook <keescook@chromium.org> writes:
> >>
> >> > On Mon, Feb 12, 2018 at 7:25 PM, Michael Ellerman <mpe@ellerman.id.au> wrote:
> >> >> Michal Hocko <mhocko@kernel.org> writes:
> >> >>> Hi,
> >> >>> my build test machinery chokes on samples/seccomp when cross compiling
> >> >>> s390 and ppc64 allyesconfig. This has been the case for quite some
> >> >>> time already but I never found time to look at the problem and report
> >> >>> it. It seems this is not new issue and similar thing happend for
> >> >>> MIPS e9107f88c985 ("samples/seccomp/Makefile: do not build tests if
> >> >>> cross-compiling for MIPS").
> >> >>>
> >> >>> The build logs are attached.
> >> >>>
> >> >>> What is the best way around this? Should we simply skip compilation on
> >> >>> cross compile or is actually anybody relying on that? Or should I simply
> >> >>> disable it for s390 and ppc?
> >> >>
> >> >> The whole thing seems very confused. It's not building for the target,
> >> >> it's building for the host, ie. the Makefile sets hostprogs-m and
> >> >> HOSTCFLAGS etc.
> >> >>
> >> >> So it can't possibly work with cross compiling as it's currently
> >> >> written.
> >> >>
> >> >> Either the Makefile needs some serious work to properly support cross
> >> >> compiling or it should just be disabled when cross compiling.
> >> >
> >> > Hrm, yeah, the goal was to entirely disable cross compiling, but I
> >> > guess we didn't hit it with a hard enough hammer. :)
> >>
> >> Do you know why it is written that way? Why doesn't it just try to cross
> >> compile like normal code?
> >
> > No idea, sorry. All I know about this code is that it breaks my build
> > testing.
> 
> IIRC, one of the problems is with build ordering problems: the kernel
> headers used by the samples aren't available when cross compiling.
> 
> I'm happy to kill it entirely with Michal's patch, though. Feel free
> to carry in your tree!
> 
> Acked-by: Kees Cook <keescook@chromium.org>

OK, so let's try to nuke it. How should I route this patch?

>From 8d8457e96296538508e478f598d1c8b3406a8626 Mon Sep 17 00:00:00 2001
From: Michal Hocko <mhocko@suse.com>
Date: Wed, 14 Feb 2018 10:15:12 +0100
Subject: [PATCH] samples/seccomp: do not compile when cross compiled
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

samples/seccomp relies on the host setting which is not suitable for
crosscompilation and it actually fails when crosscompiling s390 and
powerpc all{yes,mod}config on x86_64 with

samples/seccomp/bpf-helper.h:135:2: error: #error __BITS_PER_LONG value unusable.
 #error __BITS_PER_LONG value unusable.
  ^
In file included from samples/seccomp/bpf-fancy.c:13:0:
samples/seccomp/bpf-fancy.c: In function ‘main’:
samples/seccomp/bpf-fancy.c:38:11: error: ‘__NR_exit’ undeclared (first use in this function)
   SYSCALL(__NR_exit, ALLOW),

and many others. I am doing these for compile testing and it's been
quite useful to catch issues. Crosscompiling sample code on the other
hand doesn't seem all that important so it seems like the easiest way to
simply disable samples/seccomp when crosscompiling.

Fixing this properly is not that easy as Kees explains:
: IIRC, one of the problems is with build ordering problems: the kernel
: headers used by the samples aren't available when cross compiling.

Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
 samples/seccomp/Makefile | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/samples/seccomp/Makefile b/samples/seccomp/Makefile
index 0e349b80686e..ba942e3ead89 100644
--- a/samples/seccomp/Makefile
+++ b/samples/seccomp/Makefile
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
+ifndef CROSS_COMPILE
 hostprogs-$(CONFIG_SAMPLE_SECCOMP) := bpf-fancy dropper bpf-direct
 
 HOSTCFLAGS_bpf-fancy.o += -I$(objtree)/usr/include
@@ -16,7 +17,6 @@ HOSTCFLAGS_bpf-direct.o += -idirafter $(objtree)/include
 bpf-direct-objs := bpf-direct.o
 
 # Try to match the kernel target.
-ifndef CROSS_COMPILE
 ifndef CONFIG_64BIT
 
 # s390 has -m31 flag to build 31 bit binaries
@@ -35,12 +35,4 @@ HOSTLOADLIBES_bpf-fancy += $(MFLAG)
 HOSTLOADLIBES_dropper += $(MFLAG)
 endif
 always := $(hostprogs-m)
-else
-# MIPS system calls are defined based on the -mabi that is passed
-# to the toolchain which may or may not be a valid option
-# for the host toolchain. So disable tests if target architecture
-# is MIPS but the host isn't.
-ifndef CONFIG_MIPS
-always := $(hostprogs-m)
-endif
 endif
-- 
2.15.1

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply related

* Re: [PATCH] powerpc/xmon: Dont register sysrq key when kernel param xmon=off
From: Michael Ellerman @ 2018-02-14 11:40 UTC (permalink / raw)
  To: Vaibhav Jain, Balbir Singh
  Cc: open list:LINUX FOR POWERPC (32-BIT AND 64-BIT),
	linux-kernel@vger.kernel.org, Benjamin Herrenschmidt,
	Paul Mackerras, Nicholas Piggin, Douglas Miller, Pan Xinhui
In-Reply-To: <8737264c91.fsf@vajain21.in.ibm.com>

Vaibhav Jain <vaibhav@linux.vnet.ibm.com> writes:

> Thanks for reviewing this patch Balbir
>
> Balbir Singh <bsingharora@gmail.com> writes:
>
>> Any specific issue you've run into without this patch? 
> Without this patch since xmon is still accessible via sysrq and there is
> no indication/warning on the xmon console mentioning that its is not
> fully functional. Specifically xmon-console would still allow user to
> set instruction/data breakpoint eventhough they wont work and will
> result in a kernel-oops.
>
> Below is command log illustrating this problem on one of my test system
> where I tried setting an instruction breakpoint on cmdline_proc_show()
> with xmon=off:

<snip>

But the same crash happens with XMON_DEFAULT=n and nothing on the
command line.

The problem is not xmon=off on the command line.

The problem is that when xmon_on = false and we enter xmon via sysrq and
then set breakpoints, we need to enable xmon_on before leaving xmon.

So this is a bug introduced by:

  3b5bf42b81d5 ("powerpc/xmon: Fix an unexpected xmon on/off state change")


How to fix it is not entirely clear. In general I like the behaviour we
have since the above commit, ie. quickly dropping into xmon and
inspecting something doesn't leave xmon enabled, which then causes the
system not to kdump/reboot later.

What would be nice is if we keep that behaviour, but any action you take
in xmon that requires xmon to remain resident, ie. setting a breakpoint,
calls a function which makes sure xmon_on = true and if it wasn't prints
a nice message saying "Turning xmon on due to breakpoint insertion" or
something.

cheers

^ permalink raw reply

* [PATCH] powerpc: add empty update_numa_cpu_lookup_table for !CONFIG_NUMA
From: Corentin Labbe @ 2018-02-14 12:17 UTC (permalink / raw)
  To: benh, mpe, paulus, nfont, tyreld
  Cc: linux-kernel, linuxppc-dev, Corentin Labbe

When CONFIG_NUMA is not set, build fail with:
arch/powerpc/platforms/pseries/hotplug-cpu.c:335:4: error: déclaration implicite de la fonction « update_numa_cpu_lookup_table » [-Werror=implicit-function-declaration]

So we have to add update_numa_cpu_lookup_table as an empty function when CONFIG_NUMA is not set.

Fixes: 1d9a090783be ("powerpc/numa: Invalidate numa_cpu_lookup_table on cpu remove")
Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 arch/powerpc/include/asm/topology.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
index 593248110902..9f421641a35c 100644
--- a/arch/powerpc/include/asm/topology.h
+++ b/arch/powerpc/include/asm/topology.h
@@ -81,6 +81,9 @@ static inline int numa_update_cpu_topology(bool cpus_locked)
 {
 	return 0;
 }
+
+static inline void update_numa_cpu_lookup_table(unsigned int cpu, int node) {}
+
 #endif /* CONFIG_NUMA */
 
 #if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
-- 
2.13.6

^ permalink raw reply related

* [GIT PULL] Please pull powerpc/linux.git powerpc-4.16-2 tag
From: Michael Ellerman @ 2018-02-14 13:36 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: aik, andrew.donnellan, aneesh.kumar, bsingharora, colin.king,
	fbarrat, harish, linux-kernel, linux, linuxppc-dev, maddy, nfont,
	npiggin, sam.bobroff

[-- Attachment #1: Type: text/plain, Size: 5008 bytes --]

Hi Linus,

Please pull some powerpc fixes for 4.16:

The following changes since commit 581e400ff935d34d95811258586128bf11baef15:

  Merge tag 'modules-for-v4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux (2018-02-07 14:29:34 -0800)

are available in the git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git tags/powerpc-4.16-2

for you to fetch changes up to ecdf06e1ea5376bba03c155751f6869d3dfaa210:

  selftests/powerpc: Fix to use ucontext_t instead of struct ucontext (2018-02-13 22:44:18 +1100)

----------------------------------------------------------------
powerpc fixes for 4.16 #2

A larger batch of fixes than we'd like. Roughly 1/3 fixes for new code, 1/3
fixes for stable and 1/3 minor things.

There's four commits fixing bugs when using 16GB huge pages on hash, caused by
some of the preparatory changes for pkeys.

Two fixes for bugs in the enhanced IRQ soft masking for local_t, one of which
broke KVM in some circumstances.

Four fixes for Power9. The most bizarre being a bug where futexes stopped
working because a NULL pointer dereference didn't trap during early boot (it
aliased the kernel mapping). A fix for memory hotplug when using the Radix MMU,
and a fix for live migration of guests using the Radix MMU.

Two fixes for hotplug on pseries machines. One where we weren't correctly
updating NUMA info when CPUs are added and removed. And the other fixes
crashes/hangs seen when doing memory hot remove during boot, which is apparently
a thing people do.

Finally a handful of build fixes for obscure configs and other minor fixes.

Thanks to:
  Alexey Kardashevskiy, Aneesh Kumar K.V, Balbir Singh, Colin Ian King, Daniel
  Henrique Barboza, Florian Weimer, Guenter Roeck, Harish, Laurent Vivier,
  Madhavan Srinivasan, Mauricio Faria de Oliveira, Nathan Fontenot, Nicholas
  Piggin, Sam Bobroff.

----------------------------------------------------------------
Alexey Kardashevskiy (1):
      powerpc/mm: Flush radix process translations when setting MMU type

Aneesh Kumar K.V (4):
      powerpc/mm: Fix crashes with 16G huge pages
      powerpc/mm/hash64: Allocate larger PMD table if hugetlb config is enabled
      powerpc/mm/hash64: Store the slot information at the right offset for hugetlb
      powerpc/mm/hash64: Zero PGD pages on allocation

Balbir Singh (1):
      powerpc/mm/radix: Split linear mapping on hot-unplug

Colin Ian King (1):
      ocxl: fix signed comparison with less than zero

Guenter Roeck (2):
      powerpc/pseries: Fix build break for SPLPAR=n and CPU hotplug
      powerpc/kdump: Fix powernv build break when KEXEC_CORE=n

Harish (1):
      selftests/powerpc: Fix to use ucontext_t instead of struct ucontext

Madhavan Srinivasan (1):
      powerpc/64s: Fix MASKABLE_RELON_EXCEPTION_HV_OOL macro

Nathan Fontenot (1):
      powerpc/numa: Invalidate numa_cpu_lookup_table on cpu remove

Nicholas Piggin (3):
      powerpc/64s: Fix may_hard_irq_enable() for PMI soft masking
      powerpc/64s/radix: Boot-time NULL pointer protection using a guard-PID
      powerpc/vas: Don't set uses_vas for kernel windows

Sam Bobroff (1):
      powerpc/pseries: Enable RAS hotplug events later

 arch/powerpc/include/asm/book3s/32/pgtable.h       |   1 +
 arch/powerpc/include/asm/book3s/64/hash-4k.h       |   3 +-
 arch/powerpc/include/asm/book3s/64/hash-64k.h      |  16 ++-
 arch/powerpc/include/asm/book3s/64/hash.h          |  13 ++-
 arch/powerpc/include/asm/book3s/64/pgalloc.h       |  16 ++-
 arch/powerpc/include/asm/book3s/64/pgtable.h       |   4 +-
 arch/powerpc/include/asm/exception-64s.h           |   2 +-
 arch/powerpc/include/asm/hw_irq.h                  |  12 ++-
 arch/powerpc/include/asm/kexec.h                   |   6 ++
 arch/powerpc/include/asm/nohash/32/pgtable.h       |   1 +
 arch/powerpc/include/asm/nohash/64/pgtable.h       |   1 +
 arch/powerpc/include/asm/topology.h                |  10 ++
 arch/powerpc/kernel/exceptions-64e.S               |   2 +
 arch/powerpc/kernel/exceptions-64s.S               |   6 +-
 arch/powerpc/mm/hash64_4k.c                        |   4 +-
 arch/powerpc/mm/hash64_64k.c                       |   8 +-
 arch/powerpc/mm/hash_utils_64.c                    |   1 +
 arch/powerpc/mm/hugetlbpage-hash64.c               |  10 +-
 arch/powerpc/mm/init-common.c                      |   4 +-
 arch/powerpc/mm/numa.c                             |   5 -
 arch/powerpc/mm/pgtable-radix.c                    | 117 +++++++++++++++++----
 arch/powerpc/mm/pgtable_64.c                       |   4 +
 arch/powerpc/mm/tlb_hash64.c                       |   9 +-
 arch/powerpc/platforms/powernv/vas-window.c        |  16 +--
 arch/powerpc/platforms/pseries/hotplug-cpu.c       |   4 +-
 arch/powerpc/platforms/pseries/ras.c               |  31 ++++--
 drivers/misc/ocxl/file.c                           |   2 +-
 .../powerpc/alignment/alignment_handler.c          |   2 +-	# tools/testing/selftests/
 28 files changed, 231 insertions(+), 79 deletions(-)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 800 bytes --]

^ permalink raw reply

* Re: [PATCH kernel v2] powerpc/mm: Flush radix process translations when setting MMU type
From: Michael Ellerman @ 2018-02-14 13:36 UTC (permalink / raw)
  To: Laurent Vivier, Daniel Henrique Barboza, Alexey Kardashevskiy,
	linuxppc-dev
In-Reply-To: <fe81336d-d356-59be-663b-2b81d7d407fd@redhat.com>

Laurent Vivier <lvivier@redhat.com> writes:
> On 07/02/2018 18:49, Daniel Henrique Barboza wrote:
>> On 02/07/2018 12:33 PM, Laurent Vivier wrote:
>>> On 01/02/2018 06:09, Alexey Kardashevskiy wrote:
>>>> Radix guests do normally invalidate process-scoped translations when
>>>> a new pid is allocated but migrated guests do not invalidate these so
>>>> migrated guests crash sometime, especially easy to reproduce with
>>>> migration happening within first 10 seconds after the guest boot
>>>> start on
>>>> the same machine.
>>>>
>>>> This adds the "Invalidate process-scoped translations" flush to fix
>>>> radix guests migration.
>>>>
>>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
...
>>>
>>> Tested-by: Laurent Vivier <lvivier@redhat.com>
>
> Any hope to have this patch merged soon?
>
> It fixes a real problem and migration of VM is not reliable without it.

Sorry it got lost in the merge window / rc1 madness. It's in my fixes
branch now and heading to Linus.

cheers

^ permalink raw reply

* [RFC PATCH 0/6] powerpc/mm/book3s64: Support for split pmd ptlock
From: Aneesh Kumar K.V @ 2018-02-14 13:50 UTC (permalink / raw)
  To: benh, paulus, mpe, Anton Blanchard, Nicholas Piggin
  Cc: linuxppc-dev, Aneesh Kumar K.V

This patch series add split pmd pagetable lock for book3s64. nohash64 also should
be able to switch to this. I need to workout the code dependency. This series
also migh have broken the build on platforms otherthan book3s64. I am sending this early
to get feedback on whether we should continue with the approach.

We switch the pmd allocator to use something similar to what we already use for
level 4 pagetable allocation. We get an order 0 page and divide that to fragments
and hand over fragments when we get request for a pmd pagetable. The pmd lock is
now stashed in the struct page backing the allocated page.

The series should help in reducing lock contention on mm->page_table_lock.

Aneesh Kumar K.V (6):
  powerpc/mm: Rename pte fragment functions
  powerpc/mm/4k: Switch 4k pagesize config to use pagetable fragment
  powerpc/mm: Implement helpers for pagetable fragment support at PMD
    level
  powerpc/mm: Simplify the rcu callback for page table free
  powerpc/mm: Use page fragments for allocation page table at PMD level
  enable split pmd ptlock.

 arch/powerpc/include/asm/book3s/32/pgalloc.h   |   2 +-
 arch/powerpc/include/asm/book3s/64/hash-4k.h   |  10 +-
 arch/powerpc/include/asm/book3s/64/hash-64k.h  |   4 +
 arch/powerpc/include/asm/book3s/64/mmu.h       |   7 +-
 arch/powerpc/include/asm/book3s/64/pgalloc.h   |  43 ++------
 arch/powerpc/include/asm/book3s/64/pgtable.h   |   6 ++
 arch/powerpc/include/asm/book3s/64/radix-4k.h  |   8 ++
 arch/powerpc/include/asm/book3s/64/radix-64k.h |   4 +
 arch/powerpc/include/asm/pgalloc.h             |   9 ++
 arch/powerpc/mm/hash_utils_64.c                |   2 +
 arch/powerpc/mm/init-common.c                  |   2 -
 arch/powerpc/mm/mmu_context_book3s64.c         |  39 ++++---
 arch/powerpc/mm/pgtable-radix.c                |   2 +
 arch/powerpc/mm/pgtable_64.c                   | 144 +++++++++++++++++++++----
 arch/powerpc/platforms/Kconfig.cputype         |   4 +
 15 files changed, 209 insertions(+), 77 deletions(-)

-- 
2.14.3

^ permalink raw reply

* [RFC PATCH 1/6] powerpc/mm: Rename pte fragment functions
From: Aneesh Kumar K.V @ 2018-02-14 13:50 UTC (permalink / raw)
  To: benh, paulus, mpe, Anton Blanchard, Nicholas Piggin
  Cc: linuxppc-dev, Aneesh Kumar K.V
In-Reply-To: <20180214135009.32748-1-aneesh.kumar@linux.vnet.ibm.com>

We rename the alloc and get_from_cache to indicate they operate on pte
fragments. In later patch we will add pmd fragment support.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 arch/powerpc/mm/pgtable_64.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index a0f8928c0b86..330ef1d1daf5 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -322,7 +322,7 @@ struct page *pmd_page(pmd_t pmd)
 }
 
 #ifdef CONFIG_PPC_64K_PAGES
-static pte_t *get_from_cache(struct mm_struct *mm)
+static pte_t *get_pte_from_cache(struct mm_struct *mm)
 {
 	void *pte_frag, *ret;
 
@@ -341,7 +341,7 @@ static pte_t *get_from_cache(struct mm_struct *mm)
 	return (pte_t *)ret;
 }
 
-static pte_t *__alloc_for_cache(struct mm_struct *mm, int kernel)
+static pte_t *__alloc_for_ptecache(struct mm_struct *mm, int kernel)
 {
 	void *ret = NULL;
 	struct page *page;
@@ -380,12 +380,13 @@ pte_t *pte_fragment_alloc(struct mm_struct *mm, unsigned long vmaddr, int kernel
 {
 	pte_t *pte;
 
-	pte = get_from_cache(mm);
+	pte = get_pte_from_cache(mm);
 	if (pte)
 		return pte;
 
-	return __alloc_for_cache(mm, kernel);
+	return __alloc_for_ptecache(mm, kernel);
 }
+
 #endif /* CONFIG_PPC_64K_PAGES */
 
 void pte_fragment_free(unsigned long *table, int kernel)
-- 
2.14.3

^ permalink raw reply related

* [RFC PATCH 2/6] powerpc/mm/4k: Switch 4k pagesize config to use pagetable fragment
From: Aneesh Kumar K.V @ 2018-02-14 13:50 UTC (permalink / raw)
  To: benh, paulus, mpe, Anton Blanchard, Nicholas Piggin
  Cc: linuxppc-dev, Aneesh Kumar K.V
In-Reply-To: <20180214135009.32748-1-aneesh.kumar@linux.vnet.ibm.com>

4K config use one full page at level 4 of the table. Add support single fragment
and use that for 4K config. This makes both 4k and 64k use the same code path.
Later we will switch pmd to use the page table fragment code

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/book3s/64/hash-4k.h  |  6 ++++--
 arch/powerpc/include/asm/book3s/64/mmu.h      |  6 +++---
 arch/powerpc/include/asm/book3s/64/pgalloc.h  | 26 --------------------------
 arch/powerpc/include/asm/book3s/64/radix-4k.h |  6 ++++++
 arch/powerpc/mm/mmu_context_book3s64.c        | 10 ----------
 arch/powerpc/mm/pgtable_64.c                  | 10 +++++++---
 6 files changed, 20 insertions(+), 44 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h b/arch/powerpc/include/asm/book3s/64/hash-4k.h
index 67c5475311ee..62098daa3af8 100644
--- a/arch/powerpc/include/asm/book3s/64/hash-4k.h
+++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h
@@ -32,8 +32,10 @@
 #define H_PAGE_4K_PFN	0x0
 #define H_PAGE_THP_HUGE 0x0
 #define H_PAGE_COMBO	0x0
-#define H_PTE_FRAG_NR	0
-#define H_PTE_FRAG_SIZE_SHIFT  0
+
+/* 8 bytes per each pte entry */
+#define H_PTE_FRAG_SIZE_SHIFT  (H_PTE_INDEX_SIZE + 3)
+#define H_PTE_FRAG_NR	(PAGE_SIZE >> H_PTE_FRAG_SIZE_SHIFT)
 /*
  * On all 4K setups, remap_4k_pfn() equates to remap_pfn_range()
  */
diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h b/arch/powerpc/include/asm/book3s/64/mmu.h
index 0abeb0e2d616..00a961bc76a9 100644
--- a/arch/powerpc/include/asm/book3s/64/mmu.h
+++ b/arch/powerpc/include/asm/book3s/64/mmu.h
@@ -101,10 +101,10 @@ typedef struct {
 #ifdef CONFIG_PPC_SUBPAGE_PROT
 	struct subpage_prot_table spt;
 #endif /* CONFIG_PPC_SUBPAGE_PROT */
-#ifdef CONFIG_PPC_64K_PAGES
-	/* for 4K PTE fragment support */
+	/*
+	 * pagetable fragment support
+	 */
 	void *pte_frag;
-#endif
 #ifdef CONFIG_SPAPR_TCE_IOMMU
 	struct list_head iommu_group_mem_list;
 #endif
diff --git a/arch/powerpc/include/asm/book3s/64/pgalloc.h b/arch/powerpc/include/asm/book3s/64/pgalloc.h
index d6ee7563b09d..8de75c2ae7c9 100644
--- a/arch/powerpc/include/asm/book3s/64/pgalloc.h
+++ b/arch/powerpc/include/asm/book3s/64/pgalloc.h
@@ -167,31 +167,6 @@ static inline pgtable_t pmd_pgtable(pmd_t pmd)
 	return (pgtable_t)pmd_page_vaddr(pmd);
 }
 
-#ifdef CONFIG_PPC_4K_PAGES
-static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
-					  unsigned long address)
-{
-	return (pte_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
-}
-
-static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
-				      unsigned long address)
-{
-	struct page *page;
-	pte_t *pte;
-
-	pte = (pte_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO | __GFP_ACCOUNT);
-	if (!pte)
-		return NULL;
-	page = virt_to_page(pte);
-	if (!pgtable_page_ctor(page)) {
-		__free_page(page);
-		return NULL;
-	}
-	return pte;
-}
-#else /* if CONFIG_PPC_64K_PAGES */
-
 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
 					  unsigned long address)
 {
@@ -203,7 +178,6 @@ static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
 {
 	return (pgtable_t)pte_fragment_alloc(mm, address, 0);
 }
-#endif
 
 static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
 {
diff --git a/arch/powerpc/include/asm/book3s/64/radix-4k.h b/arch/powerpc/include/asm/book3s/64/radix-4k.h
index a61aa9cd63ec..14717cfe15e2 100644
--- a/arch/powerpc/include/asm/book3s/64/radix-4k.h
+++ b/arch/powerpc/include/asm/book3s/64/radix-4k.h
@@ -9,5 +9,11 @@
 #define RADIX_PMD_INDEX_SIZE  9  /* 1G huge page */
 #define RADIX_PUD_INDEX_SIZE	 9
 #define RADIX_PGD_INDEX_SIZE  13
+/*
+ * One fragment per per page
+ */
+#define RADIX_PTE_FRAG_SIZE_SHIFT  (RADIX_PTE_INDEX_SIZE + 3)
+#define RADIX_PTE_FRAG_NR	(PAGE_SIZE >> RADIX_PTE_FRAG_SIZE_SHIFT)
+
 
 #endif /* _ASM_POWERPC_PGTABLE_RADIX_4K_H */
diff --git a/arch/powerpc/mm/mmu_context_book3s64.c b/arch/powerpc/mm/mmu_context_book3s64.c
index 929d9ef7083f..b4d795b5162a 100644
--- a/arch/powerpc/mm/mmu_context_book3s64.c
+++ b/arch/powerpc/mm/mmu_context_book3s64.c
@@ -166,9 +166,7 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 
 	mm->context.id = index;
 
-#ifdef CONFIG_PPC_64K_PAGES
 	mm->context.pte_frag = NULL;
-#endif
 #ifdef CONFIG_SPAPR_TCE_IOMMU
 	mm_iommu_init(mm);
 #endif
@@ -185,7 +183,6 @@ void __destroy_context(int context_id)
 }
 EXPORT_SYMBOL_GPL(__destroy_context);
 
-#ifdef CONFIG_PPC_64K_PAGES
 static void destroy_pagetable_page(struct mm_struct *mm)
 {
 	int count;
@@ -206,13 +203,6 @@ static void destroy_pagetable_page(struct mm_struct *mm)
 	}
 }
 
-#else
-static inline void destroy_pagetable_page(struct mm_struct *mm)
-{
-	return;
-}
-#endif
-
 void destroy_context(struct mm_struct *mm)
 {
 #ifdef CONFIG_SPAPR_TCE_IOMMU
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index 330ef1d1daf5..ff4973565abb 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -321,7 +321,6 @@ struct page *pmd_page(pmd_t pmd)
 	return virt_to_page(pmd_page_vaddr(pmd));
 }
 
-#ifdef CONFIG_PPC_64K_PAGES
 static pte_t *get_pte_from_cache(struct mm_struct *mm)
 {
 	void *pte_frag, *ret;
@@ -360,7 +359,14 @@ static pte_t *__alloc_for_ptecache(struct mm_struct *mm, int kernel)
 			return NULL;
 	}
 
+
 	ret = page_address(page);
+	/*
+	 * if we support only one fragment just return the
+	 * allocated page.
+	 */
+	if (PTE_FRAG_NR == 1)
+		return ret;
 	spin_lock(&mm->page_table_lock);
 	/*
 	 * If we find pgtable_page set, we return
@@ -387,8 +393,6 @@ pte_t *pte_fragment_alloc(struct mm_struct *mm, unsigned long vmaddr, int kernel
 	return __alloc_for_ptecache(mm, kernel);
 }
 
-#endif /* CONFIG_PPC_64K_PAGES */
-
 void pte_fragment_free(unsigned long *table, int kernel)
 {
 	struct page *page = virt_to_page(table);
-- 
2.14.3

^ permalink raw reply related

* [RFC PATCH 3/6] powerpc/mm: Implement helpers for pagetable fragment support at PMD level
From: Aneesh Kumar K.V @ 2018-02-14 13:50 UTC (permalink / raw)
  To: benh, paulus, mpe, Anton Blanchard, Nicholas Piggin
  Cc: linuxppc-dev, Aneesh Kumar K.V
In-Reply-To: <20180214135009.32748-1-aneesh.kumar@linux.vnet.ibm.com>

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/book3s/64/hash-4k.h   |  4 ++
 arch/powerpc/include/asm/book3s/64/hash-64k.h  |  4 ++
 arch/powerpc/include/asm/book3s/64/mmu.h       |  1 +
 arch/powerpc/include/asm/book3s/64/pgalloc.h   |  2 +
 arch/powerpc/include/asm/book3s/64/pgtable.h   |  6 ++
 arch/powerpc/include/asm/book3s/64/radix-4k.h  |  2 +
 arch/powerpc/include/asm/book3s/64/radix-64k.h |  4 ++
 arch/powerpc/mm/hash_utils_64.c                |  2 +
 arch/powerpc/mm/mmu_context_book3s64.c         | 37 +++++++++--
 arch/powerpc/mm/pgtable-radix.c                |  2 +
 arch/powerpc/mm/pgtable_64.c                   | 85 ++++++++++++++++++++++++++
 11 files changed, 143 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h b/arch/powerpc/include/asm/book3s/64/hash-4k.h
index 62098daa3af8..fc3dc6a93939 100644
--- a/arch/powerpc/include/asm/book3s/64/hash-4k.h
+++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h
@@ -36,6 +36,10 @@
 /* 8 bytes per each pte entry */
 #define H_PTE_FRAG_SIZE_SHIFT  (H_PTE_INDEX_SIZE + 3)
 #define H_PTE_FRAG_NR	(PAGE_SIZE >> H_PTE_FRAG_SIZE_SHIFT)
+
+#define H_PMD_FRAG_SIZE_SHIFT  (H_PMD_INDEX_SIZE + 3)
+#define H_PMD_FRAG_NR	(PAGE_SIZE >> H_PMD_FRAG_SIZE_SHIFT)
+
 /*
  * On all 4K setups, remap_4k_pfn() equates to remap_pfn_range()
  */
diff --git a/arch/powerpc/include/asm/book3s/64/hash-64k.h b/arch/powerpc/include/asm/book3s/64/hash-64k.h
index 0aa4f755b3f6..b8ca64fd2bea 100644
--- a/arch/powerpc/include/asm/book3s/64/hash-64k.h
+++ b/arch/powerpc/include/asm/book3s/64/hash-64k.h
@@ -33,6 +33,10 @@
 #define H_PTE_FRAG_SIZE_SHIFT  (H_PTE_INDEX_SIZE + 3 + 1)
 #define H_PTE_FRAG_NR	(PAGE_SIZE >> H_PTE_FRAG_SIZE_SHIFT)
 
+/* +1 for THP and hugetlb */
+#define H_PMD_FRAG_SIZE_SHIFT  (H_PMD_INDEX_SIZE + 3 + 1)
+#define H_PMD_FRAG_NR	(PAGE_SIZE >> H_PMD_FRAG_SIZE_SHIFT)
+
 #ifndef __ASSEMBLY__
 #include <asm/errno.h>
 
diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h b/arch/powerpc/include/asm/book3s/64/mmu.h
index 00a961bc76a9..ad19651ea10e 100644
--- a/arch/powerpc/include/asm/book3s/64/mmu.h
+++ b/arch/powerpc/include/asm/book3s/64/mmu.h
@@ -105,6 +105,7 @@ typedef struct {
 	 * pagetable fragment support
 	 */
 	void *pte_frag;
+	void *pmd_frag;
 #ifdef CONFIG_SPAPR_TCE_IOMMU
 	struct list_head iommu_group_mem_list;
 #endif
diff --git a/arch/powerpc/include/asm/book3s/64/pgalloc.h b/arch/powerpc/include/asm/book3s/64/pgalloc.h
index 8de75c2ae7c9..f3838ad0dc6c 100644
--- a/arch/powerpc/include/asm/book3s/64/pgalloc.h
+++ b/arch/powerpc/include/asm/book3s/64/pgalloc.h
@@ -42,7 +42,9 @@ extern struct kmem_cache *pgtable_cache[];
 		})
 
 extern pte_t *pte_fragment_alloc(struct mm_struct *, unsigned long, int);
+extern pmd_t *pmd_fragment_alloc(struct mm_struct *, unsigned long);
 extern void pte_fragment_free(unsigned long *, int);
+extern void pmd_fragment_free(unsigned long *);
 extern void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift);
 #ifdef CONFIG_SMP
 extern void __tlb_remove_table(void *_table);
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
index a6b9f1d74600..88d10319adfe 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -265,6 +265,12 @@ extern unsigned long __pte_frag_size_shift;
 #define PTE_FRAG_SIZE_SHIFT __pte_frag_size_shift
 #define PTE_FRAG_SIZE (1UL << PTE_FRAG_SIZE_SHIFT)
 
+extern unsigned long __pmd_frag_nr;
+#define PMD_FRAG_NR __pmd_frag_nr
+extern unsigned long __pmd_frag_size_shift;
+#define PMD_FRAG_SIZE_SHIFT __pmd_frag_size_shift
+#define PMD_FRAG_SIZE (1UL << PMD_FRAG_SIZE_SHIFT)
+
 #define PTRS_PER_PTE	(1 << PTE_INDEX_SIZE)
 #define PTRS_PER_PMD	(1 << PMD_INDEX_SIZE)
 #define PTRS_PER_PUD	(1 << PUD_INDEX_SIZE)
diff --git a/arch/powerpc/include/asm/book3s/64/radix-4k.h b/arch/powerpc/include/asm/book3s/64/radix-4k.h
index 14717cfe15e2..863c3e8286fb 100644
--- a/arch/powerpc/include/asm/book3s/64/radix-4k.h
+++ b/arch/powerpc/include/asm/book3s/64/radix-4k.h
@@ -15,5 +15,7 @@
 #define RADIX_PTE_FRAG_SIZE_SHIFT  (RADIX_PTE_INDEX_SIZE + 3)
 #define RADIX_PTE_FRAG_NR	(PAGE_SIZE >> RADIX_PTE_FRAG_SIZE_SHIFT)
 
+#define RADIX_PMD_FRAG_SIZE_SHIFT  (RADIX_PMD_INDEX_SIZE + 3)
+#define RADIX_PMD_FRAG_NR	(PAGE_SIZE >> RADIX_PMD_FRAG_SIZE_SHIFT)
 
 #endif /* _ASM_POWERPC_PGTABLE_RADIX_4K_H */
diff --git a/arch/powerpc/include/asm/book3s/64/radix-64k.h b/arch/powerpc/include/asm/book3s/64/radix-64k.h
index 830082496876..ccb78ca9d0c5 100644
--- a/arch/powerpc/include/asm/book3s/64/radix-64k.h
+++ b/arch/powerpc/include/asm/book3s/64/radix-64k.h
@@ -16,4 +16,8 @@
  */
 #define RADIX_PTE_FRAG_SIZE_SHIFT  (RADIX_PTE_INDEX_SIZE + 3)
 #define RADIX_PTE_FRAG_NR	(PAGE_SIZE >> RADIX_PTE_FRAG_SIZE_SHIFT)
+
+#define RADIX_PMD_FRAG_SIZE_SHIFT  (RADIX_PMD_INDEX_SIZE + 3)
+#define RADIX_PMD_FRAG_NR	(PAGE_SIZE >> RADIX_PMD_FRAG_SIZE_SHIFT)
+
 #endif /* _ASM_POWERPC_PGTABLE_RADIX_64K_H */
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index cf290d415dcd..efdb49124b2a 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -1003,6 +1003,8 @@ void __init hash__early_init_mmu(void)
 	 */
 	__pte_frag_nr = H_PTE_FRAG_NR;
 	__pte_frag_size_shift = H_PTE_FRAG_SIZE_SHIFT;
+	__pmd_frag_nr = H_PMD_FRAG_NR;
+	__pmd_frag_size_shift = H_PMD_FRAG_SIZE_SHIFT;
 
 	__pte_index_size = H_PTE_INDEX_SIZE;
 	__pmd_index_size = H_PMD_INDEX_SIZE;
diff --git a/arch/powerpc/mm/mmu_context_book3s64.c b/arch/powerpc/mm/mmu_context_book3s64.c
index b4d795b5162a..ee2b1fa0cbe3 100644
--- a/arch/powerpc/mm/mmu_context_book3s64.c
+++ b/arch/powerpc/mm/mmu_context_book3s64.c
@@ -167,6 +167,7 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 	mm->context.id = index;
 
 	mm->context.pte_frag = NULL;
+	mm->context.pmd_frag = NULL;
 #ifdef CONFIG_SPAPR_TCE_IOMMU
 	mm_iommu_init(mm);
 #endif
@@ -183,16 +184,11 @@ void __destroy_context(int context_id)
 }
 EXPORT_SYMBOL_GPL(__destroy_context);
 
-static void destroy_pagetable_page(struct mm_struct *mm)
+static void pte_frag_destory(void *pte_frag)
 {
 	int count;
-	void *pte_frag;
 	struct page *page;
 
-	pte_frag = mm->context.pte_frag;
-	if (!pte_frag)
-		return;
-
 	page = virt_to_page(pte_frag);
 	/* drop all the pending references */
 	count = ((unsigned long)pte_frag & ~PAGE_MASK) >> PTE_FRAG_SIZE_SHIFT;
@@ -203,6 +199,35 @@ static void destroy_pagetable_page(struct mm_struct *mm)
 	}
 }
 
+static void pmd_frag_destory(void *pmd_frag)
+{
+	int count;
+	struct page *page;
+
+	page = virt_to_page(pmd_frag);
+	/* drop all the pending references */
+	count = ((unsigned long)pmd_frag & ~PAGE_MASK) >> PMD_FRAG_SIZE_SHIFT;
+	/* We allow PTE_FRAG_NR fragments from a PTE page */
+	if (page_ref_sub_and_test(page, PMD_FRAG_NR - count)) {
+		pgtable_pmd_page_dtor(page);
+		free_unref_page(page);
+	}
+}
+
+static void destroy_pagetable_page(struct mm_struct *mm)
+{
+	void *frag;
+
+	frag = mm->context.pte_frag;
+	if (frag)
+		pte_frag_destory(frag);
+
+	frag = mm->context.pmd_frag;
+	if (frag)
+		pmd_frag_destory(frag);
+	return;
+}
+
 void destroy_context(struct mm_struct *mm)
 {
 #ifdef CONFIG_SPAPR_TCE_IOMMU
diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c
index f8b3f4a99659..b2f89851d8eb 100644
--- a/arch/powerpc/mm/pgtable-radix.c
+++ b/arch/powerpc/mm/pgtable-radix.c
@@ -559,6 +559,8 @@ void __init radix__early_init_mmu(void)
 #endif
 	__pte_frag_nr = RADIX_PTE_FRAG_NR;
 	__pte_frag_size_shift = RADIX_PTE_FRAG_SIZE_SHIFT;
+	__pmd_frag_nr = RADIX_PMD_FRAG_NR;
+	__pmd_frag_size_shift = RADIX_PMD_FRAG_SIZE_SHIFT;
 
 	if (!firmware_has_feature(FW_FEATURE_LPAR)) {
 		radix_init_native();
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index ff4973565abb..0a6859e6ef76 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -114,6 +114,11 @@ unsigned long __pte_frag_nr;
 EXPORT_SYMBOL(__pte_frag_nr);
 unsigned long __pte_frag_size_shift;
 EXPORT_SYMBOL(__pte_frag_size_shift);
+unsigned long __pmd_frag_nr;
+EXPORT_SYMBOL(__pmd_frag_nr);
+unsigned long __pmd_frag_size_shift;
+EXPORT_SYMBOL(__pmd_frag_size_shift);
+
 unsigned long ioremap_bot;
 #else /* !CONFIG_PPC_BOOK3S_64 */
 unsigned long ioremap_bot = IOREMAP_BASE;
@@ -393,6 +398,75 @@ pte_t *pte_fragment_alloc(struct mm_struct *mm, unsigned long vmaddr, int kernel
 	return __alloc_for_ptecache(mm, kernel);
 }
 
+static pmd_t *get_pmd_from_cache(struct mm_struct *mm)
+{
+	void *pmd_frag, *ret;
+
+	spin_lock(&mm->page_table_lock);
+	ret = mm->context.pmd_frag;
+	if (ret) {
+		pmd_frag = ret + PMD_FRAG_SIZE;
+		/*
+		 * If we have taken up all the fragments mark PTE page NULL
+		 */
+		if (((unsigned long)pmd_frag & ~PAGE_MASK) == 0)
+			pmd_frag = NULL;
+		mm->context.pmd_frag = pmd_frag;
+	}
+	spin_unlock(&mm->page_table_lock);
+	return (pmd_t *)ret;
+}
+
+static pmd_t *__alloc_for_pmdcache(struct mm_struct *mm)
+{
+	void *ret = NULL;
+	struct page *page;
+	gfp_t gfp = GFP_KERNEL_ACCOUNT | __GFP_ZERO;
+
+	if (mm == &init_mm)
+		gfp &= ~__GFP_ACCOUNT;
+	page = alloc_page(gfp);
+	if (!page)
+		return NULL;
+	if (!pgtable_pmd_page_ctor(page)) {
+		__free_pages(page, 0);
+		return NULL;
+	}
+
+	ret = page_address(page);
+	/*
+	 * if we support only one fragment just return the
+	 * allocated page.
+	 */
+	if (PMD_FRAG_NR == 1)
+		return ret;
+
+	spin_lock(&mm->page_table_lock);
+	/*
+	 * If we find pgtable_page set, we return
+	 * the allocated page with single fragement
+	 * count.
+	 */
+	if (likely(!mm->context.pmd_frag)) {
+		set_page_count(page, PMD_FRAG_NR);
+		mm->context.pmd_frag = ret + PMD_FRAG_SIZE;
+	}
+	spin_unlock(&mm->page_table_lock);
+
+	return (pmd_t *)ret;
+}
+
+pmd_t *pmd_fragment_alloc(struct mm_struct *mm, unsigned long vmaddr)
+{
+	pmd_t *pmd;
+
+	pmd = get_pmd_from_cache(mm);
+	if (pmd)
+		return pmd;
+
+	return __alloc_for_pmdcache(mm);
+}
+
 void pte_fragment_free(unsigned long *table, int kernel)
 {
 	struct page *page = virt_to_page(table);
@@ -403,6 +477,17 @@ void pte_fragment_free(unsigned long *table, int kernel)
 	}
 }
 
+void pmd_fragment_free(unsigned long *pmd)
+{
+	struct page *page = virt_to_page(pmd);
+
+	if (put_page_testzero(page)) {
+		pgtable_pmd_page_dtor(page);
+		free_unref_page(page);
+	}
+}
+
+
 #ifdef CONFIG_SMP
 void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift)
 {
-- 
2.14.3

^ permalink raw reply related

* [RFC PATCH 4/6] powerpc/mm: Simplify the rcu callback for page table free
From: Aneesh Kumar K.V @ 2018-02-14 13:50 UTC (permalink / raw)
  To: benh, paulus, mpe, Anton Blanchard, Nicholas Piggin
  Cc: linuxppc-dev, Aneesh Kumar K.V
In-Reply-To: <20180214135009.32748-1-aneesh.kumar@linux.vnet.ibm.com>

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/book3s/32/pgalloc.h |  2 +-
 arch/powerpc/include/asm/book3s/64/pgalloc.h |  6 ++--
 arch/powerpc/include/asm/pgalloc.h           |  9 ++++++
 arch/powerpc/mm/pgtable_64.c                 | 44 ++++++++++++++++++----------
 4 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/32/pgalloc.h b/arch/powerpc/include/asm/book3s/32/pgalloc.h
index 9f5c411bce1b..f102920fade4 100644
--- a/arch/powerpc/include/asm/book3s/32/pgalloc.h
+++ b/arch/powerpc/include/asm/book3s/32/pgalloc.h
@@ -137,7 +137,7 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
 				  unsigned long address)
 {
 	pgtable_page_dtor(table);
-	pgtable_free_tlb(tlb, page_address(table), 0);
+	pgtable_free_tlb(tlb, page_address(table), PTE_INDEX);
 }
 
 static inline void pgd_ctor(void *addr)
diff --git a/arch/powerpc/include/asm/book3s/64/pgalloc.h b/arch/powerpc/include/asm/book3s/64/pgalloc.h
index f3838ad0dc6c..e5d104caae26 100644
--- a/arch/powerpc/include/asm/book3s/64/pgalloc.h
+++ b/arch/powerpc/include/asm/book3s/64/pgalloc.h
@@ -123,7 +123,7 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud,
 	 * ahead and flush the page walk cache
 	 */
 	flush_tlb_pgtable(tlb, address);
-        pgtable_free_tlb(tlb, pud, PUD_CACHE_INDEX);
+        pgtable_free_tlb(tlb, pud, PUD_INDEX);
 }
 
 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
@@ -149,7 +149,7 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
 	 * ahead and flush the page walk cache
 	 */
 	flush_tlb_pgtable(tlb, address);
-        return pgtable_free_tlb(tlb, pmd, PMD_CACHE_INDEX);
+        return pgtable_free_tlb(tlb, pmd, PMD_INDEX);
 }
 
 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
@@ -199,7 +199,7 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
 	 * ahead and flush the page walk cache
 	 */
 	flush_tlb_pgtable(tlb, address);
-	pgtable_free_tlb(tlb, table, 0);
+	pgtable_free_tlb(tlb, table, PTE_INDEX);
 }
 
 #define check_pgt_cache()	do { } while (0)
diff --git a/arch/powerpc/include/asm/pgalloc.h b/arch/powerpc/include/asm/pgalloc.h
index e11f03007b57..8949e73a028e 100644
--- a/arch/powerpc/include/asm/pgalloc.h
+++ b/arch/powerpc/include/asm/pgalloc.h
@@ -19,6 +19,15 @@ static inline gfp_t pgtable_gfp_flags(struct mm_struct *mm, gfp_t gfp)
 #endif /* MODULE */
 
 #define PGALLOC_GFP (GFP_KERNEL | __GFP_ZERO)
+/*
+ * Used as an indicator for rcu callback functions
+ */
+enum pgtable_index {
+	PTE_INDEX = 0,
+	PMD_INDEX,
+	PUD_INDEX,
+	PGD_INDEX,
+};
 
 #ifdef CONFIG_PPC_BOOK3S
 #include <asm/book3s/pgalloc.h>
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index 0a6859e6ef76..db3ee7ab8418 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -487,39 +487,51 @@ void pmd_fragment_free(unsigned long *pmd)
 	}
 }
 
-
 #ifdef CONFIG_SMP
-void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift)
+void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int index)
 {
 	unsigned long pgf = (unsigned long)table;
 
-	BUG_ON(shift > MAX_PGTABLE_INDEX_SIZE);
-	pgf |= shift;
+	BUG_ON(index > MAX_PGTABLE_INDEX_SIZE);
+	pgf |= index;
 	tlb_remove_table(tlb, (void *)pgf);
 }
 
 void __tlb_remove_table(void *_table)
 {
 	void *table = (void *)((unsigned long)_table & ~MAX_PGTABLE_INDEX_SIZE);
-	unsigned shift = (unsigned long)_table & MAX_PGTABLE_INDEX_SIZE;
+	unsigned index = (unsigned long)_table & MAX_PGTABLE_INDEX_SIZE;
 
-	if (!shift)
-		/* PTE page needs special handling */
+	switch (index) {
+	case PTE_INDEX:
 		pte_fragment_free(table, 0);
-	else {
-		BUG_ON(shift > MAX_PGTABLE_INDEX_SIZE);
-		kmem_cache_free(PGT_CACHE(shift), table);
+		break;
+	case PMD_INDEX:
+		pmd_fragment_free(table);
+		break;
+	case PUD_INDEX:
+		kmem_cache_free(PGT_CACHE(PUD_CACHE_INDEX), table);
+		break;
+	default:
+		BUG();
 	}
 }
 #else
-void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift)
+void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int index)
 {
-	if (!shift) {
-		/* PTE page needs special handling */
+	switch (index) {
+	case PTE_INDEX:
 		pte_fragment_free(table, 0);
-	} else {
-		BUG_ON(shift > MAX_PGTABLE_INDEX_SIZE);
-		kmem_cache_free(PGT_CACHE(shift), table);
+		break;
+	case PMD_INDEX:
+		kmem_cache_free(PGT_CACHE(PMD_CACHE_INDEX), table);
+		break;
+	case PUD_INDEX:
+		kmem_cache_free(PGT_CACHE(PUD_CACHE_INDEX), table);
+		break;
+	/* We don't free pgd table via RCU callback */
+	default:
+		BUG();
 	}
 }
 #endif
-- 
2.14.3

^ permalink raw reply related

* [RFC PATCH 5/6] powerpc/mm: Use page fragments for allocation page table at PMD level
From: Aneesh Kumar K.V @ 2018-02-14 13:50 UTC (permalink / raw)
  To: benh, paulus, mpe, Anton Blanchard, Nicholas Piggin
  Cc: linuxppc-dev, Aneesh Kumar K.V
In-Reply-To: <20180214135009.32748-1-aneesh.kumar@linux.vnet.ibm.com>

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/book3s/64/pgalloc.h | 9 ++-------
 arch/powerpc/mm/init-common.c                | 2 --
 arch/powerpc/mm/pgtable_64.c                 | 2 +-
 3 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/64/pgalloc.h b/arch/powerpc/include/asm/book3s/64/pgalloc.h
index e5d104caae26..f91a8bc1d67f 100644
--- a/arch/powerpc/include/asm/book3s/64/pgalloc.h
+++ b/arch/powerpc/include/asm/book3s/64/pgalloc.h
@@ -128,17 +128,12 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud,
 
 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
 {
-	pmd_t *pmd;
-	pmd = kmem_cache_alloc(PGT_CACHE(PMD_CACHE_INDEX),
-			       pgtable_gfp_flags(mm, GFP_KERNEL));
-	memset(pmd, 0, PMD_TABLE_SIZE);
-	return pmd;
-
+	return pmd_fragment_alloc(mm, addr);
 }
 
 static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
 {
-	kmem_cache_free(PGT_CACHE(PMD_CACHE_INDEX), pmd);
+	pmd_fragment_free((unsigned long *)pmd);
 }
 
 static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
diff --git a/arch/powerpc/mm/init-common.c b/arch/powerpc/mm/init-common.c
index f92dd8cee3c5..0382df3ef6a8 100644
--- a/arch/powerpc/mm/init-common.c
+++ b/arch/powerpc/mm/init-common.c
@@ -78,8 +78,6 @@ void pgtable_cache_init(void)
 {
 	pgtable_cache_add(PGD_INDEX_SIZE, pgd_ctor);
 
-	if (PMD_CACHE_INDEX && !PGT_CACHE(PMD_CACHE_INDEX))
-		pgtable_cache_add(PMD_CACHE_INDEX, pmd_ctor);
 	/*
 	 * In all current configs, when the PUD index exists it's the
 	 * same size as either the pgd or pmd index except with THP enabled
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index db3ee7ab8418..05267a8764f5 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -524,7 +524,7 @@ void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int index)
 		pte_fragment_free(table, 0);
 		break;
 	case PMD_INDEX:
-		kmem_cache_free(PGT_CACHE(PMD_CACHE_INDEX), table);
+		pmd_fragment_free(table);
 		break;
 	case PUD_INDEX:
 		kmem_cache_free(PGT_CACHE(PUD_CACHE_INDEX), table);
-- 
2.14.3

^ permalink raw reply related

* [RFC PATCH 6/6] enable split pmd ptlock.
From: Aneesh Kumar K.V @ 2018-02-14 13:50 UTC (permalink / raw)
  To: benh, paulus, mpe, Anton Blanchard, Nicholas Piggin
  Cc: linuxppc-dev, Aneesh Kumar K.V
In-Reply-To: <20180214135009.32748-1-aneesh.kumar@linux.vnet.ibm.com>

---
 arch/powerpc/platforms/Kconfig.cputype | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index a429d859f15d..28ba1acb7842 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -287,6 +287,10 @@ config PPC_STD_MMU_32
 	def_bool y
 	depends on PPC_STD_MMU && PPC32
 
+config ARCH_ENABLE_SPLIT_PMD_PTLOCK
+	def_bool y
+	depends on PPC_BOOK3S_64
+
 config PPC_RADIX_MMU
 	bool "Radix MMU Support"
 	depends on PPC_BOOK3S_64
-- 
2.14.3

^ permalink raw reply related

* Re: [PATCH] crypto: nx-842: Delete an error message for a failed memory allocation in nx842_pseries_init()
From: Dan Streetman @ 2018-02-14 16:48 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Linux Crypto Mailing List, linuxppc-dev, Benjamin Herrenschmidt,
	David S. Miller, Haren Myneni, Herbert Xu, Michael Ellerman,
	Paul Mackerras, LKML, kernel-janitors
In-Reply-To: <8261d041-ccd9-c0f8-4530-a4afb43ee7ab@users.sourceforge.net>

On Wed, Feb 14, 2018 at 11:17 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 14 Feb 2018 17:05:13 +0100
>
> Omit an extra message for a memory allocation failure in this function.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Reviewed-by: Dan Streetman <ddstreet@ieee.org>

> ---
>  drivers/crypto/nx/nx-842-pseries.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/crypto/nx/nx-842-pseries.c b/drivers/crypto/nx/nx-842-pseries.c
> index bf52cd1d7fca..66869976cfa2 100644
> --- a/drivers/crypto/nx/nx-842-pseries.c
> +++ b/drivers/crypto/nx/nx-842-pseries.c
> @@ -1105,10 +1105,9 @@ static int __init nx842_pseries_init(void)
>
>         RCU_INIT_POINTER(devdata, NULL);
>         new_devdata = kzalloc(sizeof(*new_devdata), GFP_KERNEL);
> -       if (!new_devdata) {
> -               pr_err("Could not allocate memory for device data\n");
> +       if (!new_devdata)
>                 return -ENOMEM;
> -       }
> +
>         RCU_INIT_POINTER(devdata, new_devdata);
>
>         ret = vio_register_driver(&nx842_vio_driver);
> --
> 2.16.1
>

^ permalink raw reply

* Re: samples/seccomp/ broken when cross compiling s390, ppc allyesconfig
From: Kees Cook @ 2018-02-14 17:14 UTC (permalink / raw)
  To: Michal Hocko; +Cc: Michael Ellerman, Will Drewry, linux-s390, PowerPC, LKML
In-Reply-To: <20180214092045.GZ3443@dhcp22.suse.cz>

On Wed, Feb 14, 2018 at 1:20 AM, Michal Hocko <mhocko@kernel.org> wrote:
> On Tue 13-02-18 13:27:30, Kees Cook wrote:
>> On Tue, Feb 13, 2018 at 2:32 AM, Michal Hocko <mhocko@kernel.org> wrote:
>> > On Tue 13-02-18 21:16:55, Michael Ellerman wrote:
>> >> Kees Cook <keescook@chromium.org> writes:
>> >>
>> >> > On Mon, Feb 12, 2018 at 7:25 PM, Michael Ellerman <mpe@ellerman.id.=
au> wrote:
>> >> >> Michal Hocko <mhocko@kernel.org> writes:
>> >> >>> Hi,
>> >> >>> my build test machinery chokes on samples/seccomp when cross comp=
iling
>> >> >>> s390 and ppc64 allyesconfig. This has been the case for quite som=
e
>> >> >>> time already but I never found time to look at the problem and re=
port
>> >> >>> it. It seems this is not new issue and similar thing happend for
>> >> >>> MIPS e9107f88c985 ("samples/seccomp/Makefile: do not build tests =
if
>> >> >>> cross-compiling for MIPS").
>> >> >>>
>> >> >>> The build logs are attached.
>> >> >>>
>> >> >>> What is the best way around this? Should we simply skip compilati=
on on
>> >> >>> cross compile or is actually anybody relying on that? Or should I=
 simply
>> >> >>> disable it for s390 and ppc?
>> >> >>
>> >> >> The whole thing seems very confused. It's not building for the tar=
get,
>> >> >> it's building for the host, ie. the Makefile sets hostprogs-m and
>> >> >> HOSTCFLAGS etc.
>> >> >>
>> >> >> So it can't possibly work with cross compiling as it's currently
>> >> >> written.
>> >> >>
>> >> >> Either the Makefile needs some serious work to properly support cr=
oss
>> >> >> compiling or it should just be disabled when cross compiling.
>> >> >
>> >> > Hrm, yeah, the goal was to entirely disable cross compiling, but I
>> >> > guess we didn't hit it with a hard enough hammer. :)
>> >>
>> >> Do you know why it is written that way? Why doesn't it just try to cr=
oss
>> >> compile like normal code?
>> >
>> > No idea, sorry. All I know about this code is that it breaks my build
>> > testing.
>>
>> IIRC, one of the problems is with build ordering problems: the kernel
>> headers used by the samples aren't available when cross compiling.
>>
>> I'm happy to kill it entirely with Michal's patch, though. Feel free
>> to carry in your tree!
>>
>> Acked-by: Kees Cook <keescook@chromium.org>
>
> OK, so let's try to nuke it. How should I route this patch?

I'm fine if goes in via ppc (especially if it can land for 4.16). If
Michael doesn't want it, I can send it through my seccomp tree via
James Morris.

-Kees

>
> From 8d8457e96296538508e478f598d1c8b3406a8626 Mon Sep 17 00:00:00 2001
> From: Michal Hocko <mhocko@suse.com>
> Date: Wed, 14 Feb 2018 10:15:12 +0100
> Subject: [PATCH] samples/seccomp: do not compile when cross compiled
> MIME-Version: 1.0
> Content-Type: text/plain; charset=3DUTF-8
> Content-Transfer-Encoding: 8bit
>
> samples/seccomp relies on the host setting which is not suitable for
> crosscompilation and it actually fails when crosscompiling s390 and
> powerpc all{yes,mod}config on x86_64 with
>
> samples/seccomp/bpf-helper.h:135:2: error: #error __BITS_PER_LONG value u=
nusable.
>  #error __BITS_PER_LONG value unusable.
>   ^
> In file included from samples/seccomp/bpf-fancy.c:13:0:
> samples/seccomp/bpf-fancy.c: In function =E2=80=98main=E2=80=99:
> samples/seccomp/bpf-fancy.c:38:11: error: =E2=80=98__NR_exit=E2=80=99 und=
eclared (first use in this function)
>    SYSCALL(__NR_exit, ALLOW),
>
> and many others. I am doing these for compile testing and it's been
> quite useful to catch issues. Crosscompiling sample code on the other
> hand doesn't seem all that important so it seems like the easiest way to
> simply disable samples/seccomp when crosscompiling.
>
> Fixing this properly is not that easy as Kees explains:
> : IIRC, one of the problems is with build ordering problems: the kernel
> : headers used by the samples aren't available when cross compiling.
>
> Acked-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Michal Hocko <mhocko@suse.com>
> ---
>  samples/seccomp/Makefile | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/samples/seccomp/Makefile b/samples/seccomp/Makefile
> index 0e349b80686e..ba942e3ead89 100644
> --- a/samples/seccomp/Makefile
> +++ b/samples/seccomp/Makefile
> @@ -1,4 +1,5 @@
>  # SPDX-License-Identifier: GPL-2.0
> +ifndef CROSS_COMPILE
>  hostprogs-$(CONFIG_SAMPLE_SECCOMP) :=3D bpf-fancy dropper bpf-direct
>
>  HOSTCFLAGS_bpf-fancy.o +=3D -I$(objtree)/usr/include
> @@ -16,7 +17,6 @@ HOSTCFLAGS_bpf-direct.o +=3D -idirafter $(objtree)/incl=
ude
>  bpf-direct-objs :=3D bpf-direct.o
>
>  # Try to match the kernel target.
> -ifndef CROSS_COMPILE
>  ifndef CONFIG_64BIT
>
>  # s390 has -m31 flag to build 31 bit binaries
> @@ -35,12 +35,4 @@ HOSTLOADLIBES_bpf-fancy +=3D $(MFLAG)
>  HOSTLOADLIBES_dropper +=3D $(MFLAG)
>  endif
>  always :=3D $(hostprogs-m)
> -else
> -# MIPS system calls are defined based on the -mabi that is passed
> -# to the toolchain which may or may not be a valid option
> -# for the host toolchain. So disable tests if target architecture
> -# is MIPS but the host isn't.
> -ifndef CONFIG_MIPS
> -always :=3D $(hostprogs-m)
> -endif
>  endif
> --
> 2.15.1
>
> --
> Michal Hocko
> SUSE Labs



--=20
Kees Cook
Pixel Security

^ permalink raw reply

* [PATCH v2] powerpc/via-pmu: Fix section mismatch warning
From: Mathieu Malaterre @ 2018-02-14 21:15 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Laurent Vivier, Mathieu Malaterre, Benjamin Herrenschmidt,
	linuxppc-dev, linux-kernel
In-Reply-To: <20180207194439.32680-1-malat@debian.org>

Make the struct via_pmu_driver const to avoid following warning:

WARNING: vmlinux.o(.data+0x4739c): Section mismatch in reference from the variable via_pmu_driver to the function .init.text:pmu_init()
The variable via_pmu_driver references
the function __init pmu_init()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

Signed-off-by: Mathieu Malaterre <malat@debian.org>
Suggested-by: Laurent Vivier <lvivier@redhat.com>
---
v2: pmu_init() is really an init function, leave __init marker

 drivers/macintosh/via-pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 94c0f3f7df69..fc56c7067732 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -198,7 +198,7 @@ static const struct file_operations pmu_battery_proc_fops;
 static const struct file_operations pmu_options_proc_fops;
 
 #ifdef CONFIG_ADB
-struct adb_driver via_pmu_driver = {
+const struct adb_driver via_pmu_driver = {
 	"PMU",
 	pmu_probe,
 	pmu_init,
-- 
2.11.0

^ permalink raw reply related

* Re: [PATCH] powerpc/via-pmu: Fix section mismatch warning
From: Mathieu Malaterre @ 2018-02-14 21:16 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: Michael Ellerman, linuxppc-dev, LKML
In-Reply-To: <dfdca2f9-bf75-cdd3-e149-f3a30944d4ae@redhat.com>

On Tue, Feb 13, 2018 at 7:54 PM, Laurent Vivier <lvivier@redhat.com> wrote:
> On 07/02/2018 20:44, Mathieu Malaterre wrote:
>> Remove the __init annotation from pmu_init() to avoid the
>> following warning.
>>
>> WARNING: vmlinux.o(.data+0x4739c): Section mismatch in reference from the variable via_pmu_driver to the function .init.text:pmu_init()
>> The variable via_pmu_driver references
>> the function __init pmu_init()
>> If the reference is valid then annotate the
>> variable with __init* or __refdata (see linux/init.h) or name the variable:
>> *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
>>
>> Signed-off-by: Mathieu Malaterre <malat@debian.org>
>> ---
>>  drivers/macintosh/via-pmu.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
>> index 08849e33c567..5f378272d5b2 100644
>> --- a/drivers/macintosh/via-pmu.c
>> +++ b/drivers/macintosh/via-pmu.c
>> @@ -378,7 +378,7 @@ static int pmu_probe(void)
>>       return vias == NULL? -ENODEV: 0;
>>  }
>>
>> -static int __init pmu_init(void)
>> +static int pmu_init(void)
>>  {
>>       if (vias == NULL)
>>               return -ENODEV;
>>
>
> pmu_init() is really an init function only called by another init
> function (adb_init()).
>
> So I think it could be good to let the __init marker.
>
> Did you try:
>
> --- a/drivers/macintosh/via-pmu.c
> +++ b/drivers/macintosh/via-pmu.c
> @@ -198,7 +198,7 @@ static const struct file_operations
> pmu_battery_proc_fops;
>  static const struct file_operations pmu_options_proc_fops;
>
>  #ifdef CONFIG_ADB
> -struct adb_driver via_pmu_driver = {
> +const struct adb_driver via_pmu_driver = {
>         "PMU",
>         pmu_probe,
>         pmu_init,
>
>

Indeed much better !

Thanks

^ permalink raw reply


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