From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in4.apple.com (mail-out4.apple.com [17.151.62.26]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 295F61A1F22 for ; Sat, 17 Sep 2016 09:37:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1474130222; x=2338043822; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-transfer-encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=srObJsBAedivHz3U/vH3GG0A8D8b1/hzCtnFXc1TOSU=; b=aakgj54Ns5sjZlSFw1OB4Jstn9aJNOc3npwKFF2jAeLJ5xrMrLf6wo9wc9SUPOj3 meu6pliIYCEPr/2ftpKzpl3a7Sdmu6HhCC+NvS8Ovzk903W+87YczBGfUSlTh+MD Rq+dDGzzFFTWf7yB1Gasx/gEnt02RZXRJ7F00P8HUrWY5H7HqFfgTib6wWG8dnhq 0NMvtkDeeEMq5QcLvl3/1KI+65sAkPtBgrGF4Z9m+0DB6fWbzWiW/io5ycofsy4a Kwh9elysxCGZ4IFdkPlAqJ23zrlSYLiDXsLDDixG5oNwcpDXZeOYrpYbNYPblz3v FNm5i3IbWMWjAj8QIlMCHw==; Received: from relay5.apple.com (relay5.apple.com [17.128.113.88]) by mail-in4.apple.com (Apple Secure Mail Relay) with SMTP id 7E.CF.07433.E217DD75; Sat, 17 Sep 2016 09:37:02 -0700 (PDT) X-AuditID: 11973e12-f79b16d000001d09-36-57dd712e0bef Received: from sesame.apple.com (sesame.apple.com [17.128.115.128]) by relay5.apple.com (Apple SCV relay) with SMTP id D9.56.27929.E217DD75; Sat, 17 Sep 2016 09:37:02 -0700 (PDT) MIME-version: 1.0 Received: from [17.153.21.3] by sesame.apple.com (Oracle Communications Messaging Server 8.0.1.1.0 64bit (built Jun 15 2016)) with ESMTPSA id <0ODN00GCOQ5P2950@sesame.apple.com>; Sat, 17 Sep 2016 09:37:02 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: Date: Sat, 17 Sep 2016 09:37:01 -0700 Cc: "edk2-devel@lists.01.org" Message-id: References: To: Michael Zimmermann X-Mailer: Apple Mail (2.3112) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOLMWRmVeSWpSXmKPExsUi2FAYoatXeDfc4OFufYt1e76xW8yd+pTV gclj56y77B6TLjxmDmCK4rJJSc3JLEst0rdL4Mq4unoCe8FWyYrPnZ9YGxg/iHQxcnJICJhI nD7+lxXCFpO4cG89WxcjF4eQwF5GiZMt/9lhinbdec4OkdjCKHFi8z82kASvgKDEj8n3WLoY OTiYBeQlDp6XBQkzC2hJfH/UygJRf49RYvbe+0wgCWEBcYl3ZzYxQ9iWEqfv7QJbwCagLLFi /gcwm1MgWOLtmyuMIDaLgKrE37bVjBBDzST6z09nhthrI3Hs+2mwq4UEAiQmrPkPViMiYCjx tPkxE8TRshL7NiwA+0ZCYAebxJv/p1gmMIrMQnL3LIS7ZyG5ewEj8ypGodzEzBzdzDwTvcSC gpxUveT83E2MoJCfbie0g/HUKqtDjAIcjEo8vAt474QLsSaWFVfmHmKU5mBREufl0AAKCaQn lqRmp6YWpBbFF5XmpBYfYmTi4JRqYIzSfz3jVrXMi7Dy9bFf3e2ZV9reS5nCK+ntp76Q56lV ueJdJUU+z8h5j67rnbrZ2q77IY+388XCyHC5Fylay9IZPTsffU9rfb328qldeZ3veLatEmSw EGrjqhN//SZ2d+InnilW1w8bt7qwiBf9mP/+3q16oaf/9IXTNrxebPY9+Gx1uMFrXyWW4oxE Qy3mouJEAKRyx7VaAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpikeLIzCtJLcpLzFFi42IRbChu0NUrvBtusHKejsW6Pd/YLeZOfcrq wOSxc9Zddo9JFx4zBzBFcdmkpOZklqUW6dslcGVcXT2BvWCrZMXnzk+sDYwfRLoYOTkkBEwk dt15zg5hi0lcuLeerYuRi0NIYAujxInN/9hAErwCghI/Jt9j6WLk4GAWkJc4eF4WJMwsoCXx /VErC0T9PUaJ2XvvM4EkhAXEJd6d2cQMYVtKnL63C2wBm4CyxIr5H8BsToFgibdvrjCC2CwC qhJ/21YzQgw1k+g/P50ZYq+NxLHvp1lBbCGBAIkJa/6D1YgIGEo8bX7MBHG0rMS+DQvYJjAK zkJy6iyEU2chOXUBI/MqRoGi1JzESlO9xIKCnFS95PzcTYzgEC2M2MH4f5nVIUYBDkYlHl4P 7jvhQqyJZcWVuYcYJTiYlUR4v6TfDRfiTUmsrEotyo8vKs1JLT7EmAx0/0RmKdHkfGD85JXE G5qYGJgYG5sZG5ubmJMmrCTOK6V2PVxIID2xJDU7NbUgtQhmCxMHp1QDo4ps7quVj+/tWzJj qTLn3b62Z38V/jucs/Db+SRs3qo1Rw4fYRX4cTtbP+Pi6Sb5D8+nOlRPXb+X+5nDwqRT3pba OzNbJbTb9/lFl4nZVW/lLTjKn/D6UraElOXFBjEvRfMnGxKun+O+lK785Snn7qDnMYsj5cSe TDp97MSjpNyjEYVSuwo3XVJiKc5INNRiLipOBAC7pxkDlQIAAA== Subject: Re: how big is the timer event overhead? X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Sep 2016 16:37:03 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII > On Sep 17, 2016, at 8:13 AM, Michael Zimmermann wrote: > > Hi, > > if I add a timer with an interval of 1ms, how much will it affect the > system performance? > The callback only adds +1 to a global variable so I can keep track of the > total uptime without the need of a RTC. > Michael, In general the EFI Contract is you get at least the delay you asked for, but the quality of service is not guaranteed. The PI spec abstracts the system timer for the DXE Core via the Timer Architectural Protocol, https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Protocol/Timer.h. The timers you request in EFI are software timers that are implemented using the Timer Protocol, but you are only going to get the quality of service of the Timer Period set by the Timer Protocol implementation (platform). You can query the period by calling GetTimerPeriod(). 1st rule of performance tuning is to never assume how stuff works and always measure, that caveat aside here is conceptually what is going on..... EFI has an event driven model and it is cooperative (you could also argue it is a run to completion model) in that event functions exit to give control to other events. Events at equal to or less than TPL are blocked from running when an event is running at a given TPL (that is the run to completion bit). The cooperative bit is there is no scheduler, and there is only one thread and thus a common stack for the driver/application that is running and all the events. There is basically a queue, per TPL, of all the events that have been registered. This event queue is processed on calls to gBS->RestoreTPL() and any event that is a higher TPL than the restore can get called. Given the Timer tick is an interrupt it will raise to TPL_HIGH_LEVEL and then restore the TPL. This restoring of the TPL is what causes events to happen. So to answer your question it kind of depends on your timer period and how many events you have as that is the time that is being stolen away from the driver/application that is running. If you are trying to measure elapsed time using a timer event is probably not a good way to do that since there is no scheduler the quality of service is not that good (the time between ticks will be no shorter than requested but could be longer). If your code is independent of the platform the Timestamp protocol may be useful for what you are doing https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Protocol/Timestamp.h. Note it is newish so may not be on every platform. For code in the ROM that knows about the platform the TimerLib, https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Library/TimerLib.h, is used for getting timing information. The combination of GetPerfomanceCounter(), GetPerfomanceCounterProperties(), and GetTimeInNanoSecond() can be used to do what you want I think. Generally on an X86 system this is the TSC, but figuring out the period of the TSC can be tricky if you don't know about your platform. Thanks, Andrew Fish > Thanks > Michael > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel