OpenCloudOS-Kernel/drivers/gpu/drm/i915
Vlastimil Babka 2dba5eb1c7 lib/stackdepot: allow optional init and stack_table allocation by kvmalloc()
Currently, enabling CONFIG_STACKDEPOT means its stack_table will be
allocated from memblock, even if stack depot ends up not actually used.
The default size of stack_table is 4MB on 32-bit, 8MB on 64-bit.

This is fine for use-cases such as KASAN which is also a config option
and has overhead on its own.  But it's an issue for functionality that
has to be actually enabled on boot (page_owner) or depends on hardware
(GPU drivers) and thus the memory might be wasted.  This was raised as
an issue [1] when attempting to add stackdepot support for SLUB's debug
object tracking functionality.  It's common to build kernels with
CONFIG_SLUB_DEBUG and enable slub_debug on boot only when needed, or
create only specific kmem caches with debugging for testing purposes.

It would thus be more efficient if stackdepot's table was allocated only
when actually going to be used.  This patch thus makes the allocation
(and whole stack_depot_init() call) optional:

 - Add a CONFIG_STACKDEPOT_ALWAYS_INIT flag to keep using the current
   well-defined point of allocation as part of mem_init(). Make
   CONFIG_KASAN select this flag.

 - Other users have to call stack_depot_init() as part of their own init
   when it's determined that stack depot will actually be used. This may
   depend on both config and runtime conditions. Convert current users
   which are page_owner and several in the DRM subsystem. Same will be
   done for SLUB later.

 - Because the init might now be called after the boot-time memblock
   allocation has given all memory to the buddy allocator, change
   stack_depot_init() to allocate stack_table with kvmalloc() when
   memblock is no longer available. Also handle allocation failure by
   disabling stackdepot (could have theoretically happened even with
   memblock allocation previously), and don't unnecessarily align the
   memblock allocation to its own size anymore.

[1] https://lore.kernel.org/all/CAMuHMdW=eoVzM1Re5FVoEN87nKfiLmM2+Ah7eNu2KXEhCvbZyA@mail.gmail.com/

Link: https://lkml.kernel.org/r/20211013073005.11351-1-vbabka@suse.cz
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Marco Elver <elver@google.com> # stackdepot
Cc: Marco Elver <elver@google.com>
Cc: Vijayanand Jitta <vjitta@codeaurora.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Oliver Glitta <glittao@gmail.com>
Cc: Imran Khan <imran.f.khan@oracle.com>
From: Colin Ian King <colin.king@canonical.com>
Subject: lib/stackdepot: fix spelling mistake and grammar in pr_err message

There is a spelling mistake of the work allocation so fix this and
re-phrase the message to make it easier to read.

Link: https://lkml.kernel.org/r/20211015104159.11282-1-colin.king@canonical.com
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
From: Vlastimil Babka <vbabka@suse.cz>
Subject: lib/stackdepot: allow optional init and stack_table allocation by kvmalloc() - fixup

On FLATMEM, we call page_ext_init_flatmem_late() just before
kmem_cache_init() which means stack_depot_init() (called by page owner
init) will not recognize properly it should use kvmalloc() and not
memblock_alloc().  memblock_alloc() will also not issue a warning and
return a block memory that can be invalid and cause kernel page fault when
saving stacks, as reported by the kernel test robot [1].

Fix this by moving page_ext_init_flatmem_late() below kmem_cache_init() so
that slab_is_available() is true during stack_depot_init().  SPARSEMEM
doesn't have this issue, as it doesn't do page_ext_init_flatmem_late(),
but a different page_ext_init() even later in the boot process.

Thanks to Mike Rapoport for pointing out the FLATMEM init ordering issue.

While at it, also actually resolve a checkpatch warning in stack_depot_init()
from DRM CI, which was supposed to be in the original patch already.

[1] https://lore.kernel.org/all/20211014085450.GC18719@xsang-OptiPlex-9020/

Link: https://lkml.kernel.org/r/6abd9213-19a9-6d58-cedc-2414386d2d81@suse.cz
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Reported-by: kernel test robot <oliver.sang@intel.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
From: Vlastimil Babka <vbabka@suse.cz>
Subject: lib/stackdepot: allow optional init and stack_table allocation by kvmalloc() - fixup3

