13 Jan, 2021

6 commits

  • Memory hotplugging is allowed only for multiples of section sizes.
    Section size could be huge (ex. 1GB for arm64 targets) thus limiting
    to add/remove lower chunks of memory. This patch allows drivers to add
    memory of subsection sizes which are then added to memblock. This does
    not create a separate memblock device nodes for newly added subsections
    until the whole of the memblock section is added.

    Bug: 170460867
    Change-Id: I15749b5320340cba4d526e7ddb26a9cd6029c690
    Signed-off-by: Sudarshan Rajagopalan

    Sudarshan Rajagopalan
     
  • There are out of tree drivers which need IOMMU_SYS_CACHE_ONLY
    to be able to cache their data buffers in the system cache,
    so restore it.

    Bug: 176778547
    Change-Id: Ic632a6f5951f9917e6006088b065fdbaf4e1b374
    Signed-off-by: Isaac J. Manjarres

    Isaac J. Manjarres
     
  • After certain memory blocks are offlined, some usecases require that the
    page-table mappings are removed while still keeping the memblock device nodes,
    memory resources and the memmap entries intact. This is to avoid the overhead
    involved in using 'remove_memory' if the offlined blocks will be added/onlined
    back into the system at later point. {populate/depopulate}_range_driver_managed
    provide the abilty to drivers to tear-down and create page-table mappings of
    memory blocks that its managing, without having to use 'remove_memory' and
    friends for the purpose.
    These functions does not interfere with mappings of boot memory or resources
    that isn't owned by the driver.

    Bug: 171907330
    Change-Id: Ie11201334bd7438bf87f933ccc81814fa99162c4
    Signed-off-by: Sudarshan Rajagopalan

    Sudarshan Rajagopalan
     
  • The vendor hook in select_task_rq_fair() currently sees a potentially
    stale task utilization. Make sure to sync it beforehand to avoid any
    issues.

    Fixes: a1fc1fba460b ("ANDROID: sched: add restrict vendor hook to modify task placement policy in EAS")
    Signed-off-by: Quentin Perret
    Change-Id: I7675ce9fd37b160f8a7ba9651ae73b69a16d6d12

    Quentin Perret
     
  • The vendor hook in find_energy_efficient_cpu() currently sees a
    potentially stale task utilization. Make sure to sync it beforehand to
    avoid any issues by moving the call at the top of the function. This
    also ensures the check on task_fits_capacity() when the sync flag is set
    sees an up-to-date task util.

    Fixes: a9c5fcfe9c76 ("ANDROID: sched/fair: Have sync honor fits_capacity")
    Fixes: 147a9b3d9eab ("ANDROID: sched: Add vendor hooks for find_energy_efficient_cpu")
    Signed-off-by: Quentin Perret
    Change-Id: Ie9a6c89249a2aefbccced4786ce4d4728e39dd12

    Quentin Perret
     
  • Enable the KUNIT core, which has a small ABI impact, and also the
    DEBUGFS feature so that results can be reaped. This change does not
    actually enable any KUNIT tests or the internal selftests, those must be
    enabled by downstream builds.

    Bug: 176228452
    Change-Id: I2817cb1495fe7bf0485e63f877a68b1971e26cc5
    Signed-off-by: Alistair Delva

    Alistair Delva
     

12 Jan, 2021

