Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753482AbcJKOAm (ORCPT ); Tue, 11 Oct 2016 10:00:42 -0400 Received: from mail-bn3nam01on0138.outbound.protection.outlook.com ([104.47.33.138]:5245 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751905AbcJKOAk (ORCPT ); Tue, 11 Oct 2016 10:00:40 -0400 X-Greylist: delayed 2071 seconds by postgrey-1.27 at vger.kernel.org; Tue, 11 Oct 2016 10:00:40 EDT From: "Boylston, Brian" To: "Kani, Toshimitsu" , "viro@ZenIV.linux.org.uk" 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: AQHSILN59cTVvSYUSUSa231m+pcopKCdOYEAgASaUYCAAXBw8A== Date: Tue, 11 Oct 2016 13:26:07 +0000 Message-ID: References: <20161007155511.21502-1-brian.boylston@hpe.com> <20161007170842.GQ19539@ZenIV.linux.org.uk> <1476113071.20881.15.camel@hpe.com> In-Reply-To: <1476113071.20881.15.camel@hpe.com> 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=brian.boylston@hpe.com; x-originating-ip: [98.26.140.10] x-ms-office365-filtering-correlation-id: 0a707ff1-a0fe-4dee-b525-08d3f1da289c x-microsoft-exchange-diagnostics: 1;CS1PR84MB0294;7:OHxP7pzg/KwhByltpGkJNs9D5chPcLjIAGFRJ4pbdffVl9MKIdMWDE97XYyLz8ESvDe/eyxbFWYHj2iyPMV19cMtAaC1uV41CE4Aw7ASboKzygESFyMToodSFXBVTV1SvcP23+vASom8PCYkzMQoGYwEceBGEkOoMMqioK/yXjnSXm7QBEKOza93yianOUNXlD1VreWSZ59Yx/cf8+24gRHecsii/r37A6Ew1TFDgeKpIqgZyM5a/pLXamrVzTecxGNTjuWPT3UvUdwdyGULVmm14TuM/IAjuR3aUSFeA7ZoSnrzMywIzlvA10Dmp7H8CBqahDguXWxOTtNihAOQUvt0s017QAFviZidEdJ/5M4= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CS1PR84MB0294; 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:CS1PR84MB0294;BCL:0;PCL:0;RULEID:;SRVR:CS1PR84MB0294; x-forefront-prvs: 00922518D8 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(7916002)(24454002)(199003)(189002)(377424004)(74316002)(106116001)(105586002)(189998001)(87936001)(7846002)(8936002)(7736002)(106356001)(68736007)(6116002)(3846002)(102836003)(586003)(5002640100001)(11100500001)(92566002)(10400500002)(77096005)(3660700001)(3280700002)(2906002)(99286002)(33656002)(101416001)(50986999)(5001770100001)(97736004)(122556002)(66066001)(5660300001)(86362001)(305945005)(2900100001)(4326007)(76176999)(8676002)(2950100002)(81156014)(2501003)(81166006)(9686002)(54356999)(4001150100001)(7696004);DIR:OUT;SFP:1102;SCL:1;SRVR:CS1PR84MB0294;H:CS1PR84MB0119.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" MIME-Version: 1.0 X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Oct 2016 13:26:07.3693 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR84MB0294 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 u9BE0kcI007705 Content-Length: 1279 Lines: 33 Kani, Toshimitsu wrote on 2016-10-10: > 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, Al and Toshi, for the feedback. I'll re-work and come back. Brian