The patch titled Subject: dcache: fix indirectly reclaimable memory accounting has been added to the -mm tree. Its filename is dcache-account-external-names-as-indirectly-reclaimable-memory-fix-2.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/dcache-account-external-names-as-indirectly-reclaimable-memory-fix-2.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/dcache-account-external-names-as-indirectly-reclaimable-memory-fix-2.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: Roman Gushchin <guro@xxxxxx> Subject: dcache: fix indirectly reclaimable memory accounting External names can be released using kfree_rcu() from release_dentry_name_snapshot() and copy_name(), and it will lead to the imbalance in the indirectly reclaimable memory accounting. Fix this by introducing __d_free_external_name() and call it from all release paths. Link: http://lkml.kernel.org/r/20180313125701.7955-1-guro@xxxxxx Signed-off-by: Roman Gushchin <guro@xxxxxx> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Tony Lindgren <tony@xxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/dcache.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff -puN fs/dcache.c~dcache-account-external-names-as-indirectly-reclaimable-memory-fix-2 fs/dcache.c --- a/fs/dcache.c~dcache-account-external-names-as-indirectly-reclaimable-memory-fix-2 +++ a/fs/dcache.c @@ -266,16 +266,24 @@ static void __d_free(struct rcu_head *he kmem_cache_free(dentry_cache, dentry); } -static void __d_free_external(struct rcu_head *head) +static void __d_free_external_name(struct rcu_head *head) { - struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu); - struct external_name *name = external_name(dentry); + struct external_name *name = container_of(head, struct external_name, + u.head); mod_node_page_state(page_pgdat(virt_to_page(name)), NR_INDIRECTLY_RECLAIMABLE_BYTES, -ksize(name)); kfree(name); +} + +static void __d_free_external(struct rcu_head *head) +{ + struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu); + + __d_free_external_name(&external_name(dentry)->u.head); + kmem_cache_free(dentry_cache, dentry); } @@ -307,7 +315,7 @@ void release_dentry_name_snapshot(struct struct external_name *p; p = container_of(name->name, struct external_name, name[0]); if (unlikely(atomic_dec_and_test(&p->u.count))) - kfree_rcu(p, u.head); + call_rcu(&p->u.head, __d_free_external_name); } } EXPORT_SYMBOL(release_dentry_name_snapshot); @@ -2769,7 +2777,7 @@ static void copy_name(struct dentry *den dentry->d_name.hash_len = target->d_name.hash_len; } if (old_name && likely(atomic_dec_and_test(&old_name->u.count))) - kfree_rcu(old_name, u.head); + call_rcu(&old_name->u.head, __d_free_external_name); } static void dentry_lock_for_move(struct dentry *dentry, struct dentry *target) _ Patches currently in -mm which might be from guro@xxxxxx are mm-introduce-nr_indirectly_reclaimable_bytes.patch mm-treat-indirectly-reclaimable-memory-as-available-in-memavailable.patch dcache-account-external-names-as-indirectly-reclaimable-memory.patch dcache-account-external-names-as-indirectly-reclaimable-memory-fix.patch dcache-account-external-names-as-indirectly-reclaimable-memory-fix-2.patch mm-treat-indirectly-reclaimable-memory-as-free-in-overcommit-logic.patch mm-oom-refactor-the-oom_kill_process-function.patch mm-implement-mem_cgroup_scan_tasks-for-the-root-memory-cgroup.patch mm-oom-cgroup-aware-oom-killer.patch mm-oom-introduce-memoryoom_group.patch mm-oom-introduce-memoryoom_group-fix.patch mm-oom-add-cgroup-v2-mount-option-for-cgroup-aware-oom-killer.patch mm-oom-docs-describe-the-cgroup-aware-oom-killer.patch mm-oom-docs-describe-the-cgroup-aware-oom-killer-fix.patch cgroup-list-groupoom-in-cgroup-features.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