From: Peter Zijlstra <peterz@infradead.org>
To: Joel Fernandes <joelaf@google.com>
Cc: linux-kernel@vger.kernel.org, mhocko@kernel.org,
minchan@kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH RFC] ashmem: Fix lockdep RECLAIM_FS false positive
Date: Wed, 7 Feb 2018 09:07:40 +0100 [thread overview]
Message-ID: <20180207080740.GH2269@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20180206004903.224390-1-joelaf@google.com>
On Mon, Feb 05, 2018 at 04:49:03PM -0800, Joel Fernandes wrote:
> [ 2115.359650] -(1)[106:kswapd0]=================================
> [ 2115.359665] -(1)[106:kswapd0][ INFO: inconsistent lock state ]
> [ 2115.359684] -(1)[106:kswapd0]4.9.60+ #2 Tainted: G W O
> [ 2115.359699] -(1)[106:kswapd0]---------------------------------
> [ 2115.359715] -(1)[106:kswapd0]inconsistent {RECLAIM_FS-ON-W} ->
> {IN-RECLAIM_FS-W} usage.
Please don't wrap log output, this is unreadable :/
Also, the output is from an ancient kernel and doesn't match the current
code.
> ---
> drivers/staging/android/ashmem.c | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
> index 372ce9913e6d..7e060f32aaa8 100644
> --- a/drivers/staging/android/ashmem.c
> +++ b/drivers/staging/android/ashmem.c
> @@ -32,6 +32,7 @@
> #include <linux/bitops.h>
> #include <linux/mutex.h>
> #include <linux/shmem_fs.h>
> +#include <linux/sched/mm.h>
> #include "ashmem.h"
>
> #define ASHMEM_NAME_PREFIX "dev/ashmem/"
> @@ -446,8 +447,17 @@ ashmem_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
> if (!(sc->gfp_mask & __GFP_FS))
> return SHRINK_STOP;
>
> - if (!mutex_trylock(&ashmem_mutex))
> + /*
> + * Release reclaim-fs marking since we've already checked GFP_FS, This
> + * will prevent lockdep's reclaim recursion deadlock false positives.
> + * We'll renable it before returning from this function.
> + */
> + fs_reclaim_release(sc->gfp_mask);
> +
> + if (!mutex_trylock(&ashmem_mutex)) {
> + fs_reclaim_acquire(sc->gfp_mask);
> return -1;
> + }
>
> list_for_each_entry_safe(range, next, &ashmem_lru_list, lru) {
> loff_t start = range->pgstart * PAGE_SIZE;
> @@ -464,6 +474,8 @@ ashmem_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
> break;
> }
> mutex_unlock(&ashmem_mutex);
> +
> + fs_reclaim_acquire(sc->gfp_mask);
> return freed;
> }
Yuck that is horrible.. so if GFP_FS was set, we bail, but if GFP_FS
wasn't set, why is fs_reclaim_*() doing anything at all?
That is, __need_fd_reclaim() should return false when !GFP_FS.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2018-02-07 8:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-06 0:49 Joel Fernandes
2018-02-06 22:01 ` Minchan Kim
2018-02-06 22:32 ` Joel Fernandes
2018-02-06 22:55 ` Minchan Kim
2018-02-06 23:16 ` Joel Fernandes
2018-02-07 8:07 ` Peter Zijlstra [this message]
2018-02-07 16:09 ` Joel Fernandes
2018-02-07 16:58 ` Peter Zijlstra
2018-02-07 22:27 ` Joel Fernandes
2018-02-08 0:35 ` NeilBrown
2018-02-08 2:29 ` Joel Fernandes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180207080740.GH2269@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=joelaf@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=minchan@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox