Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\zswap.c Create Date:2022-07-28 15:23:18
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:attempts to compress and store an single page

Proto:static int zswap_frontswap_store(unsigned type, unsigned long offset, struct page *page)

Type:int

Parameter:

TypeParameterName
unsignedtype
unsigned longoffset
struct page *page
990  tree = zswap_trees[type]
994  dlen = PAGE_SIZE
998  struct zswap_header zhdr = {swpentry = Store a type+offset into a swp_entry_t in an arch-independent format}
1002  If PageHuge() only returns true for hugetlbfs pages, but not for* normal or transparent huge pages.* PageTransHuge() returns true for both transparent huge and* hugetlbfs pages, but not normal pages. PageTransHuge() can only be Then
1003  ret = -EINVAL
1004  Go to reject
1007  If Not Enable/disable zswap (disabled by default) || Not tree Then
1008  ret = -ENODEV
1009  Go to reject
1013  If zswap_is_full() Then
1014  Pool limit was hit (see zswap_max_pool_percent) ++
1015  If zswap_shrink() Then
1017  ret = -ENOMEM
1018  Go to reject
1025  If zswap_is_full() Then
1026  ret = -ENOMEM
1027  Go to reject
1032  entry = zswap_entry_cache_alloc(GFP_KERNEL)
1033  If Not entry Then
1034  Store failed because the entry metadata could not be allocated (rare) ++
1035  ret = -ENOMEM
1036  Go to reject
1039  If Enable/disable handling same-value filled pages (enabled by default) Then
1040  src = kmap_atomic(page)
1041  If zswap_is_page_same_filled(src, & value) Then
1047  Go to insert_entry
1049  Prevent people trying to call kunmap_atomic() as if it were kunmap()* kunmap_atomic() should get the return value of kmap_atomic, not the page.(src)
1053  the zswap_pool the entry's data is in = zswap_pool_current_get()
1054  If Not the zswap_pool the entry's data is in Then
1055  ret = -EINVAL
1056  Go to freepage
1060  dst = Must be an lvalue. Since @var must be a simple identifier,* we force a syntax error here if it isn't.(per-cpu code)
1061  tfm = get_cpu_ptr(tfm)
1062  src = kmap_atomic(page)
1063  ret = crypto_comp_compress(tfm, src, PAGE_SIZE, dst, & dlen)
1064  Prevent people trying to call kunmap_atomic() as if it were kunmap()* kunmap_atomic() should get the return value of kmap_atomic, not the page.(src)
1065  put_cpu_ptr(tfm)
1066  If ret Then
1067  ret = -EINVAL
1068  Go to put_dstmem
1072  hlen = If zpool_evictable(zpool) Then size of zhdr Else 0
1073  gfp = __GFP_NORETRY | DOC: Action modifiers* Action modifiers* ~~~~~~~~~~~~~~~~* %__GFP_NOWARN suppresses allocation failure reports.* %__GFP_COMP address compound page metadata.* %__GFP_ZERO returns a zeroed page on success. | kswapd can wake
1074  If zpool_malloc_support_movable(zpool) Then gfp |= __GFP_HIGHMEM | ZONE_MOVABLE allowed
1076  ret = zpool_malloc(zpool, hlen + dlen, gfp, & handle)
1077  If ret == -ENOSPC Then
1078  Compressed page was too big for the allocator to (optimally) store ++
1079  Go to put_dstmem
1081  If ret Then
1082  Store failed because underlying allocator could not get memory ++
1083  Go to put_dstmem
1085  buf = zpool_map_handle(zpool, handle, rmal read-write mapping )
1086  No 3D Now!(buf, & zhdr, hlen)
1087  No 3D Now!(buf + hlen, dst, dlen)
1088  zpool_unmap_handle(zpool, handle)
1089  The weird & is necessary because sparse considers (void)(var) to be* a direct dereference of percpu variable (var).(per-cpu code)
1092  the swap offset for the entry. Index into the red-black tree. = offset
1093  zpool allocation handle that stores the compressed page data = handle
1094  the length in bytes of the compressed page data. Needed during = dlen
1096  insert_entry :
1098  spin_lock( & lock)
1099  Do
1100  ret = In the case that a entry with the same offset is found, a pointer to* the existing entry is stored in dupentry and the function returns -EEXIST
1101  If ret == -EEXIST Then
1107  When ret == -EEXIST cycle
1108  spin_unlock( & lock)
1111  atomic_inc( & The number of compressed pages currently stored in zswap )
1112  zswap_update_total_size()
1114  Return 0
1116  put_dstmem :
1117  The weird & is necessary because sparse considers (void)(var) to be* a direct dereference of percpu variable (var).(per-cpu code)
1118  zswap_pool_put( the zswap_pool the entry's data is in)
1119  freepage :
1120  zswap_entry_cache_free(entry)
1121  reject :
1122  Return ret