6 commits

  • Add support for IOMMU drivers to have their own map_sg() callbacks.
    This completes the path for having iommu_map_sg() invoke an IOMMU
    driver's map_sg() callback, which can then invoke the io-pgtable
    map_sg() callback with the entire scatter-gather list, so that it
    can be processed entirely in the io-pgtable layer.

    For IOMMU drivers that do not provide a callback, the default
    implementation of iterating through the scatter-gather list, while
    calling iommu_map() will be used.

    Bug: 176779203
    Link: https://lore.kernel.org/linux-iommu/1610376862-927-1-git-send-email-isaacm@codeaurora.org/T/#t
    Change-Id: I3d5a8a9e8648649d8dcdda3fa1df41d72f87a528
    Signed-off-by: Isaac J. Manjarres
    Tested-by: Sai Prakash Ranjan

    Isaac J. Manjarres
     
  • While mapping a scatter-gather list, iommu_map_sg() calls
    into the IOMMU driver through an indirect call, which can
    call into the io-pgtable code through another indirect call.

    This sequence of going through the IOMMU core code, the IOMMU
    driver, and finally the io-pgtable code, occurs for every
    element in the scatter-gather list, in the worse case, which
    is not optimal.

    Introduce a map_sg callback in the io-pgtable ops so that
    IOMMU drivers can invoke it with the complete scatter-gather
    list, so that it can be processed within the io-pgtable
    code entirely, reducing the number of indirect calls, and
    boosting overall iommu_map_sg() performance.

    Bug: 176779203
    Link: https://lore.kernel.org/linux-iommu/1610376862-927-1-git-send-email-isaacm@codeaurora.org/T/#t
    Change-Id: I4b2088dd08eb97dcd94a6c6968082a3c4395351a
    Signed-off-by: Isaac J. Manjarres
    Tested-by: Sai Prakash Ranjan

    Isaac J. Manjarres
     
  • UFS specficication allows different VCC configurations for UFS devices,
    for example:

    (1). 2.70V - 3.60V (Activated by default in UFS core driver)
    (2). 1.70V - 1.95V (Activated if "vcc-supply-1p8" is declared in
    device tree)
    (3). 2.40V - 2.70V (Supported since UFS 3.x)

    With the introduction of UFS 3.x products, an issue is happening that UFS
    driver will use wrong "min_uV-max_uV" values to configure the voltage of
    VCC regulator on UFU 3.x products with the configuration (3) used.

    To solve this issue, we simply remove pre-defined initial VCC voltage
    values in UFS core driver with below reasons,

    1. UFS specifications do not define how to detect the VCC configuration
    supported by attached device.

    2. Device tree already supports standard regulator properties.

    Therefore VCC voltage shall be defined correctly in device tree, and shall
    not changed by UFS driver. What UFS driver needs to do is simply enable or
    disable the VCC regulator only.

    Similar change is applied to VCCQ and VCCQ2 as well.

    Note that we keep struct ufs_vreg unchanged. This allows vendors to
    configure proper min_uV and max_uV of any regulators to make
    regulator_set_voltage() works during regulator toggling flow in the
    future. Without specific vendor configurations, min_uV and max_uV will be
    NULL by default and UFS core driver will enable or disable the regulator
    only without adjusting its voltage.

    Bug: 176226589
    (cherry picked from commit 5b44a07b6bb2c26905b16deb479e9ba4e5605e97
    git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git 5.11/scsi-queue)
    Link: https://lore.kernel.org/r/20201202091819.22363-1-stanley.chu@mediatek.com
    Reviewed-by: Asutosh Das
    Reviewed-by: Bjorn Andersson
    Reviewed-by: Can Guo
    Acked-by: Avri Altman
    Signed-off-by: Stanley Chu
    Signed-off-by: Martin K. Petersen

    Signed-off-by: Bao D. Nguyen
    Signed-off-by: Paul Lawrence
    Change-Id: Icb9c24d50cd8b6fff9f21748773686271d5dbd7b

    Stanley Chu
     
  • Export pcpu_nr_pages symbol which is used as part
    of meminfo collection from minidump module.

    Bug: 177027175
    Change-Id: I08262ec95a3f1be8322b9b8d2d9c4098518fc408
    Signed-off-by: Vijayanand Jitta

    Vijayanand Jitta
     
  • Enable TRACE_MMIO_ACCESS config for memory mapped io
    register read and write tracing support in GKI image.

    Bug: 169045115
    Change-Id: I27d115092789303a4c8f0c99d9bcb887ef3cc163
    Signed-off-by: Prasad Sodagudi

    Prasad Sodagudi
     
  • Add register read/write operations tracing support.
    ftrace events helps to trace register read and write
    location details of memory mapped IO registers.
    These trace logs helps to debug un clocked access
    of peripherals.

    Bug: 169045115
    Change-Id: I849bf75b84c24c8f3e9d2e8fba34a10ddcf4aaca
    Signed-off-by: Prasad Sodagudi

    Prasad Sodagudi
     

