Bug 189893 - [JSC][Linux] Support Perf JITDump logging
Summary: [JSC][Linux] Support Perf JITDump logging
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-09-23 02:52 PDT by Yusuke Suzuki
Modified: 2018-10-05 13:01 PDT (History)
11 users (show)

See Also:


Attachments
Patch (21.29 KB, patch)
2018-09-23 02:58 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Screenshot #1 (614.12 KB, image/png)
2018-09-23 02:59 PDT, Yusuke Suzuki
no flags Details
Screenshot #2 (482.93 KB, image/png)
2018-09-23 03:00 PDT, Yusuke Suzuki
no flags Details
Patch (21.54 KB, patch)
2018-09-23 04:32 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (21.71 KB, patch)
2018-09-23 04:34 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (21.71 KB, patch)
2018-09-23 04:36 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (24.93 KB, patch)
2018-09-23 07:22 PDT, Yusuke Suzuki
mark.lam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2018-09-23 02:52:45 PDT
[JSC][Linux] Support Perf JITDump logging
Comment 1 Yusuke Suzuki 2018-09-23 02:58:30 PDT
Created attachment 350557 [details]
Patch
Comment 2 Yusuke Suzuki 2018-09-23 02:59:46 PDT
Created attachment 350558 [details]
Screenshot #1
Comment 3 Yusuke Suzuki 2018-09-23 03:00:06 PDT
Created attachment 350559 [details]
Screenshot #2
Comment 4 EWS Watchlist 2018-09-23 03:00:42 PDT
Attachment 350557 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/assembler/LinkBuffer.h:356:  Wrong number of spaces before statement. (expected: 12)  [whitespace/indent] [4]
ERROR: Source/JavaScriptCore/assembler/LinkBuffer.h:358:  Wrong number of spaces before statement. (expected: 16)  [whitespace/indent] [4]
Total errors found: 2 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Yusuke Suzuki 2018-09-23 04:32:51 PDT
Created attachment 350562 [details]
Patch
Comment 6 EWS Watchlist 2018-09-23 04:33:57 PDT
Attachment 350562 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/assembler/LinkBuffer.h:356:  Wrong number of spaces before statement. (expected: 12)  [whitespace/indent] [4]
ERROR: Source/JavaScriptCore/assembler/LinkBuffer.h:358:  Wrong number of spaces before statement. (expected: 16)  [whitespace/indent] [4]
Total errors found: 2 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Yusuke Suzuki 2018-09-23 04:34:58 PDT
Created attachment 350563 [details]
Patch
Comment 8 Yusuke Suzuki 2018-09-23 04:36:50 PDT
Created attachment 350564 [details]
Patch
Comment 9 EWS Watchlist 2018-09-23 04:40:06 PDT
Attachment 350564 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/assembler/LinkBuffer.h:356:  Wrong number of spaces before statement. (expected: 12)  [whitespace/indent] [4]
ERROR: Source/JavaScriptCore/assembler/LinkBuffer.h:358:  Wrong number of spaces before statement. (expected: 16)  [whitespace/indent] [4]
Total errors found: 2 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 10 Yusuke Suzuki 2018-09-23 06:15:18 PDT
Comment on attachment 350564 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=350564&action=review

> Source/JavaScriptCore/ChangeLog:20
> +        Currently, due to perf inject command's bug (maybe), some JIT code information is not attached,
> +        but it should be fixed in perf command's side.

I've found that this is because perf's MMAP record is a bit tricky if we use `mmap(..., PROT_NONE, ...)`.
The simple workaround is that using the normal protection in OSAllocator::reserveUncommitted OS(LINUX) code if perf is enabled.
Comment 11 Yusuke Suzuki 2018-09-23 06:21:59 PDT
Comment on attachment 350564 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=350564&action=review

> Source/JavaScriptCore/assembler/PerfLog.cpp:185
> +    if (!size) {
> +        dataLogLnIf(PerfLogInternal::verbose, "0 size record ", name, " ", RawPointer(executableAddress));
> +        return;
> +    }

