Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp435639ybt; Sat, 13 Jun 2020 09:05:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyub9Kgwycec50/lWvGUn3nw12dpbXwsWb6V25Y95xYdUSSZC0sUS2MW2NqWFmUhQ14z9ea X-Received: by 2002:a17:906:3653:: with SMTP id r19mr11540980ejb.246.1592064313606; Sat, 13 Jun 2020 09:05:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592064313; cv=none; d=google.com; s=arc-20160816; b=Qd+Oxng+dX2oSw4fWF265GFjASyBq492s+xErVOncNVadLwOinHWnNaErauqkrhRJN D/i6TKmSxBF2lngeDUbwVeGL1Vr3uI/hJA9L1aSAoV27X8T/ou81or/NzQNTwvBElloa 0D0Czhj7jrg9t1gknunAnK8t2j9qv/i5Kk1oBRnPqVgzwV8CeaX+FjhWEUmQ0S3i0uDb t+LnQbZX2dRpavIyJJ0hF/NoYQjbwI1tQRIk6WTuD8FGyaUMJxOZI9Kxt8tnBihlcIYB rgnb1XRJXp4sKet3C83AbE+POJ0+K5vbOoHwr06mog98oyOT/pnVLTZkMVpsqoj3IZwN LIgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=hcHF+8Acj4ThRLkxTaJQirlj41XPcKsFbuCbXrFZHZE=; b=oN6b/dxeh1am6kyWCbFqC94u5AzsJiyr/D/arRqxg4EerYok2gynaQzb6Hsu/Gyq4x leu3243Gd+sRA3rxF42r+Kkyezogg50N8pE5a9K85aaZfbqavwmqIUdejV3Nl69TqRWC 8zX8nxvz9TpjHueGPIqsGg/hRDXaY6nX13EmyZzcaHj/8yJy+BS9bj/Hz82H3Via7zvp b+ry20Gfms0fOnCc8SLGKbK81EiZ4I+JrRgr6NNXU9/HhRLEnJtufLljySYYsdXawBVX /wv5IzFKwZRFc7vB9vS7nTRpIXAHzhgXkTj+i51gpqgmHqXJ4xSq/N7jDcoSAUs0HmwY /2lg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si5902542edb.116.2020.06.13.09.04.51; Sat, 13 Jun 2020 09:05:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726489AbgFMQBS (ORCPT + 99 others); Sat, 13 Jun 2020 12:01:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726378AbgFMQBS (ORCPT ); Sat, 13 Jun 2020 12:01:18 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB847C03E96F for ; Sat, 13 Jun 2020 09:01:16 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.93 #3 (Red Hat Linux)) id 1jk8aG-008Em7-6w; Sat, 13 Jun 2020 16:00:40 +0000 Date: Sat, 13 Jun 2020 17:00:40 +0100 From: Al Viro To: afzal mohammed Cc: Arnd Bergmann , 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" Subject: Re: [RFC 1/3] lib: copy_{from,to}_user using gup & kmap_atomic() Message-ID: <20200613160040.GI23230@ZenIV.linux.org.uk> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200613154118.GH23230@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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...