public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Heyi Guo <heyi.guo@linaro.org>
To: "Zeng, Star" <star.zeng@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	"Gao, Liming" <liming.gao@intel.com>
Cc: "Carsey, Jaben" <jaben.carsey@intel.com>,
	Daryl McDaniel <edk2-lists@mc2research.org>
Subject: Re: [RFC] Add EFI lock when creating new gauge record
Date: Mon, 27 Nov 2017 11:14:32 +0800	[thread overview]
Message-ID: <83f0b339-0eb3-b3a3-97e7-4e1be06273d7@linaro.org> (raw)
In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B9BC210@shsmsx102.ccr.corp.intel.com>

Thanks; will do that.

Regards,

Gary (Heyi Guo)


在 11/27/2017 10:06 AM, Zeng, Star 写道:
> I am ok with the approach.
>
> If no comment from others, I think you can post the patch for code review.
>
> Liming, do you have any comment? :)
>
>
> Thanks,
> Star
> -----Original Message-----
> From: Heyi Guo [mailto:heyi.guo@linaro.org]
> Sent: Saturday, November 25, 2017 5:10 PM
> To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
> Cc: Carsey, Jaben <jaben.carsey@intel.com>; Daryl McDaniel <edk2-lists@mc2research.org>; Gao, Liming <liming.gao@intel.com>
> Subject: Re: [edk2] [RFC] Add EFI lock when creating new gauge record
>
> Hi Star,
>
> Sorry to make a mistake with the code package :)
>
> Please see my test results below.
>
>
> 在 11/24/2017 5:41 PM, Zeng, Star 写道:
>> Good problem statement.
>>
>> EndGaugeEx and GetGaugeEx also need to be updated as they are operating same memory buffer, otherwise the performance data may be messed up.
>>
>> Another idea is to just use a global variable, for example mRecording, to prevent reentrance, but that there may be perf data missing.
>>
>> How to realize " not impacted much " in " the performance measuring data was not impacted much by this patch "?
>> That means there is a little performance impact?
> I tested more than 50 times on my platform with the original version and the modified one, and calculated the average "Total Duration", which were 32567ms and 32600ms respectively. So the performance impact almost can be ignored.
>> Could you re-measure with all StartGaugeEx, EndGaugeEx and GetGaugeEx add lock?
> Good point. The above result was tested with all of them locked.
>
> I also attached my patch.
>
> Thanks and regards,
>
> Gary (Heyi Guo)
>>
>> Cc Liming.
>>
>>
>> Thanks,
>> Star
>> -----Original Message-----
>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>> Heyi Guo
>> Sent: Friday, November 24, 2017 3:04 PM
>> To: edk2-devel@lists.01.org
>> Cc: Carsey, Jaben <jaben.carsey@intel.com>; Daryl McDaniel
>> <edk2-lists@mc2research.org>
>> Subject: [edk2] [RFC] Add EFI lock when creating new gauge record
>>
>> Hi folks,
>>
>> We got occasional system exceptions after enabling performance measuring feature in edk2. After debugging, we found there is potential memory overflow in DXE/DXE_CORE PerformanceLib when PERF_START is reentered, and reentrance is possible since we are supporting something like USB hot-plug, which is a timer event where gBS->ConnectController might be called and then PERF will be called in CoreConnectSingleController.
>> However I can't reproduce the issue right now; please let me know if PERF reentrance is not theoretically possible in the latest edk2 code.
>>
>> When StartGaugeEx is being reentered, not only the gauge record might be overwritten, more serious situation will be caused if gauge data buffer reallocation procedure is interrupted, between line 180 and 187 in DxeCorePerformanceLib.c specifically. There, mMaxGaugeRecords will be doubled twice (denoted as 4X), but mGaugeData only points to a buffer of size 2X, which will probably cause the following 2X memory to be overflowed when gauge records are increased.
>>
>> My proposal is to add EFI lock with TPL notify in StartGaugeEx to avoid such situation. The test result seemed good on our platforms and the performance measuring data was not impacted much by this patch.
>>
>> Please let me know your comments.
>>
>> Thanks,
>>
>> Gary (Heyi Guo)
>>
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel



  reply	other threads:[~2017-11-27  3:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-24  7:04 [RFC] Add EFI lock when creating new gauge record Heyi Guo
2017-11-24  9:41 ` Zeng, Star
2017-11-25  9:09   ` Heyi Guo
2017-11-27  2:06     ` Zeng, Star
2017-11-27  3:14       ` Heyi Guo [this message]
2017-11-27  6:58     ` Gao, Liming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83f0b339-0eb3-b3a3-97e7-4e1be06273d7@linaro.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox