Skip to content

Commit da0c025

Browse files
ryncsnakpm00
authored andcommitted
mm/list_lru: simplify the list_lru walk callback function
Now isolation no longer takes the list_lru global node lock, only use the per-cgroup lock instead. And this lock is inside the list_lru_one being walked, no longer needed to pass the lock explicitly. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Kairui Song <[email protected]> Cc: Chengming Zhou <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Muchun Song <[email protected]> Cc: Qi Zheng <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: Waiman Long <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent fb56fdf commit da0c025

File tree

13 files changed

+25
-33
lines changed

13 files changed

+25
-33
lines changed

drivers/android/binder_alloc.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,17 +1047,16 @@ void binder_alloc_vma_close(struct binder_alloc *alloc)
10471047
/**
10481048
* binder_alloc_free_page() - shrinker callback to free pages
10491049
* @item: item to free
1050-
* @lock: lock protecting the item
1050+
* @lru: list_lru instance of the item
10511051
* @cb_arg: callback argument
10521052
*
10531053
* Called from list_lru_walk() in binder_shrink_scan() to free
10541054
* up pages when the system is under memory pressure.
10551055
*/
10561056
enum lru_status binder_alloc_free_page(struct list_head *item,
10571057
struct list_lru_one *lru,
1058-
spinlock_t *lock,
10591058
void *cb_arg)
1060-
__must_hold(lock)
1059+
__must_hold(&lru->lock)
10611060
{
10621061
struct binder_lru_page *page = container_of(item, typeof(*page), lru);
10631062
struct binder_alloc *alloc = page->alloc;
@@ -1092,7 +1091,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item,
10921091

10931092
list_lru_isolate(lru, item);
10941093
spin_unlock(&alloc->lock);
1095-
spin_unlock(lock);
1094+
spin_unlock(&lru->lock);
10961095

10971096
if (vma) {
10981097
trace_binder_unmap_user_start(alloc, index);

drivers/android/binder_alloc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static inline void binder_selftest_alloc(struct binder_alloc *alloc) {}
118118
#endif
119119
enum lru_status binder_alloc_free_page(struct list_head *item,
120120
struct list_lru_one *lru,
121-
spinlock_t *lock, void *cb_arg);
121+
void *cb_arg);
122122
struct binder_buffer *binder_alloc_new_buf(struct binder_alloc *alloc,
123123
size_t data_size,
124124
size_t offsets_size,

fs/dcache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ void shrink_dentry_list(struct list_head *list)
10891089
}
10901090

10911091
static enum lru_status dentry_lru_isolate(struct list_head *item,
1092-
struct list_lru_one *lru, spinlock_t *lru_lock, void *arg)
1092+
struct list_lru_one *lru, void *arg)
10931093
{
10941094
struct list_head *freeable = arg;
10951095
struct dentry *dentry = container_of(item, struct dentry, d_lru);
@@ -1170,7 +1170,7 @@ long prune_dcache_sb(struct super_block *sb, struct shrink_control *sc)
11701170
}
11711171