11 Jan, 2021

2 commits


10 Jan, 2021

1 commit

  • Changes in 5.10.5
    net/sched: sch_taprio: reset child qdiscs before freeing them
    mptcp: fix security context on server socket
    ethtool: fix error paths in ethnl_set_channels()
    ethtool: fix string set id check
    md/raid10: initialize r10_bio->read_slot before use.
    drm/amd/display: Add get_dig_frontend implementation for DCEx
    io_uring: close a small race gap for files cancel
    jffs2: Allow setting rp_size to zero during remounting
    jffs2: Fix NULL pointer dereference in rp_size fs option parsing
    spi: dw-bt1: Fix undefined devm_mux_control_get symbol
    opp: fix memory leak in _allocate_opp_table
    opp: Call the missing clk_put() on error
    scsi: block: Fix a race in the runtime power management code
    mm/hugetlb: fix deadlock in hugetlb_cow error path
    mm: memmap defer init doesn't work as expected
    lib/zlib: fix inflating zlib streams on s390
    io_uring: don't assume mm is constant across submits
    io_uring: use bottom half safe lock for fixed file data
    io_uring: add a helper for setting a ref node
    io_uring: fix io_sqe_files_unregister() hangs
    uapi: move constants from to
    tools headers UAPI: Sync linux/const.h with the kernel headers
    cgroup: Fix memory leak when parsing multiple source parameters
    zlib: move EXPORT_SYMBOL() and MODULE_LICENSE() out of dfltcc_syms.c
    scsi: cxgb4i: Fix TLS dependency
    Bluetooth: hci_h5: close serdev device and free hu in h5_close
    fbcon: Disable accelerated scrolling
    reiserfs: add check for an invalid ih_entry_count
    misc: vmw_vmci: fix kernel info-leak by initializing dbells in vmci_ctx_get_chkpt_doorbells()
    media: gp8psk: initialize stats at power control logic
    f2fs: fix shift-out-of-bounds in sanity_check_raw_super()
    ALSA: seq: Use bool for snd_seq_queue internal flags
    ALSA: rawmidi: Access runtime->avail always in spinlock
    bfs: don't use WARNING: string when it's just info.
    ext4: check for invalid block size early when mounting a file system
    fcntl: Fix potential deadlock in send_sig{io, urg}()
    io_uring: check kthread stopped flag when sq thread is unparked
    rtc: sun6i: Fix memleak in sun6i_rtc_clk_init
    module: set MODULE_STATE_GOING state when a module fails to load
    quota: Don't overflow quota file offsets
    rtc: pl031: fix resource leak in pl031_probe
    powerpc: sysdev: add missing iounmap() on error in mpic_msgr_probe()
    i3c master: fix missing destroy_workqueue() on error in i3c_master_register
    NFSv4: Fix a pNFS layout related use-after-free race when freeing the inode
    f2fs: avoid race condition for shrinker count
    f2fs: fix race of pending_pages in decompression
    module: delay kobject uevent until after module init call
    powerpc/64: irq replay remove decrementer overflow check
    fs/namespace.c: WARN if mnt_count has become negative
    watchdog: rti-wdt: fix reference leak in rti_wdt_probe
    um: random: Register random as hwrng-core device
    um: ubd: Submit all data segments atomically
    NFSv4.2: Don't error when exiting early on a READ_PLUS buffer overflow
    ceph: fix inode refcount leak when ceph_fill_inode on non-I_NEW inode fails
    drm/amd/display: updated wm table for Renoir
    tick/sched: Remove bogus boot "safety" check
    s390: always clear kernel stack backchain before calling functions
    io_uring: remove racy overflow list fast checks
    ALSA: pcm: Clear the full allocated memory at hw_params
    dm verity: skip verity work if I/O error when system is shutting down
    ext4: avoid s_mb_prefetch to be zero in individual scenarios
    device-dax: Fix range release
    Linux 5.10.5

    Signed-off-by: Greg Kroah-Hartman
    Change-Id: I2b481bfac06bafdef2cf3cc1ac2c2a4ddf9913dc

    Greg Kroah-Hartman
     

