[PATCH] powerpc/64s/mm: Move __real_pte stubs into hash-4k.h

2024-08-21 Thread Michael Ellerman
The stub versions of __real_pte() etc are only used with HPT & 4K pages, so move them into the hash-4k.h header. Signed-off-by: Michael Ellerman --- arch/powerpc/include/asm/book3s/64/hash-4k.h | 20 +++ arch/powerpc/include/asm/book3s/64/pgtable.h | 26 2 files

[PATCH] powerpc/64s: Make mmu_hash_ops __ro_after_init

2024-08-21 Thread Michael Ellerman
The mmu_hash_ops are only assigned to during boot, so mark them __ro_after_init to prevent any further modification. Signed-off-by: Michael Ellerman --- arch/powerpc/mm/book3s64/hash_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/mm/book3s64/hash_utils.c

[PATCH] macintosh/via-pmu: register_pmu_pm_ops() can be __init

2024-08-21 Thread Michael Ellerman
register_pmu_pm_ops() is only called at init time, via device_initcall(), so can be marked __init. The driver can't be built as a module. Signed-off-by: Michael Ellerman --- drivers/macintosh/via-pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/macintosh/via-pmu.

perf build failure with v6.11-rc4 (commit 4bbe60029319 ("perf daemon: Fix the build on 32-bit architectures"))

2024-08-21 Thread LEROY Christophe
Got the following build failure on v6.11-rc4, see https://github.com/chleroy/linux/actions/runs/10485680041/job/29042302519 builtin-daemon.c: In function 'cmd_session_list': Error: builtin-daemon.c:692:16: error: format '%llu' expects argument of type 'long long unsigned int', but argument 4 has

Re: [PATCH 06/14] mm: handle_pte_fault() use pte_offset_map_maywrite_nolock()

2024-08-21 Thread LEROY Christophe
Le 21/08/2024 à 10:18, Qi Zheng a écrit : > In handle_pte_fault(), we may modify the vmf->pte after acquiring the > vmf->ptl, so convert it to using pte_offset_map_maywrite_nolock(). But > since we already do the pte_same() check, so there is no need to get > pmdval to do pmd_same() check, just p

Re: [PATCH] powerpc/pseries: Use correct data types from pseries_hp_errorlog struct

2024-08-21 Thread Michael Ellerman
Haren Myneni writes: > _be32 type is defined for some elements in pseries_hp_errorlog > struct but also used them u32 after be32_to_cpu() conversion. > > Example: In handle_dlpar_errorlog() > hp_elog->_drc_u.drc_index = be32_to_cpu(hp_elog->_drc_u.drc_index); > > And later assigned to u32 type > d

[PATCH 00/14] introduce pte_offset_map_{readonly|maywrite}_nolock()

2024-08-21 Thread Qi Zheng
Hi all, As proposed by David Hildenbrand [1], this series introduces the following two new helper functions to replace pte_offset_map_nolock(). 1. pte_offset_map_readonly_nolock() 2. pte_offset_map_maywrite_nolock() As the name suggests, pte_offset_map_readonly_nolock() is used for read-only cas

[PATCH 01/14] mm: pgtable: introduce pte_offset_map_{readonly|maywrite}_nolock()

2024-08-21 Thread Qi Zheng
Currently, the usage of pte_offset_map_nolock() can be divided into the following two cases: 1) After acquiring PTL, only read-only operations are performed on the PTE page. In this case, the RCU lock in pte_offset_map_nolock() will ensure that the PTE page will not be freed, and there is no

[PATCH 02/14] arm: adjust_pte() use pte_offset_map_maywrite_nolock()

2024-08-21 Thread Qi Zheng
In do_adjust_pte(), we may modify the pte entry. At this time, the write lock of mmap_lock is not held, and the pte_same() check is not performed after the PTL held. The corresponding pmd entry may have been modified concurrently. Therefore, in order to ensure the stability if pmd entry, use pte_of

[PATCH 03/14] powerpc: assert_pte_locked() use pte_offset_map_readonly_nolock()

2024-08-21 Thread Qi Zheng
In assert_pte_locked(), we just get the ptl and assert if it was already held, so convert it to using pte_offset_map_readonly_nolock(). Signed-off-by: Qi Zheng --- arch/powerpc/mm/pgtable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/mm/pgtable.c b/arch/power

[PATCH 04/14] mm: filemap: filemap_fault_recheck_pte_none() use pte_offset_map_readonly_nolock()

2024-08-21 Thread Qi Zheng
In filemap_fault_recheck_pte_none(), we just do pte_none() check, so convert it to using pte_offset_map_readonly_nolock(). Signed-off-by: Qi Zheng --- mm/filemap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index d87c858465962..491eb92d6db

