Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753164AbcJJRCl (ORCPT ); Mon, 10 Oct 2016 13:02:41 -0400 Received: from mail-cys01nam02on0096.outbound.protection.outlook.com ([104.47.37.96]:10425 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752245AbcJJRCi (ORCPT ); Mon, 10 Oct 2016 13:02:38 -0400 X-Greylist: delayed 3692 seconds by postgrey-1.27 at vger.kernel.org; Mon, 10 Oct 2016 13:02:38 EDT From: "Kani, Toshimitsu" To: "viro@ZenIV.linux.org.uk" , "Boylston, Brian" CC: "linux-kernel@vger.kernel.org" , "tglx@linutronix.de" , "x86@kernel.org" , "dan.j.williams@intel.com" , "hpa@zytor.com" , "linux-nvdimm@lists.01.org" , "Moreno, Oliver" , "mingo@redhat.com" , "ross.zwisler@linux.intel.com" Subject: Re: [PATCH] use a nocache copy for bvecs in copy_from_iter_nocache() Thread-Topic: [PATCH] use a nocache copy for bvecs in copy_from_iter_nocache() Thread-Index: AQHSILN+aItLHflkh0KwEo1pStmsFKCdOYEAgASZ44A= Date: Mon, 10 Oct 2016 15:26:03 +0000 Message-ID: <1476113071.20881.15.camel@hpe.com> References: <20161007155511.21502-1-brian.boylston@hpe.com> <20161007170842.GQ19539@ZenIV.linux.org.uk> In-Reply-To: <20161007170842.GQ19539@ZenIV.linux.org.uk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=toshi.kani@hpe.com; x-originating-ip: [15.219.163.9] x-ms-office365-filtering-correlation-id: fa36e06b-09b1-474c-af7c-08d3f121bf75 x-microsoft-exchange-diagnostics: 1;CS1PR84MB0295;7:F7s99/g1BQl1Ehc58JaT8t18ilxLVgu0C9N5IIIVqxQRx5b7kdwkYvhHDa4sKgLCPdSRfX92i16roi9ScdlEzkxW+fnB4bZkI/c4jjLXLHrIYmNNZViBMhqeILI8PcdEJmwqTz8svC8eY0rTCBJVVRyED8ujrolWF8V8HHqLFEA2isPRpVhXvEXm+rut3to3Vg4a62wxMAa4YcYrtPQHc4KhqLj6vIr+FDQDUpVIiQbNEpZw/sHcnqxrocfwbZiRo4/3l+LA1K3TwqbjOg1S0Yqsa/gJPwlo025FqVj+fRscU9NtZjTY0MnlQPd9blgLeMwxjjTLqspcAntq/1QxcUjci7ocQxZhoqnfG1KbkG0= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CS1PR84MB0295; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026);SRVR:CS1PR84MB0295;BCL:0;PCL:0;RULEID:;SRVR:CS1PR84MB0295; x-forefront-prvs: 0091C8F1EB x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(7916002)(199003)(377424004)(24454002)(189002)(2501003)(101416001)(105586002)(3660700001)(66066001)(102836003)(6116002)(3846002)(81166006)(81156014)(8676002)(77096005)(2950100002)(99286002)(92566002)(106356001)(586003)(106116001)(6636002)(122556002)(33646002)(54356999)(50986999)(76176999)(10400500002)(7846002)(305945005)(7736002)(2906002)(3280700002)(5001770100001)(97736004)(5660300001)(4326007)(87936001)(5002640100001)(8936002)(11100500001)(68736007)(2900100001)(103116003)(189998001)(36756003)(86362001);DIR:OUT;SFP:1102;SCL:1;SRVR:CS1PR84MB0295;H:CS1PR84MB0005.NAMPRD84.PROD.OUTLOOK.COM;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: <49938475457C2849B27452052CD4DCE6@NAMPRD84.PROD.OUTLOOK.COM> MIME-Version: 1.0 X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Oct 2016 15:26:03.5545 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR84MB0295 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id u9AH2k6v003982 Content-Length: 1160 Lines: 30 On Fri, 2016-10-07 at 18:08 +0100, Al Viro wrote: > On Fri, Oct 07, 2016 at 10:55:11AM -0500, Brian Boylston wrote: > > > > copy_from_iter_nocache() is only "nocache" for iovecs.  Enhance it > > to also use a nocache copy for bvecs.  This improves performance by > > 2-3X when splice()ing to a file in a DAX-mounted, pmem-backed file > > system. > > > > > +static void memcpy_from_page_nocache(char *to, struct page *page, > > size_t offset, size_t len) > > +{ > > + char *from = kmap_atomic(page); > > + __copy_from_user_inatomic_nocache(to, from, len); > > + kunmap_atomic(from); > > +} > > At the very least, it will blow up on any architecture with split > userland and kernel MMU contexts.  You *can't* feed a kernel pointer > to things like that and expect it to work.  At the very least, you > need to add memcpy_nocache() and have it default to memcpy(), with > non-dummy version on x86.  And use _that_, rather than messing with > __copy_from_user_inatomic_nocache() Good point.  I think we can add memcpy_nocache() which calls __copy_from_user_inatomic_nocache() on x86 and defauts to memcpy() on other architectures. Thanks, -Toshi