Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\swapfile.c Create Date:2022-07-28 15:16:37
Last Modify:2020-03-17 22:19:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Doing discard actually. After a cluster discard is finished, the cluster* will be added to free cluster list. caller should hold si->lock.

Proto:static void swap_do_scheduled_discard(struct swap_info_struct *si)

Type:void

Parameter:

TypeParameterName
struct swap_info_struct *si
474  info = cluster info. Only for SSD
476  When Not cluster_list_empty( & discard clusters list ) cycle
477  idx = cluster_list_del_first( & discard clusters list , info)
478  spin_unlock( & protect map scan related fields like* swap_map, lowest_bit, highest_bit,* inuse_pages, cluster_next,* cluster_nr, lowest_alloc,* highest_alloc, free/discard cluster* list. other fields are only changed* at swapon/swapoff, so are protected* by swap_lock)
480  swap allocation tell device that a cluster of swap can now be discarded,* to allow the swap device to optimize its wear-levelling.
483  spin_lock( & protect map scan related fields like* swap_map, lowest_bit, highest_bit,* inuse_pages, cluster_next,* cluster_nr, lowest_alloc,* highest_alloc, free/discard cluster* list. other fields are only changed* at swapon/swapoff, so are protected* by swap_lock)
484  ci = lock_cluster(si, idx * SWAPFILE_CLUSTER)
485  __free_cluster(si, idx)
486  memset(vmalloc'ed array of usage counts + idx * SWAPFILE_CLUSTER, 0, SWAPFILE_CLUSTER)
488  unlock_cluster(ci)
Caller
NameDescribe
swap_discard_work
scan_swap_map_try_ssd_clusterTry to get a swap entry from current cpu's swap entry pool (a cluster). This* might involve allocating a new cluster for current CPU too.