[PATCH 05/14] mm: khugepaged: __collapse_huge_page_swapin() use pte_offset_map_readonly_nolock()

2024-08-21 Thread Qi Zheng
In __collapse_huge_page_swapin(), we just use the ptl for pte_same() check in do_swap_page(). In other places, we directly use pte_offset_map_lock(), so convert it to using pte_offset_map_readonly_nolock(). Signed-off-by: Qi Zheng --- mm/khugepaged.c | 6 +- 1 file changed, 5 insertions(+),

[PATCH 06/14] mm: handle_pte_fault() use pte_offset_map_maywrite_nolock()

2024-08-21 Thread Qi Zheng
In handle_pte_fault(), we may modify the vmf->pte after acquiring the vmf->ptl, so convert it to using pte_offset_map_maywrite_nolock(). But since we already do the pte_same() check, so there is no need to get pmdval to do pmd_same() check, just pass NULL to pmdvalp parameter. Signed-off-by: Qi Zh

[PATCH 07/14] mm: khugepaged: collapse_pte_mapped_thp() use pte_offset_map_maywrite_nolock()

2024-08-21 Thread Qi Zheng
In collapse_pte_mapped_thp(), we may modify the pte and pmd entry after acquring the ptl, so convert it to using pte_offset_map_maywrite_nolock(). At this time, the write lock of mmap_lock is not held, and the pte_same() check is not performed after the PTL held. So we should get pgt_pmd and do pmd

[PATCH 08/14] mm: copy_pte_range() use pte_offset_map_maywrite_nolock()

2024-08-21 Thread Qi Zheng
In copy_pte_range(), we may modify the src_pte entry after holding the src_ptl, so convert it to using pte_offset_map_maywrite_nolock(). But since we already hold the write lock of mmap_lock, there is no need to get pmdval to do pmd_same() check, just pass NULL to pmdvalp parameter. Signed-off-by:

[PATCH 09/14] mm: mremap: move_ptes() use pte_offset_map_maywrite_nolock()

2024-08-21 Thread Qi Zheng
In move_ptes(), we may modify the new_pte after acquiring the new_ptl, so convert it to using pte_offset_map_maywrite_nolock(). But since we already hold the exclusive mmap_lock, there is no need to get pmdval to do pmd_same() check, just pass NULL to pmdvalp parameter. Signed-off-by: Qi Zheng --

[PATCH 10/14] mm: page_vma_mapped_walk: map_pte() use pte_offset_map_maywrite_nolock()

2024-08-21 Thread Qi Zheng
In the caller of map_pte(), we may modify the pvmw->pte after acquiring the pvmw->ptl, so convert it to using pte_offset_map_maywrite_nolock(). At this time, the write lock of mmap_lock is not held, and the pte_same() check is not performed after the pvmw->ptl held, so we should get pmdval and do p

[PATCH 11/14] mm: userfaultfd: move_pages_pte() use pte_offset_map_maywrite_nolock()

2024-08-21 Thread Qi Zheng
In move_pages_pte(), we may modify the dst_pte and src_pte after acquiring the ptl, so convert it to using pte_offset_map_maywrite_nolock(). But since we already do the pte_same() check, there is no need to get pmdval to do pmd_same() check, just pass NULL to pmdvalp parameter. Signed-off-by: Qi Z

[PATCH 12/14] mm: multi-gen LRU: walk_pte_range() use pte_offset_map_maywrite_nolock()

2024-08-21 Thread Qi Zheng
In walk_pte_range(), we may modify the pte entry after holding the ptl, so convert it to using pte_offset_map_maywrite_nolock(). At this time, the write lock of mmap_lock is not held, and the pte_same() check is not performed after the ptl held, so we should get pmdval and do pmd_same() check to en

[PATCH 13/14] mm: pgtable: remove pte_offset_map_nolock()

2024-08-21 Thread Qi Zheng
Now no users are using the pte_offset_map_nolock(), remove it. Signed-off-by: Qi Zheng --- Documentation/mm/split_page_table_lock.rst | 3 --- include/linux/mm.h | 2 -- mm/pgtable-generic.c | 21 - 3 files changed, 26 deletions

[PATCH 14/14] mm: khugepaged: retract_page_tables() use pte_offset_map_maywrite_nolock()

2024-08-21 Thread Qi Zheng
In retract_page_tables(), we may modify the pmd entry after acquiring the pml and ptl, so we should also check whether the pmd entry is stable. Using pte_offset_map_maywrite_nolock() + pmd_same() to do it. Signed-off-by: Qi Zheng --- mm/khugepaged.c | 17 - 1 file changed, 16 ins

Re: [PATCH 06/14] mm: handle_pte_fault() use pte_offset_map_maywrite_nolock()

