From owner-freebsd-arm@FreeBSD.ORG Thu May 12 18:53:01 2011 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AFAAB1065740 for ; Thu, 12 May 2011 18:53:01 +0000 (UTC) (envelope-from marktinguely@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id 63F658FC16 for ; Thu, 12 May 2011 18:53:01 +0000 (UTC) Received: by qwc9 with SMTP id 9so1252722qwc.13 for ; Thu, 12 May 2011 11:53:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type; bh=tHs3J8+k029PZlMHwfNyNeU8u+/lB4LCWODQwrvyKsY=; b=LN7gqqobKF0m4EgQxcymcSqUIox30eo+E9Vzq3iEPZegKnSTyQiAMTfriqq0JdxjAG OOo5bGTucMv7ypa5xmprQpr0s4uQ7cg6cCg6Vm4DwTj8VzGKUnRsrqF1oLUNCS/pg4hN 0q3nszmN8ywnWWkH5Mn36Ozz6yntFy1fVsMGk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; b=T4pOQ2PbnwXfQRtimlNbf7OllUQIvGhCrJTx54OD0gUf1+IRMxE8IkxREJiMgYEfXa IGzMkB24+d5OA7TigSb4q5NeOjxIZgj+/yUoR80SUVaoxwhXsSpEhxk03UMuuNPMeTQc gLJpwX7f5OMp3RQGr0P7Q/uE2YcAmj8S8B3vI= Received: by 10.224.112.204 with SMTP id x12mr468841qap.384.1305226380608; Thu, 12 May 2011 11:53:00 -0700 (PDT) Received: from [192.168.1.111] (173-19-151-200.client.mchsi.com [173.19.151.200]) by mx.google.com with ESMTPS id l38sm877543qck.6.2011.05.12.11.52.59 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 12 May 2011 11:52:59 -0700 (PDT) Message-ID: <4DCC2C88.3030809@gmail.com> Date: Thu, 12 May 2011 13:52:56 -0500 From: Mark Tinguely User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: =?KOI8-R?Q?=F7=CC=C1=C4=C9=CD=C9=D2_=E6=C5=DD=C5=CE=CB=CF?= References: <578421305188959@web64.yandex.ru> <4DCBEB00.3040608@gmail.com> <881651305221476@web156.yandex.ru> In-Reply-To: <881651305221476@web156.yandex.ru> Content-Type: multipart/mixed; boundary="------------000601050508020001050305" Cc: freebsd-arm@freebsd.org Subject: Re: S3C2440A strange perfomance issue X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2011 18:53:01 -0000 This is a multi-part message in MIME format. --------------000601050508020001050305 Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 8bit On 5/12/2011 12:31 PM, Владимир Фещенко wrote: > 12.05.2011, 18:13, "Mark Tinguely": >> On 5/12/2011 3:29 AM, Владимир Фещенко wrote: >> >>> %cc -O0 -o test test.c >>> >>> and execute it: >>> >>> Code: >>> >>> %/usr/bin/time -l ./test >>> 120.16 real 119.44 user 0.16 sys >>> 12177 involuntary context switches >>> >>> time of execution is over 120 sec ... but after system reboot: >>> >>> Code: >>> >>> %/usr/bin/time -l ./test >>> 2.85 real 2.55 user 0.25 sys >>> 292 involuntary context switches >>> >>> execution time is 2.85(!) sec, but it's not all! >>> >>> Code: >>> >>> %cat test> /dev/null >>> >>> %/usr/bin/time -l ./test >>> 120.40 real 119.51 user 0.23 sys >>> 12201 involuntary context switches >>> >>> Once the file has been opened for reading (cat test> /dev/null), execution time again increased to 120 sec (until the next reboot). >>> >>> What is it?! >> Sounds like the executable cache gets disabled on the executable page >> that is also writable issue that we talked about year or so ago. If you >> want a quick test, in pmap_fix_cache(), and exit the routine immediately >> if the mapping is executable. I did some tracing, and there are cases >> where this is not the correct solution - executable mappings that are >> really shared and cache should be disabled. I have a idea level patch >> for this but never tested it well enough. >> >> I also notice a huge jump in "involuntary context switch" counts in your >> runs. >> >> --Mark Tinguely > please, i want code sample for use pmap_fix_cache() :) > may be this issue is caching problem ... but why 'open for read' make this effect? If the page is still in a kernel mapping (mapped to do I/O) then the cache sharing rules are applied to turn off caching. Below should bypass cache disabling if the page is executable. Quick test only: *** arm/arm/pmap.c.orig Thu May 12 13:31:35 2011 --- arm/arm/pmap.c Thu May 12 13:37:00 2011 *************** pmap_fix_cache(struct vm_page *pg, pmap_ *** 1313,1318 **** --- 1313,1321 ---- mtx_assert(&vm_page_queue_mtx, MA_OWNED); + if (pv->pv_flags & PVF_EXEC) + return(); + /* the cache gets written back/invalidated on context switch. * therefore, if a user page shares an entry in the same page or * with the kernel map and at least one is writable, then the --Mark --------------000601050508020001050305 Content-Type: text/x-patch; name="pmapTEMP.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pmapTEMP.diff" *** arm/arm/pmap.c.orig Thu May 12 13:31:35 2011 --- arm/arm/pmap.c Thu May 12 13:37:00 2011 *************** pmap_fix_cache(struct vm_page *pg, pmap_ *** 1313,1318 **** --- 1313,1321 ---- mtx_assert(&vm_page_queue_mtx, MA_OWNED); + if (pv->pv_flags & PVF_EXEC) + return(); + /* the cache gets written back/invalidated on context switch. * therefore, if a user page shares an entry in the same page or * with the kernel map and at least one is writable, then the --------------000601050508020001050305--