1. 06 Jan, 2022 16 commits
    • Vlastimil Babka's avatar
      mm/slub: Convert most struct page to struct slab by spatch · bb192ed9
      Vlastimil Babka authored
      The majority of conversion from struct page to struct slab in SLUB
      internals can be delegated to a coccinelle semantic patch. This includes
      renaming of variables with 'page' in name to 'slab', and similar.
      
      Big thanks to Julia Lawall and Luis Chamberlain for help with
      coccinelle.
      
      // Options: --include-headers --no-includes --smpl-spacing include/linux/slub_def.h mm/slub.c
      // Note: needs coccinelle 1.1.1 to avoid breaking whitespace, and ocaml for the
      // embedded script
      
      // build list of functions to exclude from applying the next rule
      @initialize:ocaml@
      @@
      
      let ok_function p =
        not (List.mem (List.hd p).current_element ["nearest_obj";"obj_to_index";"objs_per_slab_page";"__slab_lock";"__slab_unlock";"free_nonslab_page";"kmalloc_large_node"])
      
      // convert the type from struct page to struct page in all functions except the
      // list from previous rule
      // this also affects struct kmem_cache_cpu, but that's ok
      @@
      position p : script:ocaml() { ok_function p };
      @@
      
      - struct page@p
      + struct slab
      
      // in struct kmem_cache_cpu, change the name from page to slab
      // the type was already converted by the previous rule
      @@
      @@
      
      struct kmem_cache_cpu {
      ...
      -struct slab *page;
      +struct slab *slab;
      ...
      }
      
      // there are many places that use c->page which is now c->slab after the
      // previous rule
      @@
      struct kmem_cache_cpu *c;
      @@
      
      -c->page
      +c->slab
      
      @@
      @@
      
      struct kmem_cache {
      ...
      - unsigned int cpu_partial_pages;
      + unsigned int cpu_partial_slabs;
      ...
      }
      
      @@
      struct kmem_cache *s;
      @@
      
      - s->cpu_partial_pages
      + s->cpu_partial_slabs
      
      @@
      @@
      
      static void
      - setup_page_debug(
      + setup_slab_debug(
       ...)
       {...}
      
      @@
      @@
      
      - setup_page_debug(
      + setup_slab_debug(
       ...);
      
      // for all functions (with exceptions), change any "struct slab *page"
      // parameter to "struct slab *slab" in the signature, and generally all
      // occurences of "page" to "slab" in the body - with some special cases.
      
      @@
      identifier fn !~ "free_nonslab_page|obj_to_index|objs_per_slab_page|nearest_obj";
      @@
       fn(...,
      -   struct slab *page
      +   struct slab *slab
          ,...)
       {
      <...
      - page
      + slab
      ...>
       }
      
      // similar to previous but the param is called partial_page
      @@
      identifier fn;
      @@
      
       fn(...,
      -   struct slab *partial_page
      +   struct slab *partial_slab
          ,...)
       {
      <...
      - partial_page
      + partial_slab
      ...>
       }
      
      // similar to previous but for functions that take pointer to struct page ptr
      @@
      identifier fn;
      @@
      
       fn(...,
      -   struct slab **ret_page
      +   struct slab **ret_slab
          ,...)
       {
      <...
      - ret_page
      + ret_slab
      ...>
       }
      
      // functions converted by previous rules that were temporarily called using
      // slab_page(E) so we want to remove the wrapper now that they accept struct
      // slab ptr directly
      @@
      identifier fn =~ "slab_free|do_slab_free";
      expression E;
      @@
      
       fn(...,
      - slab_page(E)
      + E
        ,...)
      
      // similar to previous but for another pattern
      @@
      identifier fn =~ "slab_pad_check|check_object";
      @@
      
       fn(...,
      - folio_page(folio, 0)
      + slab
        ,...)
      
      // functions that were returning struct page ptr and now will return struct
      // slab ptr, including slab_page() wrapper removal
      @@
      identifier fn =~ "allocate_slab|new_slab";
      expression E;
      @@
      
       static
      -struct slab *
      +struct slab *
       fn(...)
       {
      <...
      - slab_page(E)
      + E
      ...>
       }
      
      // rename any former struct page * declarations
      @@
      @@
      
      struct slab *
      (
      - page
      + slab
      |
      - partial_page
      + partial_slab
      |
      - oldpage
      + oldslab
      )
      ;
      
      // this has to be separate from previous rule as page and page2 appear at the
      // same line
      @@
      @@
      
      struct slab *
      -page2
      +slab2
      ;
      
      // similar but with initial assignment
      @@
      expression E;
      @@
      
      struct slab *
      (
      - page
      + slab
      |
      - flush_page
      + flush_slab
      |
      - discard_page
      + slab_to_discard
      |
      - page_to_unfreeze
      + slab_to_unfreeze
      )
      = E;
      
      // convert most of struct page to struct slab usage inside functions (with
      // exceptions), including specific variable renames
      @@
      identifier fn !~ "nearest_obj|obj_to_index|objs_per_slab_page|__slab_(un)*lock|__free_slab|free_nonslab_page|kmalloc_large_node";
      expression E;
      @@
      
       fn(...)
       {
      <...
      (
      - int pages;
      + int slabs;
      |
      - int pages = E;
      + int slabs = E;
      |
      - page
      + slab
      |
      - flush_page
      + flush_slab
      |
      - partial_page
      + partial_slab
      |
      - oldpage->pages
      + oldslab->slabs
      |
      - oldpage
      + oldslab
      |
      - unsigned int nr_pages;
      + unsigned int nr_slabs;
      |
      - nr_pages
      + nr_slabs
      |
      - unsigned int partial_pages = E;
      + unsigned int partial_slabs = E;
      |
      - partial_pages
      + partial_slabs
      )
      ...>
       }
      
      // this has to be split out from the previous rule so that lines containing
      // multiple matching changes will be fully converted
      @@
      identifier fn !~ "nearest_obj|obj_to_index|objs_per_slab_page|__slab_(un)*lock|__free_slab|free_nonslab_page|kmalloc_large_node";
      @@
      
       fn(...)
       {
      <...
      (
      - slab->pages
      + slab->slabs
      |
      - pages
      + slabs
      |
      - page2
      + slab2
      |
      - discard_page
      + slab_to_discard
      |
      - page_to_unfreeze
      + slab_to_unfreeze
      )
      ...>
       }
      
      // after we simply changed all occurences of page to slab, some usages need
      // adjustment for slab-specific functions, or use slab_page() wrapper
      @@
      identifier fn !~ "nearest_obj|obj_to_index|objs_per_slab_page|__slab_(un)*lock|__free_slab|free_nonslab_page|kmalloc_large_node";
      @@
      
       fn(...)
       {
      <...
      (
      - page_slab(slab)
      + slab
      |
      - kasan_poison_slab(slab)
      + kasan_poison_slab(slab_page(slab))
      |
      - page_address(slab)
      + slab_address(slab)
      |
      - page_size(slab)
      + slab_size(slab)
      |
      - PageSlab(slab)
      + folio_test_slab(slab_folio(slab))
      |
      - page_to_nid(slab)
      + slab_nid(slab)
      |
      - compound_order(slab)
      + slab_order(slab)
      )
      ...>
       }
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      Reviewed-by: default avatarHyeonggon Yoo <42.hyeyoo@gmail.com>
      Tested-by: default avatarHyeonggon Yoo <42.hyeyoo@gmail.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Luis Chamberlain <mcgrof@kernel.org>
      bb192ed9
    • Matthew Wilcox (Oracle)'s avatar
      mm/slub: Convert pfmemalloc_match() to take a struct slab · 01b34d16
      Matthew Wilcox (Oracle) authored
      Preparatory for mass conversion. Use the new slab_test_pfmemalloc()
      helper.  As it doesn't do VM_BUG_ON(!PageSlab()) we no longer need the
      pfmemalloc_match_unsafe() variant.
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      Reviewed-by: default avatarHyeonggon Yoo <42.hyeyoo@gmail.com>
      01b34d16
    • Vlastimil Babka's avatar
      mm/slub: Convert __free_slab() to use struct slab · 4020b4a2
      Vlastimil Babka authored
      __free_slab() is on the boundary of distinguishing struct slab and
      struct page so start with struct slab but convert to folio for working
      with flags and folio_page() to call functions that require struct page.
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      Reviewed-by: default avatarHyeonggon Yoo <42.hyeyoo@gmail.com>
      Tested-by: default avatarHyeonggon Yoo <42.hyeyoo@gmail.com>
      4020b4a2
    • Vlastimil Babka's avatar
      mm/slub: Convert alloc_slab_page() to return a struct slab · 45387b8c
      Vlastimil Babka authored
      Preparatory, callers convert back to struct page for now.
      
      Also move setting page flags to alloc_slab_page() where we still operate
      on a struct page. This means the page->slab_cache pointer is now set
      later than the PageSlab flag, which could theoretically confuse some pfn
      walker assuming PageSlab means there would be a valid cache pointer. But
      as the code had no barriers and used __set_bit() anyway, it could have
      happened already, so there shouldn't be such a walker.
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      Reviewed-by: default avatarHyeonggon Yoo <42.hyeyoo@gmail.com>
      Tested-by: default avatarHyeonggon Yoo <42.hyeyoo@gmail.com>
      45387b8c
    • Matthew Wilcox (Oracle)'s avatar
      mm/slub: Convert print_page_info() to print_slab_info() · fb012e27
      Matthew Wilcox (Oracle) authored
      Improve the type safety and prepare for further conversion. For flags
      access, convert to folio internally.
      
      [ vbabka@suse.cz: access flags via folio_flags() ]
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      Reviewed-by: default avatarHyeonggon Yoo <42.hyeyoo@gmail.com>
      fb012e27
    • Vlastimil Babka's avatar
      mm/slub: Convert __slab_lock() and __slab_unlock() to struct slab · 0393895b
      Vlastimil Babka authored
      These functions operate on the PG_locked page flag, but make them accept
      struct slab to encapsulate this implementation detail.
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      0393895b
    • Matthew Wilcox (Oracle)'s avatar
      mm/slub: Convert kfree() to use a struct slab · d835eef4
      Matthew Wilcox (Oracle) authored
      Convert kfree(), kmem_cache_free() and ___cache_free() to resolve object
      addresses to struct slab, using folio as intermediate step where needed.
      Keep passing the result as struct page for now in preparation for mass
      conversion of internal functions.
      
      [ vbabka@suse.cz: Use folio as intermediate step when checking for
        large kmalloc pages, and when freeing them - rename
        free_nonslab_page() to free_large_kmalloc() that takes struct folio ]
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      d835eef4
    • Matthew Wilcox (Oracle)'s avatar
      mm/slub: Convert detached_freelist to use a struct slab · cc465c3b
      Matthew Wilcox (Oracle) authored
      This gives us a little bit of extra typesafety as we know that nobody
      called virt_to_page() instead of virt_to_head_page().
      
      [ vbabka@suse.cz: Use folio as intermediate step when filtering out
        large kmalloc pages ]
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      cc465c3b
    • Matthew Wilcox (Oracle)'s avatar
      mm: Convert check_heap_object() to use struct slab · 0b3eb091
      Matthew Wilcox (Oracle) authored
      Ensure that we're not seeing a tail page inside __check_heap_object() by
      converting to a slab instead of a page.  Take the opportunity to mark
      the slab as const since we're not modifying it.  Also move the
      declaration of __check_heap_object() to mm/slab.h so it's not available
      to the wider kernel.
      
      [ vbabka@suse.cz: in check_heap_object() only convert to struct slab for
        actual PageSlab pages; use folio as intermediate step instead of page ]
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      0b3eb091
    • Matthew Wilcox (Oracle)'s avatar
      mm: Use struct slab in kmem_obj_info() · 7213230a
      Matthew Wilcox (Oracle) authored
      All three implementations of slab support kmem_obj_info() which reports
      details of an object allocated from the slab allocator.  By using the
      slab type instead of the page type, we make it obvious that this can
      only be called for slabs.
      
      [ vbabka@suse.cz: also convert the related kmem_valid_obj() to folios ]
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      7213230a
    • Matthew Wilcox (Oracle)'s avatar
      mm: Convert __ksize() to struct slab · 0c24811b
      Matthew Wilcox (Oracle) authored
      In SLUB, use folios, and struct slab to access slab_cache field.
      In SLOB, use folios to properly resolve pointers beyond
      PAGE_SIZE offset of the object.
      
      [ vbabka@suse.cz: use folios, and only convert folio_test_slab() == true
        folios to struct slab ]
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      0c24811b
    • Matthew Wilcox (Oracle)'s avatar
      mm: Convert virt_to_cache() to use struct slab · 82c1775d
      Matthew Wilcox (Oracle) authored
      This function is entirely self-contained, so can be converted from page
      to slab.
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      Reviewed-by: default avatarHyeonggon Yoo <42.hyeyoo@gmail.com>
      82c1775d
    • Matthew Wilcox (Oracle)'s avatar
      mm: Convert [un]account_slab_page() to struct slab · b918653b
      Matthew Wilcox (Oracle) authored
      Convert the parameter of these functions to struct slab instead of
      struct page and drop _page from the names. For now their callers just
      convert page to slab.
      
      [ vbabka@suse.cz: replace existing functions instead of calling them ]
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      b918653b
    • Matthew Wilcox (Oracle)'s avatar
      mm: Split slab into its own type · d122019b
      Matthew Wilcox (Oracle) authored
      Make struct slab independent of struct page. It still uses the
      underlying memory in struct page for storing slab-specific data, but
      slab and slub can now be weaned off using struct page directly.  Some of
      the wrapper functions (slab_address() and slab_order()) still need to
      cast to struct folio, but this is a significant disentanglement.
      
      [ vbabka@suse.cz: Rebase on folios, use folio instead of page where
        possible.
      
        Do not duplicate flags field in struct slab, instead make the related
        accessors go through slab_folio(). For testing pfmemalloc use the
        folio_*_active flag accessors directly so the PageSlabPfmemalloc
        wrappers can be removed later.
      
        Make folio_slab() expect only folio_test_slab() == true folios and
        virt_to_slab() return NULL when folio_test_slab() == false.
      
        Move struct slab to mm/slab.h.
      
        Don't represent with struct slab pages that are not true slab pages,
        but just a compound page obtained directly rom page allocator (with
        large kmalloc() for SLUB and SLOB). ]
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      d122019b
    • Vlastimil Babka's avatar
      mm/slub: Make object_err() static · ae16d059
      Vlastimil Babka authored
      There are no callers outside of mm/slub.c anymore.
      
      Move freelist_corrupted() that calls object_err() to avoid a need for
      forward declaration.
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      ae16d059
    • Vlastimil Babka's avatar
      mm/slab: Dissolve slab_map_pages() in its caller · c7981543
      Vlastimil Babka authored
      The function no longer does what its name and comment suggests, and just
      sets two struct page fields, which can be done directly in its sole
      caller.
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reviewed-by: default avatarRoman Gushchin <guro@fb.com>
      Reviewed-by: default avatarHyeonggon Yoo <42.hyeyoo@gmail.com>
      c7981543
  2. 20 Dec, 2021 1 commit
  3. 19 Dec, 2021 14 commits
  4. 18 Dec, 2021 9 commits
    • Linus Torvalds's avatar
      Merge tag 'tty-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty · 3f667b5d
      Linus Torvalds authored
      Pull tty/serial fixes from Greg KH:
       "Here are two small tty/serial fixes for 5.16-rc6.  They include:
      
         - n_hdlc fix for syzbot reported problem that you were previously
           copied on.
      
         - 8250_fintek driver fix that resolved a console problem by removing
           a previous change.
      
        Both have been in linux-next with no reported issues"
      
      * tag 'tty-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
        serial: 8250_fintek: Fix garbled text for console
        tty: n_hdlc: make n_hdlc_tty_wakeup() asynchronous
      3f667b5d
    • Linus Torvalds's avatar
      Merge tag 'usb-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb · fb7d0829
      Linus Torvalds authored
      Pull USB fixes from Greg KH:
       "Here are a number of small USB driver fixes for reported problems.
        They include:
      
         - dwc2 driver fixes
      
         - xhci driver fixes
      
         - cdnsp driver fixes
      
         - typec driver fix
      
         - gadget u_ether driver fix
      
         - new quirk additions
      
         - usb gadget endpoint calculation fix
      
         - usb serial new device ids
      
         - revert of a xhci-dbg change that broke early debug booting
      
        All changes, except for the revert, have been in linux-next with no
        reported problems. The revert was from yesterday, and it was reported
        by the developers affected that it resolved their problem"
      
      * tag 'usb-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
        Revert "usb: early: convert to readl_poll_timeout_atomic()"
        usb: typec: tcpm: fix tcpm unregister port but leave a pending timer
        usb: cdnsp: Fix lack of spin_lock_irqsave/spin_lock_restore
        USB: NO_LPM quirk Lenovo USB-C to Ethernet Adapher(RTL8153-04)
        usb: xhci: Extend support for runtime power management for AMD's Yellow carp.
        usb: dwc2: fix STM ID/VBUS detection startup delay in dwc2_driver_probe
        USB: gadget: bRequestType is a bitfield, not a enum
        USB: serial: option: add Telit FN990 compositions
        USB: serial: cp210x: fix CP2105 GPIO registration
        usb: cdnsp: Fix incorrect status for control request
        usb: cdnsp: Fix issue in cdnsp_log_ep trace event
        usb: cdnsp: Fix incorrect calling of cdnsp_died function
        usb: xhci-mtk: fix list_del warning when enable list debug
        usb: gadget: u_ether: fix race in setting MAC address in setup phase
      fb7d0829
    • Linus Torvalds's avatar
      Merge tag 'perf-tools-fixes-for-v5.16-2021-12-18' of... · 0f03adcc
      Linus Torvalds authored
      Merge tag 'perf-tools-fixes-for-v5.16-2021-12-18' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
      Pull perf tools fixes from Arnaldo Carvalho de Melo:
      
       - Fix segfaults in 'perf inject' related to usage of unopened files
      
       - The return value of hashmap__new() should be checked using IS_ERR()
      
      * tag 'perf-tools-fixes-for-v5.16-2021-12-18' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
        perf inject: Fix segfault due to perf_data__fd() without open
        perf inject: Fix segfault due to close without open
        perf expr: Fix missing check for return value of hashmap__new()
      0f03adcc
    • Adrian Hunter's avatar
      perf inject: Fix segfault due to perf_data__fd() without open · c271a55b
      Adrian Hunter authored
      The fixed commit attempts to get the output file descriptor even if the
      file was never opened e.g.
      
        $ perf record uname
        Linux
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.002 MB perf.data (7 samples) ]
        $ perf inject -i perf.data --vm-time-correlation=dry-run
        Segmentation fault (core dumped)
        $ gdb --quiet perf
        Reading symbols from perf...
        (gdb) r inject -i perf.data --vm-time-correlation=dry-run
        Starting program: /home/ahunter/bin/perf inject -i perf.data --vm-time-correlation=dry-run
        [Thread debugging using libthread_db enabled]
        Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
      
        Program received signal SIGSEGV, Segmentation fault.
        __GI___fileno (fp=0x0) at fileno.c:35
        35      fileno.c: No such file or directory.
        (gdb) bt
        #0  __GI___fileno (fp=0x0) at fileno.c:35
        #1  0x00005621e48dd987 in perf_data__fd (data=0x7fff4c68bd08) at util/data.h:72
        #2  perf_data__fd (data=0x7fff4c68bd08) at util/data.h:69
        #3  cmd_inject (argc=<optimized out>, argv=0x7fff4c69c1f0) at builtin-inject.c:1017
        #4  0x00005621e4936783 in run_builtin (p=0x5621e4ee6878 <commands+600>, argc=4, argv=0x7fff4c69c1f0) at perf.c:313
        #5  0x00005621e4897d5c in handle_internal_command (argv=<optimized out>, argc=<optimized out>) at perf.c:365
        #6  run_argv (argcp=<optimized out>, argv=<optimized out>) at perf.c:409
        #7  main (argc=4, argv=0x7fff4c69c1f0) at perf.c:539
        (gdb)
      
      Fixes: 0ae03893 ("perf tools: Pass a fd to perf_file_header__read_pipe()")
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20211213084829.114772-3-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c271a55b
    • Adrian Hunter's avatar
      perf inject: Fix segfault due to close without open · 0c8e32fe
      Adrian Hunter authored
      The fixed commit attempts to close inject.output even if it was never
      opened e.g.
      
        $ perf record uname
        Linux
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.002 MB perf.data (7 samples) ]
        $ perf inject -i perf.data --vm-time-correlation=dry-run
        Segmentation fault (core dumped)
        $ gdb --quiet perf
        Reading symbols from perf...
        (gdb) r inject -i perf.data --vm-time-correlation=dry-run
        Starting program: /home/ahunter/bin/perf inject -i perf.data --vm-time-correlation=dry-run
        [Thread debugging using libthread_db enabled]
        Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
      
        Program received signal SIGSEGV, Segmentation fault.
        0x00007eff8afeef5b in _IO_new_fclose (fp=0x0) at iofclose.c:48
        48      iofclose.c: No such file or directory.
        (gdb) bt
        #0  0x00007eff8afeef5b in _IO_new_fclose (fp=0x0) at iofclose.c:48
        #1  0x0000557fc7b74f92 in perf_data__close (data=data@entry=0x7ffcdafa6578) at util/data.c:376
        #2  0x0000557fc7a6b807 in cmd_inject (argc=<optimized out>, argv=<optimized out>) at builtin-inject.c:1085
        #3  0x0000557fc7ac4783 in run_builtin (p=0x557fc8074878 <commands+600>, argc=4, argv=0x7ffcdafb6a60) at perf.c:313
        #4  0x0000557fc7a25d5c in handle_internal_command (argv=<optimized out>, argc=<optimized out>) at perf.c:365
        #5  run_argv (argcp=<optimized out>, argv=<optimized out>) at perf.c:409
        #6  main (argc=4, argv=0x7ffcdafb6a60) at perf.c:539
        (gdb)
      
      Fixes: 02e6246f ("perf inject: Close inject.output on exit")
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20211213084829.114772-2-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0c8e32fe
    • Miaoqian Lin's avatar
      perf expr: Fix missing check for return value of hashmap__new() · 0a515a06
      Miaoqian Lin authored
      The hashmap__new() function may return ERR_PTR(-ENOMEM) when malloc()
      fails, add IS_ERR() checking for ctx->ids.
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20211212062504.25841-1-linmq006@gmail.com
      [ s/kfree()/free()/ and add missing linux/err.h include ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0a515a06
    • Zqiang's avatar
      locking/rtmutex: Fix incorrect condition in rtmutex_spin_on_owner() · 8f556a32
      Zqiang authored
      Optimistic spinning needs to be terminated when the spinning waiter is not
      longer the top waiter on the lock, but the condition is negated. It
      terminates if the waiter is the top waiter, which is defeating the whole
      purpose.
      
      Fixes: c3123c43 ("locking/rtmutex: Dont dereference waiter lockless")
      Signed-off-by: default avatarZqiang <qiang1.zhang@intel.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20211217074207.77425-1-qiang1.zhang@intel.com
      8f556a32
    • Linus Torvalds's avatar
      Merge tag 'libata-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata · 9eaa88c7
      Linus Torvalds authored
      Pull libata fix from Damien Le Moal:
       "A single fix for this cycle:
      
         - Check that ATA16 passthrough commands that do not transfer any data
           have a DMA direction set to DMA_NONE (From George)"
      
      * tag 'libata-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata:
        libata: if T_LENGTH is zero, dma direction should be DMA_NONE
      9eaa88c7
    • Linus Torvalds's avatar
      Merge tag 'zonefs-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs · 1887bf5c
      Linus Torvalds authored
      Pull zonefs fixes from Damien Le Moal:
       "One fix and one trivial update for rc6:
      
         - Add MODULE_ALIAS_FS to get automatic module loading on mount
           (Naohiro)
      
         - Update Damien's email address in the MAINTAINERS file (me)"
      
      * tag 'zonefs-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs:
        MAITAINERS: Change zonefs maintainer email address
        zonefs: add MODULE_ALIAS_FS
      1887bf5c