16 Oct, 2020

1 commit

  • Literal blocks with :: markup should be indented, as otherwise
    Sphinx complains:

    Documentation/vm/hmm.rst:363: WARNING: Literal block expected; none found.

    Fixes: f7ebd9ed7767 ("mm/doc: add usage description for migrate_vma_*()")
    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     

17 Sep, 2020

1 commit

  • The migrate_vma_setup(), migrate_vma_pages(), and migrate_vma_finalize()
    API usage by device drivers is not well documented.
    Add a description for how device drivers are expected to use it.

    Signed-off-by: Ralph Campbell
    Reviewed-by: Alistair Popple
    Link: https://lore.kernel.org/r/20200909212956.20104-1-rcampbell@nvidia.com
    Signed-off-by: Jonathan Corbet

    Ralph Campbell
     

10 Sep, 2020

1 commit

  • Add Sphinx reference links to HMM and CPUSETS, and numerous small
    editorial changes to make the page_migration.rst document more readable.

    Signed-off-by: Ralph Campbell
    Reviewed-by: Randy Dunlap
    Link: https://lore.kernel.org/r/20200902225247.15213-1-rcampbell@nvidia.com
    Signed-off-by: Jonathan Corbet

    Ralph Campbell
     

10 Jun, 2020

1 commit

  • Convert comments that reference old mmap_sem APIs to reference
    corresponding new mmap locking APIs instead.

    Signed-off-by: Michel Lespinasse
    Signed-off-by: Andrew Morton
    Reviewed-by: Vlastimil Babka
    Reviewed-by: Davidlohr Bueso
    Reviewed-by: Daniel Jordan
    Cc: David Rientjes
    Cc: Hugh Dickins
    Cc: Jason Gunthorpe
    Cc: Jerome Glisse
    Cc: John Hubbard
    Cc: Laurent Dufour
    Cc: Liam Howlett
    Cc: Matthew Wilcox
    Cc: Peter Zijlstra
    Cc: Ying Han
    Link: http://lkml.kernel.org/r/20200520052908.204642-12-walken@google.com
    Signed-off-by: Linus Torvalds

    Michel Lespinasse
     

11 May, 2020

2 commits

  • Presumably the intent here was that hmm_range_fault() could put the data
    into some HW specific format and thus avoid some work. However, nothing
    actually does that, and it isn't clear how anything actually could do that
    as hmm_range_fault() provides CPU addresses which must be DMA mapped.

    Perhaps there is some special HW that does not need DMA mapping, but we
    don't have any examples of this, and the theoretical performance win of
    avoiding an extra scan over the pfns array doesn't seem worth the
    complexity. Plus pfns needs to be scanned anyhow to sort out any
    DEVICE_PRIVATE pages.

    This version replaces the uint64_t with an usigned long containing a pfn
    and fixed flags. On input flags is filled with the HMM_PFN_REQ_* values,
    on successful output it is filled with HMM_PFN_* values, describing the
    state of the pages.

    amdgpu is simple to convert, it doesn't use snapshot and doesn't use
    per-page flags.

    nouveau uses only 16 hmm_pte entries at most (ie fits in a few cache
    lines), and it sweeps over its pfns array a couple of times anyhow. It
    also has a nasty call chain before it reaches the dma map and hardware
    suggesting performance isn't important:

    nouveau_svm_fault():
    args.i.m.method = NVIF_VMM_V0_PFNMAP
    nouveau_range_fault()
    nvif_object_ioctl()
    client->driver->ioctl()
    struct nvif_driver nvif_driver_nvkm:
    .ioctl = nvkm_client_ioctl
    nvkm_ioctl()
    nvkm_ioctl_path()
    nvkm_ioctl_v0[type].func(..)
    nvkm_ioctl_mthd()
    nvkm_object_mthd()
    struct nvkm_object_func nvkm_uvmm:
    .mthd = nvkm_uvmm_mthd
    nvkm_uvmm_mthd()
    nvkm_uvmm_mthd_pfnmap()
    nvkm_vmm_pfn_map()
    nvkm_vmm_ptes_get_map()
    func == gp100_vmm_pgt_pfn
    struct nvkm_vmm_desc_func gp100_vmm_desc_spt:
    .pfn = gp100_vmm_pgt_pfn
    nvkm_vmm_iter()
    REF_PTES == func == gp100_vmm_pgt_pfn()
    dma_map_page()

    Link: https://lore.kernel.org/r/5-v2-b4e84f444c7d+24f57-hmm_no_flags_jgg@mellanox.com
    Acked-by: Felix Kuehling
    Tested-by: Ralph Campbell
    Signed-off-by: Christoph Hellwig
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe

    Jason Gunthorpe
     
  • hmm_vma_walk->last is supposed to be updated after every write to the
    pfns, so that it can be returned by hmm_range_fault(). However, this is
    not done consistently. Fortunately nothing checks the return code of
    hmm_range_fault() for anything other than error.

    More importantly last must be set before returning -EBUSY as it is used to
    prevent reading an output pfn as an input flags when the loop restarts.

    For clarity and simplicity make hmm_range_fault() return 0 or -ERRNO. Only
    set last when returning -EBUSY.

    Link: https://lore.kernel.org/r/2-v2-b4e84f444c7d+24f57-hmm_no_flags_jgg@mellanox.com
    Acked-by: Felix Kuehling
    Tested-by: Ralph Campbell
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe

    Jason Gunthorpe
     

