From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751133Ab1EREFa (ORCPT ); Wed, 18 May 2011 00:05:30 -0400 Received: from one.firstfloor.org ([213.235.205.2]:44761 "EHLO one.firstfloor.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750755Ab1EREF3 (ORCPT ); Wed, 18 May 2011 00:05:29 -0400 Message-ID: <9317a84b59d0a78a4b8e304ac2da490a.squirrel@www.firstfloor.org> In-Reply-To: <493994B35A117E4F832F97C4719C4C04011505C39D@orsmsx505.amr.corp.intel.com> References: <1305671358-14478-1-git-send-email-fenghua.yu@intel.com> <1305671358-14478-10-git-send-email-fenghua.yu@intel.com> <08d8c27c0495452cad52b62b362dd1d1.squirrel@www.firstfloor.org> <493994B35A117E4F832F97C4719C4C04011505C39D@orsmsx505.amr.corp.intel.com> Date: Wed, 18 May 2011 06:05:26 +0200 Subject: RE: [PATCH 9/9] x86/lib/memset_64.S: Optimize memset by enhanced REP MOVSB/STOSB From: "Andi Kleen" To: "Yu, Fenghua" Cc: "Andi Kleen" , "Ingo Molnar" , "Thomas Gleixner" , "H Peter Anvin" , "Mallick, Asit K" , "Linus Torvalds" , "Avi Kivity" , "Arjan van de Ven" , "Andrew Morton" , "linux-kernel" User-Agent: SquirrelMail/1.4.21 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT X-Priority: 3 (Normal) Importance: Normal Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > Only memcpy are generated by gcc when gcc version >=4.3. Other functions > are defined by kernel lib. Are you sure? AFAIK it supports more. > I would leave gcc optimization for most memcpy cases instead of forcing > memcpy to call the kernel lib memcpy. I hope gcc will catch up and > implement a good enhanced rep movsb/stosb solution soon. If turns out gcc > can not generate good memcpy, it's easy to switch to the patching kernel > lib memcpy. The problem is that gcc can only do that if you tell it to generate code for that. But it has no mechanism to patch in/out different variants for the same binary. So it would only work for a specially optimized kernel for that CPU. I suspect for smaller copies it won't make too much different anyways and gcc's code is probably fine. But gcc won't know that you can do better on large copies, so using a macro would be a way to tell it that. -Andi