* [PATCH v1 02/15] powerpc/mm: define __pud_free_tlb() at all time on nohash/64
From: Christophe Leroy @ 2019-04-03 20:06 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
aneesh.kumar
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <cover.1554321743.git.christophe.leroy@c-s.fr>
CONFIG_PPC_64K_PAGES is not selectable on nohash/64, so get
__pud_free_tlb() defined at all time.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/nohash/64/pgalloc.h | 3 ---
1 file changed, 3 deletions(-)
diff --git a/arch/powerpc/include/asm/nohash/64/pgalloc.h b/arch/powerpc/include/asm/nohash/64/pgalloc.h
index 66d086f85bd5..ded453f9b5a8 100644
--- a/arch/powerpc/include/asm/nohash/64/pgalloc.h
+++ b/arch/powerpc/include/asm/nohash/64/pgalloc.h
@@ -171,12 +171,9 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
#define __pmd_free_tlb(tlb, pmd, addr) \
pgtable_free_tlb(tlb, pmd, PMD_CACHE_INDEX)
-#ifndef CONFIG_PPC_64K_PAGES
#define __pud_free_tlb(tlb, pud, addr) \
pgtable_free_tlb(tlb, pud, PUD_INDEX_SIZE)
-#endif /* CONFIG_PPC_64K_PAGES */
-
#define check_pgt_cache() do { } while (0)
#endif /* _ASM_POWERPC_PGALLOC_64_H */
--
2.13.3
^ permalink raw reply related
* [PATCH v1 04/15] powerpc/mm: move pgtable_t in asm/mmu.h
From: Christophe Leroy @ 2019-04-03 20:06 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
aneesh.kumar
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <cover.1554321743.git.christophe.leroy@c-s.fr>
pgtable_t is now identical for all subarches, move it to the
top level asm/mmu.h
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/book3s/32/mmu-hash.h | 4 ----
arch/powerpc/include/asm/book3s/64/mmu.h | 8 --------
arch/powerpc/include/asm/mmu.h | 3 +++
arch/powerpc/include/asm/nohash/32/mmu.h | 6 ------
arch/powerpc/include/asm/nohash/64/mmu.h | 6 ------
5 files changed, 3 insertions(+), 24 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/32/mmu-hash.h b/arch/powerpc/include/asm/book3s/32/mmu-hash.h
index 5cb588395fdc..2612d7a1688c 100644
--- a/arch/powerpc/include/asm/book3s/32/mmu-hash.h
+++ b/arch/powerpc/include/asm/book3s/32/mmu-hash.h
@@ -10,8 +10,6 @@
* BATs
*/
-#include <asm/page.h>
-
/* Block size masks */
#define BL_128K 0x000
#define BL_256K 0x001
@@ -49,8 +47,6 @@ struct ppc_bat {
u32 batu;
u32 batl;
};
-
-typedef pte_t *pgtable_t;
#endif /* !__ASSEMBLY__ */
/*
diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h b/arch/powerpc/include/asm/book3s/64/mmu.h
index 1ceee000c18d..b98b5b304307 100644
--- a/arch/powerpc/include/asm/book3s/64/mmu.h
+++ b/arch/powerpc/include/asm/book3s/64/mmu.h
@@ -25,14 +25,6 @@ struct mmu_psize_def {
};
};
extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT];
-
-/*
- * For BOOK3s 64 with 4k and 64K linux page size
- * we want to use pointers, because the page table
- * actually store pfn
- */
-typedef pte_t *pgtable_t;
-
#endif /* __ASSEMBLY__ */
/* 64-bit classic hash table MMU */
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index 598cdcdd1355..d10dc714f95f 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -124,6 +124,9 @@
#ifndef __ASSEMBLY__
#include <linux/bug.h>
#include <asm/cputable.h>
+#include <asm/page.h>
+
+typedef pte_t *pgtable_t;
#ifdef CONFIG_PPC_FSL_BOOK3E
#include <asm/percpu.h>
diff --git a/arch/powerpc/include/asm/nohash/32/mmu.h b/arch/powerpc/include/asm/nohash/32/mmu.h
index 7d94a36d57d2..af0e8b54876a 100644
--- a/arch/powerpc/include/asm/nohash/32/mmu.h
+++ b/arch/powerpc/include/asm/nohash/32/mmu.h
@@ -2,8 +2,6 @@
#ifndef _ASM_POWERPC_NOHASH_32_MMU_H_
#define _ASM_POWERPC_NOHASH_32_MMU_H_
-#include <asm/page.h>
-
#if defined(CONFIG_40x)
/* 40x-style software loaded TLB */
#include <asm/nohash/32/mmu-40x.h>
@@ -18,8 +16,4 @@
#include <asm/nohash/32/mmu-8xx.h>
#endif
-#ifndef __ASSEMBLY__
-typedef pte_t *pgtable_t;
-#endif
-
#endif /* _ASM_POWERPC_NOHASH_32_MMU_H_ */
diff --git a/arch/powerpc/include/asm/nohash/64/mmu.h b/arch/powerpc/include/asm/nohash/64/mmu.h
index 3376f5222d24..87871d027b75 100644
--- a/arch/powerpc/include/asm/nohash/64/mmu.h
+++ b/arch/powerpc/include/asm/nohash/64/mmu.h
@@ -2,13 +2,7 @@
#ifndef _ASM_POWERPC_NOHASH_64_MMU_H_
#define _ASM_POWERPC_NOHASH_64_MMU_H_
-#include <asm/page.h>
-
/* Freescale Book-E software loaded TLB or Book-3e (ISA 2.06+) MMU */
#include <asm/nohash/mmu-book3e.h>
-#ifndef __ASSEMBLY__
-typedef pte_t *pgtable_t;
-#endif
-
#endif /* _ASM_POWERPC_NOHASH_64_MMU_H_ */
--
2.13.3
^ permalink raw reply related
* [PATCH v1 00/15] Refactor pgalloc stuff
From: Christophe Leroy @ 2019-04-03 20:06 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
aneesh.kumar
Cc: linuxppc-dev, linux-kernel
This series converts book3e64 to pte_fragment and refactor
things that are common among subarches.
Christophe Leroy (15):
powerpc/mm: drop __bad_pte()
powerpc/mm: define __pud_free_tlb() at all time on nohash/64
powerpc/mm: convert Book3E 64 to pte_fragment
powerpc/mm: move pgtable_t in asm/mmu.h
powerpc/mm: get rid of nohash/32/mmu.h and nohash/64/mmu.h
powerpc/Kconfig: select PPC_MM_SLICES from subarch type
powerpc/book3e: move early_alloc_pgtable() to init section
powerpc/mm: don't use pte_alloc_kernel() until slab is available on
PPC32
powerpc/mm: inline pte_alloc_one_kernel() and pte_alloc_one() on PPC32
powerpc/mm: refactor pte_alloc_one() and pte_free() families
definition.
powerpc/mm: refactor definition of pgtable_cache[]
powerpc/mm: Only keep one version of pmd_populate() functions on
nohash/32
powerpc/mm: refactor pgtable freeing functions on nohash
powerpc/mm: refactor pmd_pgtable()
powerpc/mm: refactor pgd_alloc() and pgd_free() on nohash
arch/powerpc/include/asm/book3s/32/mmu-hash.h | 4 -
arch/powerpc/include/asm/book3s/32/pgalloc.h | 41 ---------
arch/powerpc/include/asm/book3s/64/mmu.h | 8 --
arch/powerpc/include/asm/book3s/64/pgalloc.h | 49 ----------
arch/powerpc/include/asm/mmu.h | 3 +
arch/powerpc/include/asm/mmu_context.h | 6 --
arch/powerpc/include/asm/nohash/32/mmu.h | 25 ------
arch/powerpc/include/asm/nohash/32/pgalloc.h | 123 ++------------------------
arch/powerpc/include/asm/nohash/64/mmu.h | 12 ---
arch/powerpc/include/asm/nohash/64/pgalloc.h | 117 +-----------------------
arch/powerpc/include/asm/nohash/mmu.h | 16 +++-
arch/powerpc/include/asm/nohash/pgalloc.h | 56 ++++++++++++
arch/powerpc/include/asm/pgalloc.h | 51 +++++++++++
arch/powerpc/mm/Makefile | 4 +-
arch/powerpc/mm/mmu_context.c | 2 +-
arch/powerpc/mm/pgtable-book3e.c | 4 +-
arch/powerpc/mm/pgtable_32.c | 42 +++++----
arch/powerpc/platforms/Kconfig.cputype | 4 +-
18 files changed, 165 insertions(+), 402 deletions(-)
delete mode 100644 arch/powerpc/include/asm/nohash/32/mmu.h
delete mode 100644 arch/powerpc/include/asm/nohash/64/mmu.h
--
2.13.3
^ permalink raw reply
* Re: [PATCH V2] ASoC: fsl_esai: Support synchronous mode
From: Nicolin Chen @ 2019-04-03 18:57 UTC (permalink / raw)
To: S.j. Wang
Cc: alsa-devel@alsa-project.org, timur@kernel.org,
Xiubo.Lee@gmail.com, festevam@gmail.com, broonie@kernel.org,
linuxppc-dev@lists.ozlabs.org
In-Reply-To: <dac7c52215b4bb09f3548bcb9246f8fe21799e38.1554285839.git.shengjiu.wang@nxp.com>
This looks better :)
On Wed, Apr 03, 2019 at 10:07:40AM +0000, S.j. Wang wrote:
> @@ -218,7 +218,7 @@ static int fsl_esai_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
> {
> struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai);
> struct clk *clksrc = esai_priv->extalclk;
> - bool tx = clk_id <= ESAI_HCKT_EXTAL;
> + bool tx = (clk_id <= ESAI_HCKT_EXTAL || esai_priv->synchronous);
> bool in = dir == SND_SOC_CLOCK_IN;
> u32 ratio, ecr = 0;
> unsigned long clk_rate;
> @@ -253,7 +253,7 @@ static int fsl_esai_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
> ecr |= ESAI_ECR_ETI;
> /* fall through */
Btw, I am also wondering if the fall through here is a bug....
Because I don't recall that there is a specific reason to fall
through here. Can you please help confirm? Perhaps we need to
submit a separate fix as well by replacing it with a "break;".
> case ESAI_HCKR_EXTAL:
> - ecr |= ESAI_ECR_ERI;
> + ecr |= esai_priv->synchronous ? ESAI_ECR_ETI : ESAI_ECR_ERI;
> break;
> default:
> return -EINVAL;
> @@ -537,10 +537,18 @@ static int fsl_esai_hw_params(struct snd_pcm_substream *substream,
>
> bclk = params_rate(params) * slot_width * esai_priv->slots;
>
> - ret = fsl_esai_set_bclk(dai, tx, bclk);
> + ret = fsl_esai_set_bclk(dai, esai_priv->synchronous || tx, bclk);
> if (ret)
> return ret;
>
> + mask = ESAI_xCR_xSWS_MASK;
> + val = ESAI_xCR_xSWS(slot_width, width);
> +
> + regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), mask, val);
> + /* Recording in synchronous mode needs to set TCR also */
> + if (!tx && esai_priv->synchronous)
> + regmap_update_bits(esai_priv->regmap, REG_ESAI_TCR, mask, val);
> +
> /* Use Normal mode to support monaural audio */
> regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx),
> ESAI_xCR_xMOD_MASK, params_channels(params) > 1 ?
> @@ -556,10 +564,9 @@ static int fsl_esai_hw_params(struct snd_pcm_substream *substream,
>
> regmap_update_bits(esai_priv->regmap, REG_ESAI_xFCR(tx), mask, val);
>
> - mask = ESAI_xCR_xSWS_MASK | (tx ? ESAI_xCR_PADC : 0);
> - val = ESAI_xCR_xSWS(slot_width, width) | (tx ? ESAI_xCR_PADC : 0);
> -
> - regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), mask, val);
> + if (tx)
> + regmap_update_bits(esai_priv->regmap, REG_ESAI_TCR,
> + ESAI_xCR_PADC, ESAI_xCR_PADC);
Mind aligning the indentation here like the one below?
regmap_update_bits(esai_priv->regmap, REG_ESAI_TCR,
ESAI_xCR_PADC, ESAI_xCR_PADC);
Once you fix the indentation, add this:
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Thanks
^ permalink raw reply
* Re: Question about Power8/9, PHB3/4 and setting of DMA mask
From: Christoph Hellwig @ 2019-04-03 18:08 UTC (permalink / raw)
To: Oded Gabbay; +Cc: linuxppc-dev, Christoph Hellwig
In-Reply-To: <CAFCwf13rpx4HdWeW_Gw5NaaPnFB95z3qw5ATN=uDOMz2if_X5g@mail.gmail.com>
On Sun, Mar 31, 2019 at 12:50:21PM +0300, Oded Gabbay wrote:
> Due to some limitation in Goya, the driver first need to allocate a
> 2MB chunk in a DMA-able address under 39 bits and then we would like
> to move to using up to 48 bits. Therefore, the driver first tries to
> set the DMA mask to 39 bits, allocate the 2MB area and later on,
> change the DMA mask to 48 bits. On x86 this works fine.
You can't just change the DMA mask while you have active allocations,
this will fail for many implementations.
^ permalink raw reply
* Re: [PATCH 0/6] convert locked_vm from unsigned long to atomic64_t
From: Daniel Jordan @ 2019-04-03 16:52 UTC (permalink / raw)
To: Steven Sistare
Cc: Davidlohr Bueso, linux_lkml_grp, kvm, Alan Tull,
Alexey Kardashevskiy, linux-fpga, linux-kernel, kvm-ppc,
Daniel Jordan, linux-mm, Alex Williamson, Moritz Fischer, akpm,
linuxppc-dev, Christoph Lameter, Wu Hao
In-Reply-To: <abe31bae-1bdf-b763-c4d1-5e4ea2ccda13@oracle.com>
On Wed, Apr 03, 2019 at 08:51:13AM -0400, Steven Sistare wrote:
> On 4/2/2019 4:41 PM, Daniel Jordan wrote:
> > [1] https://lore.kernel.org/linux-mm/20190211224437.25267-1-daniel.m.jordan@oracle.com/
>
> You could clean all 6 patches up nicely with a common subroutine that
> increases locked_vm subject to the rlimit. Pass a bool arg that is true if
> the limit should be enforced, !dma->lock_cap for one call site, and
> !capable(CAP_IPC_LOCK) for the rest. Push the warnings and debug statements
> to the subroutine as well. One patch could refactor, and a second could
> change the locking method.
Yes, I tried writing, but didn't end up including, such a subroutine for [1].
The devil was in the details, but with the cmpxchg business, it's more
worthwhile to iron all those out. I'll give it a try.
^ permalink raw reply
* Re: [PATCH v2 4/6] powerpc: use common ptrace_syscall_enter hook to handle _TIF_SYSCALL_EMU
From: Will Deacon @ 2019-04-03 16:50 UTC (permalink / raw)
To: Oleg Nesterov
Cc: Haibo Xu, Steve Capper, Catalin Marinas, jdike, x86, linux-kernel,
Bin Lu, Richard Weinberger, Ingo Molnar, Paul Mackerras,
Andy Lutomirski, Sudeep Holla, Thomas Gleixner, linuxppc-dev,
linux-arm-kernel
In-Reply-To: <20190319173233.GB11525@redhat.com>
Hi Oleg,
On Tue, Mar 19, 2019 at 06:32:33PM +0100, Oleg Nesterov wrote:
> On 03/19, Oleg Nesterov wrote:
> >
> > Well, personally I see no point... Again, after the trivial simplification
> > x86 does
> >
> > if (work & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) {
> > ret = tracehook_report_syscall_entry(regs);
> > if (ret || (work & _TIF_SYSCALL_EMU))
> > return -1L;
> > }
> >
> > this looks simple enough for copy-and-paste.
> >
> > > If there's a better way to achieve the same
> >
> > I can only say that if we add a common helper, I think it should absorb
> > tracehook_report_syscall_entry() and handle both TIF's just like the code
> > above does. Not sure this makes any sense.
>
> this won't work, looking at 6/6 I see that arm64 needs to distinguish
> _TRACE and _EMU ... I don't understand this code, but it looks suspicious.
> If tracehook_report_syscall_entry() returns nonzero the tracee was killed,
> syscall_trace_enter() should just return.
>
> To me this is another indication that consolidation makes no sense ;)
The reason I'm pushing for consolidation here is because I think it's the
only sane way to maintain the tracing and debug hooks on the syscall
entry/exit paths. Having to look at all the different arch implementations
and distil the portable semantics is a nightmare and encourages gradual
divergence over time. Given that we don't support this SYSCALL_EMU stuff
on arm64 today, we have the opportunity to make this generic and allow other
architectures (e.g. riscv) to hook in the same way that we do. It clearly
shouldn't affect the behaviour of existing architectures which already
support the functionality.
However, I also agree that this patch series looks dodgy as it stands -- we
shouldn't have code paths that can result in calling
tracehook_report_syscall_entry() twice.
Will
^ permalink raw reply
* Re: [PATCH 5/6] powerpc/mmu: drop mmap_sem now that locked_vm is atomic
From: Daniel Jordan @ 2019-04-03 16:40 UTC (permalink / raw)
To: Christophe Leroy
Cc: Davidlohr Bueso, Alexey Kardashevskiy, linux-kernel,
Daniel Jordan, linux-mm, Paul Mackerras, akpm, linuxppc-dev,
Christoph Lameter
In-Reply-To: <964bd5b0-f1e5-7bf0-5c58-18e75c550841@c-s.fr>
On Wed, Apr 03, 2019 at 06:58:45AM +0200, Christophe Leroy wrote:
> Le 02/04/2019 à 22:41, Daniel Jordan a écrit :
> > With locked_vm now an atomic, there is no need to take mmap_sem as
> > writer. Delete and refactor accordingly.
>
> Could you please detail the change ?
Ok, I'll be more specific in the next version, using some of your language in
fact. :)
> It looks like this is not the only
> change. I'm wondering what the consequences are.
>
> Before we did:
> - lock
> - calculate future value
> - check the future value is acceptable
> - update value if future value acceptable
> - return error if future value non acceptable
> - unlock
>
> Now we do:
> - atomic update with future (possibly too high) value
> - check the new value is acceptable
> - atomic update back with older value if new value not acceptable and return
> error
>
> So if a concurrent action wants to increase locked_vm with an acceptable
> step while another one has temporarily set it too high, it will now fail.
>
> I think we should keep the previous approach and do a cmpxchg after
> validating the new value.
That's a good idea, and especially worth doing considering that an arbitrary
number of threads that charge a low amount of locked_vm can fail just because
one thread charges lots of it.
pinned_vm appears to be broken the same way, so I can fix it too unless someone
beats me to it.
^ permalink raw reply
* Re: [PATCH 1/6] mm: change locked_vm's type from unsigned long to atomic64_t
From: Daniel Jordan @ 2019-04-03 16:07 UTC (permalink / raw)
To: Andrew Morton, Daniel Jordan, Alan Tull, Alexey Kardashevskiy,
Alex Williamson, Benjamin Herrenschmidt, Christoph Lameter,
Michael Ellerman, Moritz Fischer, Paul Mackerras, Wu Hao,
linux-mm, kvm, kvm-ppc, linuxppc-dev, linux-fpga, linux-kernel
In-Reply-To: <20190402234357.tn3tik4r7k6nbrau@linux-r8p5>
On Tue, Apr 02, 2019 at 04:43:57PM -0700, Davidlohr Bueso wrote:
> On Tue, 02 Apr 2019, Andrew Morton wrote:
>
> > Also, we didn't remove any down_write(mmap_sem)s from core code so I'm
> > thinking that the benefit of removing a few mmap_sem-takings from a few
> > obscure drivers (sorry ;)) is pretty small.
>
> afaik porting the remaining incorrect users of locked_vm to pinned_vm was
> the next step before this one, which made converting locked_vm to atomic
> hardly worth it. Daniel?
Right, as you know I tried those incorrect users first, but there were concerns
about user-visible changes regarding RLIMIT_MEMLOCK and pinned_vm/locked_vm
without the accounting problem between all three being solved.
To my knowledge no one has a solution for that, so in the meantime I'm taking
the incremental step of getting rid of mmap_sem for locked_vm users. The
locked_vm -> pinned_vm conversion can happen later.
^ permalink raw reply
* Re: [PATCH 1/6] mm: change locked_vm's type from unsigned long to atomic64_t
From: Daniel Jordan @ 2019-04-03 16:09 UTC (permalink / raw)
To: Christophe Leroy
Cc: Davidlohr Bueso, kvm, Alan Tull, Alexey Kardashevskiy, linux-fpga,
linux-kernel, kvm-ppc, Daniel Jordan, linux-mm, Alex Williamson,
Moritz Fischer, akpm, linuxppc-dev, Christoph Lameter, Wu Hao
In-Reply-To: <4140911c-8193-010b-e8fc-c8b24ffdf423@c-s.fr>
On Wed, Apr 03, 2019 at 06:46:07AM +0200, Christophe Leroy wrote:
>
>
> Le 02/04/2019 à 22:41, Daniel Jordan a écrit :
> > Taking and dropping mmap_sem to modify a single counter, locked_vm, is
> > overkill when the counter could be synchronized separately.
> >
> > Make mmap_sem a little less coarse by changing locked_vm to an atomic,
> > the 64-bit variety to avoid issues with overflow on 32-bit systems.
>
> Can you elaborate on the above ? Previously it was 'unsigned long', what
> were the issues ?
Sure, I responded to this in another thread from this series.
> If there was such issues, shouldn't there be a first patch
> moving it from unsigned long to u64 before this atomic64_t change ? Or at
> least it should be clearly explain here what the issues are and how
> switching to a 64 bit counter fixes them.
Yes, I can explain the motivation in the next version.
^ permalink raw reply
* Re: [PATCH 1/6] mm: change locked_vm's type from unsigned long to atomic64_t
From: Daniel Jordan @ 2019-04-03 15:58 UTC (permalink / raw)
To: Andrew Morton
Cc: Davidlohr Bueso, kvm, Alan Tull, Alexey Kardashevskiy, linux-fpga,
linux-kernel, kvm-ppc, Daniel Jordan, linux-mm, Alex Williamson,
Moritz Fischer, Christoph Lameter, linuxppc-dev, Wu Hao
In-Reply-To: <20190402150424.5cf64e19deeafa58fc6c1a9f@linux-foundation.org>
On Tue, Apr 02, 2019 at 03:04:24PM -0700, Andrew Morton wrote:
> On Tue, 2 Apr 2019 16:41:53 -0400 Daniel Jordan <daniel.m.jordan@oracle.com> wrote:
> > static long kvmppc_account_memlimit(unsigned long stt_pages, bool inc)
> > {
> > long ret = 0;
> > + s64 locked_vm;
> >
> > if (!current || !current->mm)
> > return ret; /* process exited */
> >
> > down_write(¤t->mm->mmap_sem);
> >
> > + locked_vm = atomic64_read(¤t->mm->locked_vm);
> > if (inc) {
> > unsigned long locked, lock_limit;
> >
> > - locked = current->mm->locked_vm + stt_pages;
> > + locked = locked_vm + stt_pages;
> > lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
> > if (locked > lock_limit && !capable(CAP_IPC_LOCK))
> > ret = -ENOMEM;
> > else
> > - current->mm->locked_vm += stt_pages;
> > + atomic64_add(stt_pages, ¤t->mm->locked_vm);
> > } else {
> > - if (WARN_ON_ONCE(stt_pages > current->mm->locked_vm))
> > - stt_pages = current->mm->locked_vm;
> > + if (WARN_ON_ONCE(stt_pages > locked_vm))
> > + stt_pages = locked_vm;
> >
> > - current->mm->locked_vm -= stt_pages;
> > + atomic64_sub(stt_pages, ¤t->mm->locked_vm);
> > }
>
> With the current code, current->mm->locked_vm cannot go negative.
> After the patch, it can go negative. If someone else decreased
> current->mm->locked_vm between this function's atomic64_read() and
> atomic64_sub().
>
> I guess this is a can't-happen in this case because the racing code
> which performed the modification would have taken it negative anyway.
>
> But this all makes me rather queazy.
mmap_sem is still held in this patch, so updates to locked_vm are still
serialized and I don't think what you describe can happen. A later patch
removes mmap_sem, of course, but it also rewrites the code to do something
different. This first patch is just a mechanical type change from unsigned
long to atomic64_t.
So...does this alleviate your symptoms?
> Also, we didn't remove any down_write(mmap_sem)s from core code so I'm
> thinking that the benefit of removing a few mmap_sem-takings from a few
> obscure drivers (sorry ;)) is pretty small.
Not sure about the other drivers, but vfio type1 isn't obscure. We use it
extensively in our cloud, and from Andrea's __GFP_THISNODE thread a few months
back it seems Red Hat also uses it:
https://lore.kernel.org/linux-mm/20180820032204.9591-3-aarcange@redhat.com/
> Also, the argument for switching 32-bit arches to a 64-bit counter was
> suspiciously vague. What overflow issues? Or are we just being lazy?
If user-controlled values are used to increase locked_vm, multiple threads
doing it at once on a 32-bit system could theoretically cause overflow, so in
the absence of atomic overflow checking, the 64-bit counter on 32b is defensive
programming.
I wouldn't have thought to do it, but Jason Gunthorpe raised the same issue in
the pinned_vm series:
https://lore.kernel.org/linux-mm/20190115205311.GD22031@mellanox.com/
I'm fine with changing it to atomic_long_t if the scenario is too theoretical
for people.
Anyway, thanks for looking at this.
^ permalink raw reply
* Re: [PATCH 2/2] arch: add pidfd and io_uring syscalls everywhere
From: Jens Axboe @ 2019-04-03 15:51 UTC (permalink / raw)
To: Will Deacon
Cc: Rich Felker, linux-ia64, linux-sh, Heiko Carstens, linux-mips,
James E . J . Bottomley, Max Filippov, Paul Mackerras, sparclinux,
linux-s390, Helge Deller, Russell King, Geert Uytterhoeven,
Catalin Marinas, James Hogan, Firoz Khan, Matt Turner, Fenghua Yu,
Arnd Bergmann, linux-m68k, Ivan Kokshaysky, linux-arm-kernel,
Richard Henderson, Michal Simek, Tony Luck, linux-parisc,
linux-kernel, Ralf Baechle, Paul Burton, linux-alpha,
Martin Schwidefsky, Andrew Morton, linuxppc-dev, David S . Miller
In-Reply-To: <20190403154902.GB16866@fuggles.cambridge.arm.com>
On 4/3/19 9:49 AM, Will Deacon wrote:
> On Wed, Apr 03, 2019 at 09:39:52AM -0600, Jens Axboe wrote:
>> On 4/3/19 9:19 AM, Will Deacon wrote:
>>> On Wed, Apr 03, 2019 at 07:49:26AM -0600, Jens Axboe wrote:
>>>> On 4/3/19 5:11 AM, Will Deacon wrote:
>>>>> will@autoplooker:~/liburing/test$ ./io_uring_register
>>>>> RELIMIT_MEMLOCK: 67108864 (67108864)
>>>>> [ 35.477875] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000070
>>>>> [ 35.478969] Mem abort info:
>>>>> [ 35.479296] ESR = 0x96000004
>>>>> [ 35.479785] Exception class = DABT (current EL), IL = 32 bits
>>>>> [ 35.480528] SET = 0, FnV = 0
>>>>> [ 35.480980] EA = 0, S1PTW = 0
>>>>> [ 35.481345] Data abort info:
>>>>> [ 35.481680] ISV = 0, ISS = 0x00000004
>>>>> [ 35.482267] CM = 0, WnR = 0
>>>>> [ 35.482618] user pgtable: 4k pages, 48-bit VAs, pgdp = (____ptrval____)
>>>>> [ 35.483486] [0000000000000070] pgd=0000000000000000
>>>>> [ 35.484041] Internal error: Oops: 96000004 [#1] PREEMPT SMP
>>>>> [ 35.484788] Modules linked in:
>>>>> [ 35.485311] CPU: 113 PID: 3973 Comm: io_uring_regist Not tainted 5.1.0-rc3-00012-g40b114779944 #1
>>>>> [ 35.486712] Hardware name: linux,dummy-virt (DT)
>>>>> [ 35.487450] pstate: 20400005 (nzCv daif +PAN -UAO)
>>>>> [ 35.488228] pc : link_pwq+0x10/0x60
>>>>> [ 35.488794] lr : apply_wqattrs_commit+0xe0/0x118
>>>>> [ 35.489550] sp : ffff000017e2bbc0
>>>>
>>>> Huh, this looks odd, it's crashing inside the wq setup.
>>>
>>> Enabling KASAN seems to indicate a double-free, which may well be related.
>>
>> Does this help?
>
> Yes, thanks for the quick patch. Feel free to add:
>
> Reported-by: Will Deacon <will.deacon@arm.com>
> Tested-by: Will Deacon <will.deacon@arm.com>
>
> if you spin a proper patch.
Great, thanks for reporting/testing.
--
Jens Axboe
^ permalink raw reply
* Re: [PATCH 2/2] arch: add pidfd and io_uring syscalls everywhere
From: Will Deacon @ 2019-04-03 15:49 UTC (permalink / raw)
To: Jens Axboe
Cc: Rich Felker, linux-ia64, linux-sh, Heiko Carstens, linux-mips,
James E . J . Bottomley, Max Filippov, Paul Mackerras, sparclinux,
linux-s390, Helge Deller, Russell King, Geert Uytterhoeven,
Catalin Marinas, James Hogan, Firoz Khan, Matt Turner, Fenghua Yu,
Arnd Bergmann, linux-m68k, Ivan Kokshaysky, linux-arm-kernel,
Richard Henderson, Michal Simek, Tony Luck, linux-parisc,
linux-kernel, Ralf Baechle, Paul Burton, linux-alpha,
Martin Schwidefsky, Andrew Morton, linuxppc-dev, David S . Miller
In-Reply-To: <032faa2f-6317-75b6-8514-076ef1a244e8@kernel.dk>
On Wed, Apr 03, 2019 at 09:39:52AM -0600, Jens Axboe wrote:
> On 4/3/19 9:19 AM, Will Deacon wrote:
> > On Wed, Apr 03, 2019 at 07:49:26AM -0600, Jens Axboe wrote:
> >> On 4/3/19 5:11 AM, Will Deacon wrote:
> >>> will@autoplooker:~/liburing/test$ ./io_uring_register
> >>> RELIMIT_MEMLOCK: 67108864 (67108864)
> >>> [ 35.477875] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000070
> >>> [ 35.478969] Mem abort info:
> >>> [ 35.479296] ESR = 0x96000004
> >>> [ 35.479785] Exception class = DABT (current EL), IL = 32 bits
> >>> [ 35.480528] SET = 0, FnV = 0
> >>> [ 35.480980] EA = 0, S1PTW = 0
> >>> [ 35.481345] Data abort info:
> >>> [ 35.481680] ISV = 0, ISS = 0x00000004
> >>> [ 35.482267] CM = 0, WnR = 0
> >>> [ 35.482618] user pgtable: 4k pages, 48-bit VAs, pgdp = (____ptrval____)
> >>> [ 35.483486] [0000000000000070] pgd=0000000000000000
> >>> [ 35.484041] Internal error: Oops: 96000004 [#1] PREEMPT SMP
> >>> [ 35.484788] Modules linked in:
> >>> [ 35.485311] CPU: 113 PID: 3973 Comm: io_uring_regist Not tainted 5.1.0-rc3-00012-g40b114779944 #1
> >>> [ 35.486712] Hardware name: linux,dummy-virt (DT)
> >>> [ 35.487450] pstate: 20400005 (nzCv daif +PAN -UAO)
> >>> [ 35.488228] pc : link_pwq+0x10/0x60
> >>> [ 35.488794] lr : apply_wqattrs_commit+0xe0/0x118
> >>> [ 35.489550] sp : ffff000017e2bbc0
> >>
> >> Huh, this looks odd, it's crashing inside the wq setup.
> >
> > Enabling KASAN seems to indicate a double-free, which may well be related.
>
> Does this help?
Yes, thanks for the quick patch. Feel free to add:
Reported-by: Will Deacon <will.deacon@arm.com>
Tested-by: Will Deacon <will.deacon@arm.com>
if you spin a proper patch.
Will
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index bbdbd56cf2ac..07d6ef195d05 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -2215,6 +2215,7 @@ static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg,
> fput(ctx->user_files[i]);
>
> kfree(ctx->user_files);
> + ctx->user_files = NULL;
> ctx->nr_user_files = 0;
> return ret;
> }
>
> --
> Jens Axboe
>
^ permalink raw reply
* Re: [PATCH 2/2] arch: add pidfd and io_uring syscalls everywhere
From: Jens Axboe @ 2019-04-03 15:39 UTC (permalink / raw)
To: Will Deacon
Cc: Rich Felker, linux-ia64, linux-sh, Heiko Carstens, linux-mips,
James E . J . Bottomley, Max Filippov, Paul Mackerras, sparclinux,
linux-s390, Helge Deller, Russell King, Geert Uytterhoeven,
Catalin Marinas, James Hogan, Firoz Khan, Matt Turner, Fenghua Yu,
Arnd Bergmann, linux-m68k, Ivan Kokshaysky, linux-arm-kernel,
Richard Henderson, Michal Simek, Tony Luck, linux-parisc,
linux-kernel, Ralf Baechle, Paul Burton, linux-alpha,
Martin Schwidefsky, Andrew Morton, linuxppc-dev, David S . Miller
In-Reply-To: <20190403151932.GA16866@fuggles.cambridge.arm.com>
On 4/3/19 9:19 AM, Will Deacon wrote:
> Hi Jens,
>
> On Wed, Apr 03, 2019 at 07:49:26AM -0600, Jens Axboe wrote:
>> On 4/3/19 5:11 AM, Will Deacon wrote:
>>> will@autoplooker:~/liburing/test$ ./io_uring_register
>>> RELIMIT_MEMLOCK: 67108864 (67108864)
>>> [ 35.477875] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000070
>>> [ 35.478969] Mem abort info:
>>> [ 35.479296] ESR = 0x96000004
>>> [ 35.479785] Exception class = DABT (current EL), IL = 32 bits
>>> [ 35.480528] SET = 0, FnV = 0
>>> [ 35.480980] EA = 0, S1PTW = 0
>>> [ 35.481345] Data abort info:
>>> [ 35.481680] ISV = 0, ISS = 0x00000004
>>> [ 35.482267] CM = 0, WnR = 0
>>> [ 35.482618] user pgtable: 4k pages, 48-bit VAs, pgdp = (____ptrval____)
>>> [ 35.483486] [0000000000000070] pgd=0000000000000000
>>> [ 35.484041] Internal error: Oops: 96000004 [#1] PREEMPT SMP
>>> [ 35.484788] Modules linked in:
>>> [ 35.485311] CPU: 113 PID: 3973 Comm: io_uring_regist Not tainted 5.1.0-rc3-00012-g40b114779944 #1
>>> [ 35.486712] Hardware name: linux,dummy-virt (DT)
>>> [ 35.487450] pstate: 20400005 (nzCv daif +PAN -UAO)
>>> [ 35.488228] pc : link_pwq+0x10/0x60
>>> [ 35.488794] lr : apply_wqattrs_commit+0xe0/0x118
>>> [ 35.489550] sp : ffff000017e2bbc0
>>
>> Huh, this looks odd, it's crashing inside the wq setup.
>
> Enabling KASAN seems to indicate a double-free, which may well be related.
Does this help?
diff --git a/fs/io_uring.c b/fs/io_uring.c
index bbdbd56cf2ac..07d6ef195d05 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2215,6 +2215,7 @@ static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg,
fput(ctx->user_files[i]);
kfree(ctx->user_files);
+ ctx->user_files = NULL;
ctx->nr_user_files = 0;
return ret;
}
--
Jens Axboe
^ permalink raw reply related
* Re: [5/7] cpufreq/pasemi: Checking implementation of pas_cpufreq_cpu_init()
From: Dan Carpenter @ 2019-04-03 15:31 UTC (permalink / raw)
To: Markus Elfring
Cc: Yi Wang, Rafael J. Wysocki, linux-pm, Viresh Kumar,
kernel-janitors, linux-kernel, linuxppc-dev, Wen Yang
In-Reply-To: <c0c9c429-a09f-41ba-611d-123b64e410c8@web.de>
On Wed, Apr 03, 2019 at 04:23:54PM +0200, Markus Elfring wrote:
> > @@ -146,6 +146,7 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)
> >
> > cpu = of_get_cpu_node(policy->cpu, NULL);
> >
> > + of_node_put(cpu);
> > if (!cpu)
> > goto out;
>
> Can the statement “return -ENODEV” be nicer as exception handling
> in the if branch of this source code place?
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cpufreq/pasemi-cpufreq.c?id=bf97b82f37c6d90e16de001d0659644c57fa490d#n137
>
Why am I only receiving only one side of this conversation?
I don't know why you're responding to... It's not required to fix/change
unrelated style choices. If people want, they can just focus on their
own thing.
regards,
dan carpenter
^ permalink raw reply
* Re: [PATCH 2/2] arch: add pidfd and io_uring syscalls everywhere
From: Will Deacon @ 2019-04-03 15:19 UTC (permalink / raw)
To: Jens Axboe
Cc: Rich Felker, linux-ia64, linux-sh, Heiko Carstens, linux-mips,
James E . J . Bottomley, Max Filippov, Paul Mackerras, sparclinux,
linux-s390, Helge Deller, Russell King, Geert Uytterhoeven,
Catalin Marinas, James Hogan, Firoz Khan, Matt Turner, Fenghua Yu,
Arnd Bergmann, linux-m68k, Ivan Kokshaysky, linux-arm-kernel,
Richard Henderson, Michal Simek, Tony Luck, linux-parisc,
linux-kernel, Ralf Baechle, Paul Burton, linux-alpha,
Martin Schwidefsky, Andrew Morton, linuxppc-dev, David S . Miller
In-Reply-To: <9d673dfd-0051-3676-653e-6376430d73dd@kernel.dk>
Hi Jens,
On Wed, Apr 03, 2019 at 07:49:26AM -0600, Jens Axboe wrote:
> On 4/3/19 5:11 AM, Will Deacon wrote:
> > will@autoplooker:~/liburing/test$ ./io_uring_register
> > RELIMIT_MEMLOCK: 67108864 (67108864)
> > [ 35.477875] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000070
> > [ 35.478969] Mem abort info:
> > [ 35.479296] ESR = 0x96000004
> > [ 35.479785] Exception class = DABT (current EL), IL = 32 bits
> > [ 35.480528] SET = 0, FnV = 0
> > [ 35.480980] EA = 0, S1PTW = 0
> > [ 35.481345] Data abort info:
> > [ 35.481680] ISV = 0, ISS = 0x00000004
> > [ 35.482267] CM = 0, WnR = 0
> > [ 35.482618] user pgtable: 4k pages, 48-bit VAs, pgdp = (____ptrval____)
> > [ 35.483486] [0000000000000070] pgd=0000000000000000
> > [ 35.484041] Internal error: Oops: 96000004 [#1] PREEMPT SMP
> > [ 35.484788] Modules linked in:
> > [ 35.485311] CPU: 113 PID: 3973 Comm: io_uring_regist Not tainted 5.1.0-rc3-00012-g40b114779944 #1
> > [ 35.486712] Hardware name: linux,dummy-virt (DT)
> > [ 35.487450] pstate: 20400005 (nzCv daif +PAN -UAO)
> > [ 35.488228] pc : link_pwq+0x10/0x60
> > [ 35.488794] lr : apply_wqattrs_commit+0xe0/0x118
> > [ 35.489550] sp : ffff000017e2bbc0
>
> Huh, this looks odd, it's crashing inside the wq setup.
Enabling KASAN seems to indicate a double-free, which may well be related.
Will
[ 149.890370] ==================================================================
[ 149.891266] BUG: KASAN: double-free or invalid-free in io_sqe_files_unregister+0xa8/0x140
[ 149.892218]
[ 149.892411] CPU: 113 PID: 3974 Comm: io_uring_regist Tainted: G B 5.1.0-rc3-00012-g40b114779944 #3
[ 149.893623] Hardware name: linux,dummy-virt (DT)
[ 149.894169] Call trace:
[ 149.894539] dump_backtrace+0x0/0x228
[ 149.895172] show_stack+0x14/0x20
[ 149.895747] dump_stack+0xe8/0x124
[ 149.896335] print_address_description+0x60/0x258
[ 149.897148] kasan_report_invalid_free+0x78/0xb8
[ 149.897936] __kasan_slab_free+0x1fc/0x228
[ 149.898641] kasan_slab_free+0x10/0x18
[ 149.899283] kfree+0x70/0x1f8
[ 149.899798] io_sqe_files_unregister+0xa8/0x140
[ 149.900574] io_ring_ctx_wait_and_kill+0x190/0x3c0
[ 149.901402] io_uring_release+0x2c/0x48
[ 149.902068] __fput+0x18c/0x510
[ 149.902612] ____fput+0xc/0x18
[ 149.903146] task_work_run+0xf0/0x148
[ 149.903778] do_notify_resume+0x554/0x748
[ 149.904467] work_pending+0x8/0x10
[ 149.905060]
[ 149.905331] Allocated by task 3974:
[ 149.905934] __kasan_kmalloc.isra.0.part.1+0x48/0xf8
[ 149.906786] __kasan_kmalloc.isra.0+0xb8/0xd8
[ 149.907531] kasan_kmalloc+0xc/0x18
[ 149.908134] __kmalloc+0x168/0x248
[ 149.908724] __arm64_sys_io_uring_register+0x2b8/0x15a8
[ 149.909622] el0_svc_common+0x100/0x258
[ 149.910281] el0_svc_handler+0x48/0xc0
[ 149.910928] el0_svc+0x8/0xc
[ 149.911425]
[ 149.911696] Freed by task 3974:
[ 149.912242] __kasan_slab_free+0x114/0x228
[ 149.912955] kasan_slab_free+0x10/0x18
[ 149.913602] kfree+0x70/0x1f8
[ 149.914118] __arm64_sys_io_uring_register+0xc2c/0x15a8
[ 149.915009] el0_svc_common+0x100/0x258
[ 149.915670] el0_svc_handler+0x48/0xc0
[ 149.916317] el0_svc+0x8/0xc
[ 149.916817]
[ 149.917101] The buggy address belongs to the object at ffff8004ce07ed00
[ 149.917101] which belongs to the cache kmalloc-128 of size 128
[ 149.919197] The buggy address is located 0 bytes inside of
[ 149.919197] 128-byte region [ffff8004ce07ed00, ffff8004ce07ed80)
[ 149.921142] The buggy address belongs to the page:
[ 149.921953] page:ffff7e0013381f00 count:1 mapcount:0 mapping:ffff800503417c00 index:0x0 compound_mapcount: 0
[ 149.923595] flags: 0x1ffff00000010200(slab|head)
[ 149.924388] raw: 1ffff00000010200 dead000000000100 dead000000000200 ffff800503417c00
[ 149.925706] raw: 0000000000000000 0000000080400040 00000001ffffffff 0000000000000000
[ 149.927011] page dumped because: kasan: bad access detected
[ 149.927956]
[ 149.928224] Memory state around the buggy address:
[ 149.929054] ffff8004ce07ec00: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
[ 149.930274] ffff8004ce07ec80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[ 149.931494] >ffff8004ce07ed00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[ 149.932712] ^
[ 149.933281] ffff8004ce07ed80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[ 149.934508] ffff8004ce07ee00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[ 149.935725] ==================================================================
^ permalink raw reply
* Re: [5/7] cpufreq/pasemi: Checking implementation of pas_cpufreq_cpu_init()
From: Markus Elfring @ 2019-04-03 14:23 UTC (permalink / raw)
To: Wen Yang, Rafael J. Wysocki, Viresh Kumar, kernel-janitors
Cc: Yi Wang, linuxppc-dev, linux-kernel, linux-pm
In-Reply-To: <1554082674-2049-6-git-send-email-wen.yang99@zte.com.cn>
> @@ -146,6 +146,7 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)
>
> cpu = of_get_cpu_node(policy->cpu, NULL);
>
> + of_node_put(cpu);
> if (!cpu)
> goto out;
Can the statement “return -ENODEV” be nicer as exception handling
in the if branch of this source code place?
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cpufreq/pasemi-cpufreq.c?id=bf97b82f37c6d90e16de001d0659644c57fa490d#n137
Regards,
Markus
^ permalink raw reply
* Re: [PATCH v4 4/4] ocxl: Remove some unused exported symbols
From: Frederic Barrat @ 2019-04-03 14:23 UTC (permalink / raw)
To: Alastair D'Silva, alastair
Cc: Greg Kroah-Hartman, linuxppc-dev, Arnd Bergmann, Andrew Donnellan,
linux-kernel
In-Reply-To: <20190325053456.14599-5-alastair@au1.ibm.com>
Le 25/03/2019 à 06:34, Alastair D'Silva a écrit :
> From: Alastair D'Silva <alastair@d-silva.org>
>
> Remove some unused exported symbols.
>
> Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
> ---
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
> drivers/misc/ocxl/config.c | 4 +---
> drivers/misc/ocxl/ocxl_internal.h | 23 +++++++++++++++++++++++
> include/misc/ocxl.h | 23 -----------------------
> 3 files changed, 24 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c
> index 4dc11897237d..5e65acb8e134 100644
> --- a/drivers/misc/ocxl/config.c
> +++ b/drivers/misc/ocxl/config.c
> @@ -2,8 +2,8 @@
> // Copyright 2017 IBM Corp.
> #include <linux/pci.h>
> #include <asm/pnv-ocxl.h>
> -#include <misc/ocxl.h>
> #include <misc/ocxl-config.h>
> +#include "ocxl_internal.h"
>
> #define EXTRACT_BIT(val, bit) (!!(val & BIT(bit)))
> #define EXTRACT_BITS(val, s, e) ((val & GENMASK(e, s)) >> s)
> @@ -299,7 +299,6 @@ int ocxl_config_check_afu_index(struct pci_dev *dev,
> }
> return 1;
> }
> -EXPORT_SYMBOL_GPL(ocxl_config_check_afu_index);
>
> static int read_afu_name(struct pci_dev *dev, struct ocxl_fn_config *fn,
> struct ocxl_afu_config *afu)
> @@ -535,7 +534,6 @@ int ocxl_config_get_pasid_info(struct pci_dev *dev, int *count)
> {
> return pnv_ocxl_get_pasid_count(dev, count);
> }
> -EXPORT_SYMBOL_GPL(ocxl_config_get_pasid_info);
>
> void ocxl_config_set_afu_pasid(struct pci_dev *dev, int pos, int pasid_base,
> u32 pasid_count_log)
> diff --git a/drivers/misc/ocxl/ocxl_internal.h b/drivers/misc/ocxl/ocxl_internal.h
> index 321b29e77f45..06fd98c989c8 100644
> --- a/drivers/misc/ocxl/ocxl_internal.h
> +++ b/drivers/misc/ocxl/ocxl_internal.h
> @@ -107,6 +107,29 @@ void ocxl_pasid_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
> int ocxl_actag_afu_alloc(struct ocxl_fn *fn, u32 size);
> void ocxl_actag_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
>
> +/*
> + * Get the max PASID value that can be used by the function
> + */
> +int ocxl_config_get_pasid_info(struct pci_dev *dev, int *count);
> +
> +/*
> + * Check if an AFU index is valid for the given function.
> + *
> + * AFU indexes can be sparse, so a driver should check all indexes up
> + * to the maximum found in the function description
> + */
> +int ocxl_config_check_afu_index(struct pci_dev *dev,
> + struct ocxl_fn_config *fn, int afu_idx);
> +
> +/**
> + * Update values within a Process Element
> + *
> + * link_handle: the link handle associated with the process element
> + * pasid: the PASID for the AFU context
> + * tid: the new thread id for the process element
> + */
> +int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid);
> +
> struct ocxl_context *ocxl_context_alloc(void);
> int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
> struct address_space *mapping);
> diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h
> index 4544573cc93c..9530d3be1b30 100644
> --- a/include/misc/ocxl.h
> +++ b/include/misc/ocxl.h
> @@ -56,15 +56,6 @@ struct ocxl_fn_config {
> int ocxl_config_read_function(struct pci_dev *dev,
> struct ocxl_fn_config *fn);
>
> -/*
> - * Check if an AFU index is valid for the given function.
> - *
> - * AFU indexes can be sparse, so a driver should check all indexes up
> - * to the maximum found in the function description
> - */
> -int ocxl_config_check_afu_index(struct pci_dev *dev,
> - struct ocxl_fn_config *fn, int afu_idx);
> -
> /*
> * Read the configuration space of a function for the AFU specified by
> * the index 'afu_idx'. Fills in a ocxl_afu_config structure
> @@ -74,11 +65,6 @@ int ocxl_config_read_afu(struct pci_dev *dev,
> struct ocxl_afu_config *afu,
> u8 afu_idx);
>
> -/*
> - * Get the max PASID value that can be used by the function
> - */
> -int ocxl_config_get_pasid_info(struct pci_dev *dev, int *count);
> -
> /*
> * Tell an AFU, by writing in the configuration space, the PASIDs that
> * it can use. Range starts at 'pasid_base' and its size is a multiple
> @@ -188,15 +174,6 @@ int ocxl_link_add_pe(void *link_handle, int pasid, u32 pidr, u32 tidr,
> void (*xsl_err_cb)(void *data, u64 addr, u64 dsisr),
> void *xsl_err_data);
>
> -/**
> - * Update values within a Process Element
> - *
> - * link_handle: the link handle associated with the process element
> - * pasid: the PASID for the AFU context
> - * tid: the new thread id for the process element
> - */
> -int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid);
> -
> /*
> * Remove a Process Element from the Shared Process Area for a link
> */
>
^ permalink raw reply
* Re: [PATCH 3/5] s390: Fix vDSO clock_getres()
From: Vincenzo Frascino @ 2019-04-03 14:21 UTC (permalink / raw)
To: Thomas Gleixner, Martin Schwidefsky
Cc: linux-arch, linux-s390, Shuah Khan, Arnd Bergmann, Heiko Carstens,
Catalin Marinas, Will Deacon, Paul Mackerras, Vincent Chen,
linuxppc-dev, linux-arm-kernel, Greentime Hu
In-Reply-To: <alpine.DEB.2.21.1904031205460.1967@nanos.tec.linutronix.de>
On 03/04/2019 11:06, Thomas Gleixner wrote:
> On Wed, 3 Apr 2019, Martin Schwidefsky wrote:
>
>> On Mon, 1 Apr 2019 12:51:50 +0100
>> Vincenzo Frascino <vincenzo.frascino@arm.com> wrote:
>>
>>> clock_getres in the vDSO library has to preserve the same behaviour
>>> of posix_get_hrtimer_res().
>>>
>>> In particular, posix_get_hrtimer_res() does:
>>> sec = 0;
>>> ns = hrtimer_resolution;
>>> and hrtimer_resolution depends on the enablement of the high
>>> resolution timers that can happen either at compile or at run time.
>>>
>>> Fix the s390 vdso implementation of clock_getres keeping a copy of
>>> hrtimer_resolution in vdso data and using that directly.
>>>
>>> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
>>> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
>>> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
>>> ---
>>> arch/s390/include/asm/vdso.h | 1 +
>>> arch/s390/kernel/asm-offsets.c | 2 +-
>>> arch/s390/kernel/time.c | 1 +
>>> arch/s390/kernel/vdso32/clock_getres.S | 17 ++++++++++++-----
>>> arch/s390/kernel/vdso64/clock_getres.S | 15 ++++++++++-----
>>> 5 files changed, 25 insertions(+), 11 deletions(-)
>>
>> I tried this patch and in principle this works. In that regard
>> Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
>>
>> But I wonder if the loop to check the update counter is really
>> necessary. The hrtimer_resolution value can only changes once with
>> the first call to hrtimer_switch_to_hres(). With the TOD clock
>> as the only clock available on s390 we always have the ability
>> to do hrtimer. It then all depends on the highres=[on|off] kernel
>> parameter what value we get with clock_getres().
>
> Yes, it's not changing after boot anymore.
>
> Thanks,
>
> tglx
>
Ok, I will remove the loop from both the implementations and post it with v2.
--
Regards,
Vincenzo
^ permalink raw reply
* Re: [PATCH v4 3/4] ocxl: Remove superfluous 'extern' from headers
From: Frederic Barrat @ 2019-04-03 14:20 UTC (permalink / raw)
To: Alastair D'Silva, alastair
Cc: Greg Kroah-Hartman, linuxppc-dev, Arnd Bergmann, Andrew Donnellan,
linux-kernel
In-Reply-To: <20190325053456.14599-4-alastair@au1.ibm.com>
Le 25/03/2019 à 06:34, Alastair D'Silva a écrit :
> From: Alastair D'Silva <alastair@d-silva.org>
>
> The 'extern' keyword adds no value here.
>
> Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
> ---
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
> drivers/misc/ocxl/ocxl_internal.h | 54 +++++++++++++++----------------
> include/misc/ocxl.h | 36 ++++++++++-----------
> 2 files changed, 44 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/misc/ocxl/ocxl_internal.h b/drivers/misc/ocxl/ocxl_internal.h
> index a32f2151029f..321b29e77f45 100644
> --- a/drivers/misc/ocxl/ocxl_internal.h
> +++ b/drivers/misc/ocxl/ocxl_internal.h
> @@ -16,7 +16,6 @@
>
> extern struct pci_driver ocxl_pci_driver;
>
> -
> struct ocxl_fn {
> struct device dev;
> int bar_used[3];
> @@ -92,41 +91,40 @@ struct ocxl_process_element {
> __be32 software_state;
> };
>
> +struct ocxl_afu *ocxl_afu_get(struct ocxl_afu *afu);
> +void ocxl_afu_put(struct ocxl_afu *afu);
>
> -extern struct ocxl_afu *ocxl_afu_get(struct ocxl_afu *afu);
> -extern void ocxl_afu_put(struct ocxl_afu *afu);
> -
> -extern int ocxl_create_cdev(struct ocxl_afu *afu);
> -extern void ocxl_destroy_cdev(struct ocxl_afu *afu);
> -extern int ocxl_register_afu(struct ocxl_afu *afu);
> -extern void ocxl_unregister_afu(struct ocxl_afu *afu);
> +int ocxl_create_cdev(struct ocxl_afu *afu);
> +void ocxl_destroy_cdev(struct ocxl_afu *afu);
> +int ocxl_register_afu(struct ocxl_afu *afu);
> +void ocxl_unregister_afu(struct ocxl_afu *afu);
>
> -extern int ocxl_file_init(void);
> -extern void ocxl_file_exit(void);
> +int ocxl_file_init(void);
> +void ocxl_file_exit(void);
>
> -extern int ocxl_pasid_afu_alloc(struct ocxl_fn *fn, u32 size);
> -extern void ocxl_pasid_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
> -extern int ocxl_actag_afu_alloc(struct ocxl_fn *fn, u32 size);
> -extern void ocxl_actag_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
> +int ocxl_pasid_afu_alloc(struct ocxl_fn *fn, u32 size);
> +void ocxl_pasid_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
> +int ocxl_actag_afu_alloc(struct ocxl_fn *fn, u32 size);
> +void ocxl_actag_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
>
> -extern struct ocxl_context *ocxl_context_alloc(void);
> -extern int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
> +struct ocxl_context *ocxl_context_alloc(void);
> +int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
> struct address_space *mapping);
> -extern int ocxl_context_attach(struct ocxl_context *ctx, u64 amr);
> -extern int ocxl_context_mmap(struct ocxl_context *ctx,
> +int ocxl_context_attach(struct ocxl_context *ctx, u64 amr);
> +int ocxl_context_mmap(struct ocxl_context *ctx,
> struct vm_area_struct *vma);
> -extern int ocxl_context_detach(struct ocxl_context *ctx);
> -extern void ocxl_context_detach_all(struct ocxl_afu *afu);
> -extern void ocxl_context_free(struct ocxl_context *ctx);
> +int ocxl_context_detach(struct ocxl_context *ctx);
> +void ocxl_context_detach_all(struct ocxl_afu *afu);
> +void ocxl_context_free(struct ocxl_context *ctx);
>
> -extern int ocxl_sysfs_add_afu(struct ocxl_afu *afu);
> -extern void ocxl_sysfs_remove_afu(struct ocxl_afu *afu);
> +int ocxl_sysfs_add_afu(struct ocxl_afu *afu);
> +void ocxl_sysfs_remove_afu(struct ocxl_afu *afu);
>
> -extern int ocxl_afu_irq_alloc(struct ocxl_context *ctx, u64 *irq_offset);
> -extern int ocxl_afu_irq_free(struct ocxl_context *ctx, u64 irq_offset);
> -extern void ocxl_afu_irq_free_all(struct ocxl_context *ctx);
> -extern int ocxl_afu_irq_set_fd(struct ocxl_context *ctx, u64 irq_offset,
> +int ocxl_afu_irq_alloc(struct ocxl_context *ctx, u64 *irq_offset);
> +int ocxl_afu_irq_free(struct ocxl_context *ctx, u64 irq_offset);
> +void ocxl_afu_irq_free_all(struct ocxl_context *ctx);
> +int ocxl_afu_irq_set_fd(struct ocxl_context *ctx, u64 irq_offset,
> int eventfd);
> -extern u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, u64 irq_offset);
> +u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, u64 irq_offset);
>
> #endif /* _OCXL_INTERNAL_H_ */
> diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h
> index 9ff6ddc28e22..4544573cc93c 100644
> --- a/include/misc/ocxl.h
> +++ b/include/misc/ocxl.h
> @@ -53,7 +53,7 @@ struct ocxl_fn_config {
> * Read the configuration space of a function and fill in a
> * ocxl_fn_config structure with all the function details
> */
> -extern int ocxl_config_read_function(struct pci_dev *dev,
> +int ocxl_config_read_function(struct pci_dev *dev,
> struct ocxl_fn_config *fn);
>
> /*
> @@ -62,14 +62,14 @@ extern int ocxl_config_read_function(struct pci_dev *dev,
> * AFU indexes can be sparse, so a driver should check all indexes up
> * to the maximum found in the function description
> */
> -extern int ocxl_config_check_afu_index(struct pci_dev *dev,
> +int ocxl_config_check_afu_index(struct pci_dev *dev,
> struct ocxl_fn_config *fn, int afu_idx);
>
> /*
> * Read the configuration space of a function for the AFU specified by
> * the index 'afu_idx'. Fills in a ocxl_afu_config structure
> */
> -extern int ocxl_config_read_afu(struct pci_dev *dev,
> +int ocxl_config_read_afu(struct pci_dev *dev,
> struct ocxl_fn_config *fn,
> struct ocxl_afu_config *afu,
> u8 afu_idx);
> @@ -77,7 +77,7 @@ extern int ocxl_config_read_afu(struct pci_dev *dev,
> /*
> * Get the max PASID value that can be used by the function
> */
> -extern int ocxl_config_get_pasid_info(struct pci_dev *dev, int *count);
> +int ocxl_config_get_pasid_info(struct pci_dev *dev, int *count);
>
> /*
> * Tell an AFU, by writing in the configuration space, the PASIDs that
> @@ -87,7 +87,7 @@ extern int ocxl_config_get_pasid_info(struct pci_dev *dev, int *count);
> * 'afu_control_offset' is the offset of the AFU control DVSEC which
> * can be found in the function configuration
> */
> -extern void ocxl_config_set_afu_pasid(struct pci_dev *dev,
> +void ocxl_config_set_afu_pasid(struct pci_dev *dev,
> int afu_control_offset,
> int pasid_base, u32 pasid_count_log);
>
> @@ -98,7 +98,7 @@ extern void ocxl_config_set_afu_pasid(struct pci_dev *dev,
> * 'supported' is the total number of actags desired by all the AFUs
> * of the function.
> */
> -extern int ocxl_config_get_actag_info(struct pci_dev *dev,
> +int ocxl_config_get_actag_info(struct pci_dev *dev,
> u16 *base, u16 *enabled, u16 *supported);
>
> /*
> @@ -108,7 +108,7 @@ extern int ocxl_config_get_actag_info(struct pci_dev *dev,
> * 'func_offset' is the offset of the Function DVSEC that can found in
> * the function configuration
> */
> -extern void ocxl_config_set_actag(struct pci_dev *dev, int func_offset,
> +void ocxl_config_set_actag(struct pci_dev *dev, int func_offset,
> u32 actag_base, u32 actag_count);
>
> /*
> @@ -118,7 +118,7 @@ extern void ocxl_config_set_actag(struct pci_dev *dev, int func_offset,
> * 'afu_control_offset' is the offset of the AFU control DVSEC for the
> * desired AFU. It can be found in the AFU configuration
> */
> -extern void ocxl_config_set_afu_actag(struct pci_dev *dev,
> +void ocxl_config_set_afu_actag(struct pci_dev *dev,
> int afu_control_offset,
> int actag_base, int actag_count);
>
> @@ -128,7 +128,7 @@ extern void ocxl_config_set_afu_actag(struct pci_dev *dev,
> * 'afu_control_offset' is the offset of the AFU control DVSEC for the
> * desired AFU. It can be found in the AFU configuration
> */
> -extern void ocxl_config_set_afu_state(struct pci_dev *dev,
> +void ocxl_config_set_afu_state(struct pci_dev *dev,
> int afu_control_offset, int enable);
>
> /*
> @@ -139,7 +139,7 @@ extern void ocxl_config_set_afu_state(struct pci_dev *dev,
> * between the host and device, and set the Transaction Layer on both
> * accordingly.
> */
> -extern int ocxl_config_set_TL(struct pci_dev *dev, int tl_dvsec);
> +int ocxl_config_set_TL(struct pci_dev *dev, int tl_dvsec);
>
> /*
> * Request an AFU to terminate a PASID.
> @@ -152,7 +152,7 @@ extern int ocxl_config_set_TL(struct pci_dev *dev, int tl_dvsec);
> * 'afu_control_offset' is the offset of the AFU control DVSEC for the
> * desired AFU. It can be found in the AFU configuration
> */
> -extern int ocxl_config_terminate_pasid(struct pci_dev *dev,
> +int ocxl_config_terminate_pasid(struct pci_dev *dev,
> int afu_control_offset, int pasid);
>
> /*
> @@ -165,13 +165,13 @@ extern int ocxl_config_terminate_pasid(struct pci_dev *dev,
> * Returns a 'link handle' that should be used for further calls for
> * the link
> */
> -extern int ocxl_link_setup(struct pci_dev *dev, int PE_mask,
> +int ocxl_link_setup(struct pci_dev *dev, int PE_mask,
> void **link_handle);
>
> /*
> * Remove the association between the function and its link.
> */
> -extern void ocxl_link_release(struct pci_dev *dev, void *link_handle);
> +void ocxl_link_release(struct pci_dev *dev, void *link_handle);
>
> /*
> * Add a Process Element to the Shared Process Area for a link.
> @@ -183,7 +183,7 @@ extern void ocxl_link_release(struct pci_dev *dev, void *link_handle);
> * 'xsl_err_data' is an argument passed to the above callback, if
> * defined
> */
> -extern int ocxl_link_add_pe(void *link_handle, int pasid, u32 pidr, u32 tidr,
> +int ocxl_link_add_pe(void *link_handle, int pasid, u32 pidr, u32 tidr,
> u64 amr, struct mm_struct *mm,
> void (*xsl_err_cb)(void *data, u64 addr, u64 dsisr),
> void *xsl_err_data);
> @@ -195,12 +195,12 @@ extern int ocxl_link_add_pe(void *link_handle, int pasid, u32 pidr, u32 tidr,
> * pasid: the PASID for the AFU context
> * tid: the new thread id for the process element
> */
> -extern int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid);
> +int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid);
>
> /*
> * Remove a Process Element from the Shared Process Area for a link
> */
> -extern int ocxl_link_remove_pe(void *link_handle, int pasid);
> +int ocxl_link_remove_pe(void *link_handle, int pasid);
>
> /*
> * Allocate an AFU interrupt associated to the link.
> @@ -212,12 +212,12 @@ extern int ocxl_link_remove_pe(void *link_handle, int pasid);
> * interrupt. It is an MMIO address which needs to be remapped (one
> * page).
> */
> -extern int ocxl_link_irq_alloc(void *link_handle, int *hw_irq,
> +int ocxl_link_irq_alloc(void *link_handle, int *hw_irq,
> u64 *obj_handle);
>
> /*
> * Free a previously allocated AFU interrupt
> */
> -extern void ocxl_link_free_irq(void *link_handle, int hw_irq);
> +void ocxl_link_free_irq(void *link_handle, int hw_irq);
>
> #endif /* _MISC_OCXL_H_ */
>
^ permalink raw reply
* Re: [PATCH v4 2/4] ocxl: read_pasid never returns an error, so make it void
From: Frederic Barrat @ 2019-04-03 14:20 UTC (permalink / raw)
To: Alastair D'Silva, alastair
Cc: Arnd Bergmann, Greg Kroah-Hartman, Greg Kurz, linux-kernel,
Andrew Donnellan, linuxppc-dev
In-Reply-To: <20190325053456.14599-3-alastair@au1.ibm.com>
Le 25/03/2019 à 06:34, Alastair D'Silva a écrit :
> From: Alastair D'Silva <alastair@d-silva.org>
>
> No need for a return value in read_pasid as it only returns 0.
>
> Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
> Reviewed-by: Greg Kurz <groug@kaod.org>
> ---
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
> drivers/misc/ocxl/config.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c
> index 8f2c5d8bd2ee..4dc11897237d 100644
> --- a/drivers/misc/ocxl/config.c
> +++ b/drivers/misc/ocxl/config.c
> @@ -68,7 +68,7 @@ static int find_dvsec_afu_ctrl(struct pci_dev *dev, u8 afu_idx)
> return 0;
> }
>
> -static int read_pasid(struct pci_dev *dev, struct ocxl_fn_config *fn)
> +static void read_pasid(struct pci_dev *dev, struct ocxl_fn_config *fn)
> {
> u16 val;
> int pos;
> @@ -89,7 +89,6 @@ static int read_pasid(struct pci_dev *dev, struct ocxl_fn_config *fn)
> out:
> dev_dbg(&dev->dev, "PASID capability:\n");
> dev_dbg(&dev->dev, " Max PASID log = %d\n", fn->max_pasid_log);
> - return 0;
> }
>
> static int read_dvsec_tl(struct pci_dev *dev, struct ocxl_fn_config *fn)
> @@ -205,11 +204,7 @@ int ocxl_config_read_function(struct pci_dev *dev, struct ocxl_fn_config *fn)
> {
> int rc;
>
> - rc = read_pasid(dev, fn);
> - if (rc) {
> - dev_err(&dev->dev, "Invalid PASID configuration: %d\n", rc);
> - return -ENODEV;
> - }
> + read_pasid(dev, fn);
>
> rc = read_dvsec_tl(dev, fn);
> if (rc) {
>
^ permalink raw reply
* Re: [PATCH v4 1/4] ocxl: Rename struct link to ocxl_link
From: Frederic Barrat @ 2019-04-03 14:18 UTC (permalink / raw)
To: Alastair D'Silva, alastair
Cc: Arnd Bergmann, Greg Kroah-Hartman, Greg Kurz, linux-kernel,
Andrew Donnellan, linuxppc-dev
In-Reply-To: <20190325053456.14599-2-alastair@au1.ibm.com>
Le 25/03/2019 à 06:34, Alastair D'Silva a écrit :
> From: Alastair D'Silva <alastair@d-silva.org>
>
> The term 'link' is ambiguous (especially when the struct is used for a
> list), so rename it for clarity.
>
> Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
> Reviewed-by: Greg Kurz <groug@kaod.org>
> ---
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
> drivers/misc/ocxl/file.c | 5 ++---
> drivers/misc/ocxl/link.c | 36 ++++++++++++++++++------------------
> 2 files changed, 20 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
> index e6a607488f8a..009e09b7ded5 100644
> --- a/drivers/misc/ocxl/file.c
> +++ b/drivers/misc/ocxl/file.c
> @@ -151,10 +151,9 @@ static long afu_ioctl_enable_p9_wait(struct ocxl_context *ctx,
> mutex_unlock(&ctx->status_mutex);
>
> if (status == ATTACHED) {
> - int rc;
> - struct link *link = ctx->afu->fn->link;
> + int rc = ocxl_link_update_pe(ctx->afu->fn->link,
> + ctx->pasid, ctx->tidr);
>
> - rc = ocxl_link_update_pe(link, ctx->pasid, ctx->tidr);
> if (rc)
> return rc;
> }
> diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
> index d50b861d7e57..8d2690a1a9de 100644
> --- a/drivers/misc/ocxl/link.c
> +++ b/drivers/misc/ocxl/link.c
> @@ -76,7 +76,7 @@ struct spa {
> * limited number of opencapi slots on a system and lookup is only
> * done when the device is probed
> */
> -struct link {
> +struct ocxl_link {
> struct list_head list;
> struct kref ref;
> int domain;
> @@ -179,7 +179,7 @@ static void xsl_fault_handler_bh(struct work_struct *fault_work)
>
> static irqreturn_t xsl_fault_handler(int irq, void *data)
> {
> - struct link *link = (struct link *) data;
> + struct ocxl_link *link = (struct ocxl_link *) data;
> struct spa *spa = link->spa;
> u64 dsisr, dar, pe_handle;
> struct pe_data *pe_data;
> @@ -256,7 +256,7 @@ static int map_irq_registers(struct pci_dev *dev, struct spa *spa)
> &spa->reg_tfc, &spa->reg_pe_handle);
> }
>
> -static int setup_xsl_irq(struct pci_dev *dev, struct link *link)
> +static int setup_xsl_irq(struct pci_dev *dev, struct ocxl_link *link)
> {
> struct spa *spa = link->spa;
> int rc;
> @@ -311,7 +311,7 @@ static int setup_xsl_irq(struct pci_dev *dev, struct link *link)
> return rc;
> }
>
> -static void release_xsl_irq(struct link *link)
> +static void release_xsl_irq(struct ocxl_link *link)
> {
> struct spa *spa = link->spa;
>
> @@ -323,7 +323,7 @@ static void release_xsl_irq(struct link *link)
> unmap_irq_registers(spa);
> }
>
> -static int alloc_spa(struct pci_dev *dev, struct link *link)
> +static int alloc_spa(struct pci_dev *dev, struct ocxl_link *link)
> {
> struct spa *spa;
>
> @@ -350,7 +350,7 @@ static int alloc_spa(struct pci_dev *dev, struct link *link)
> return 0;
> }
>
> -static void free_spa(struct link *link)
> +static void free_spa(struct ocxl_link *link)
> {
> struct spa *spa = link->spa;
>
> @@ -364,12 +364,12 @@ static void free_spa(struct link *link)
> }
> }
>
> -static int alloc_link(struct pci_dev *dev, int PE_mask, struct link **out_link)
> +static int alloc_link(struct pci_dev *dev, int PE_mask, struct ocxl_link **out_link)
> {
> - struct link *link;
> + struct ocxl_link *link;
> int rc;
>
> - link = kzalloc(sizeof(struct link), GFP_KERNEL);
> + link = kzalloc(sizeof(struct ocxl_link), GFP_KERNEL);
> if (!link)
> return -ENOMEM;
>
> @@ -405,7 +405,7 @@ static int alloc_link(struct pci_dev *dev, int PE_mask, struct link **out_link)
> return rc;
> }
>
> -static void free_link(struct link *link)
> +static void free_link(struct ocxl_link *link)
> {
> release_xsl_irq(link);
> free_spa(link);
> @@ -415,7 +415,7 @@ static void free_link(struct link *link)
> int ocxl_link_setup(struct pci_dev *dev, int PE_mask, void **link_handle)
> {
> int rc = 0;
> - struct link *link;
> + struct ocxl_link *link;
>
> mutex_lock(&links_list_lock);
> list_for_each_entry(link, &links_list, list) {
> @@ -442,7 +442,7 @@ EXPORT_SYMBOL_GPL(ocxl_link_setup);
>
> static void release_xsl(struct kref *ref)
> {
> - struct link *link = container_of(ref, struct link, ref);
> + struct ocxl_link *link = container_of(ref, struct ocxl_link, ref);
>
> list_del(&link->list);
> /* call platform code before releasing data */
> @@ -452,7 +452,7 @@ static void release_xsl(struct kref *ref)
>
> void ocxl_link_release(struct pci_dev *dev, void *link_handle)
> {
> - struct link *link = (struct link *) link_handle;
> + struct ocxl_link *link = (struct ocxl_link *) link_handle;
>
> mutex_lock(&links_list_lock);
> kref_put(&link->ref, release_xsl);
> @@ -488,7 +488,7 @@ int ocxl_link_add_pe(void *link_handle, int pasid, u32 pidr, u32 tidr,
> void (*xsl_err_cb)(void *data, u64 addr, u64 dsisr),
> void *xsl_err_data)
> {
> - struct link *link = (struct link *) link_handle;
> + struct ocxl_link *link = (struct ocxl_link *) link_handle;
> struct spa *spa = link->spa;
> struct ocxl_process_element *pe;
> int pe_handle, rc = 0;
> @@ -558,7 +558,7 @@ EXPORT_SYMBOL_GPL(ocxl_link_add_pe);
>
> int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid)
> {
> - struct link *link = (struct link *) link_handle;
> + struct ocxl_link *link = (struct ocxl_link *) link_handle;
> struct spa *spa = link->spa;
> struct ocxl_process_element *pe;
> int pe_handle, rc;
> @@ -594,7 +594,7 @@ int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid)
>
> int ocxl_link_remove_pe(void *link_handle, int pasid)
> {
> - struct link *link = (struct link *) link_handle;
> + struct ocxl_link *link = (struct ocxl_link *) link_handle;
> struct spa *spa = link->spa;
> struct ocxl_process_element *pe;
> struct pe_data *pe_data;
> @@ -666,7 +666,7 @@ EXPORT_SYMBOL_GPL(ocxl_link_remove_pe);
>
> int ocxl_link_irq_alloc(void *link_handle, int *hw_irq, u64 *trigger_addr)
> {
> - struct link *link = (struct link *) link_handle;
> + struct ocxl_link *link = (struct ocxl_link *) link_handle;
> int rc, irq;
> u64 addr;
>
> @@ -687,7 +687,7 @@ EXPORT_SYMBOL_GPL(ocxl_link_irq_alloc);
>
> void ocxl_link_free_irq(void *link_handle, int hw_irq)
> {
> - struct link *link = (struct link *) link_handle;
> + struct ocxl_link *link = (struct ocxl_link *) link_handle;
>
> pnv_ocxl_free_xive_irq(hw_irq);
> atomic_inc(&link->irq_available);
>
^ permalink raw reply
* [PATCH v8 05/20] KVM: PPC: Book3S HV: Remove pmd_is_leaf()
From: Steven Price @ 2019-04-03 14:16 UTC (permalink / raw)
To: linux-mm
Cc: Mark Rutland, Peter Zijlstra, Dave Hansen, Will Deacon,
H. Peter Anvin, 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: <20190403141627.11664-1-steven.price@arm.com>
Since pmd_large() is now always available, pmd_is_leaf() is redundant.
Replace all uses with calls to pmd_large().
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: Paul Mackerras <paulus@ozlabs.org>
CC: kvm-ppc@vger.kernel.org
CC: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Steven Price <steven.price@arm.com>
---
arch/powerpc/kvm/book3s_64_mmu_radix.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c
index f55ef071883f..1b57b4e3f819 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
@@ -363,12 +363,6 @@ static void kvmppc_pte_free(pte_t *ptep)
kmem_cache_free(kvm_pte_cache, ptep);
}
-/* Like pmd_huge() and pmd_large(), but works regardless of config options */
-static inline int pmd_is_leaf(pmd_t pmd)
-{
- return !!(pmd_val(pmd) & _PAGE_PTE);
-}
-
static pmd_t *kvmppc_pmd_alloc(void)
{
return kmem_cache_alloc(kvm_pmd_cache, GFP_KERNEL);
@@ -460,7 +454,7 @@ static void kvmppc_unmap_free_pmd(struct kvm *kvm, pmd_t *pmd, bool full,
for (im = 0; im < PTRS_PER_PMD; ++im, ++p) {
if (!pmd_present(*p))
continue;
- if (pmd_is_leaf(*p)) {
+ if (pmd_large(*p)) {
if (full) {
pmd_clear(p);
} else {
@@ -593,7 +587,7 @@ int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, pte_t pte,
else if (level <= 1)
new_pmd = kvmppc_pmd_alloc();
- if (level == 0 && !(pmd && pmd_present(*pmd) && !pmd_is_leaf(*pmd)))
+ if (level == 0 && !(pmd && pmd_present(*pmd) && !pmd_large(*pmd)))
new_ptep = kvmppc_pte_alloc();
/* Check if we might have been invalidated; let the guest retry if so */
@@ -662,7 +656,7 @@ int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, pte_t pte,
new_pmd = NULL;
}
pmd = pmd_offset(pud, gpa);
- if (pmd_is_leaf(*pmd)) {
+ if (pmd_large(*pmd)) {
unsigned long lgpa = gpa & PMD_MASK;
/* Check if we raced and someone else has set the same thing */
--
2.20.1
^ permalink raw reply related
* [PATCH v8 04/20] powerpc: mm: Add p?d_large() definitions
From: Steven Price @ 2019-04-03 14:16 UTC (permalink / raw)
To: linux-mm
Cc: Mark Rutland, Peter Zijlstra, Dave Hansen, Will Deacon,
Paul Mackerras, H. Peter Anvin, 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: <20190403141627.11664-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_large() functions/macros.
For powerpc pmd_large() was already implemented, so hoist it out of the
CONFIG_TRANSPARENT_HUGEPAGE condition and implement the other levels.
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 581f91be9dd4..f6d1ac8b832e 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -897,6 +897,12 @@ static inline int pud_present(pud_t pud)
return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PRESENT));
}
+#define pud_large 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)
@@ -940,6 +946,12 @@ static inline int pgd_present(pgd_t pgd)
return !!(pgd_raw(pgd) & cpu_to_be64(_PAGE_PRESENT));
}
+#define pgd_large 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));
@@ -1093,6 +1105,15 @@ static inline bool pmd_access_permitted(pmd_t pmd, bool write)
return pte_access_permitted(pmd_pte(pmd), write);
}
+#define pmd_large 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);
@@ -1119,15 +1140,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: [PATCH -next] ocxl: remove set but not used variables 'tid' and 'lpid'
From: Frederic Barrat @ 2019-04-03 13:58 UTC (permalink / raw)
To: Yue Haibing, andrew.donnellan, arnd, gregkh; +Cc: linuxppc-dev, linux-kernel
In-Reply-To: <20190329154456.27152-1-yuehaibing@huawei.com>
Le 29/03/2019 à 16:44, Yue Haibing a écrit :
> From: YueHaibing <yuehaibing@huawei.com>
>
> Fixes gcc '-Wunused-but-set-variable' warning:
>
> drivers/misc/ocxl/link.c: In function 'xsl_fault_handler':
> drivers/misc/ocxl/link.c:187:17: warning: variable 'tid' set but not used [-Wunused-but-set-variable]
> drivers/misc/ocxl/link.c:187:6: warning: variable 'lpid' set but not used [-Wunused-but-set-variable]
>
> They are never used and can be removed.
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
> drivers/misc/ocxl/link.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
> index d50b861..3be07e9 100644
> --- a/drivers/misc/ocxl/link.c
> +++ b/drivers/misc/ocxl/link.c
> @@ -184,7 +184,7 @@ static irqreturn_t xsl_fault_handler(int irq, void *data)
> u64 dsisr, dar, pe_handle;
> struct pe_data *pe_data;
> struct ocxl_process_element *pe;
> - int lpid, pid, tid;
> + int pid;
> bool schedule = false;
>
> read_irq(spa, &dsisr, &dar, &pe_handle);
> @@ -192,9 +192,7 @@ static irqreturn_t xsl_fault_handler(int irq, void *data)
>
> WARN_ON(pe_handle > SPA_PE_MASK);
> pe = spa->spa_mem + pe_handle;
> - lpid = be32_to_cpu(pe->lpid);
> pid = be32_to_cpu(pe->pid);
> - tid = be32_to_cpu(pe->tid);
> /* We could be reading all null values here if the PE is being
> * removed while an interrupt kicks in. It's not supposed to
> * happen if the driver notified the AFU to terminate the
>
^ permalink raw reply
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