From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BE99C433E0 for ; Sat, 13 Jun 2020 18:55:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B1CD6206B7 for ; Sat, 13 Jun 2020 18:55:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1CD6206B7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arndb.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EA9466B0003; Sat, 13 Jun 2020 14:55:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E59A16B0005; Sat, 13 Jun 2020 14:55:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6E726B0006; Sat, 13 Jun 2020 14:55:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0093.hostedemail.com [216.40.44.93]) by kanga.kvack.org (Postfix) with ESMTP id BAC7F6B0003 for ; Sat, 13 Jun 2020 14:55:28 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 6FC651EE6 for ; Sat, 13 Jun 2020 18:55:28 +0000 (UTC) X-FDA: 76925091936.25.swim89_2c0d5b926de7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 46E971804E3A1 for ; Sat, 13 Jun 2020 18:55:28 +0000 (UTC) X-HE-Tag: swim89_2c0d5b926de7 X-Filterd-Recvd-Size: 5877 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.130]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Sat, 13 Jun 2020 18:55:27 +0000 (UTC) Received: from mail-qt1-f179.google.com ([209.85.160.179]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPSA (Nemesis) id 1N3KkM-1ilJIi0Txa-010If0 for ; Sat, 13 Jun 2020 20:55:26 +0200 Received: by mail-qt1-f179.google.com with SMTP id k22so9671987qtm.6 for ; Sat, 13 Jun 2020 11:55:25 -0700 (PDT) X-Gm-Message-State: AOAM533L++X6AIN5R2gDM13fAK53DKyZnkloBAyqDqOLsYHjkNmLWc1P GuAHxoTxJUlw77v2qbKoL3NMFp7h/i3L8euBPqc= X-Google-Smtp-Source: ABdhPJyuxw4tUYCzfqYU9Qk2nyGDIv212AgyB/v6klMsDa80OnzI1YzehoJDFzRkxl5xXtHUS44S4533nKMvd4MIeK8= X-Received: by 2002:ac8:4742:: with SMTP id k2mr8988128qtp.304.1592074524733; Sat, 13 Jun 2020 11:55:24 -0700 (PDT) MIME-Version: 1.0 References: <9e1de19f35e2d5e1d115c9ec3b7c3284b4a4e077.1591885760.git.afzal.mohd.ma@gmail.com> <20200612135538.GA13399@afzalpc> <20200613120432.GA5319@afzalpc> <20200613125126.GE23230@ZenIV.linux.org.uk> <20200613125615.GF23230@ZenIV.linux.org.uk> <20200613134236.GA4086@afzalpc> <20200613153102.GG23230@ZenIV.linux.org.uk> <20200613154118.GH23230@ZenIV.linux.org.uk> <20200613160040.GI23230@ZenIV.linux.org.uk> In-Reply-To: <20200613160040.GI23230@ZenIV.linux.org.uk> From: Arnd Bergmann Date: Sat, 13 Jun 2020 20:55:08 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC 1/3] lib: copy_{from,to}_user using gup & kmap_atomic() To: Al Viro Cc: afzal mohammed , Russell King - ARM Linux admin , Linus Walleij , "linux-kernel@vger.kernel.org" , Linux-MM , Linux ARM , Nicolas Pitre , Catalin Marinas , Will Deacon , "Paul E. McKenney" Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:ZakhuupxeaIJ472XSvelTAl3jUc3nnwOSZOmpbfX7aSOhgLeBed x77D11/5jpkKL7u/kvkVDiKlVvVv/nqN+FDD/qyCoX9WnCo1o24kIQusrO5xZWsrkJHESr6 PgrvPUV5hnjNU1x1hvXwNmi6pOXEGWwMIPrht9u2U2LK/YvO2kxD54pGx0Lz3+Tn+F+oLbo 5rJqy/Z+FJ9DORPiYITyQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:5qhl3MpUbGs=:hV246aQTpIV4gr0mZAZqoZ RJBa4iwq9Fv6RmsnlDfA4XlfamaQBJ3scOS2euQXbonIYOSASgVUcJdJjSx5Qlkn+OGGg7qMF AhZ8z1ImLb0DcC3iuy8u53gsvVbutt3WWUjEt9aSrEPuQh2q4FY8flyCBCy4NStjiZCgrE3u+ i11ZKvjyvCPJBQEll0Il3/d8rpbab5dHThuGMWdcqKgHE7w2Bv3jXyup4hZFX3ML43IWd2hrP eLT29AWeqczWeub85pNP5bn2Ows2UmVOCSW0u8MEcAafw41j37l7j2MBe6o3TOIL81FpU3qL8 66eBqEw8vh+/Zb51iIC8XxyU9QaDiZATadE6u6MjFgxkLD/diLQWXYgxchtusc2688+5VeE67 tikXApc/CtUhjWU7cE4baS0J5K1R1fNiErVSNs9T66xfUB01o09trxKOLZfWT8hp4kshjKsZ5 M6XWorMEJePlL4SFGuTtywE248b7StdL7D2ihEKk5AbmVa7jFBtgfeJdg/b4OtXhfZQtc0zMi 95s29jL+wnS+BUXr9+1X2ZzR4cxU/SgJsBBEIU6nTl68lfVh0+ye5dueuf+e6EAb2n/gEe4P2 zu9py5smyZkA+VgVpOrWm3ytFtTJGnLo5GvcZa/ZWclJvBCW4iCT+94ARzlHoynHfpQudgE/4 +xabDpzui0qnVRA4h+EAbI5bmKzVjSyl87AErX4vkxmAY1iXesPWPevzOOuQ6DH4OOx7YJWh4 F74AYZXU2FlZgDCvE5ViLuuBk2m58DwxplDA9kL4RH5ApOV8pMhXUVEDe2cNmiVHL6W6HFzoY EBKvtw3z7aMktyTKp5neGfFXVmdFcbR3vQGIfxMOO5y+pnQQvw= X-Rspamd-Queue-Id: 46E971804E3A1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Jun 13, 2020 at 6:00 PM Al Viro wrote: > On Sat, Jun 13, 2020 at 04:41:18PM +0100, Al Viro wrote: > > On Sat, Jun 13, 2020 at 04:31:02PM +0100, Al Viro wrote: > > > On Sat, Jun 13, 2020 at 07:12:36PM +0530, afzal mohammed wrote: > > > > Hi, > > > > > > > > On Sat, Jun 13, 2020 at 01:56:15PM +0100, Al Viro wrote: > > > > > > > > > Incidentally, what about get_user()/put_user()? _That_ is where it's > > > > > going to really hurt... > > > > > > > > All other uaccess routines are also planned to be added, posting only > > > > copy_{from,to}_user() was to get early feedback (mentioned in the > > > > cover letter) > > > > > > Sure, but what I mean is that I'd expect the performance loss to be > > > dominated by that, not by copy_from_user/copy_to_user on large amounts > > > of data. Especially on the loads like kernel builds - a lot of stat() > > > and getdents() calls there. > > > > To clarify: stat() means small copy_to_user(), getdents() - a mix of > > put_user() and small copy_to_user(). I would be very surprised if it > > does not hurt a lot. > > PS: there's another fun issue here: > > fill a file with zeroes > mmap that file in two areas, MAP_SHARED > thread 1: > munmap() the first area > fill the second one with 'X' > thread 2: > write() from the first area into pipe > > One could expect that nothing by zeroes gets written into > pipe - it might be a short write() (or -EFAULT), but finding > any 'X' there would be a bug. > > Your patches allow for a possibility of write() doing > get_user_pages_fast(), getting the first page just as > munmap() is about to remove it from page tables and bugger > off. Then thread 1 proceeds with the store (via the > second area). And then thread 2 does memcpy() from that > thing via a kmap_atomic()-created alias, observing the > effect of the store. > > That might or might not be a POSIX violation, but it does > look like a QoI issue... I assume this problem exists in arch/um/kernel/skas/uaccess.c and in Ingo's old x86 VMSPLIT_4G_4G patch as well, right? I guess holding mmap_read_lock() would prevent it but make it even more expensive. Arnd