android_kernel_xiaomi_sm8450/block
Lincheng Yang 6356ed35b9 ANDROID: add vendor hook of add/delete/iterate node for swap_avail_heads
Our Android phones occur Panic as follows:

[77522.303024][ T9734] Call trace:
[77522.303039][ T9734] dump_backtrace.cfi_jt+0x0/0x8
[77522.303052][ T9734] dump_stack_lvl+0xc4/0x140
[77522.303061][ T9734] dump_stack+0x1c/0x2c
[77522.303123][ T9734] mrdump_common_die+0x3a8/0x544 [mrdump]
[77522.303177][ T9734] ipanic_die+0x24/0x38 [mrdump]
[77522.303189][ T9734] die+0x340/0x698
[77522.303199][ T9734] bug_handler+0x48/0x108
[77522.303210][ T9734] brk_handler+0xac/0x1a8
[77522.303221][ T9734] do_debug_exception+0xe0/0x1e0
[77522.303233][ T9734] el1_dbg+0x38/0x54
[77522.303242][ T9734] el1_sync_handler+0x40/0x88
[77522.303255][ T9734] el1_sync+0x8c/0x140
[77522.303264][ T9734] plist_requeue+0xd4/0x110
[77522.303297][ T9734] tran_get_swap_pages+0xc8/0x364 [memfusion]
[77522.303329][ T9734] probe_android_vh_get_swap_page+0x1b4/0x220 [memfusion]
[77522.303342][ T9734] get_swap_page+0x258/0x304
[77522.303352][ T9734] shrink_page_list+0xe00/0x1e0c
[77522.303361][ T9734] shrink_inactive_list+0x2f4/0xac8
[77522.303373][ T9734] shrink_lruvec+0x1a4/0x34c
[77522.303383][ T9734] shrink_node_memcgs+0x84/0x3b0
[77522.303391][ T9734] shrink_node+0x2c4/0x6e4
[77522.303400][ T9734] shrink_zones+0x16c/0x29c
[77522.303410][ T9734] do_try_to_free_pages+0xe4/0x2bc
[77522.303418][ T9734] try_to_free_pages+0x388/0x7b4
[77522.303429][ T9734] __alloc_pages_direct_reclaim+0x88/0x278
[77522.303438][ T9734] __alloc_pages_slowpath+0x464/0xb24
[77522.303447][ T9734] __alloc_pages_nodemask+0x1f4/0x3dc
[77522.303458][ T9734] do_anonymous_page+0x164/0x914
[77522.303466][ T9734] handle_pte_fault+0x15c/0x9f8
[77522.303476][ T9734] ___handle_speculative_fault+0x234/0xe18
[77522.303485][ T9734] __handle_speculative_fault+0x78/0x21c
[77522.303497][ T9734] do_page_fault+0x36c/0x754
[77522.303506][ T9734] do_translation_fault+0x48/0x64
[77522.303514][ T9734] do_mem_abort+0x6c/0x164
[77522.303522][ T9734] el0_da+0x24/0x34
[77522.303531][ T9734] el0_sync_handler+0xc8/0xf0
[77522.303539][ T9734] el0_sync+0x1b4/0x1c0

The analysis shows that when we iterate the swap_avail_heads list, we get
node A, but before we access node A, node A is maybe deleted, and by the time
we actually access node A, it no longer exists, as follows:

            CPU1 thread1                                 CPU2 thread2
plist_for_each_entry_safe()
get si->avail_lists[node] from swap_avail_heads
                                             remove si->avail_lists[node] from swap_avail_heads
plist_requeue(&si->avail_lists[node])
BUG_ON(plist_node_empty(node)); // trigger

Due to when we use vendor hook of get_swap_page, the get_swap_pages() function
is overridden, use our own spin_lock to protect when iterate swap_avail_heads
list, but now use native swap_avail_lock spin_lock protect when the
swap_avail_heads list to add and delete nodes, so there will be concurrent
access.

So add vendor hook of add/delete/iterate node for avail_list, in this way, we
can use our own spin_lock to protect the swap_avail_heads list to add, delete
and iterate node.

Due to enable_swap_info function to call vendor hook of add_to_avail_list,
need first init swap_avail_heads, so also add vendor hook of
swap_avail_heads_init.

Due to the vendor hook of __cgroup_throttle_swaprate need to call
blkcg_schedule_throttle function, so export it also.