2024-08-21 Thread Qi Zheng
On 2024/8/21 17:17, LEROY Christophe wrote: Le 21/08/2024 à 10:18, Qi Zheng a écrit : In handle_pte_fault(), we may modify the vmf->pte after acquiring the vmf->ptl, so convert it to using pte_offset_map_maywrite_nolock(). But since we already do the pte_same() check, so there is no need to

Re: [PATCH 06/14] mm: handle_pte_fault() use pte_offset_map_maywrite_nolock()

2024-08-21 Thread David Hildenbrand
On 21.08.24 11:24, Qi Zheng wrote: On 2024/8/21 17:17, LEROY Christophe wrote: Le 21/08/2024 à 10:18, Qi Zheng a écrit : In handle_pte_fault(), we may modify the vmf->pte after acquiring the vmf->ptl, so convert it to using pte_offset_map_maywrite_nolock(). But since we already do the pte_s

Re: [PATCH 06/14] mm: handle_pte_fault() use pte_offset_map_maywrite_nolock()

2024-08-21 Thread Qi Zheng
On 2024/8/21 17:41, David Hildenbrand wrote: On 21.08.24 11:24, Qi Zheng wrote: On 2024/8/21 17:17, LEROY Christophe wrote: Le 21/08/2024 à 10:18, Qi Zheng a écrit : In handle_pte_fault(), we may modify the vmf->pte after acquiring the vmf->ptl, so convert it to using pte_offset_map_may

Re: [PATCH 06/14] mm: handle_pte_fault() use pte_offset_map_maywrite_nolock()

2024-08-21 Thread David Hildenbrand
On 21.08.24 11:51, Qi Zheng wrote: On 2024/8/21 17:41, David Hildenbrand wrote: On 21.08.24 11:24, Qi Zheng wrote: On 2024/8/21 17:17, LEROY Christophe wrote: Le 21/08/2024 à 10:18, Qi Zheng a écrit : In handle_pte_fault(), we may modify the vmf->pte after acquiring the vmf->ptl, so con

Re: perf build failure with v6.11-rc4 (commit 4bbe60029319 ("perf daemon: Fix the build on 32-bit architectures"))

2024-08-21 Thread Arnaldo Carvalho de Melo
On Wed, Aug 21, 2024, 6:06 AM LEROY Christophe < christophe.ler...@cs-soprasteria.com> wrote: > Got the following build failure on v6.11-rc4, see > https://github.com/chleroy/linux/actions/runs/10485680041/job/29042302519 > > > > > Can you try with https://git.kernel.org/pub/scm/linux/kernel/git/p

Re: [PATCH 06/14] mm: handle_pte_fault() use pte_offset_map_maywrite_nolock()

2024-08-21 Thread Qi Zheng
On 2024/8/21 17:53, David Hildenbrand wrote: On 21.08.24 11:51, Qi Zheng wrote: On 2024/8/21 17:41, David Hildenbrand wrote: On 21.08.24 11:24, Qi Zheng wrote: On 2024/8/21 17:17, LEROY Christophe wrote: Le 21/08/2024 à 10:18, Qi Zheng a écrit : In handle_pte_fault(), we may modify

Re: [PATCH v12 4/6] arm64: support copy_mc_[user]_highpage()

2024-08-21 Thread Jonathan Cameron
On Tue, 20 Aug 2024 11:02:05 +0800 Tong Tiangen wrote: > 在 2024/8/19 19:56, Jonathan Cameron 写道: > > On Tue, 28 May 2024 16:59:13 +0800 > > Tong Tiangen wrote: > > > >> Currently, many scenarios that can tolerate memory errors when copying page > >> have been supported in the kernel[1~5], all

Re: [PATCH 3/3] cpuidle: Select a different state on tick_broadcast_enter() failures

2024-08-21 Thread Dhruva Gole
Hi, On May 10, 2015 at 01:19:52 +0200, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > If tick_broadcast_enter() fails in cpuidle_enter_state(), > try to find another idle state to enter instead of invoking > default_idle_call() immediately and returning -EBUSY which > should increase the

Re: [PATCH 3/3] cpuidle: Select a different state on tick_broadcast_enter() failures

2024-08-21 Thread Rafael J. Wysocki
On Wed, Aug 21, 2024 at 1:15 PM Dhruva Gole wrote: > > Hi, > > On May 10, 2015 at 01:19:52 +0200, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki > > > > If tick_broadcast_enter() fails in cpuidle_enter_state(), > > try to find another idle state to enter instead of invoking > > default_idle

Re: [PATCH v12 4/6] arm64: support copy_mc_[user]_highpage()

