From: "Ewan D. Milne" <emilne@redhat.com>
To: Laurence Oberman <loberman@redhat.com>
Cc: Eyal Ben David <bdeyal@gmail.com>,
Johannes Thumshirn <jthumshirn@suse.de>,
dgilbert@interlog.com, linux-scsi@vger.kernel.org
Subject: Re: SG does not ignore dxferp (direct io + mmap)
Date: Wed, 23 Nov 2016 15:22:04 -0500 [thread overview]
Message-ID: <1479932524.28416.43.camel@localhost.localdomain> (raw)
In-Reply-To: <2146476957.2165908.1479927335303.JavaMail.zimbra@redhat.com>
On Wed, 2016-11-23 at 13:55 -0500, Laurence Oberman wrote:
>
> ----- Original Message -----
> > From: "Eyal Ben David" <bdeyal@gmail.com>
> > To: "Ewan D. Milne" <emilne@redhat.com>
> > Cc: "Johannes Thumshirn" <jthumshirn@suse.de>, dgilbert@interlog.com, "Laurence Oberman" <loberman@redhat.com>,
> > linux-scsi@vger.kernel.org
> > Sent: Tuesday, November 22, 2016 3:55:44 PM
> > Subject: Re: SG does not ignore dxferp (direct io + mmap)
> >
> > On Tue, Nov 22, 2016 at 8:30 PM, Ewan D. Milne <emilne@redhat.com> wrote:
> > >
> > > I see the behavior (zero byte) on the 4.4.34, 4.5.7, 4.6.7, and 4.7.10
> > > -stable kernels. But not (of course) on 4.8.10 -stable.
> > >
> > > It doesn't look like the sg driver, might be something in the mmap code?
> >
> >
> > A kernel guy colleague suggested to look at copy_from_user / copy_to_user
> > code.
> > It was changed in 4.8
> >
> > It was OK with 3.13 (Ubuntu 14.04) but from some kernel (prior or equal to
> > 4.4)
> > until 4.7 we see the bug. It was somehow fixed at 4.8.
> >
> > In order to fully understand what happened, there are two changes to find.
> > They might not even be related.
> >
> > Thanks!
> > Eyal
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
>
> So 4.7.9 fails and 4.8.0 works and 4.8.0 is a rebase so we have
>
> [loberman@localhost linux-stable-4.8.10]$ git log --oneline v4.7.9..v4.8 | wc -l
> 14552
>
> No obvious single commits stand out for me for copy_from* or copy_to*
> There is this:
>
> 3fa6c50 mm: optimize copy_page_to/from_iter_iovec
> 6e05050 sh: fix copy_from_user()
> e697100 x86/uaccess: force copy_*_user() to be inlined
>
> I will have to do this the hard way with bisects to figure out which commit addresses this.
>
> Back when I have had enough time to do it.
>
> Thanks
> Laurence
Yes, in fact...
Bisecting between 4.7 and 4.8 to see where the behavior changes so that
the zero byte no longer appears leads to this commit:
---
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[3fa6c507319c897598512da91c010a4ad2ed682c] mm: optimize copy_page_to/from_iter_iovec
---
commit 3fa6c507319c897598512da91c010a4ad2ed682c
Author: Mikulas Patocka <mpatocka@redhat.com>
Date: Thu Jul 28 15:48:50 2016 -0700
mm: optimize copy_page_to/from_iter_iovec
copy_page_to_iter_iovec() and copy_page_from_iter_iovec() copy some data
to userspace or from userspace. These functions have a fast path where
they map a page using kmap_atomic and a slow path where they use kmap.
kmap is slower than kmap_atomic, so the fast path is preferred.
However, on kernels without highmem support, kmap just calls
page_address, so there is no need to avoid kmap. On kernels without
highmem support, the fast path just increases code size (and cache
footprint) and it doesn't improve copy performance in any way.
This patch enables the fast path only if CONFIG_HIGHMEM is defined.
Code size reduced by this patch:
x86 (without highmem) 928
x86-64 960
sparc64 848
alpha 1136
pa-risc 1200
[akpm@linux-foundation.org: use IS_ENABLED(), per Andi]
Link: http://lkml.kernel.org/r/alpine.LRH.2.02.1607221711410.4818@file01.intranet.prod.int.rdu2.redhat.com
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
In other words, this commit made the bad behavior go away in 4.8.
Need to look at this in more detail, it doesn't appear as if this patch
was intended to fix such a problem.
-Ewan
next prev parent reply other threads:[~2016-11-23 20:22 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-20 16:02 SG does not ignore dxferp (direct io + mmap) Eyal Ben David
2016-11-21 0:04 ` Laurence Oberman
2016-11-21 9:23 ` Eyal Ben David
2016-11-21 14:24 ` Ewan D. Milne
2016-11-21 14:54 ` Laurence Oberman
2016-11-21 14:55 ` Eyal Ben David
2016-11-21 15:12 ` Laurence Oberman
2016-11-21 15:15 ` Johannes Thumshirn
2016-11-21 15:44 ` Johannes Thumshirn
2016-11-21 16:04 ` Eyal Ben David
2016-11-21 16:25 ` Ewan D. Milne
2016-11-21 17:34 ` Douglas Gilbert
2016-11-21 18:24 ` Ewan D. Milne
2016-11-22 8:37 ` Johannes Thumshirn
2016-11-22 13:48 ` Eyal Ben David
2016-11-22 15:31 ` Laurence Oberman
2016-11-22 16:00 ` Johannes Thumshirn
2016-11-22 16:28 ` Eyal Ben David
2016-11-22 18:30 ` Ewan D. Milne
2016-11-22 18:46 ` Laurence Oberman
2016-11-22 20:55 ` Eyal Ben David
2016-11-23 18:55 ` Laurence Oberman
2016-11-23 20:22 ` Ewan D. Milne [this message]
2016-11-25 8:07 ` Johannes Thumshirn
2016-11-25 11:20 ` Eyal Ben David
2016-11-25 11:53 ` Johannes Thumshirn
2016-11-25 12:28 ` Johannes Thumshirn
2016-11-25 12:36 ` Eyal Ben David
2016-11-25 14:46 ` Laurence Oberman
2016-11-28 10:30 ` Johannes Thumshirn
2016-11-25 17:56 ` Ewan Milne
2016-11-25 18:01 ` Laurence Oberman
2016-11-30 16:26 ` Ewan D. Milne
2016-12-01 13:40 ` Martin K. Petersen
2016-12-02 12:21 ` Christoph Hellwig
2016-12-02 13:29 ` Ewan D. Milne
2016-12-02 14:10 ` Hannes Reinecke
2016-12-02 14:17 ` Laurence Oberman
2016-12-02 19:29 ` Ewan D. Milne
2016-12-02 20:37 ` Ewan D. Milne
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=1479932524.28416.43.camel@localhost.localdomain \
--to=emilne@redhat.com \
--cc=bdeyal@gmail.com \
--cc=dgilbert@interlog.com \
--cc=jthumshirn@suse.de \
--cc=linux-scsi@vger.kernel.org \
--cc=loberman@redhat.com \
/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).