11721172
static enum lru_status dentry_lru_isolate_shrink(struct list_head *item,
1173-
struct list_lru_one *lru, spinlock_t *lru_lock, void *arg)
1173+
struct list_lru_one *lru, void *arg)
11741174
{
11751175
struct list_head *freeable = arg;
11761176
struct dentry *dentry = container_of(item, struct dentry, d_lru);

fs/gfs2/quota.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static void gfs2_qd_list_dispose(struct list_head *list)
149149

150150

151151
static enum lru_status gfs2_qd_isolate(struct list_head *item,
152-
struct list_lru_one *lru, spinlock_t *lru_lock, void *arg)
152+
struct list_lru_one *lru, void *arg)
153153
{
154154
struct list_head *dispose = arg;
155155
struct gfs2_quota_data *qd =

fs/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ void invalidate_inodes(struct super_block *sb)
881881
* with this flag set because they are the inodes that are out of order.
882882
*/
883883
static enum lru_status inode_lru_isolate(struct list_head *item,
884-
struct list_lru_one *lru, spinlock_t *lru_lock, void *arg)
884+
struct list_lru_one *lru, void *arg)
885885
{
886886
struct list_head *freeable = arg;
887887
struct inode *inode = container_of(item, struct inode, i_lru);
@@ -923,7 +923,7 @@ static enum lru_status inode_lru_isolate(struct list_head *item,
923923
if (inode_has_buffers(inode) || !mapping_empty(&inode->i_data)) {
924924
inode_pin_lru_isolating(inode);
925925
spin_unlock(&inode->i_lock);
926-
spin_unlock(lru_lock);
926+
spin_unlock(&lru->lock);
927927
if (remove_inode_buffers(inode)) {
928928
unsigned long reap;
929929
reap = invalidate_mapping_pages(&inode->i_data, 0, -1);

fs/nfs/nfs42xattr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ static struct shrinker *nfs4_xattr_large_entry_shrinker;
802802

803803
static enum lru_status
804804
cache_lru_isolate(struct list_head *item,
805-
struct list_lru_one *lru, spinlock_t *lru_lock, void *arg)
805+
struct list_lru_one *lru, void *arg)
806806
{
807807
struct list_head *dispose = arg;
808808
struct inode *inode;
@@ -867,7 +867,7 @@ nfs4_xattr_cache_count(struct shrinker *shrink, struct shrink_control *sc)
867867

868868
static enum lru_status
869869
entry_lru_isolate(struct list_head *item,
870-
struct list_lru_one *lru, spinlock_t *lru_lock, void *arg)
870+
struct list_lru_one *lru, void *arg)
871871
{
872872
struct list_head *dispose = arg;
873873
struct nfs4_xattr_bucket *bucket;

fs/nfsd/filecache.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ void nfsd_file_net_dispose(struct nfsd_net *nn)
487487
* nfsd_file_lru_cb - Examine an entry on the LRU list
488488
* @item: LRU entry to examine
489489
* @lru: controlling LRU
490-
* @lock: LRU list lock (unused)
491490
* @arg: dispose list
492491
*
493492
* Return values:
@@ -497,9 +496,7 @@ void nfsd_file_net_dispose(struct nfsd_net *nn)
497496
*/
498497
static enum lru_status
499498
nfsd_file_lru_cb(struct list_head *item, struct list_lru_one *lru,
500-
spinlock_t *lock, void *arg)
501-
__releases(lock)
502-
__acquires(lock)
499+
void *arg)
503500
{
504501
struct list_head *head = arg;
505502
struct nfsd_file *nf = list_entry(item, struct nfsd_file, nf_lru);

fs/xfs/xfs_buf.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,7 +1857,6 @@ static enum lru_status
18571857
xfs_buftarg_drain_rele(
18581858
struct list_head *item,
18591859
struct list_lru_one *lru,
1860-
spinlock_t *lru_lock,
18611860
void *arg)
18621861

18631862
{
@@ -1956,7 +1955,6 @@ static enum lru_status
19561955
xfs_buftarg_isolate(
19571956
struct list_head *item,
19581957
struct list_lru_one *lru,
1959-
spinlock_t *lru_lock,
19601958
void *arg)
19611959
{
19621960
struct xfs_buf *bp = container_of(item, struct xfs_buf, b_lru);

fs/xfs/xfs_qm.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,8 @@ static enum lru_status
412412
xfs_qm_dquot_isolate(
413413
struct list_head *item,
414414
struct list_lru_one *lru,
415-
spinlock_t *lru_lock,
416415
void *arg)
417-
__releases(lru_lock) __acquires(lru_lock)
416+
__releases(&lru->lock) __acquires(&lru->lock)
418417
{
419418
struct xfs_dquot *dqp = container_of(item,
420419
struct xfs_dquot, q_lru);
@@ -460,7 +459,7 @@ xfs_qm_dquot_isolate(
460459
trace_xfs_dqreclaim_dirty(dqp);
461460

462461
/* we have to drop the LRU lock to flush the dquot */
463-
spin_unlock(lru_lock);
462+
spin_unlock(&lru->lock);
464463

465464
error = xfs_qm_dqflush(dqp, &bp);
466465
if (error)

include/linux/list_lru.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void list_lru_isolate_move(struct list_lru_one *list, struct list_head *item,
184184
struct list_head *head);
185185

186186
typedef enum lru_status (*list_lru_walk_cb)(struct list_head *item,
187-
struct list_lru_one *list, spinlock_t *lock, void *cb_arg);
187+
struct list_lru_one *list, void *cb_arg);
188188

189189
/**
190190
* list_lru_walk_one: walk a @lru, isolating and disposing freeable items.

0 commit comments

Comments
 (0)