The patch titled Subject: mm/list_lru: introduce list_lru_shrink_walk_irq() has been added to the -mm tree. Its filename is mm-list_lru-introduce-list_lru_shrink_walk_irq.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-list_lru-introduce-list_lru_shrink_walk_irq.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-list_lru-introduce-list_lru_shrink_walk_irq.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> Subject: mm/list_lru: introduce list_lru_shrink_walk_irq() Provide list_lru_shrink_walk_irq() and let it behave like list_lru_walk_one() except that it locks the spinlock with spin_lock_irq(). This is used by scan_shadow_nodes() because its lock nests within the i_pages lock which is acquired with IRQ. This change allows to use proper locking promitives instead hand crafted lock_irq_disable() plus spin_lock(). There is no EXPORT_SYMBOL provided because the current user is in-kernel only. Add list_lru_shrink_walk_irq() which acquires the spinlock with the proper locking primitives. Link: http://lkml.kernel.org/r/20180716111921.5365-5-bigeasy@xxxxxxxxxxxxx Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> Reviewed-by: Vladimir Davydov <vdavydov.dev@xxxxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/list_lru.h | 25 +++++++++++++++++++++++++ mm/list_lru.c | 15 +++++++++++++++ mm/workingset.c | 8 ++------ 3 files changed, 42 insertions(+), 6 deletions(-) diff -puN include/linux/list_lru.h~mm-list_lru-introduce-list_lru_shrink_walk_irq include/linux/list_lru.h --- a/include/linux/list_lru.h~mm-list_lru-introduce-list_lru_shrink_walk_irq +++ a/include/linux/list_lru.h @@ -166,6 +166,23 @@ unsigned long list_lru_walk_one(struct l int nid, struct mem_cgroup *memcg, list_lru_walk_cb isolate, void *cb_arg, unsigned long *nr_to_walk); +/** + * list_lru_walk_one_irq: walk a list_lru, isolating and disposing freeable items. + * @lru: the lru pointer. + * @nid: the node id to scan from. + * @memcg: the cgroup to scan from. + * @isolate: callback function that is resposible for deciding what to do with + * the item currently being scanned + * @cb_arg: opaque type that will be passed to @isolate + * @nr_to_walk: how many items to scan. + * + * Same as @list_lru_walk_one except that the spinlock is acquired with + * spin_lock_irq(). + */ +unsigned long list_lru_walk_one_irq(struct list_lru *lru, + int nid, struct mem_cgroup *memcg, + list_lru_walk_cb isolate, void *cb_arg, + unsigned long *nr_to_walk); unsigned long list_lru_walk_node(struct list_lru *lru, int nid, list_lru_walk_cb isolate, void *cb_arg, unsigned long *nr_to_walk); @@ -179,6 +196,14 @@ list_lru_shrink_walk(struct list_lru *lr } static inline unsigned long +list_lru_shrink_walk_irq(struct list_lru *lru, struct shrink_control *sc, + list_lru_walk_cb isolate, void *cb_arg) +{ + return list_lru_walk_one_irq(lru, sc->nid, sc->memcg, isolate, cb_arg, + &sc->nr_to_scan); +} + +static inline unsigned long list_lru_walk(struct list_lru *lru, list_lru_walk_cb isolate, void *cb_arg, unsigned long nr_to_walk) { diff -puN mm/list_lru.c~mm-list_lru-introduce-list_lru_shrink_walk_irq mm/list_lru.c --- a/mm/list_lru.c~mm-list_lru-introduce-list_lru_shrink_walk_irq +++ a/mm/list_lru.c @@ -282,6 +282,21 @@ list_lru_walk_one(struct list_lru *lru, } EXPORT_SYMBOL_GPL(list_lru_walk_one); +unsigned long +list_lru_walk_one_irq(struct list_lru *lru, int nid, struct mem_cgroup *memcg, + list_lru_walk_cb isolate, void *cb_arg, + unsigned long *nr_to_walk) +{ + struct list_lru_node *nlru = &lru->node[nid]; + unsigned long ret; + + spin_lock_irq(&nlru->lock); + ret = __list_lru_walk_one(nlru, memcg_cache_id(memcg), isolate, cb_arg, + nr_to_walk); + spin_unlock_irq(&nlru->lock); + return ret; +} + unsigned long list_lru_walk_node(struct list_lru *lru, int nid, list_lru_walk_cb isolate, void *cb_arg, unsigned long *nr_to_walk) diff -puN mm/workingset.c~mm-list_lru-introduce-list_lru_shrink_walk_irq mm/workingset.c --- a/mm/workingset.c~mm-list_lru-introduce-list_lru_shrink_walk_irq +++ a/mm/workingset.c @@ -510,13 +510,9 @@ out: static unsigned long scan_shadow_nodes(struct shrinker *shrinker, struct shrink_control *sc) { - unsigned long ret; - /* list_lru lock nests inside the IRQ-safe i_pages lock */ - local_irq_disable(); - ret = list_lru_shrink_walk(&shadow_nodes, sc, shadow_lru_isolate, NULL); - local_irq_enable(); - return ret; + return list_lru_shrink_walk_irq(&shadow_nodes, sc, shadow_lru_isolate, + NULL); } static struct shrinker workingset_shadow_shrinker = { _ Patches currently in -mm which might be from bigeasy@xxxxxxxxxxxxx are ntfs-dont-disable-interrupts-during-kmap_atomic.patch mm-workingset-remove-local_irq_disable-from-count_shadow_nodes.patch mm-workingset-make-shadow_lru_isolate-use-locking-suffix.patch mm-list_lru-use-list_lru_walk_one-in-list_lru_walk_node.patch mm-list_lru-move-locking-from-__list_lru_walk_one-to-its-caller.patch mm-list_lru-pass-struct-list_lru_node-as-an-argument-__list_lru_walk_one.patch mm-list_lru-introduce-list_lru_shrink_walk_irq.patch bdi-use-refcount_t-for-reference-counting-instead-atomic_t.patch userns-use-refcount_t-for-reference-counting-instead-atomic_t.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html