43
43
* statistics
44
44
**********************************/
45
45
/* The number of compressed pages currently stored in zswap */
46
- atomic_t zswap_stored_pages = ATOMIC_INIT (0 );
46
+ atomic_long_t zswap_stored_pages = ATOMIC_INIT (0 );
47
47
48
48
/*
49
49
* The statistics below are not protected from concurrent access for
@@ -802,7 +802,7 @@ static void zswap_entry_free(struct zswap_entry *entry)
802
802
obj_cgroup_put (entry -> objcg );
803
803
}
804
804
zswap_entry_cache_free (entry );
805
- atomic_dec (& zswap_stored_pages );
805
+ atomic_long_dec (& zswap_stored_pages );
806
806
}
807
807
808
808
/*********************************
@@ -1233,7 +1233,7 @@ static unsigned long zswap_shrinker_count(struct shrinker *shrinker,
1233
1233
nr_stored = memcg_page_state (memcg , MEMCG_ZSWAPPED );
1234
1234
} else {
1235
1235
nr_backing = zswap_total_pages ();
1236
- nr_stored = atomic_read (& zswap_stored_pages );
1236
+ nr_stored = atomic_long_read (& zswap_stored_pages );
1237
1237
}
1238
1238
1239
1239
if (!nr_stored )
@@ -1502,7 +1502,7 @@ bool zswap_store(struct folio *folio)
1502
1502
}
1503
1503
1504
1504
/* update stats */
1505
- atomic_inc (& zswap_stored_pages );
1505
+ atomic_long_inc (& zswap_stored_pages );
1506
1506
count_vm_event (ZSWPOUT );
1507
1507
1508
1508
return true;
@@ -1654,6 +1654,13 @@ static int debugfs_get_total_size(void *data, u64 *val)
1654
1654
}
1655
1655
DEFINE_DEBUGFS_ATTRIBUTE (total_size_fops , debugfs_get_total_size , NULL , "%llu\n" );
1656
1656
1657
+ static int debugfs_get_stored_pages (void * data , u64 * val )
1658
+ {
1659
+ * val = atomic_long_read (& zswap_stored_pages );
1660
+ return 0 ;
1661
+ }
1662
+ DEFINE_DEBUGFS_ATTRIBUTE (stored_pages_fops , debugfs_get_stored_pages , NULL , "%llu\n" );
1663
+
1657
1664
static int zswap_debugfs_init (void )
1658
1665
{
1659
1666
if (!debugfs_initialized ())
@@ -1677,8 +1684,8 @@ static int zswap_debugfs_init(void)
1677
1684
zswap_debugfs_root , & zswap_written_back_pages );
1678
1685
debugfs_create_file ("pool_total_size" , 0444 ,
1679
1686
zswap_debugfs_root , NULL , & total_size_fops );
1680
- debugfs_create_atomic_t ("stored_pages" , 0444 ,
1681
- zswap_debugfs_root , & zswap_stored_pages );
1687
+ debugfs_create_file ("stored_pages" , 0444 ,
1688
+ zswap_debugfs_root , NULL , & stored_pages_fops );
1682
1689
1683
1690
return 0 ;
1684
1691
}
0 commit comments