Due to cd06ab2fd4 ("drm/locking: add backtrace for locking contended
locks without backoff") landing recently to -next adding a new stack depot
user in drivers/gpu/drm/drm_modeset_lock.c we need to add an appropriate
call to stack_depot_init() there as well.

Link: https://lkml.kernel.org/r/2a692365-cfa1-64f2-34e0-8aa5674dce5e@suse.cz
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
Cc: Marco Elver <elver@google.com>
Cc: Vijayanand Jitta <vjitta@codeaurora.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Oliver Glitta <glittao@gmail.com>
Cc: Imran Khan <imran.f.khan@oracle.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
From: Vlastimil Babka <vbabka@suse.cz>
Subject: lib/stackdepot: allow optional init and stack_table allocation by kvmalloc() - fixup4

Due to 4e66934eaa ("lib: add reference counting tracking
infrastructure") landing recently to net-next adding a new stack depot
user in lib/ref_tracker.c we need to add an appropriate call to
stack_depot_init() there as well.

Link: https://lkml.kernel.org/r/45c1b738-1a2f-5b5f-2f6d-86fab206d01c@suse.cz
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Cc: Jiri Slab <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-01-22 08:33:37 +02:00
..
display drm/i915/display/adlp: Implement new step in the TC voltage swing prog sequence 2022-01-17 10:19:41 +00:00
gem drm fixes for 5.17-rc1: 2022-01-16 06:52:38 +02:00
gt Merge tag 'drm-intel-gt-next-2021-12-23' of git://anongit.freedesktop.org/drm/drm-intel into drm-next 2021-12-24 06:14:51 +10:00
gvt Merge tag 'drm-intel-gt-next-2021-12-23' of git://anongit.freedesktop.org/drm/drm-intel into drm-next 2021-12-24 06:14:51 +10:00
pxp drm/i915/pxp: Hold RPM wakelock during PXP unbind 2022-01-10 13:54:53 +00:00
selftests drm/i915: Ensure i915_vma tests do not get -ENOSPC with the locking changes. 2021-12-20 16:34:20 +01:00
.gitignore
Kconfig Merge drm/drm-next into drm-intel-next 2021-11-22 17:35:32 +02:00
Kconfig.debug drm/i915: Improve debug Kconfig texts a bit 2021-07-06 10:10:07 +02:00
Kconfig.profile
Kconfig.unstable
Makefile Merge tag 'drm-intel-gt-next-2021-12-23' of git://anongit.freedesktop.org/drm/drm-intel into drm-next 2021-12-24 06:14:51 +10:00
TODO.txt
i915_active.c drm/i915: Remove unused bits of i915_vma/active api 2021-12-20 16:26:09 +01:00
i915_active.h drm/i915: Remove unused bits of i915_vma/active api 2021-12-20 16:26:09 +01:00
i915_active_types.h drm/i915/active: remove useless i915_utils.h include 2021-12-13 12:04:44 +02:00
i915_buddy.c drm/i915/buddy: add some pretty printing 2021-08-20 09:40:22 +01:00
i915_buddy.h drm/i915/buddy: add some pretty printing 2021-08-20 09:40:22 +01:00
i915_cmd_parser.c drm/i915: Correct the docs for intel_engine_cmd_parser 2021-07-21 11:49:36 -04:00
i915_config.c drm/i915: remove IS_ACTIVE 2021-10-07 11:04:05 -07:00
i915_debugfs.c Merge tag 'drm-intel-gt-next-2021-12-23' of git://anongit.freedesktop.org/drm/drm-intel into drm-next 2021-12-24 06:14:51 +10:00
i915_debugfs.h
i915_debugfs_params.c drm/i915: Use to_gt() helper 2021-12-17 21:51:59 -08:00
i915_debugfs_params.h
i915_deps.c drm/i915: Break out the i915_deps utility 2021-12-22 08:52:57 +01:00
i915_deps.h drm/i915: Break out the i915_deps utility 2021-12-22 08:52:57 +01:00
i915_driver.c Merge tag 'drm-intel-gt-next-2021-12-23' of git://anongit.freedesktop.org/drm/drm-intel into drm-next 2021-12-24 06:14:51 +10:00
i915_driver.h drm/i915/driver: add i915_driver_ prefix to functions 2021-11-17 11:47:55 +02:00
i915_drv.h Merge tag 'drm-intel-gt-next-2021-12-23' of git://anongit.freedesktop.org/drm/drm-intel into drm-next 2021-12-24 06:14:51 +10:00
i915_fixed.h
i915_gem.c drm/i915: Force ww lock for i915_gem_object_ggtt_pin_ww, v2. 2021-12-20 16:33:03 +01:00
i915_gem.h
i915_gem_evict.c drm/i915/guc: Update intel_gt_wait_for_idle to work with GuC 2021-07-22 10:07:23 -07:00
i915_gem_gtt.c drm/i915: Use direction definition DMA_BIDIRECTIONAL instead of PCI_DMA_BIDIRECTIONAL 2021-09-30 16:19:45 +02:00
i915_gem_gtt.h
i915_gem_ww.c
i915_gem_ww.h drm/i915: Ditch the i915_gem_ww_ctx loop member 2021-08-20 09:39:41 +01:00
i915_getparam.c drm/i915: Use to_gt() helper 2021-12-17 21:51:59 -08:00
i915_gpu_error.c drm/i915: Use to_gt() helper 2021-12-17 21:51:59 -08:00
i915_gpu_error.h drm/i915: Avoid allocating a page array for the gpu coredump 2021-11-26 08:26:08 +01:00
i915_ioc32.c
i915_ioc32.h
i915_iosf_mbi.h drm/i915: abstraction for iosf to compile on all archs 2021-10-27 00:32:01 -07:00
i915_irq.c Merge tag 'drm-intel-gt-next-2021-12-23' of git://anongit.freedesktop.org/drm/drm-intel into drm-next 2021-12-24 06:14:51 +10:00
i915_irq.h drm/i915/irq: reduce inlines to reduce header dependencies 2021-08-20 10:28:31 +03:00
i915_memcpy.c
i915_memcpy.h
i915_mitigations.c
i915_mitigations.h
i915_mm.c drm/i915: Skip remap_io_mapping() for non-x86 platforms 2021-12-08 13:26:14 -08:00
i915_mm.h drm/i915: Skip remap_io_mapping() for non-x86 platforms 2021-12-08 13:26:14 -08:00
i915_module.c drm-misc-next for 5.17: 2021-12-09 09:31:45 +01:00
i915_params.c drm/i915: Test all device memory on probing 2021-12-14 15:08:20 +05:30
i915_params.h drm/i915: Test all device memory on probing 2021-12-14 15:08:20 +05:30
i915_pci.c Merge tag 'drm-intel-gt-next-2021-12-23' of git://anongit.freedesktop.org/drm/drm-intel into drm-next 2021-12-24 06:14:51 +10:00
i915_pci.h drm/i915/pci: rename functions to have i915_pci prefix 2021-08-26 10:50:19 +03:00
i915_perf.c i915: simplify subdirectory registration with register_sysctl() 2022-01-22 08:33:34 +02:00
i915_perf.h drm/i915: Use a table for i915_init/exit (v2) 2021-07-22 12:05:17 +02:00
i915_perf_types.h
i915_pmu.c drm/i915: Use to_gt() helper 2021-12-17 21:51:59 -08:00
i915_pmu.h drm/i915: Use a table for i915_init/exit (v2) 2021-07-22 12:05:17 +02:00
i915_priolist_types.h
i915_pvinfo.h
i915_query.c drm/i915: Use to_gt() helper 2021-12-17 21:51:59 -08:00
i915_query.h
i915_reg.h drm/i915/display/adlp: Implement new step in the TC voltage swing prog sequence 2022-01-17 10:19:41 +00:00
i915_request.c Merge tag 'drm-intel-gt-next-2021-12-23' of git://anongit.freedesktop.org/drm/drm-intel into drm-next 2021-12-24 06:14:51 +10:00
i915_request.h drm/i915: Avoid using the i915_fence_array when collecting dependencies 2021-12-22 08:14:30 +01:00
i915_scatterlist.c drm/i915: Introduce refcounted sg-tables 2021-11-01 18:10:49 +01:00
i915_scatterlist.h drm/i915: Introduce refcounted sg-tables 2021-11-01 18:10:49 +01:00
i915_scheduler.c drm/i915: move scheduler slabs to direct module init/exit 2021-07-28 17:18:56 +02:00
i915_scheduler.h drm/i915: move scheduler slabs to direct module init/exit 2021-07-28 17:18:56 +02:00
i915_scheduler_types.h drm/i915/guc: Implement GuC priority management 2021-07-27 17:32:27 -07:00
i915_selftest.h
i915_suspend.c
i915_suspend.h
i915_sw_fence.c drm/i915: Drop stealing of bits from i915_sw_fence function pointer 2021-11-30 17:52:15 -08:00
i915_sw_fence.h drm/i915: Drop stealing of bits from i915_sw_fence function pointer 2021-11-30 17:52:15 -08:00
i915_sw_fence_work.c drm/i915: Drop stealing of bits from i915_sw_fence function pointer 2021-11-30 17:52:15 -08:00
i915_sw_fence_work.h drm/i915: Drop error handling from dma_fence_work 2021-07-16 21:47:39 +02:00
i915_switcheroo.c drm/i915/driver: add i915_driver_ prefix to functions 2021-11-17 11:47:55 +02:00
i915_switcheroo.h
i915_syncmap.c
i915_syncmap.h
i915_sysfs.c drm/i915: Use to_gt() helper 2021-12-17 21:51:59 -08:00
i915_sysfs.h
i915_trace.h drm/i915/trace: split out display trace to a separate file 2021-12-09 11:21:46 +02:00
i915_trace_points.c
i915_ttm_buddy_manager.c drm/i915/buddy: add some pretty printing 2021-08-20 09:40:22 +01:00
i915_ttm_buddy_manager.h drm/i915: support forcing the page size with lmem 2021-06-30 13:24:29 +01:00
i915_user_extensions.c
i915_user_extensions.h
i915_utils.c
i915_utils.h drm for 5.16-rc1 2021-11-02 16:47:49 -07:00
i915_vgpu.c
i915_vgpu.h
i915_vma.c drm/i915: Require the vm mutex for i915_vma_bind() 2021-12-22 08:52:57 +01:00
i915_vma.h drm/i915: Remove pages_mutex and intel_gtt->vma_ops.set/clear_pages members, v3. 2021-12-20 16:31:02 +01:00
i915_vma_snapshot.c drm/i915: Update error capture code to avoid using the current vma state 2021-12-01 16:53:22 +01:00
i915_vma_snapshot.h drm/i915: Update error capture code to avoid using the current vma state 2021-12-01 16:53:22 +01:00
i915_vma_types.h Merge tag 'drm-intel-gt-next-2021-12-23' of git://anongit.freedesktop.org/drm/drm-intel into drm-next 2021-12-24 06:14:51 +10:00
intel_device_info.c Merge tag 'drm-intel-next-2021-12-14' of ssh://git.freedesktop.org/git/drm/drm-intel into drm-next 2021-12-17 15:23:49 +10:00
intel_device_info.h Merge tag 'drm-intel-gt-next-2021-12-23' of git://anongit.freedesktop.org/drm/drm-intel into drm-next 2021-12-24 06:14:51 +10:00
intel_dram.c drm/i915: Remove memory frequency calculation 2021-10-19 10:45:52 +03:00
intel_dram.h
intel_gvt.c drm/i915: Use to_gt() helper 2021-12-17 21:51:59 -08:00
intel_gvt.h
intel_memory_region.c drm/i915: Test all device memory on probing 2021-12-14 15:08:20 +05:30
intel_memory_region.h drm/i915/ttm: Drop region reference counting 2021-11-25 09:36:16 +01:00
intel_pch.c drm/i915/rpl-s: Add PCH Support for Raptor Lake S 2021-12-08 13:03:04 -08:00
intel_pch.h drm/i915/rpl-s: Add PCH Support for Raptor Lake S 2021-12-08 13:03:04 -08:00
intel_pcode.c drm/i915: split out intel_pcode.[ch] to separate file 2021-10-14 18:04:17 +03:00
intel_pcode.h drm/i915: split out intel_pcode.[ch] to separate file 2021-10-14 18:04:17 +03:00
intel_pm.c Merge tag 'drm-intel-next-2021-12-14' of ssh://git.freedesktop.org/git/drm/drm-intel into drm-next 2021-12-17 15:23:49 +10:00
intel_pm.h drm/i915/wm: provide wrappers around watermark vfuncs calls (v3) 2021-09-29 08:53:57 +03:00
intel_pm_types.h drm/i915: split out intel_pm_types.h 2021-12-03 11:28:12 +02:00
intel_region_ttm.c drm/i915/ttm: Drop region reference counting 2021-11-25 09:36:16 +01:00
intel_region_ttm.h drm/i915/ttm: Drop region reference counting 2021-11-25 09:36:16 +01:00
intel_runtime_pm.c lib/stackdepot: allow optional init and stack_table allocation by kvmalloc() 2022-01-22 08:33:37 +02:00
intel_runtime_pm.h drm/i915: intel_runtime_pm.h does not actually need intel_display.h 2021-08-20 10:28:49 +03:00
intel_sbi.c drm/i915: rename intel_sideband.[ch] to intel_sbi.[ch] 2021-10-14 18:05:04 +03:00
intel_sbi.h drm/i915: rename intel_sideband.[ch] to intel_sbi.[ch] 2021-10-14 18:05:04 +03:00
intel_step.c drm/i915: Rename GT_STEP to GRAPHICS_STEP 2021-11-02 13:05:40 -07:00
intel_step.h drm/i915: Rename GT_STEP to GRAPHICS_STEP 2021-11-02 13:05:40 -07:00
intel_uncore.c Merge tag 'drm-intel-gt-next-2021-12-23' of git://anongit.freedesktop.org/drm/drm-intel into drm-next 2021-12-24 06:14:51 +10:00
intel_uncore.h drm/i915: Store backpointer to GT in uncore 2021-12-17 21:47:15 -08:00
intel_wakeref.c
intel_wakeref.h drm/i915/guc: Take engine PM when a context is pinned with GuC submission 2021-10-15 10:37:26 -07:00
intel_wopcm.c drm/i915: Use to_gt() helper 2021-12-17 21:51:59 -08:00
intel_wopcm.h
vlv_sideband.c drm/i915: abstraction for iosf to compile on all archs 2021-10-27 00:32:01 -07:00
vlv_sideband.h drm/i915: split out vlv sideband to a separate file 2021-10-14 12:22:55 +03:00
vlv_suspend.c
vlv_suspend.h