2024-08-21 Thread Tong Tiangen
在 2024/8/21 19:28, Jonathan Cameron 写道: On Tue, 20 Aug 2024 11:02:05 +0800 Tong Tiangen wrote: 在 2024/8/19 19:56, Jonathan Cameron 写道: On Tue, 28 May 2024 16:59:13 +0800 Tong Tiangen wrote: Currently, many scenarios that can tolerate memory errors when copying page have been supporte

Re: [PATCH] powerpc/pseries: Fix dtl_access_lock to be a rw_semaphore

2024-08-21 Thread Nysal Jan K.A.
On Mon, Aug 19, 2024 at 10:24:01PM GMT, Michael Ellerman wrote: > Fixes: 06220d78f24a ("powerpc/pseries: Introduce rwlock to gatekeep DTLB > usage") > Signed-off-by: Michael Ellerman > --- > arch/powerpc/include/asm/dtl.h| 3 ++- > arch/powerpc/platforms/pseries/dtl.c | 8 >

Re: [PATCH v2] ata: pata_macio: Use WARN instead of BUG

2024-08-21 Thread Sergei Shtylyov
On 8/20/24 6:04 AM, Michael Ellerman wrote: > The overflow/underflow conditions in pata_macio_qc_prep() should never > happen. But if they do there's no need to kill the system entirely, a > WARN and failing the IO request should be sufficient and might allow the > system to keep running. WARN

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-21 Thread Christian Lamparter
Sorry to write a reply to this old mail. But after years, I finally decided to tackle an "old" problem that has come up... And unfortunately it is related to this patch. But let me explain. On 9/16/21 4:52 PM, Christophe Leroy wrote: dcbz instruction shouldn't be used on non-cached memory. Using

[PATCH v3 1/3] powerpc/pseries: Use correct data types from pseries_hp_errorlog struct

2024-08-21 Thread Haren Myneni
_be32 type is defined for some elements in pseries_hp_errorlog struct but also used them u32 after be32_to_cpu() conversion. Example: In handle_dlpar_errorlog() hp_elog->_drc_u.drc_index = be32_to_cpu(hp_elog->_drc_u.drc_index); And later assigned to u32 type dlpar_cpu() - u32 drc_index = hp_elog

[PATCH v3 2/3] powerpc/pseries/dlpar: Remove device tree node for DLPAR IO remove

2024-08-21 Thread Haren Myneni
In the powerpc-pseries specific implementation, the IO hotplug event is handled in the user space (drmgr tool). But update the device tree and /dev/mem access to allocate buffers for some RTAS calls are restricted when the kernel lockdown feature is enabled. For the DLPAR IO REMOVE, the correspondi

[PATCH v3 3/3] powerpc/pseries/dlpar: Add device tree nodes for DLPAR IO add

2024-08-21 Thread Haren Myneni
In the powerpc-pseries specific implementation, the IO hotplug event is handled in the user space (drmgr tool). For the DLPAR IO ADD, the corresponding device tree nodes and properties will be added to the device tree after the device enable. The user space (drmgr tool) uses configure_connector RTA

Re: [PATCH v2] ata: pata_macio: Use WARN instead of BUG

2024-08-21 Thread Christoph Hellwig
On Thu, Aug 22, 2024 at 12:13:52AM +0300, Sergei Shtylyov wrote: > On 8/20/24 6:04 AM, Michael Ellerman wrote: > > > The overflow/underflow conditions in pata_macio_qc_prep() should never > > happen. But if they do there's no need to kill the system entirely, a > > WARN and failing the IO request

Re: [PATCH v6 RESED 0/2] dma: support DMA zone starting above 4GB

2024-08-21 Thread Christoph Hellwig
Thanks, applied to the dma-mapping tree for Linux 6.12.

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-21 Thread LEROY Christophe
+ CC Christoph Hellwig Hi, Le 22/08/2024 à 00:39, Christian Lamparter a écrit : > [Vous ne recevez pas souvent de courriers de > christian.lampar...@isd.uni-stuttgart.de. Découvrez pourquoi ceci est > important à https://aka.ms/LearnAboutSenderIdentification ] > > Sorry to write a reply to this o

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-21 Thread Christoph Hellwig
On Thu, Aug 22, 2024 at 05:25:10AM +, LEROY Christophe wrote: > > and this results in a call to dma_direct_allocation(), which has one > > innocent looking memset(): > > > memset() can't be used on non-cached memory, memset_io() has to be used > instead. No, we use memset on uncached memory

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-21 Thread LEROY Christophe
Le 22/08/2024 à 07:32, Christoph Hellwig a écrit : > On Thu, Aug 22, 2024 at 05:25:10AM +, LEROY Christophe wrote: >>> and this results in a call to dma_direct_allocation(), which has one >>> innocent looking memset(): >> >> >> memset() can't be used on non-cached memory, memset_io() has to b