09 Jan, 2021

3 commits


08 Jan, 2021

10 commits

  • Add export symbol resched_curr to enable scheduler value add.

    Bug: 176077958
    Change-Id: I9c26b4d8738d6fd7d1067cb164a30b0228c5a301
    Signed-off-by: Shaleen Agrawal

    Shaleen Agrawal
     
  • Add vendors hooks for to facilitate various scheduler value adds.

    Bug: 176077958
    Change-Id: I5d488ae78ce05f81e6c73b69c56128b065647fec
    Signed-off-by: Shaleen Agrawal

    Shaleen Agrawal
     
  • Handling all combinations of the VMAP_STACK and SHADOW_CALL_STACK options
    in sdei_arch_get_entry_point() makes the code difficult to read,
    particularly when considering the error and cleanup paths.

    Move the checking of these options into the callee functions, so that
    they return early if the relevant option is not enabled.

    Bug: 169781940
    Change-Id: I3daf8a409d3544fa4e76a28c2b2ae9efb82001ba
    (cherry picked from commit eec3bf6861a8703ab63992578b1776353c5ac2a1)
    Signed-off-by: Will Deacon
    Signed-off-by: Sami Tolvanen

    Will Deacon
     
  • Use scs_alloc() to allocate also IRQ and SDEI shadow stacks instead of
    using statically allocated stacks.

    Bug: 169781940
    Change-Id: If3f38d603a7c1e8ebcf1e8655b70fa6bfde7c48d
    (cherry picked from commit ac20ffbb0279aae7be48567fb734eae7d050769e)
    Signed-off-by: Sami Tolvanen
    Acked-by: Will Deacon
    Link: https://lore.kernel.org/r/20201130233442.2562064-3-samitolvanen@google.com
    [will: Move CONFIG_SHADOW_CALL_STACK check into init_irq_scs()]
    Signed-off-by: Will Deacon

    Sami Tolvanen
     
  • The kernel currently uses kmem_cache to allocate shadow call stacks,
    which means an overflows may not be immediately detected and can
    potentially result in another task's shadow stack to be overwritten.

    This change switches SCS to use virtually mapped shadow stacks for
    tasks, which increases shadow stack size to a full page and provides
    more robust overflow detection, similarly to VMAP_STACK.

    Bug: 169781940
    Change-Id: I92c8f5706c11e4bf45b071e4f302a65502faa1e1
    (cherry picked from commit a2abe7cbd8fe2db5ff386c968e2273d9dc6c468d)
    Signed-off-by: Sami Tolvanen
    Acked-by: Will Deacon
    Link: https://lore.kernel.org/r/20201130233442.2562064-2-samitolvanen@google.com
    Signed-off-by: Will Deacon

    Sami Tolvanen
     
  • At present, EAS gets disabled when on ASYM Capacity systems
    if all BIG or Little CPUs gets hot-plugged. Instead of disabling
    EAS by default, add trace hook and let vendor decide if EAS should
    be disabled or not.

    Bug: 176964092
    Change-Id: I583272cc89d44f3e3a4b1c43e3f75d731092ebf6
    Signed-off-by: Satya Durga Srinivasu Prabhala

    Satya Durga Srinivasu Prabhala
     
  • A task can migrate either while it is waking or while it
    is running via load balancer. Print the task status
    i.e running or not in sched_migrate_task. This helps in
    counting the different types of migrations without relying
    on other trace events.

    Bug: 176709810
    Change-Id: Ib473f9ccdc78003bb1f5d2dc24354f2db7a684f5
    Signed-off-by: Pavankumar Kondeti
    Signed-off-by: Satya Durga Srinivasu Prabhala

    Pavankumar Kondeti
     
  • When the sum of the utilization of CPUs in a power domain is zero,
    return the energy as 0 without doing any computations.

    Acked-by: Quentin Perret
    Reviewed-by: Dietmar Eggemann
    Signed-off-by: Pavankumar Kondeti
    Signed-off-by: Rafael J. Wysocki

    (cherry picked from commit 9cc7e96aa846f9086431d6c2d33ff9ab42d72b2d)
    Bug: 173981595
    Signed-off-by: Pavankumar Kondeti
    Change-Id: I9b1a83d210c30a8a86da26f94ac0c2f855d2ed10

    Pavankumar Kondeti
     
  • Temporary workaround to enable arm64 gki devices to boot.

    Virtual devices failed to boot with 5.10 ARM64 GKI because symbol
    stripping has removed tracepoint symbols pertaining to xdp which are
    included in the symbol allowlist.

    klog excerpt for this error.
    init: Loading module /lib/modules/virtio_net.ko with args ""
    virtio_net: disagrees about version of symbol __traceiter_xdp_exception
    virtio_net: Unknown symbol __traceiter_xdp_exception (err -22)
    virtio_net: disagrees about version of symbol __tracepoint_xdp_exception
    virtio_net: Unknown symbol __tracepoint_xdp_exception (err -22)
    init: Failed to insmod '/lib/modules/virtio_net.ko' with args ''
    init: LoadWithAliases was unable to load virtio_net
    init: Failed to load kernel modules

    Bug: 176831960
    Test: Treehugger
    Signed-off-by: Ram Muthiah
    Change-Id: If5b6fd12ce1c783966ff4ed0a8bc141d077c71a3

    Ram Muthiah
     
  • To enable bfq i/o group scheduling for separating i/o groups to
    foreground and background i/o groups, we need to set CONFIG_IOSCHED_BFQ
    and CONFIG_BFQ_GROUP_IOSCHED to "y".

    Bug: 171739280
    Bug: 172520400
    Signed-off-by: Daeho Jeong
    Change-Id: If9b5664ecfc8f78d9792d7ee5d3ea5a88a50b9d7

    Daeho Jeong
     