If we have 0-sized record, `perf inject` command's fixing up overlapping map region gets stuck! So, recording 0-sized code load is not allowed.
Comment 12 Yusuke Suzuki 2018-09-23 07:22:21 PDT
Created attachment 350565 [details]
Patch
Comment 13 EWS Watchlist 2018-09-23 07:23:39 PDT
Attachment 350565 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/assembler/LinkBuffer.h:356:  Wrong number of spaces before statement. (expected: 12)  [whitespace/indent] [4]
ERROR: Source/JavaScriptCore/assembler/LinkBuffer.h:358:  Wrong number of spaces before statement. (expected: 16)  [whitespace/indent] [4]
Total errors found: 2 in 11 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 14 Yusuke Suzuki 2018-10-05 12:23:32 PDT
Ping?
Comment 15 Mark Lam 2018-10-05 12:46:56 PDT
Comment on attachment 350565 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=350565&action=review

r=me with fixes.

> Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:1162
> +		E45E4CF7243D4BFF924852DC /* PerfLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CF028A1ED94468C977A3BB2 /* PerfLog.h */; settings = {ATTRIBUTES = (Private, ); }; };

Do we need to add to JavaScriptCore.xcodeproj/project.pbxproj at all given this is a linux only feature?  If you can build on Mac without this, then let's leave it out.

> Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:2205
> +		1AEC53058BC44112AF424E00 /* PerfLog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerfLog.cpp; sourceTree = "<group>"; };

Ditto.

> Source/JavaScriptCore/assembler/LinkBuffer.h:357
> +        : (UNLIKELY(JSC::Options::logJITCodeForPerf()) \
> +            ? (linkBufferReference).finalizeCodeWithDisassembly<resultPtrTag>(false, __VA_ARGS__) \

Can you wrap this in #if OS(LINUX)?

> Source/JavaScriptCore/assembler/PerfLog.cpp:210
> +#endif

nit: Add // ENABLE(ASSEMBLER) && OS(LINUX)

> Source/JavaScriptCore/assembler/PerfLog.h:57
> +#endif

nit: Add ENABLE(ASSEMBLER) && OS(LINUX)

> Source/JavaScriptCore/runtime/Options.h:182
> +    v(bool, logJITCodeForPerf, false, Normal, nullptr) \

Since this feature is linux only, can you make this Configurable instead of Normal, and disable it completely for anything other than linux.  See the useSigillCrashAnalyzer option for an example.  This way, we won't falsely advertise that its an available option.
Comment 16 Yusuke Suzuki 2018-10-05 12:58:46 PDT
Comment on attachment 350565 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=350565&action=review

Thank you!

>> Source/JavaScriptCore/assembler/LinkBuffer.h:357
>> +            ? (linkBufferReference).finalizeCodeWithDisassembly<resultPtrTag>(false, __VA_ARGS__) \
> 
> Can you wrap this in #if OS(LINUX)?

Fixed.

>> Source/JavaScriptCore/assembler/PerfLog.cpp:210
>> +#endif
> 
> nit: Add // ENABLE(ASSEMBLER) && OS(LINUX)

Fixed.

>> Source/JavaScriptCore/assembler/PerfLog.h:57
>> +#endif
> 
> nit: Add ENABLE(ASSEMBLER) && OS(LINUX)

Fixed.

>> Source/JavaScriptCore/runtime/Options.h:182
>> +    v(bool, logJITCodeForPerf, false, Normal, nullptr) \
> 
> Since this feature is linux only, can you make this Configurable instead of Normal, and disable it completely for anything other than linux.  See the useSigillCrashAnalyzer option for an example.  This way, we won't falsely advertise that its an available option.

Nice, fixed.
Comment 17 Yusuke Suzuki 2018-10-05 12:59:10 PDT
Committed r236883: <https://trac.webkit.org/changeset/236883>
Comment 18 Radar WebKit Bug Importer 2018-10-05 13:01:46 PDT
<rdar://problem/45051667>