Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965839AbcJ1CHZ convert rfc822-to-8bit (ORCPT ); Thu, 27 Oct 2016 22:07:25 -0400 Received: from mail-bn3nam01on0103.outbound.protection.outlook.com ([104.47.33.103]:59952 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S964894AbcJ1CHY (ORCPT ); Thu, 27 Oct 2016 22:07:24 -0400 From: "Boylston, Brian" To: Thomas Gleixner CC: "linux-nvdimm@ml01.01.org" , "linux-kernel@vger.kernel.org" , "Kani, Toshimitsu" , "Moreno, Oliver" , Ross Zwisler , Ingo Molnar , "H. Peter Anvin" , "x86@kernel.org" , Al Viro , Dan Williams , "boylston@burromesa.net" Subject: RE: [PATCH v2 1/3] introduce memcpy_nocache() Thread-Topic: [PATCH v2 1/3] introduce memcpy_nocache() Thread-Index: AQHSL6D1lerMctkfoESlwuQONZJ2RqC7H5uAgAHxXsA= Date: Fri, 28 Oct 2016 01:52:47 +0000 Message-ID: References: <20161026155021.20892-1-brian.boylston@hpe.com> <20161026155021.20892-2-brian.boylston@hpe.com> In-Reply-To: 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: 3a7ef873-a257-4671-9fa1-08d3fed51e10 x-microsoft-exchange-diagnostics: 1;CS1PR84MB0293;7:Qh0yPqa2ymnIrA4dU5wqzLa2OfccvyBd+PQlbj0HSaCG5FBAH6aNiUoroFQEvxz3kM0FwFxQqGb3kaL5zNbT2ZOg3d611VqauDjZOGtr6NZ/xHsztXyn33ATJQLzy2Ziqi4/i/slxryokAHEE9U7wj/+iFq8aWSnKYt3NZmIYEbjsbUtT/8tejCRKYA4WJ1nh7bdKAUETuz0Kiv+hb8QPij06iJx60Sopc28/kGOLP5tarVZRcBv27xhternCzh03fWpM42z0lV8Fw7V1o1R7NEYgPzB/yhIityEkNaRp7qQXFbUouHRLJB07117NmR20+RrcWdmhEZ0t7gU1S8UhjlvRqCgNZHMiSXgewUEjSA= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CS1PR84MB0293; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(788757137089); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026);SRVR:CS1PR84MB0293;BCL:0;PCL:0;RULEID:;SRVR:CS1PR84MB0293; x-forefront-prvs: 0109D382B0 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(7916002)(199003)(377424004)(189002)(24454002)(54534003)(7416002)(97736004)(122556002)(3280700002)(305945005)(7736002)(4326007)(8936002)(7846002)(4001150100001)(11100500001)(92566002)(81166006)(101416001)(81156014)(106356001)(7696004)(110136003)(50986999)(76176999)(106116001)(2906002)(54356999)(6116002)(99286002)(105586002)(68736007)(74316002)(10400500002)(8676002)(5660300001)(87936001)(9686002)(102836003)(3846002)(33656002)(2900100001)(586003)(3660700001)(66066001)(2950100002)(189998001)(77096005)(5002640100001)(6916009)(86362001);DIR:OUT;SFP:1102;SCL:1;SRVR:CS1PR84MB0293;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="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Oct 2016 01:52:47.4136 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR84MB0293 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3293 Lines: 98 Thomas Gleixner wrote on 2016-10-26: > On Wed, 26 Oct 2016, Brian Boylston wrote: >> --- a/arch/x86/include/asm/string_32.h >> +++ b/arch/x86/include/asm/string_32.h >> @@ -196,6 +196,9 @@ static inline void *__memcpy3d(void *to, const void *from, size_t len) > >> +#define __HAVE_ARCH_MEMCPY_NOCACHE >> +extern void *memcpy_nocache(void *dest, const void *src, size_t count); > > Can we please move that prototype to linux/string.h instead of having it in > both files and just define __HAVE_ARCH_MEMCPY_NOCACHE? And that define can > move into x86/include/asm/string.h. There is no point in duplicating all > that stuff. Yes, sounds good. > >> --- a/arch/x86/include/asm/string_64.h >> +++ b/arch/x86/include/asm/string_64.h >> @@ -51,6 +51,9 @@ extern void *__memcpy(void *to, const void *from, size_t len); > >> +#define __HAVE_ARCH_MEMCPY_NOCACHE >> +extern void *memcpy_nocache(void *dest, const void *src, size_t count) > >> +#ifdef __HAVE_ARCH_MEMCPY_NOCACHE > > You define __HAVE_ARCH_MEMCPY_NOCACHE for both 32 and 64 bit. What is > this #ifdef for ? Now that you raise the question, I'm not sure, and I see that the x86 memcpy() definition isn't similarly wrapped. I can adjust it. > >> +void *memcpy_nocache(void *dest, const void *src, size_t count) >> +{ >> + __copy_from_user_inatomic_nocache(dest, src, count); > > You want to replace a memcpy with this and then use copy from user. Why? > That does not make any sense to me and even if it makes sense for whatever > reason then this wants to be documented and the src argument needs a type > cast to (void __user *).. I agree that the documentation needs improvement. The goal is to memcpy while avoiding the processor cache. Following x86's arch_memcpy_to_pmem(), I was thinking that the user nocache implementation on x86 would work, but I have none of the comments that arch_memcpy_to_pmem() has... > > Further this uses the inatomic variant. Why? Does a memcpy replacement > suddenly require to be called in atomic context? Again, this makes no sense > and lacks any form of comment. The kernel doc below does not say anything > about that. I borrowed the use of the inatomic variant from arch_memcpy_to_pmem(). Perhaps I need to look at memcpy_to_pmem() as suggested by Boaz. > > Neither provides the changelog any useful information which is > complementary to what the patch actually does. > >> +#ifndef __HAVE_ARCH_MEMCPY_NOCACHE >> +/** >> + * memcpy_nocache - Copy one area of memory to another, avoiding the >> + * processor cache if possible > > I'm not sure whether kerneldoc is happy about that line break. Did you > build the docs? > > Make the initial line shorter and explain the functionality in detail > below the arguments > >> + * @dest: Where to copy to >> + * @src: Where to copy from >> + * @count: The size of the area. > > Nit. Can you please make this in tabular form for readability sake? No, I did not try to build the docs. I'll revisit this and your other doc-related feedback. Thanks! Brian > > * @dest: Where to copy to > * @src: Where to copy from > * @count: The size of the area. >> + */ >> +static inline void *memcpy_nocache(void *dest, const void *src, size_t count) >> +{ >> + return memcpy(dest, src, count); >> +} >> +#endif > > Thanks, > > tglx