07 Jan, 2021

9 commits

  • Add vendor hook tracepoints to track when cpu util gets
    updated and when freq is choosen.

    Bug: 174488007
    Signed-off-by: Saravana Kannan
    Signed-off-by: Rohit Gupta
    Signed-off-by: Jonathan Avila
    Signed-off-by: Jimmy Shiu
    Change-Id: Ibb22fd0337a2539820a05b1e6b54b09aeaebd040
    Signed-off-by: Will McVicker

    Jimmy Shiu
     
  • Collect the time for each allocation recorded in page owner so that
    allocation "surges" can be measured.

    Record the pid for each allocation recorded in page owner so that the
    source of allocation "surges" can be better identified.

    The above is very useful when doing memory analysis. On a crash for
    example, we can get this information from kdump (or ramdump) and parse it
    to figure out memory allocation problems.

    Please note that on x86_64 this increases the size of struct page_owner
    from 16 bytes to 32.

    Vlastimil: it's not a functionality intended for production, so unless
    somebody says they need to enable page_owner for debugging and this
    increase prevents them from fitting into available memory, let's not
    complicate things with making this optional.

    [lmark@codeaurora.org: v3]
    Link: https://lkml.kernel.org/r/20201210160357.27779-1-georgi.djakov@linaro.org

    Link: https://lkml.kernel.org/r/20201209125153.10533-1-georgi.djakov@linaro.org
    Signed-off-by: Liam Mark
    Signed-off-by: Georgi Djakov
    Acked-by: Vlastimil Babka
    Acked-by: Joonsoo Kim
    Cc: Jonathan Corbet
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    (cherry picked from commit 9cc7e96aa846f9086431d6c2d33ff9ab42d72b2d)

    Bug: 175129313
    Signed-off-by: Suren Baghdasaryan
    Change-Id: I5e246ea009c7e9e34c1cc608bcd3196fc0e623b4

    Liam Mark
     
  • Formerly cuttlefish and goldfish had separate symbol lists.
    The defconfigs and symbol lists were unified recently. However, the
    symbol lists should conform to this naming convention.

    Generated with
    BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh;
    BUILD_CONFIG= \
    common-modules/virtual-device/build.config.virtual_device.aarch64 \
    build/build.sh;
    build/abi/extract_symbols out/android12-5.10/dist/ \
    --whitelist common/android/abi_gki_aarch64_virtual_device

    Test: Treehugger
    Bug: 176831960
    Signed-off-by: Ram Muthiah
    Change-Id: I21755fbd3e9ab6319fdf4fcd06e501d722fb7242

    Ram Muthiah
     
  • Free the pages parallely for a task that receives SIGKILL, from ULMK
    process, using the oom_reaper. This freeing of pages will help to give
    the pages to buddy system well advance.

    Add the boot param, reap_mem_when_killed_by=, that configures the
    process name, the kill signal to a process from which makes its memory
    reaped by oom reaper.

    As an example, when reap_mem_when_killed_by=lmkd, then all the processes
    that receives the kill signal from lmkd is added to oom reaper.

    Not initializing this param makes this feature disabled.

    Change-Id: I21adb95de5e380a80d7eb0b87d9b5b553f52e28a
    Bug: 171763461
    Signed-off-by: Charan Teja Reddy
    Signed-off-by: Isaac J. Manjarres

    Charan Teja Reddy
     
  • * aosp/upstream-f2fs-stable-linux-5.10.y:
    fs-verity: move structs needed for file signing to UAPI header
    fs-verity: rename "file measurement" to "file digest"
    fs-verity: rename fsverity_signed_digest to fsverity_formatted_digest
    fs-verity: remove filenames from file comments
    fscrypt: allow deleting files with unsupported encryption policy
    fscrypt: unexport fscrypt_get_encryption_info()
    fscrypt: move fscrypt_require_key() to fscrypt_private.h
    fscrypt: move body of fscrypt_prepare_setattr() out-of-line
    fscrypt: introduce fscrypt_prepare_readdir()
    ext4: don't call fscrypt_get_encryption_info() from dx_show_leaf()
    ubifs: remove ubifs_dir_open()
    f2fs: remove f2fs_dir_open()
    ext4: remove ext4_dir_open()
    fscrypt: simplify master key locking
    fscrypt: remove unnecessary calls to fscrypt_require_key()
    ubifs: prevent creating duplicate encrypted filenames
    f2fs: prevent creating duplicate encrypted filenames
    ext4: prevent creating duplicate encrypted filenames
    fscrypt: add fscrypt_is_nokey_name()
    fscrypt: remove kernel-internal constants from UAPI header

    Conflicts:
    fs/crypto/hooks.c

    Bug: 174873661
    Signed-off-by: Jaegeuk Kim
    Change-Id: Id56d42fc959242524628752223e9d773a2c8681c

    Jaegeuk Kim
     
  • To be able to update addresses of an IPsec SA, as required by
    supporting MOBIKE

    Bug: 169169084
    Signed-off-by: Yan Yan
    Change-Id: I5aa3f3556d615e4f0695bb78cd3cad9e83851df5

    Yan Yan
     
  • Export get_page_owner symbol for loadable vendor
    modules.

    Bug: 176277889
    Change-Id: Iea0a8022e542d1223caf4a742a888647828ca7cc
    Signed-off-by: Vijayanand Jitta

    Vijayanand Jitta
     
  • Export lookup_page_ext symbol for loadable vendor
    modules.

    Bug: 176277892
    Change-Id: If7de83bf48c2867460ec88e61e0f709958dc5e16
    Signed-off-by: Vijayanand Jitta

    Vijayanand Jitta
     
  • Export get_slabinfo symbol for loadable vendor
    modules.

    Bug: 176277895
    Change-Id: I01870a370da9bf5db842ff14801d94ef79350560
    Signed-off-by: Vijayanand Jitta

    Vijayanand Jitta
     

