From: Alexey.Brodkin@synopsys.com (Alexey Brodkin)
To: linux-snps-arc@lists.infradead.org
Subject: [PATCH] ARC: Improve handling of fatal signals in do_page_fault()
Date: Thu, 2 Aug 2018 07:08:49 +0000 [thread overview]
Message-ID: <3760e66a23a8ec1c1eb4ad0aaaed06c9d31a3f4f.camel@synopsys.com> (raw)
In-Reply-To: <432f2efe-e7cd-7bf1-40f5-f35f8954f224@synopsys.com>
Hi Vineet,
On Wed, 2018-08-01@12:49 -0700, Vineet Gupta wrote:
> Hi Alexey,
>
> I was finally forced to revisit this for my glibc tst-tls3-malloc deadlock. And
> indeed with this change we don'tsee the deadlock. But see below..
>
>
> > @@ -139,12 +139,16 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
> > */
> > fault = handle_mm_fault(vma, address, flags);
> >
> > - /* If Pagefault was interrupted by SIGKILL, exit page fault "early" */
> > + /* If we need to retry but a fatal signal is pending, handle the
> > + * signal first. We do not need to release the mmap_sem because
> > + * it would already be released in __lock_page_or_retry in
> > + * mm/filemap.c. */
>
> Right and we were already doing that: up_read() was called for !VM_FAULT_RETRY
> meaning we relied on the core mm to do that already for VM_FAULT_RETRY case.
>
> The issue here was additional check for VM_FAULT_ERROR. Typically this is not set
> by handle_mm_fault() meaning for common user faults with signal pending, we were
> not calling up_read, hence the ensuing deadlock.
Right.
> > if (unlikely(fatal_signal_pending(current))) {
> > - if ((fault & VM_FAULT_ERROR) && !(fault & VM_FAULT_RETRY))
> > - up_read(&mm->mmap_sem);
> > - if (user_mode(regs))
> > + if (fault & VM_FAULT_RETRY) {
> > + if (!user_mode(regs))
> > + goto no_context;
>
> Given this code is really tricky, lets only solve one problem with 1 one patch.
Agree.
> > return;
> > + }
> > }
>
> The fault handling is spaghetti mess of checks and more checks and has not really
> been touched since upstreaming. I need to clean it up and essentially rewrite it
> for v4.19
So would you like me to send a re-spin with less changes as discussed above so
we have something better for now and for back-porting to stable branches.
Or you're going to rewrite all that sometime soon yourself?
-Alexey
next prev parent reply other threads:[~2018-08-02 7:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-29 18:20 [PATCH] ARC: Improve handling of fatal signals in do_page_fault() Alexey Brodkin
2018-07-12 8:32 ` Alexey Brodkin
2018-08-01 19:49 ` Vineet Gupta
2018-08-02 7:08 ` Alexey Brodkin [this message]
2018-08-02 21:54 ` Vineet Gupta
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=3760e66a23a8ec1c1eb4ad0aaaed06c9d31a3f4f.camel@synopsys.com \
--to=alexey.brodkin@synopsys.com \
--cc=linux-snps-arc@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