28 Mar, 2020

1 commit

  • Now that flags are handled on a fine-grained per-page basis this global
    flag is redundant and has a confusing overlap with the pfn_flags_mask and
    default_flags.

    Normalize the HMM_FAULT_SNAPSHOT behavior into one place. Callers needing
    the SNAPSHOT behavior should set a pfn_flags_mask and default_flags that
    always results in a cleared HMM_PFN_VALID. Then no pages will be faulted,
    and HMM_FAULT_SNAPSHOT is not a special flow that overrides the masking
    mechanism.

    As this is the last flag, also remove the flags argument. If future flags
    are needed they can be part of the struct hmm_range function arguments.

    Link: https://lore.kernel.org/r/20200327200021.29372-5-jgg@ziepe.ca
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe

    Jason Gunthorpe
     

14 Jan, 2020

1 commit


24 Nov, 2019

1 commit

  • The only two users of this are now converted to use mmu_interval_notifier,
    delete all the code and update hmm.rst.

    Link: https://lore.kernel.org/r/20191112202231.3856-14-jgg@ziepe.ca
    Reviewed-by: Jérôme Glisse
    Tested-by: Ralph Campbell
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jason Gunthorpe

    Jason Gunthorpe
     

20 Aug, 2019

1 commit

  • There isn't any good reason to pass callbacks to migrate_vma. Instead
    we can just export the three steps done by this function to drivers and
    let them sequence the operation without callbacks. This removes a lot
    of boilerplate code as-is, and will allow the drivers to drastically
    improve code flow and error handling further on.

    Link: https://lore.kernel.org/r/20190814075928.23766-2-hch@lst.de
    Signed-off-by: Christoph Hellwig
    Reviewed-by: Ralph Campbell
    Tested-by: Ralph Campbell
    Signed-off-by: Jason Gunthorpe

    Christoph Hellwig
     

08 Aug, 2019

1 commit


26 Jul, 2019

2 commits

  • Add a HMM_FAULT_SNAPSHOT flag so that hmm_range_snapshot can be merged
    into the almost identical hmm_range_fault function.

    Link: https://lore.kernel.org/r/20190726005650.2566-5-rcampbell@nvidia.com
    Signed-off-by: Christoph Hellwig
    Signed-off-by: Ralph Campbell
    Reviewed-by: Jason Gunthorpe
    Signed-off-by: Jason Gunthorpe

    Christoph Hellwig
     
  • We should not have two different error codes for the same
    condition. EAGAIN must be reserved for the FAULT_FLAG_ALLOW_RETRY retry
    case and signals to the caller that the mmap_sem has been unlocked.

    Use EBUSY for the !valid case so that callers can get the locking right.

    Link: https://lore.kernel.org/r/20190724065258.16603-2-hch@lst.de
    Tested-by: Ralph Campbell
    Signed-off-by: Christoph Hellwig
    Reviewed-by: Ralph Campbell
    Reviewed-by: Jason Gunthorpe
    Reviewed-by: Felix Kuehling
    [jgg: elaborated commit message]
    Signed-off-by: Jason Gunthorpe

    Christoph Hellwig
     

03 Jul, 2019

2 commits

  • Christoph Hellwig says:

    ====================
    Below is a series that cleans up the dev_pagemap interface so that it is
    more easily usable, which removes the need to wrap it in hmm and thus
    allowing to kill a lot of code

    Changes since v3:
    - pull in "mm/swap: Fix release_pages() when releasing devmap pages" and
    rebase the other patches on top of that
    - fold the hmm_devmem_add_resource into the DEVICE_PUBLIC memory removal
    patch
    - remove _vm_normal_page as it isn't needed without DEVICE_PUBLIC memory
    - pick up various ACKs

    Changes since v2:
    - fix nvdimm kunit build
    - add a new memory type for device dax
    - fix a few issues in intermediate patches that didn't show up in the end
    result
    - incorporate feedback from Michal Hocko, including killing of
    the DEVICE_PUBLIC memory type entirely

    Changes since v1:
    - rebase
    - also switch p2pdma to the internal refcount
    - add type checking for pgmap->type
    - rename the migrate method to migrate_to_ram
    - cleanup the altmap_valid flag
    - various tidbits from the reviews
    ====================

    Conflicts resolved by:
    - Keeping Ira's version of the code in swap.c
    - Using the delete for the section in hmm.rst
    - Using the delete for the devmap code in hmm.c and .h

    * branch 'hmm-devmem-cleanup.4': (24 commits)
    mm: don't select MIGRATE_VMA_HELPER from HMM_MIRROR
    mm: remove the HMM config option
    mm: sort out the DEVICE_PRIVATE Kconfig mess
    mm: simplify ZONE_DEVICE page private data
    mm: remove hmm_devmem_add
    mm: remove hmm_vma_alloc_locked_page
    nouveau: use devm_memremap_pages directly
    nouveau: use alloc_page_vma directly
    PCI/P2PDMA: use the dev_pagemap internal refcount
    device-dax: use the dev_pagemap internal refcount
    memremap: provide an optional internal refcount in struct dev_pagemap
    memremap: replace the altmap_valid field with a PGMAP_ALTMAP_VALID flag
    memremap: remove the data field in struct dev_pagemap
    memremap: add a migrate_to_ram method to struct dev_pagemap_ops
    memremap: lift the devmap_enable manipulation into devm_memremap_pages
    memremap: pass a struct dev_pagemap to ->kill and ->cleanup
    memremap: move dev_pagemap callbacks into a separate structure
    memremap: validate the pagemap type passed to devm_memremap_pages
    mm: factor out a devm_request_free_mem_region helper
    mm: export alloc_pages_vma
    ...

    Signed-off-by: Jason Gunthorpe

    Jason Gunthorpe
     
  • There isn't really much value add in the hmm_devmem_add wrapper and
    more, as using devm_memremap_pages directly now is just as simple.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Jason Gunthorpe
    Reviewed-by: Dan Williams
    Signed-off-by: Jason Gunthorpe

    Christoph Hellwig
     

07 Jun, 2019

1 commit

  • Update the HMM documentation to reflect the latest API and make a few
    minor wording changes.

    Cc: John Hubbard
    Cc: Ira Weiny
    Cc: Dan Williams
    Cc: Arnd Bergmann
    Cc: Balbir Singh
    Cc: Dan Carpenter
    Cc: Matthew Wilcox
    Cc: Souptick Joarder
    Cc: Andrew Morton
    Signed-off-by: Ralph Campbell
    Reviewed-by: Jérôme Glisse
    Signed-off-by: Jason Gunthorpe

    Ralph Campbell
     

02 Jun, 2019

1 commit

  • Fix Sphinx warnings in Documentation/vm/hmm.rst by using "::" notation and
    inserting a blank line. Also add a missing ';'.

    Documentation/vm/hmm.rst:292: WARNING: Unexpected indentation.
    Documentation/vm/hmm.rst:300: WARNING: Unexpected indentation.

    Link: http://lkml.kernel.org/r/c5995359-7c82-4e47-c7be-b58a4dda0953@infradead.org
    Fixes: 023a019a9b4e ("mm/hmm: add default fault flags to avoid the need to pre-fill pfns arrays")
    Signed-off-by: Randy Dunlap
    Reviewed-by: Jérôme Glisse
    Reviewed-by: Mike Rapoport
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     

15 May, 2019

4 commits

  • The HMM mirror API can be use in two fashions. The first one where the
    HMM user coalesce multiple page faults into one request and set flags per
    pfns for of those faults. The second one where the HMM user want to
    pre-fault a range with specific flags. For the latter one it is a waste
    to have the user pre-fill the pfn arrays with a default flags value.

    This patch adds a default flags value allowing user to set them for a
    range without having to pre-fill the pfn array.

    Link: http://lkml.kernel.org/r/20190403193318.16478-8-jglisse@redhat.com
    Signed-off-by: Jérôme Glisse
    Reviewed-by: Ralph Campbell
    Cc: John Hubbard
    Cc: Dan Williams
    Cc: Arnd Bergmann
    Cc: Balbir Singh
    Cc: Dan Carpenter
    Cc: Ira Weiny
    Cc: Matthew Wilcox
    Cc: Souptick Joarder
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jérôme Glisse
     
  • A common use case for HMM mirror is user trying to mirror a range and
    before they could program the hardware it get invalidated by some core mm
    event. Instead of having user re-try right away to mirror the range
    provide a completion mechanism for them to wait for any active
    invalidation affecting the range.

    This also changes how hmm_range_snapshot() and hmm_range_fault() works by
    not relying on vma so that we can drop the mmap_sem when waiting and
    lookup the vma again on retry.

    Link: http://lkml.kernel.org/r/20190403193318.16478-7-jglisse@redhat.com
    Signed-off-by: Jérôme Glisse
    Reviewed-by: Ralph Campbell
    Cc: John Hubbard
    Cc: Dan Williams
    Cc: Dan Carpenter
    Cc: Matthew Wilcox
    Cc: Arnd Bergmann
    Cc: Balbir Singh
    Cc: Ira Weiny
    Cc: Souptick Joarder
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jérôme Glisse
     
  • Minor optimization around hmm_pte_need_fault(). Rename for consistency
    between code, comments and documentation. Also improves the comments on
    all the possible returns values. Improve the function by returning the
    number of populated entries in pfns array.

    Link: http://lkml.kernel.org/r/20190403193318.16478-6-jglisse@redhat.com
    Signed-off-by: Jérôme Glisse
    Reviewed-by: Ralph Campbell
    Cc: John Hubbard
    Cc: Dan Williams
    Cc: Arnd Bergmann
    Cc: Balbir Singh
    Cc: Dan Carpenter
    Cc: Ira Weiny
    Cc: Matthew Wilcox
    Cc: Souptick Joarder
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jérôme Glisse
     
  • Rename for consistency between code, comments and documentation. Also
    improves the comments on all the possible returns values. Improve the
    function by returning the number of populated entries in pfns array.

    Link: http://lkml.kernel.org/r/20190403193318.16478-5-jglisse@redhat.com
    Signed-off-by: Jérôme Glisse
    Reviewed-by: Ralph Campbell
    Reviewed-by: John Hubbard
    Reviewed-by: Ira Weiny
    Cc: Dan Williams
    Cc: Arnd Bergmann
    Cc: Balbir Singh
    Cc: Dan Carpenter
    Cc: Matthew Wilcox
    Cc: Souptick Joarder
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jérôme Glisse
     

01 Sep, 2018

1 commit


17 Apr, 2018

2 commits

  • Mike Rapoport says:

    These patches convert files in Documentation/vm to ReST format, add an
    initial index and link it to the top level documentation.

    There are no contents changes in the documentation, except few spelling
    fixes. The relatively large diffstat stems from the indentation and
    paragraph wrapping changes.

    I've tried to keep the formatting as consistent as possible, but I could
    miss some places that needed markup and add some markup where it was not
    necessary.

    [jc: significant conflicts in vm/hmm.rst]

    Jonathan Corbet
     
  • Signed-off-by: Mike Rapoport
    Signed-off-by: Jonathan Corbet

    Mike Rapoport