You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@impala.apache.org by "Tim Armstrong (Code Review)" <ge...@cloudera.org> on 2018/05/01 16:37:09 UTC
[Impala-ASF-CR] IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
Tim Armstrong has uploaded this change for review. ( http://gerrit.cloudera.org:8080/10243
Change subject: IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
......................................................................
IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
Marking the __asm__ with __volatile__ *should* prevent the compiler from
speculatively executing the instruction before the branch.
Testing:
Added a regression test that tries to emulate the problematic pattern,
but I was unable to reproduce a crash on a system with popcnt support -
there's probably some instruction scheduling differences.
Manually checked that popcnt was inside the expected branch:
(gdb) disassemble /s impala::HdfsScanNodeBase::StopAndFinalizeCounters
...
160 if (LIKELY(CpuInfo::IsSupported(CpuInfo::POPCNT))) {
0x0000000000e7261b <+491>: and $0x10,%esi
0x0000000000e7261e <+494>: je 0xe73031 <impala::HdfsScanNodeBase::StopAndFinalizeCounters()+3073>
be/src/util/sse-util.h:
147 __asm__ __volatile__("popcntq %1, %0" : "=r"(result) : "mr"(a) : "cc");
0x0000000000e72624 <+500>: popcnt %rdx,%rdx
0x0000000000e72629 <+505>: movslq %edx,%rsi
...
Change-Id: I9ec51bdfcb9455c93ff69827929a59fcccb81b80
---
M be/src/util/bit-util-test.cc
M be/src/util/sse-util.h
2 files changed, 37 insertions(+), 11 deletions(-)
git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/43/10243/2
--
To view, visit http://gerrit.cloudera.org:8080/10243
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ec51bdfcb9455c93ff69827929a59fcccb81b80
Gerrit-Change-Number: 10243
Gerrit-PatchSet: 2
Gerrit-Owner: Tim Armstrong <ta...@cloudera.com>
[Impala-ASF-CR] IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/10243 )
Change subject: IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
......................................................................
Patch Set 3: Verified+1
--
To view, visit http://gerrit.cloudera.org:8080/10243
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I9ec51bdfcb9455c93ff69827929a59fcccb81b80
Gerrit-Change-Number: 10243
Gerrit-PatchSet: 3
Gerrit-Owner: Tim Armstrong <ta...@cloudera.com>
Gerrit-Reviewer: Dan Hecht <dh...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jim Apple <jb...@apache.org>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Tue, 01 May 2018 22:41:17 +0000
Gerrit-HasComments: No
[Impala-ASF-CR] IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
Posted by "Jim Apple (Code Review)" <ge...@cloudera.org>.
Jim Apple has posted comments on this change. ( http://gerrit.cloudera.org:8080/10243 )
Change subject: IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
......................................................................
Patch Set 3: Code-Review+2
(1 comment)
http://gerrit.cloudera.org:8080/#/c/10243/2/be/src/util/bit-util-test.cc
File be/src/util/bit-util-test.cc:
http://gerrit.cloudera.org:8080/#/c/10243/2/be/src/util/bit-util-test.cc@314
PS2, Line 314: __asm__ __volatile__("ud2" : "=a"(result): "mr"(arg): "cc");
> It definitely crashes if the instruction is executed, it isn't hoisted out
And, even if we could, if GCC decided not to hoist it in a new compiler version that would break the test.
--
To view, visit http://gerrit.cloudera.org:8080/10243
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I9ec51bdfcb9455c93ff69827929a59fcccb81b80
Gerrit-Change-Number: 10243
Gerrit-PatchSet: 3
Gerrit-Owner: Tim Armstrong <ta...@cloudera.com>
Gerrit-Reviewer: Jim Apple <jb...@apache.org>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Tue, 01 May 2018 18:45:50 +0000
Gerrit-HasComments: Yes
[Impala-ASF-CR] IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/10243 )
Change subject: IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
......................................................................
IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
Marking the __asm__ with __volatile__ *should* prevent the compiler from
speculatively executing the instruction before the branch.
Testing:
Added a regression test that tries to emulate the problematic pattern,
but I was unable to reproduce a crash on a system with popcnt support -
there's probably some instruction scheduling differences.
Manually checked that popcnt was inside the expected branch:
(gdb) disassemble /s impala::HdfsScanNodeBase::StopAndFinalizeCounters
...
160 if (LIKELY(CpuInfo::IsSupported(CpuInfo::POPCNT))) {
0x0000000000e7261b <+491>: and $0x10,%esi
0x0000000000e7261e <+494>: je 0xe73031 <impala::HdfsScanNodeBase::StopAndFinalizeCounters()+3073>
be/src/util/sse-util.h:
147 __asm__ __volatile__("popcntq %1, %0" : "=r"(result) : "mr"(a) : "cc");
0x0000000000e72624 <+500>: popcnt %rdx,%rdx
0x0000000000e72629 <+505>: movslq %edx,%rsi
...
Change-Id: I9ec51bdfcb9455c93ff69827929a59fcccb81b80
Reviewed-on: http://gerrit.cloudera.org:8080/10243
Reviewed-by: Jim Apple <jb...@apache.org>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
M be/src/util/bit-util-test.cc
M be/src/util/sse-util.h
2 files changed, 38 insertions(+), 11 deletions(-)
Approvals:
Jim Apple: Looks good to me, approved
Impala Public Jenkins: Verified
--
To view, visit http://gerrit.cloudera.org:8080/10243
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9ec51bdfcb9455c93ff69827929a59fcccb81b80
Gerrit-Change-Number: 10243
Gerrit-PatchSet: 4
Gerrit-Owner: Tim Armstrong <ta...@cloudera.com>
Gerrit-Reviewer: Dan Hecht <dh...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jim Apple <jb...@apache.org>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
[Impala-ASF-CR] IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/10243 )
Change subject: IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
......................................................................
Patch Set 3:
Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/2393/
--
To view, visit http://gerrit.cloudera.org:8080/10243
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I9ec51bdfcb9455c93ff69827929a59fcccb81b80
Gerrit-Change-Number: 10243
Gerrit-PatchSet: 3
Gerrit-Owner: Tim Armstrong <ta...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jim Apple <jb...@apache.org>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Tue, 01 May 2018 18:48:36 +0000
Gerrit-HasComments: No
[Impala-ASF-CR] IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
Posted by "Jim Apple (Code Review)" <ge...@cloudera.org>.
Jim Apple has posted comments on this change. ( http://gerrit.cloudera.org:8080/10243 )
Change subject: IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
......................................................................
Patch Set 2:
(2 comments)
Thanks for taking this ticket!
http://gerrit.cloudera.org:8080/#/c/10243/2/be/src/util/bit-util-test.cc
File be/src/util/bit-util-test.cc:
http://gerrit.cloudera.org:8080/#/c/10243/2/be/src/util/bit-util-test.cc@314
PS2, Line 314: __asm__ __volatile__("ud2" : "=a"(result): "mr"(arg): "cc");
Were you able to demonstrate a crash with this? Can you use EXPECT_DEATH from gtest to test it?
http://gerrit.cloudera.org:8080/#/c/10243/2/be/src/util/bit-util-test.cc@325
PS2, Line 325: CpuInfo::TempDisable disable_sssse3(CpuInfo::SSSE3);
CpuInfo flag duplicated in above. Might want to make this a parameter to CpuInfoIsSupportedHoistHelper.
--
To view, visit http://gerrit.cloudera.org:8080/10243
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I9ec51bdfcb9455c93ff69827929a59fcccb81b80
Gerrit-Change-Number: 10243
Gerrit-PatchSet: 2
Gerrit-Owner: Tim Armstrong <ta...@cloudera.com>
Gerrit-Reviewer: Jim Apple <jb...@apache.org>
Gerrit-Comment-Date: Tue, 01 May 2018 16:47:16 +0000
Gerrit-HasComments: Yes
[Impala-ASF-CR] IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
Posted by "Tim Armstrong (Code Review)" <ge...@cloudera.org>.
Hello Jim Apple,
I'd like you to reexamine a change. Please visit
http://gerrit.cloudera.org:8080/10243
to look at the new patch set (#3).
Change subject: IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
......................................................................
IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
Marking the __asm__ with __volatile__ *should* prevent the compiler from
speculatively executing the instruction before the branch.
Testing:
Added a regression test that tries to emulate the problematic pattern,
but I was unable to reproduce a crash on a system with popcnt support -
there's probably some instruction scheduling differences.
Manually checked that popcnt was inside the expected branch:
(gdb) disassemble /s impala::HdfsScanNodeBase::StopAndFinalizeCounters
...
160 if (LIKELY(CpuInfo::IsSupported(CpuInfo::POPCNT))) {
0x0000000000e7261b <+491>: and $0x10,%esi
0x0000000000e7261e <+494>: je 0xe73031 <impala::HdfsScanNodeBase::StopAndFinalizeCounters()+3073>
be/src/util/sse-util.h:
147 __asm__ __volatile__("popcntq %1, %0" : "=r"(result) : "mr"(a) : "cc");
0x0000000000e72624 <+500>: popcnt %rdx,%rdx
0x0000000000e72629 <+505>: movslq %edx,%rsi
...
Change-Id: I9ec51bdfcb9455c93ff69827929a59fcccb81b80
---
M be/src/util/bit-util-test.cc
M be/src/util/sse-util.h
2 files changed, 38 insertions(+), 11 deletions(-)
git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/43/10243/3
--
To view, visit http://gerrit.cloudera.org:8080/10243
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I9ec51bdfcb9455c93ff69827929a59fcccb81b80
Gerrit-Change-Number: 10243
Gerrit-PatchSet: 3
Gerrit-Owner: Tim Armstrong <ta...@cloudera.com>
Gerrit-Reviewer: Jim Apple <jb...@apache.org>
[Impala-ASF-CR] IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
Posted by "Tim Armstrong (Code Review)" <ge...@cloudera.org>.
Tim Armstrong has posted comments on this change. ( http://gerrit.cloudera.org:8080/10243 )
Change subject: IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
......................................................................
Patch Set 2:
(2 comments)
http://gerrit.cloudera.org:8080/#/c/10243/2/be/src/util/bit-util-test.cc
File be/src/util/bit-util-test.cc:
http://gerrit.cloudera.org:8080/#/c/10243/2/be/src/util/bit-util-test.cc@314
PS2, Line 314: __asm__ __volatile__("ud2" : "=a"(result): "mr"(arg): "cc");
> Were you able to demonstrate a crash with this? Can you use EXPECT_DEATH fr
It definitely crashes if the instruction is executed, it isn't hoisted out of the branch even without __volatile__. I wasn't able to find a valid instruction that crashed that gcc would hoist.
http://gerrit.cloudera.org:8080/#/c/10243/2/be/src/util/bit-util-test.cc@325
PS2, Line 325: CpuInfo::TempDisable disable_sssse3(CpuInfo::SSSE3);
> CpuInfo flag duplicated in above. Might want to make this a parameter to Cp
Done
--
To view, visit http://gerrit.cloudera.org:8080/10243
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I9ec51bdfcb9455c93ff69827929a59fcccb81b80
Gerrit-Change-Number: 10243
Gerrit-PatchSet: 2
Gerrit-Owner: Tim Armstrong <ta...@cloudera.com>
Gerrit-Reviewer: Jim Apple <jb...@apache.org>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Tue, 01 May 2018 17:19:47 +0000
Gerrit-HasComments: Yes
[Impala-ASF-CR] IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
Posted by "Dan Hecht (Code Review)" <ge...@cloudera.org>.
Dan Hecht has posted comments on this change. ( http://gerrit.cloudera.org:8080/10243 )
Change subject: IMPALA-6882: prevent instr. hoist from CpuInfo::IsSupported()
......................................................................
Patch Set 3:
This is fine with me. But did we consider adding CompilerBarrier() to IsSupported() to deal with the issue in general? That would be conservative, but in the cases where the barrier is not needed, it also means it's not a fast-path...
--
To view, visit http://gerrit.cloudera.org:8080/10243
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I9ec51bdfcb9455c93ff69827929a59fcccb81b80
Gerrit-Change-Number: 10243
Gerrit-PatchSet: 3
Gerrit-Owner: Tim Armstrong <ta...@cloudera.com>
Gerrit-Reviewer: Dan Hecht <dh...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Jim Apple <jb...@apache.org>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Tue, 01 May 2018 19:06:19 +0000
Gerrit-HasComments: No