From patchwork Thu Sep 2 05:46:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao Xie X-Patchwork-Id: 148451 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o825oOom024761 for ; Thu, 2 Sep 2010 05:51:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753578Ab0IBFrJ (ORCPT ); Thu, 2 Sep 2010 01:47:09 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:60368 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752314Ab0IBFrG (ORCPT ); Thu, 2 Sep 2010 01:47:06 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 977FE17011C; Thu, 2 Sep 2010 13:46:55 +0800 (CST) Received: from fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id o825hUPs022408; Thu, 2 Sep 2010 13:43:30 +0800 Received: from [10.167.141.211] (unknown [10.167.141.211]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id C884214C030; Thu, 2 Sep 2010 13:48:15 +0800 (CST) Message-ID: <4C7F3A31.4070806@cn.fujitsu.com> Date: Thu, 02 Sep 2010 13:46:25 +0800 From: Miao Xie Reply-To: miaox@cn.fujitsu.com User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100413 Fedora/3.0.4-2.fc13 Thunderbird/3.0.4 MIME-Version: 1.0 To: Peter Zijlstra , Ingo Molnar , Andrew Morton , "Theodore Ts'o" , Andreas Dilger , Chris Mason , Yan Zheng CC: Linux Kernel , Linux Btrfs , Linux Ext4 Subject: [PATCH 3/3] x86_64/lib: improve the performance of memmove Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 02 Sep 2010 05:51:25 +0000 (UTC) diff --git a/arch/x86/lib/memmove_64.c b/arch/x86/lib/memmove_64.c index 0a33909..3640232 100644 --- a/arch/x86/lib/memmove_64.c +++ b/arch/x86/lib/memmove_64.c @@ -4,17 +4,17 @@ #define _STRING_C #include #include +#include #undef memmove void *memmove(void *dest, const void *src, size_t count) { - if (dest < src) { + if (dest - src >= count) { /* *Unsigned* compare! */ return memcpy(dest, src, count); } else { - char *p = dest + count; - const char *s = src + count; - while (count--) - *--p = *--s; + unsigned long dstp = (unsigned long)dest; + unsigned long srcp = (unsigned long)src; + mem_copy_bwd(dstp, srcp, count); } return dest; }