From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from gprs189-60.eurotel.cz ([160.218.189.60] helo=spitz.ucw.cz) by canuck.infradead.org with esmtp (Exim 4.63 #1 (Red Hat Linux)) id 1HyZG7-0001NQ-Un for kexec@lists.infradead.org; Wed, 13 Jun 2007 16:16:09 -0400 Date: Wed, 13 Jun 2007 19:46:54 +0000 From: Pavel Machek Subject: Re: [KJ PATCH] Replacing memcpy(dest, src, PAGE_SIZE) with copy_page(dest, src) in arch/i386/kernel/machine_kexec.c Message-ID: <20070613194653.GA8273@ucw.cz> References: <1181616342.2282.8.camel@shani-win> <466ECF37.6040303@zytor.com> Mime-Version: 1.0 Content-Disposition: inline In-Reply-To: <466ECF37.6040303@zytor.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: kexec-bounces@lists.infradead.org Errors-To: kexec-bounces+dwmw2=infradead.org+dwmw2=infradead.org@lists.infradead.org To: "H. Peter Anvin" Cc: linux-kernel@vger.kernel.org, kernel-janitors@lists.osdl.org, kexec@lists.infradead.org, "Eric W. Biederman" , Shani Moideen Hi! > >> Replacing memcpy(dest,src,PAGE_SIZE) with copy_page(dest,src) in > >> arch/i386/kernel/machine_kexec.c. > > > > Please no. > > > > People get creative in copy_page (especially mmx_copy_page), > > and this code path need something simple and stupid, that > > will work every time, especially when things are messed up > > elsewhere. > > memcpy() is pretty creative, too. If you want something really dumb and > robust, you should probably create an inline: > > /* > * Eric sez: his code path need something simple and stupid, that > * will work every time, especially when things are messed up > * elsewhere. > */ > static inline void braindead_copy_page(void *dst, void *src) > { > unsigned long ctr = PAGE_SIZE >> 2; > > asm volatile("cld; rep; movsl" > : "+D" (dst), "+S" (src), "+c" (ctr) > : : "memory"); > } > > (FWIW, the "cld" is supposed to be redundant, as DF=0 is supposed to be > guaranteed by the ABI.) Actually, swsusp would be second user for that. We currently do it with for loop in C, but... ...well, we'd probably need it for i386, ppc, x86-64, ppc64 and maybe arm... (But you should probably add a comment into kexec ) Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pavel Machek Date: Wed, 13 Jun 2007 19:46:54 +0000 Subject: [KJ] Re: [KJ PATCH] Replacing memcpy(dest, src, Message-Id: <20070613194653.GA8273@ucw.cz> List-Id: References: <1181616342.2282.8.camel@shani-win> <466ECF37.6040303@zytor.com> In-Reply-To: <466ECF37.6040303@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: "H. Peter Anvin" Cc: "Eric W. Biederman" , Shani Moideen , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@lists.osdl.org Hi! > >> Replacing memcpy(dest,src,PAGE_SIZE) with copy_page(dest,src) in > >> arch/i386/kernel/machine_kexec.c. > > > > Please no. > > > > People get creative in copy_page (especially mmx_copy_page), > > and this code path need something simple and stupid, that > > will work every time, especially when things are messed up > > elsewhere. > > memcpy() is pretty creative, too. If you want something really dumb and > robust, you should probably create an inline: > > /* > * Eric sez: his code path need something simple and stupid, that > * will work every time, especially when things are messed up > * elsewhere. > */ > static inline void braindead_copy_page(void *dst, void *src) > { > unsigned long ctr = PAGE_SIZE >> 2; > > asm volatile("cld; rep; movsl" > : "+D" (dst), "+S" (src), "+c" (ctr) > : : "memory"); > } > > (FWIW, the "cld" is supposed to be redundant, as DF=0 is supposed to be > guaranteed by the ABI.) Actually, swsusp would be second user for that. We currently do it with for loop in C, but... ...well, we'd probably need it for i386, ppc, x86-64, ppc64 and maybe arm... (But you should probably add a comment into kexec ) Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html _______________________________________________ Kernel-janitors mailing list Kernel-janitors@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759649AbXFMUQS (ORCPT ); Wed, 13 Jun 2007 16:16:18 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754349AbXFMUQF (ORCPT ); Wed, 13 Jun 2007 16:16:05 -0400 Received: from gprs189-60.eurotel.cz ([160.218.189.60]:2823 "EHLO spitz.ucw.cz" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752353AbXFMUQD (ORCPT ); Wed, 13 Jun 2007 16:16:03 -0400 Date: Wed, 13 Jun 2007 19:46:54 +0000 From: Pavel Machek To: "H. Peter Anvin" Cc: "Eric W. Biederman" , Shani Moideen , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@lists.osdl.org Subject: Re: [KJ PATCH] Replacing memcpy(dest,src,PAGE_SIZE) with copy_page(dest,src) in arch/i386/kernel/machine_kexec.c Message-ID: <20070613194653.GA8273@ucw.cz> References: <1181616342.2282.8.camel@shani-win> <466ECF37.6040303@zytor.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <466ECF37.6040303@zytor.com> User-Agent: Mutt/1.5.9i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Hi! > >> Replacing memcpy(dest,src,PAGE_SIZE) with copy_page(dest,src) in > >> arch/i386/kernel/machine_kexec.c. > > > > Please no. > > > > People get creative in copy_page (especially mmx_copy_page), > > and this code path need something simple and stupid, that > > will work every time, especially when things are messed up > > elsewhere. > > memcpy() is pretty creative, too. If you want something really dumb and > robust, you should probably create an inline: > > /* > * Eric sez: his code path need something simple and stupid, that > * will work every time, especially when things are messed up > * elsewhere. > */ > static inline void braindead_copy_page(void *dst, void *src) > { > unsigned long ctr = PAGE_SIZE >> 2; > > asm volatile("cld; rep; movsl" > : "+D" (dst), "+S" (src), "+c" (ctr) > : : "memory"); > } > > (FWIW, the "cld" is supposed to be redundant, as DF=0 is supposed to be > guaranteed by the ABI.) Actually, swsusp would be second user for that. We currently do it with for loop in C, but... ...well, we'd probably need it for i386, ppc, x86-64, ppc64 and maybe arm... (But you should probably add a comment into kexec ) Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html