Bug: 225795494
Change-Id: I03107cbda6310fa7ae85e41b8cf1fa8225cafe78
Signed-off-by: Lincheng Yang <lincheng.yang@transsion.com>
Suggested-by: Bing Han <bing.han@transsion.com>
2023-09-15 19:58:39 +00:00
..
partitions block: unhash blkdev part inode when the part is deleted 2022-12-08 11:23:59 +01:00
badblocks.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
bfq-cgroup.c block, bfq: fix uaf for bfqq in bic_set_bfqq() 2023-03-17 08:45:14 +01:00
bfq-iosched.c This is the 5.10.175 stable release 2023-03-24 14:42:30 +00:00
bfq-iosched.h bfq: Get rid of __bio_blkcg() usage 2022-06-09 10:21:31 +02:00
bfq-wf2q.c bfq: fix blkio cgroup leakage v4 2020-08-18 07:48:08 -07:00
bio-integrity.c block: bio-integrity: Copy flags when bio_integrity_payload is cloned 2023-03-11 16:39:16 +01:00
bio.c block: fix infinite loop for invalid zone append 2022-08-21 15:15:34 +02:00
blk-cgroup-rwstat.c blk-cgroup: Fix the recursive blkg rwstat 2021-03-30 14:31:48 +02:00
blk-cgroup-rwstat.h blk-cgroup: separate out blkg_rwstat under CONFIG_BLK_CGROUP_RWSTAT 2019-11-07 12:28:13 -07:00
blk-cgroup.c ANDROID: add vendor hook of add/delete/iterate node for swap_avail_heads 2023-09-15 19:58:39 +00:00
blk-core.c blk-mq: release crypto keyslot before reporting I/O complete 2023-05-17 11:47:32 +02:00
blk-crypto-fallback.c Merge commit 382625d0d4 ("Merge tag 'for-5.9/block-20200802' of git://git.kernel.dk/linux-block") into android-mainline 2020-08-06 10:07:17 -07:00
blk-crypto-internal.h blk-mq: release crypto keyslot before reporting I/O complete 2023-05-17 11:47:32 +02:00
blk-crypto.c blk-crypto: make blk_crypto_evict_key() more robust 2023-05-17 11:47:32 +02:00
blk-exec.c block: add a blk_account_io_merge_bio helper 2020-05-27 05:21:23 -06:00
blk-flush.c block: Fix fsync always failed if once failed 2022-01-27 10:54:30 +01:00
blk-integrity.c block: flush the integrity workqueue in blk_integrity_unregister 2021-09-30 10:11:06 +02:00
blk-ioc.c block: remove retry loop in ioc_release_fn() 2020-07-16 10:22:15 -06:00
blk-iocost.c block/blk-iocost (gcc13): keep large values in a new enum 2023-06-14 11:09:33 +02:00
blk-iolatency.c blk-iolatency: Fix inflight count imbalances and IO hangs on offline 2022-06-09 10:21:29 +02:00
blk-ioprio.c FROMGIT: block: Introduce the ioprio rq-qos policy 2021-07-01 22:31:51 -07:00
blk-ioprio.h FROMGIT: block: Introduce the ioprio rq-qos policy 2021-07-01 22:31:51 -07:00
blk-lib.c block: add a bdev_is_partition helper 2020-09-25 08:18:57 -06:00
blk-map.c block-map: add __GFP_ZERO flag for alloc_page in function bio_copy_kern 2022-05-12 12:25:45 +02:00
blk-merge.c blk-mq: release crypto keyslot before reporting I/O complete 2023-05-17 11:47:32 +02:00
blk-mq-cpumap.c blk-mq: remove the calling of local_memory_node() 2020-10-20 07:08:17 -06:00
blk-mq-debugfs-zoned.c
blk-mq-debugfs.c This is the 5.10.137 stable release 2022-08-29 16:53:14 +02:00
blk-mq-debugfs.h blk-mq: no need to check return value of debugfs_create functions 2019-06-13 03:00:30 -06:00
blk-mq-pci.c block: Fix blk_mq_*_map_queues() kernel-doc headers 2019-05-31 15:12:34 -06:00
blk-mq-rdma.c block: Fix blk_mq_*_map_queues() kernel-doc headers 2019-05-31 15:12:34 -06:00
blk-mq-sched.c This is the 5.10.173 stable release 2023-03-22 11:21:35 +00:00
blk-mq-sched.h block-5.10-2020-10-12 2020-10-13 12:12:44 -07:00
blk-mq-sysfs.c blk-mq: fix possible memleak when register 'hctx' failed 2023-01-14 10:16:19 +01:00
blk-mq-tag.c blk-mq: avoid to iterate over stale request 2021-09-30 10:11:05 +02:00
blk-mq-tag.h blk-mq: clear stale request in tags->rq[] before freeing one request pool 2021-07-14 16:55:58 +02:00
blk-mq-virtio.c Merge 4646de87d3 ("Merge tag 'mailbox-v5.7' of git://git.linaro.org/landing-teams/working/fujitsu/integration") into android-mainline 2020-04-04 15:55:11 +02:00
blk-mq.c Merge tag 'android12-5.10.177_r00' into android12-5.10 2023-05-26 15:09:40 +00:00
blk-mq.h blk-mq: grab rq->refcount before calling ->fn in blk_mq_tagset_busy_iter 2021-07-14 16:55:58 +02:00
blk-pm.c scsi: block: pm: Always set request queue runtime active in blk_post_runtime_resume() 2022-01-27 10:54:08 +01:00
blk-pm.h ANDROID: Revert "scsi: block: Do not accept any requests while suspended" 2021-07-13 10:52:35 -07:00
blk-rq-qos.c rq-qos: fix missed wake-ups in rq_qos_throttle try two 2021-07-19 09:45:00 +02:00
blk-rq-qos.h This is the 5.10.50 stable release 2021-07-14 17:35:23 +02:00
blk-settings.c Revert "BACKPORT: bio: limit bio max size" 2021-05-11 09:34:37 -07:00
blk-stat.c blk-stat: make q->stats->lock irqsafe 2020-09-01 16:48:46 -06:00
blk-stat.h
blk-sysfs.c block: don't delete queue kobject before its children 2022-04-08 14:40:00 +02:00
blk-throttle.c blk-throttle: prevent overflow while calculating wait time 2022-10-26 13:25:53 +02:00
blk-timeout.c block: blk-timeout: delete duplicated word 2020-07-31 16:29:47 -06:00
blk-wbt.c blk-wbt: fix that 'rwb->wc' is always set to 1 in wbt_init() 2022-10-30 09:41:19 +01:00
blk-wbt.h blk-wbt: introduce a new disable state to prevent false positive by rwb_enabled() 2021-07-14 16:56:12 +02:00
blk-zoned.c blk-zoned: allow BLKREPORTZONE without CAP_SYS_ADMIN 2021-09-18 13:40:06 +02:00
blk.h block: bump max plugged deferred size from 16 to 32 2021-11-18 14:03:57 +01:00
bounce.c block: make bio_crypt_clone() able to fail 2020-10-05 10:47:43 -06:00
bsg-lib.c block: drop double zeroing 2020-09-23 09:18:13 -06:00
bsg.c Merge 5.10.67 into android12-5.10-lts 2021-09-30 12:21:03 +02:00
cmdline-parser.c
elevator.c This is the 5.10.102 stable release 2022-02-23 12:56:37 +01:00
genhd.c block: Suppress uevent for hidden device when removed 2021-03-30 14:31:52 +02:00
ioctl.c block/compat_ioctl: fix range check in BLKGETSIZE 2022-04-27 13:53:57 +02:00
ioprio.c block: fix ioprio_get(IOPRIO_WHO_PGRP) vs setuid(2) 2021-12-14 11:32:40 +01:00
Kconfig FROMGIT: block: Introduce the ioprio rq-qos policy 2021-07-01 22:31:51 -07:00
Kconfig.iosched FROMGIT: block/mq-deadline: Add cgroup support 2021-07-01 22:31:54 -07:00
keyslot-manager.c blk-crypto: make blk_crypto_evict_key() more robust 2023-05-17 11:47:32 +02:00
kyber-iosched.c FROMGIT: blk-mq: Improve performance of non-mq IO schedulers with multiple HW queues 2021-07-01 22:31:49 -07:00
Makefile FROMGIT: block/mq-deadline: Add cgroup support 2021-07-01 22:31:54 -07:00
mq-deadline-cgroup.c FROMGIT: block/mq-deadline: Add cgroup support 2021-07-01 22:31:54 -07:00
mq-deadline-cgroup.h FROMGIT: block/mq-deadline: Add cgroup support 2021-07-01 22:31:54 -07:00
mq-deadline-main.c UPSTREAM: block: mq-deadline: Fix dd_finish_request() for zoned devices 2023-04-13 18:04:03 +01:00
opal_proto.h block: sed-opal: Change the check condition for regular session validity 2020-03-12 08:00:10 -06:00
scsi_ioctl.c Revert "Revert "iov_iter: transparently handle compat iovecs in import_iovec"" 2020-11-02 09:27:36 +01:00
sed-opal.c block: sed-opal: kmalloc the cmd/resp buffers 2022-11-25 17:45:43 +01:00
t10-pi.c block: Allow t10-pi to be modular 2020-01-06 20:59:04 -07:00