linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: Linux 3.19-rc3
Date: Sat, 10 Jan 2015 13:37:42 +0000	[thread overview]
Message-ID: <20150110133742.GA6999@arm.com> (raw)
In-Reply-To: <CA+55aFw3aGeiWOiKxQaC23VVX_Q9B0cDeZc37vVfK+SJVjGwFw@mail.gmail.com>

Hi Linus, Laszlo,

On Sat, Jan 10, 2015 at 04:39:05AM +0000, Linus Torvalds wrote:
> On Fri, Jan 9, 2015 at 7:29 PM, Laszlo Ersek <lersek@redhat.com> wrote:
> > I've bisected this issue to

Thanks for bisecting this!

> .. commit f045bbb9fa1b ("mmu_gather: fix over-eager
> tlb_flush_mmu_free() calling")
> 
> Hmm. That commit literally just undoes something that commit
> fb7332a9fedf ("mmu_gather: move minimal range calculations into
> generic code") changed, and that was very wrong on x86.
> 
> But arm64 did have very different TLB flushing logic, so there may be
> some ARM64 reason that Will did that change originally, and then he
> forgot that reason when he ack'ed commit f045bbb9fa1b that undid it.
> 
> Will?

I'm wondering if this is now broken in the fullmm case, because tlb->end
will be zero and we won't actually free any of the pages being unmapped
on task exit. Does that sound plausible?

> Before your mmu_gather range calculations commit, we used to have
> 
> In tlb_flush_mmu_tlbonly():
> 
>      tlb->need_flush = 0;
> 
> and in tlb_flush_mmu():
> 
>     if (!tlb->need_flush)
>                 return;
> 
> and your commit changed the rule to be
> 
>     !tlb->need_flush == !tlb->end
> 
> so in the current tree we have
> 
>  In tlb_flush_mmu_tlbonly():
> 
>     __tlb_reset_range(tlb);   // replaces "tlb->need_flush = 0;"
> 
> and in tlb_flush_mmu():
> 
>     if (!tlb->end)    // replaces if (!tlb->need_flush)
>         return;
> 
> so we seem to do exactly the same as 3.18.
> 
> But in your original patch, you moved that "if (!tlb->end) return;"
> check from tlb_flush_mmu() into tlb_flush_mmu_tlbonly(), and that
> apparently is actually needed on arm64. But *why*?

My hunch is that when a task exits and sets fullmm, end is zero and so the
old need_flush cases no longer run. With my original patch, we skipped the
TLB invalidation (since the task is exiting and we will invalidate the TLB
for that ASID before the ASID is reallocated) but still did the freeing.
With the current code, we skip the freeing too, which causes us to leak
pages on exit.

> Also, looking at that commit fb7332a9fedf, I note that some of the
> "need_flush" setting was simply removed. See for example
> arch/powerpc/mm/hugetlbpage.c, and also in mm/memory.c:
> tlb_remove_table(). Is there something non-obvious that sets tlb->end
> there?

I figured that need_flush was already set in these cases, so the additional
setting was redundant:

  https://lkml.org/lkml/2014/11/10/340

> The other need_flush removals seem to all be paired with adding a
> __tlb_adjust_range() call, which will set ->end.
> 
> I'm starting to suspect that you moved the need_flush test into
> tlbonly exactly because you removed that
> 
>         tlb->need_flush = 1;
> 
> from mm/memory.c: tlb_remove_table().
> 
> x86 doesn't care, because x86 doesn't *use* tlb_remove_table(). But
> arm64 does, at least with the RCU freeing.
> 
> Any ideas?

I guess we can either check need_flush as well as end, or we could set both
start == end == some_nonzero_value in __tlb_adjust_range when need_flush is
set. Unfortunately, I'm away from my h/w right now, so it's not easy to test
this.

What do you reckon?

Will

  reply	other threads:[~2015-01-10 13:37 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CA+55aFwsxoyLb9OWMSCL3doe_cz_EQtKsEFCyPUYn_T87pbz0A@mail.gmail.com>
2015-01-08 12:51 ` Linux 3.19-rc3 Mark Langsdorf
2015-01-08 13:45   ` Catalin Marinas
2015-01-08 17:29     ` Mark Langsdorf
2015-01-08 17:34       ` Catalin Marinas
2015-01-08 18:48         ` Mark Langsdorf
2015-01-08 19:21           ` Linus Torvalds
2015-01-09 23:27             ` Catalin Marinas
2015-01-10  0:35               ` Kirill A. Shutemov
2015-01-10  2:27                 ` Linus Torvalds
2015-01-10  2:51                   ` David Lang
2015-01-10  3:06                     ` Linus Torvalds
2015-01-10 10:46                       ` Andreas Mohr
2015-01-10 19:42                         ` Linus Torvalds
2015-01-13  3:33                     ` Rik van Riel
2015-01-13 10:28                       ` Catalin Marinas
2015-01-10  3:17                   ` Tony Luck
2015-01-10 20:16                   ` Arnd Bergmann
2015-01-10 21:00                     ` Linus Torvalds
2015-01-10 21:36                       ` Arnd Bergmann
2015-01-10 21:48                         ` Linus Torvalds
2015-01-12 11:37                         ` Kirill A. Shutemov
2015-01-12 12:18                         ` Catalin Marinas
2015-01-12 13:57                           ` Arnd Bergmann
2015-01-12 14:23                             ` Catalin Marinas
2015-01-12 15:42                               ` Arnd Bergmann
2015-01-12 11:53                     ` Catalin Marinas
2015-01-12 13:15                       ` Arnd Bergmann
2015-01-08 15:08   ` Michal Hocko
2015-01-08 16:37     ` Mark Langsdorf
2015-01-09 15:56       ` Michal Hocko
2015-01-09 12:13   ` Mark Rutland
2015-01-09 14:19     ` Steve Capper
2015-01-09 14:27       ` Mark Langsdorf
2015-01-09 17:57         ` Mark Rutland
2015-01-09 18:37           ` Marc Zyngier
2015-01-09 19:43             ` Will Deacon
2015-01-10  3:29               ` Laszlo Ersek
2015-01-10  4:39                 ` Linus Torvalds
2015-01-10 13:37                   ` Will Deacon [this message]
2015-01-10 19:47                     ` Laszlo Ersek
2015-01-10 19:56                       ` Linus Torvalds
2015-01-10 20:08                         ` Laszlo Ersek
2015-01-10 19:51                     ` Linus Torvalds
2015-01-12 12:42                       ` Will Deacon
2015-01-12 13:22                         ` Mark Langsdorf
2015-01-12 19:03                         ` Dave Hansen
2015-01-12 19:06                         ` Linus Torvalds
2015-01-12 19:07                           ` Linus Torvalds
2015-01-12 19:24                             ` Will Deacon
2015-01-10 15:22                 ` Kyle McMartin

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=20150110133742.GA6999@arm.com \
    --to=will.deacon@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).