Backport of commit a75bb4eb9e565b9f5115e2e8c07377ce32cbe69a
Hi Greg and Sasha,
Please apply this commit to 4.4 through 5.0 (patches are threaded in reply to this one), which will prevent Clang from emitting references to compiler runtime functions and doing some performance-killing optimization when using CONFIG_CC_OPTIMIZE_FOR_SIZE.
Please let me know if I did something wrong or if there are any objections.
Cheers,
Nathan
PATCH 1/1 Revert "kbuild: use -Oz instead of -Os when using clang"
From: Matthias Kaehlcke <[email protected]>
commit a75bb4eb9e565b9f5115e2e8c07377ce32cbe69a upstream.
The clang option -Oz enables *aggressive* optimization for size, which doesn't necessarily result in smaller images, but can have negative impact on performance. Switch back to the less aggressive -Os.
This reverts commit 6748cb3c299de1ffbe56733647b01dbcc398c419.
--- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Makefile +1 -2
@@ -653,8 +653,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context) KBUILD_CFLAGS += $(call cc-disable-warning, attribute-alias) ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE -KBUILD_CFLAGS += $(call cc-option,-Oz,-Os) -KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,) +KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,) else ifdef CONFIG_PROFILE_ALL_BRANCHES KBUILD_CFLAGS += -O2 $(call cc-disable-warning,maybe-uninitialized,)
Signature · 1 line
2.21.0
PATCH 1/1 Revert "kbuild: use -Oz instead of -Os when using clang"
In reply to Nathan ChancellorFrom: Matthias Kaehlcke <[email protected]>
commit a75bb4eb9e565b9f5115e2e8c07377ce32cbe69a upstream.
The clang option -Oz enables *aggressive* optimization for size, which doesn't necessarily result in smaller images, but can have negative impact on performance. Switch back to the less aggressive -Os.
This reverts commit 6748cb3c299de1ffbe56733647b01dbcc398c419.
--- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Makefile +1 -2
@@ -661,8 +661,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context) ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE -KBUILD_CFLAGS += $(call cc-option,-Oz,-Os) -KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,) +KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,) else ifdef CONFIG_PROFILE_ALL_BRANCHES KBUILD_CFLAGS += -O2 $(call cc-disable-warning,maybe-uninitialized,)
Signature · 1 line
2.21.0
PATCH 1/1 Revert "kbuild: use -Oz instead of -Os when using clang"
In reply to Nathan ChancellorFrom: Matthias Kaehlcke <[email protected]>
commit a75bb4eb9e565b9f5115e2e8c07377ce32cbe69a upstream.
The clang option -Oz enables *aggressive* optimization for size, which doesn't necessarily result in smaller images, but can have negative impact on performance. Switch back to the less aggressive -Os.
This reverts commit 6748cb3c299de1ffbe56733647b01dbcc398c419.
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
@@ -639,7 +639,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context) KBUILD_CFLAGS += $(call cc-disable-warning, attribute-alias) ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE -KBUILD_CFLAGS += $(call cc-option,-Oz,-Os) +KBUILD_CFLAGS += -Os else ifdef CONFIG_PROFILE_ALL_BRANCHES KBUILD_CFLAGS += -O2
Signature · 1 line
2.21.0
PATCH 1/1 Revert "kbuild: use -Oz instead of -Os when using clang"
In reply to Nathan ChancellorFrom: Matthias Kaehlcke <[email protected]>
commit a75bb4eb9e565b9f5115e2e8c07377ce32cbe69a upstream.
The clang option -Oz enables *aggressive* optimization for size, which doesn't necessarily result in smaller images, but can have negative impact on performance. Switch back to the less aggressive -Os.
This reverts commit 6748cb3c299de1ffbe56733647b01dbcc398c419.
--- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Makefile +1 -2
@@ -655,8 +655,7 @@ KBUILD_CFLAGS += $(call cc-option,-fdata-sections,) endif ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE -KBUILD_CFLAGS += $(call cc-option,-Oz,-Os) -KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,) +KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,) else ifdef CONFIG_PROFILE_ALL_BRANCHES KBUILD_CFLAGS += -O2 $(call cc-disable-warning,maybe-uninitialized,)
Signature · 1 line
2.21.0
PATCH 1/1 Revert "kbuild: use -Oz instead of -Os when using clang"
In reply to Nathan ChancellorFrom: Matthias Kaehlcke <[email protected]>
commit a75bb4eb9e565b9f5115e2e8c07377ce32cbe69a upstream.
The clang option -Oz enables *aggressive* optimization for size, which doesn't necessarily result in smaller images, but can have negative impact on performance. Switch back to the less aggressive -Os.
This reverts commit 6748cb3c299de1ffbe56733647b01dbcc398c419.
--- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Makefile +1 -2
@@ -678,8 +678,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context) ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE -KBUILD_CFLAGS += $(call cc-option,-Oz,-Os) -KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,) +KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,) else ifdef CONFIG_PROFILE_ALL_BRANCHES KBUILD_CFLAGS += -O2 $(call cc-disable-warning,maybe-uninitialized,)
Signature · 1 line
2.21.0
Sasha Levin
maintainerQuoted 9 lines · Nathan Chancellor
Hi Greg and Sasha,
Please apply this commit to 4.4 through 5.0 (patches are threaded in reply to this one), which will prevent Clang from emitting references to compiler runtime functions and doing some performance-killing optimization when using
CONFIG_CC_OPTIMIZE_FOR_SIZE.Please let me know if I did something wrong or if there are any objections.
This looks like a fix for a performance regression, which don't usually end up in stable unless they are severe enough.
This patch looks simple enough, and seeing peterz on it suggests to me that this was significant enough for someone to notice. Is this really the case, or is this just one of those %0.01 performance regression things?
--
Thanks,
Sasha
Quoted 12 lines · Sasha Levin
Quoted 9 lines · Nathan Chancellor
Hi Greg and Sasha,
Please apply this commit to 4.4 through 5.0 (patches are threaded in reply to this one), which will prevent Clang from emitting references to compiler runtime functions and doing some performance-killing optimization when using
CONFIG_CC_OPTIMIZE_FOR_SIZE.Please let me know if I did something wrong or if there are any objections.
Quoted 7 lines
This looks like a fix for a performance regression, which don't usually end up in stable unless they are severe enough.
This patch looks simple enough, and seeing peterz on it suggests to me that this was significant enough for someone to notice. Is this really the case, or is this just one of those %0.01 performance regression things?
I don't recall specific measurements, but when I tried Peter's suggestion and measured it, I wondered to myself how the initial patch was ever correct. The revert (what Nathan sent) should really be applied for folks building w/ Clang+CONFIG_CC_OPTIMIZE_FOR_SIZE=y, which is what some CrOS devices (and some Qualcomm BSPs) are doing. Rather than cherry pick this patch around to a bunch of different trees, it would be much better for this to land in -stable and for those trees not to diverge over this.
Nathan, thank you for sending.
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 8 lines · Sasha Levin
Quoted 7 lines · Nathan Chancellor
Hi Greg and Sasha,
Please apply this commit to 4.4 through 5.0 (patches are threaded in reply to this one), which will prevent Clang from emitting references to compiler runtime functions and doing some performance-killing optimization when using
CONFIG_CC_OPTIMIZE_FOR_SIZE.
Quoted 6 lines
Quoted 2 lines
Please let me know if I did something wrong or if there are any objections.
This looks like a fix for a performance regression, which don't usually end up in stable unless they are severe enough.
Yes and no. The original reason for the revert was because of the compiler runtime functions:
https://lore.kernel.org/lkml/CAG5bF+S6OvBnsaR6UpMCqjDR9_hMo6qRMHGiW+iCaRYQW4C3YA@mail.gmail.com/
The Chromium guys hit this [1] and have applied the patch for their kernels, I think it should be applied for everyone.
Quoted 5 lines
This patch looks simple enough, and seeing peterz on it suggests to me that this was significant enough for someone to notice. Is this really the case, or is this just one of those %0.01 performance regression things?
I don't know of anyone else who has hit this but Qualcomm enabled CONFIG_CC_OPTIMIZE_FOR_SIZE in their 4.9 kernels with clang [2] so it would be nice to have this to avoid any further issues down the road.
[1]: https://chromium.googlesource.com/chromiumos/third_party/kernel/+/8bb957d781e2350515c7cffd7e7dc0dfc1777f3b
[2]: https://source.codeaurora.org/quic/la/kernel/msm-4.9/commit/?id=e828e50380a34533c37eff98345847fd74667ddd
Thanks for the quick reply!
Nathan
Quoted 3 lines
--
Thanks,
Sasha
Quoted 16 lines · Nathan Chancellor
Quoted 8 lines · Sasha Levin
Quoted 7 lines · Nathan Chancellor
Hi Greg and Sasha,
Please apply this commit to 4.4 through 5.0 (patches are threaded in reply to this one), which will prevent Clang from emitting references to compiler runtime functions and doing some performance-killing optimization when using
CONFIG_CC_OPTIMIZE_FOR_SIZE.Quoted 6 lines
Quoted 2 lines
Please let me know if I did something wrong or if there are any objections.
This looks like a fix for a performance regression, which don't usually end up in stable unless they are severe enough.
Quoted 7 lines
Yes and no. The original reason for the revert was because of the compiler runtime functions:
https://lore.kernel.org/lkml/CAG5bF+S6OvBnsaR6UpMCqjDR9_hMo6qRMHGiW+iCaRYQW4C3YA@mail.gmail.com/
The Chromium guys hit this [1] and have applied the patch for their kernels, I think it should be applied for everyone.
We picked it into our kernels because we needed a fix *now* to unbreak our builds, but I agree it should be fixed at least in relevant LTS versions.
Quoted 6 lines
Quoted 5 lines
This patch looks simple enough, and seeing peterz on it suggests to me that this was significant enough for someone to notice. Is this really the case, or is this just one of those %0.01 performance regression things?
Quoted 6 lines
I don't know of anyone else who has hit this but Qualcomm enabled
CONFIG_CC_OPTIMIZE_FOR_SIZEin their 4.9 kernels with clang [2] so it would be nice to have this to avoid any further issues down the road.[1]: https://chromium.googlesource.com/chromiumos/third_party/kernel/+/8bb957d781e2350515c7cffd7e7dc0dfc1777f3b
[2]: https://source.codeaurora.org/quic/la/kernel/msm-4.9/commit/?id=e828e50380a34533c37eff98345847fd74667ddd
I suspect the Qualcomm tree would hit the VDSO issue if they use a sufficiently recent version of clang.
Thanks Nathan for posting this to -stable, I should have cc-ed them in the first place.
Quoted 20 lines · Matthias Kaehlcke
Quoted 19 lines · Nathan Chancellor
Quoted 8 lines · Sasha Levin
Quoted 7 lines · Nathan Chancellor
Hi Greg and Sasha,
Please apply this commit to 4.4 through 5.0 (patches are threaded in reply to this one), which will prevent Clang from emitting references to compiler runtime functions and doing some performance-killing optimization when using
CONFIG_CC_OPTIMIZE_FOR_SIZE.Quoted 6 lines
Quoted 2 lines
Please let me know if I did something wrong or if there are any objections.
This looks like a fix for a performance regression, which don't usually end up in stable unless they are severe enough.
Yes and no. The original reason for the revert was because of the compiler runtime functions:
Quoted 9 lines
Quoted 4 lines
https://lore.kernel.org/lkml/CAG5bF+S6OvBnsaR6UpMCqjDR9_hMo6qRMHGiW+iCaRYQW4C3YA@mail.gmail.com/
The Chromium guys hit this [1] and have applied the patch for their kernels, I think it should be applied for everyone.
We picked it into our kernels because we needed a fix *now* to unbreak our builds, but I agree it should be fixed at least in relevant LTS versions.
Of course, I wasn't implying that was a bad thing :) it's further justification for this being a stable worthy patch as it fixes a real world issue and could fix more.
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
This patch looks simple enough, and seeing peterz on it suggests to me that this was significant enough for someone to notice. Is this really the case, or is this just one of those %0.01 performance regression things?
I don't know of anyone else who has hit this but Qualcomm enabled
CONFIG_CC_OPTIMIZE_FOR_SIZEin their 4.9 kernels with clang [2] so it would be nice to have this to avoid any further issues down the road.
Quoted 8 lines
Quoted 2 lines
[1]: https://chromium.googlesource.com/chromiumos/third_party/kernel/+/8bb957d781e2350515c7cffd7e7dc0dfc1777f3b
[2]: https://source.codeaurora.org/quic/la/kernel/msm-4.9/commit/?id=e828e50380a34533c37eff98345847fd74667dddI suspect the Qualcomm tree would hit the VDSO issue if they use a sufficiently recent version of clang.
Thanks Nathan for posting this to -stable, I should have cc-ed them in the first place.
Sure thing, thanks for the reply and input!
Nathan
Sasha Levin
maintainerQuoted 26 lines · Nathan Chancellor
Quoted 25 lines · Matthias Kaehlcke
Quoted 23 lines · Nathan Chancellor
Quoted 8 lines · Sasha Levin
Quoted 7 lines · Nathan Chancellor
Hi Greg and Sasha,
Please apply this commit to 4.4 through 5.0 (patches are threaded in reply to this one), which will prevent Clang from emitting references to compiler runtime functions and doing some performance-killing optimization when using
CONFIG_CC_OPTIMIZE_FOR_SIZE.Quoted 6 lines
Quoted 2 lines
Please let me know if I did something wrong or if there are any objections.
This looks like a fix for a performance regression, which don't usually end up in stable unless they are severe enough.
Yes and no. The original reason for the revert was because of the compiler runtime functions:
https://lore.kernel.org/lkml/CAG5bF+S6OvBnsaR6UpMCqjDR9_hMo6qRMHGiW+iCaRYQW4C3YA@mail.gmail.com/
The Chromium guys hit this [1] and have applied the patch for their kernels, I think it should be applied for everyone.
Quoted 8 lines
Quoted 4 lines
We picked it into our kernels because we needed a fix *now* to unbreak our builds, but I agree it should be fixed at least in relevant LTS versions.
Of course, I wasn't implying that was a bad thing :) it's further justification for this being a stable worthy patch as it fixes a real world issue and could fix more.
Okay, this makes more sense. The upstream commit message failed to mention this.
I've queued it up.
--
Thanks,
Sasha
Quoted 33 lines · Sasha Levin
Quoted 31 lines · Nathan Chancellor
Quoted 29 lines · Matthias Kaehlcke
Quoted 16 lines · Nathan Chancellor
Quoted 8 lines · Sasha Levin
Quoted 7 lines · Nathan Chancellor
Hi Greg and Sasha,
Please apply this commit to 4.4 through 5.0 (patches are threaded in reply to this one), which will prevent Clang from emitting references to compiler runtime functions and doing some performance-killing optimization when using
CONFIG_CC_OPTIMIZE_FOR_SIZE.Quoted 6 lines
Quoted 2 lines
Please let me know if I did something wrong or if there are any objections.
This looks like a fix for a performance regression, which don't usually end up in stable unless they are severe enough.
Quoted 7 lines
Yes and no. The original reason for the revert was because of the compiler runtime functions:
https://lore.kernel.org/lkml/CAG5bF+S6OvBnsaR6UpMCqjDR9_hMo6qRMHGiW+iCaRYQW4C3YA@mail.gmail.com/
The Chromium guys hit this [1] and have applied the patch for their kernels, I think it should be applied for everyone.
We picked it into our kernels because we needed a fix *now* to unbreak our builds, but I agree it should be fixed at least in relevant LTS versions.
Quoted 9 lines
Quoted 3 lines
Of course, I wasn't implying that was a bad thing :) it's further justification for this being a stable worthy patch as it fixes a real world issue and could fix more.
Okay, this makes more sense. The upstream commit message failed to mention this.
I've queued it up.
Dropped my private for-5.0/kbuild-cc-optimization Git branch. One less patch to carry with me...
Thanks.
- Sedat -