From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753190AbbC0O7X (ORCPT ); Fri, 27 Mar 2015 10:59:23 -0400 Received: from smtp-out6.electric.net ([192.162.217.187]:59583 "EHLO smtp-out6.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752736AbbC0O7T convert rfc822-to-8bit (ORCPT ); Fri, 27 Mar 2015 10:59:19 -0400 From: David Laight To: "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 15/15] x86/lib/memcpy_64.S: Convert memcpy to ALTERNATIVE_2 macro Thread-Topic: [PATCH v2 15/15] x86/lib/memcpy_64.S: Convert memcpy to ALTERNATIVE_2 macro Thread-Index: AdBoj3plfpcgL1N3ShKNmT8fGQERlwADuxgw Date: Fri, 27 Mar 2015 14:58:32 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6D1CB0DA1C@AcuExch.aculab.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Outbound-IP: 213.249.233.130 X-Env-From: David.Laight@ACULAB.COM X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I've just 'fallen over' this 'optimisation' on a new Intel Atom processor. AFAICT all the copy functions get patched to 'rep movsb'. The problem arises when one of the buffers is uncached, in this case the 'rep movsb' has to perform single byte transfers. So memcpy_toio() and memcpy_fromio() need to use 'rep movsq' otherwise the performance is horrid - especially over PCIe. The same is true for any userspace code that is copying from mmap()ed PCI memory space. In my case I am using copy_to/from_user() to copy directly between PCIe space and a user buffer. While not entirely portable it only has to run on specific hardware where it works. I know which copies in my code are problematic, but there isn't general copy function that will DTRT. (Keep me on the cc list). David