06 Jan, 2021

3 commits

  • Tested-by: Jon Hunter
    Tested-by: Linux Kernel Functional Testing
    Tested-by: Jeffrin Jose T
    Tested-by: Shuah Khan
    Tested-by: Guenter Roeck
    Link: https://lore.kernel.org/r/20210104155708.800470590@linuxfoundation.org
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • [ Upstream commit 6268d7da4d192af339f4d688942b9ccb45a65e04 ]

    There are multiple locations that open-code the release of the last
    range in a device-dax instance. Consolidate this into a new
    dev_dax_trim_range() helper.

    This also addresses a kmemleak report:

    # cat /sys/kernel/debug/kmemleak
    [..]
    unreferenced object 0xffff976bd46f6240 (size 64):
    comm "ndctl", pid 23556, jiffies 4299514316 (age 5406.733s)
    hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 20 c3 37 00 00 00 .......... .7...
    ff ff ff 7f 38 00 00 00 00 00 00 00 00 00 00 00 ....8...........
    backtrace:
    [] __kmalloc_track_caller+0x136/0x379
    [] krealloc+0x67/0x92
    [] __alloc_dev_dax_range+0x73/0x25c
    [] devm_create_dev_dax+0x27d/0x416
    [] __dax_pmem_probe+0x1c9/0x1000 [dax_pmem_core]
    [] dax_pmem_probe+0x10/0x1f [dax_pmem]
    [] nvdimm_bus_probe+0x9d/0x340 [libnvdimm]
    [] really_probe+0x230/0x48d
    [] driver_probe_device+0x122/0x13b
    [] device_driver_attach+0x5b/0x60
    [] bind_store+0xb7/0xc3
    [] drv_attr_store+0x27/0x31
    [] sysfs_kf_write+0x4a/0x57
    [] kernfs_fop_write+0x150/0x1e5
    [] __vfs_write+0x1b/0x34
    [] vfs_write+0xd8/0x1d1

    Reported-by: Jane Chu
    Cc: Zhen Lei
    Link: https://lore.kernel.org/r/160834570161.1791850.14911670304441510419.stgit@dwillia2-desk3.amr.corp.intel.com
    Signed-off-by: Dan Williams
    Signed-off-by: Sasha Levin

    Dan Williams
     
  • [ Upstream commit 82ef1370b0c1757ab4ce29f34c52b4e93839b0aa ]

    Commit cfd732377221 ("ext4: add prefetching for block allocation
    bitmaps") introduced block bitmap prefetch, and expects to read block
    bitmaps of flex_bg through an IO. However, it seems to ignore the
    value range of s_log_groups_per_flex. In the scenario where the value
    of s_log_groups_per_flex is greater than 27, s_mb_prefetch or
    s_mb_prefetch_limit will overflow, cause a divide zero exception.

    In addition, the logic of calculating nr is also flawed, because the
    size of flexbg is fixed during a single mount, but s_mb_prefetch can
    be modified, which causes nr to fail to meet the value condition of
    [1, flexbg_size].

    To solve this problem, we need to set the upper limit of
    s_mb_prefetch. Since we expect to load block bitmaps of a flex_bg
    through an IO, we can consider determining a reasonable upper limit
    among the IO limit parameters. After consideration, we chose
    BLK_MAX_SEGMENT_SIZE. This is a good choice to solve divide zero
    problem and avoiding performance degradation.

    [ Some minor code simplifications to make the changes easy to follow -- TYT ]

    Reported-by: Tosk Robot
    Signed-off-by: Chunguang Xu
    Reviewed-by: Samuel Liao
    Reviewed-by: Andreas Dilger
    Link: https://lore.kernel.org/r/1607051143-24508-1-git-send-email-brookxu@tencent.com
    Signed-off-by: Theodore Ts'o
    Signed-off-by: Sasha Levin

    Chunguang Xu