* [PATCH] webkitgtk: Reduce stack and heap sizes for jsc on musl
@ 2021-03-17 0:31 Khem Raj
2021-03-17 11:10 ` [OE-core] " Alexander Kanavin
2021-03-17 16:05 ` Andrei Gherzan
0 siblings, 2 replies; 5+ messages in thread
From: Khem Raj @ 2021-03-17 0:31 UTC (permalink / raw)
To: openembedded-core; +Cc: Khem Raj, Andrei Gherzan
Fixes
[YOCTO #14281]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Andrei Gherzan <andrei@gherzan.com>
---
.../webkitgtk/musl-lower-stack-usage.patch | 51 +++++++++++++++++++
meta/recipes-sato/webkit/webkitgtk_2.30.5.bb | 1 +
2 files changed, 52 insertions(+)
create mode 100644 meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
diff --git a/meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch b/meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
new file mode 100644
index 0000000000..3d66766d9a
--- /dev/null
+++ b/meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
@@ -0,0 +1,51 @@
+reduce thread stack and heap usage for javascriptcore on musl
+
+default sizes for musl are smaller compared to glibc, this matches
+to musl defaults, avoid stack overflow crashes in jscore
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+--- a/Source/JavaScriptCore/runtime/OptionsList.h
++++ b/Source/JavaScriptCore/runtime/OptionsList.h
+@@ -75,6 +75,18 @@ constexpr bool enableWebAssemblyStreamin
+ // On instantiation of the first VM instance, the Options will be write protected
+ // and cannot be modified thereafter.
+
++#if OS(LINUX) && !defined(__GLIBC__)
++// non-glibc options on linux ( musl )
++constexpr unsigned jscMaxPerThreadStack = 80 * KB;
++constexpr unsigned jscSoftReservedZoneSize = 32 * KB;
++constexpr unsigned jscReservedZoneSize = 16 * KB;
++#else
++//default
++constexpr unsigned jscMaxPerThreadStack = 4 * MB;
++constexpr unsigned jscSoftReservedZoneSize = 128 * KB;
++constexpr unsigned jscReservedZoneSize = 64 * KB;
++#endif
++
+ #define FOR_EACH_JSC_OPTION(v) \
+ v(Bool, useKernTCSM, defaultTCSMValue(), Normal, "Note: this needs to go before other options since they depend on this value.") \
+ v(Bool, validateOptions, false, Normal, "crashes if mis-typed JSC options were passed to the VM") \
+@@ -90,9 +102,9 @@ constexpr bool enableWebAssemblyStreamin
+ \
+ v(Bool, reportMustSucceedExecutableAllocations, false, Normal, nullptr) \
+ \
+- v(Unsigned, maxPerThreadStackUsage, 5 * MB, Normal, "Max allowed stack usage by the VM") \
+- v(Unsigned, softReservedZoneSize, 128 * KB, Normal, "A buffer greater than reservedZoneSize that reserves space for stringifying exceptions.") \
+- v(Unsigned, reservedZoneSize, 64 * KB, Normal, "The amount of stack space we guarantee to our clients (and to interal VM code that does not call out to clients).") \
++ v(Unsigned, maxPerThreadStackUsage, jscMaxPerThreadStack, Normal, "Max allowed stack usage by the VM") \
++ v(Unsigned, softReservedZoneSize, jscSoftReservedZoneSize, Normal, "A buffer greater than reservedZoneSize that reserves space for stringifying exceptions.") \
++ v(Unsigned, reservedZoneSize, jscReservedZoneSize, Normal, "The amount of stack space we guarantee to our clients (and to interal VM code that does not call out to clients).") \
+ \
+ v(Bool, crashOnDisallowedVMEntry, ASSERT_ENABLED, Normal, "Forces a crash if we attempt to enter the VM when disallowed") \
+ v(Bool, crashIfCantAllocateJITMemory, false, Normal, nullptr) \
+@@ -601,7 +613,7 @@ public:
+ bool init(const char*);
+ bool isInRange(unsigned);
+ const char* rangeString() const { return (m_state > InitError) ? m_rangeString : s_nullRangeStr; }
+-
++
+ void dump(PrintStream& out) const;
+
+ private:
diff --git a/meta/recipes-sato/webkit/webkitgtk_2.30.5.bb b/meta/recipes-sato/webkit/webkitgtk_2.30.5.bb
index d0a41f48c7..36d33f550d 100644
--- a/meta/recipes-sato/webkit/webkitgtk_2.30.5.bb
+++ b/meta/recipes-sato/webkit/webkitgtk_2.30.5.bb
@@ -20,6 +20,7 @@ SRC_URI = "https://www.webkitgtk.org/releases/${BPN}-${PV}.tar.xz \
file://include_xutil.patch \
file://reduce-memory-overheads.patch \
file://0001-Extend-atomics-check-to-include-1-byte-CAS-test.patch \
+ file://musl-lower-stack-usage.patch \
"
SRC_URI[sha256sum] = "7d0dab08e3c5ae07bec80b2822ef42e952765d5724cac86eb23999bfed5a7f1f"
--
2.31.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [OE-core] [PATCH] webkitgtk: Reduce stack and heap sizes for jsc on musl
2021-03-17 0:31 [PATCH] webkitgtk: Reduce stack and heap sizes for jsc on musl Khem Raj
@ 2021-03-17 11:10 ` Alexander Kanavin
2021-03-17 20:27 ` Khem Raj
2021-03-17 16:05 ` Andrei Gherzan
1 sibling, 1 reply; 5+ messages in thread
From: Alexander Kanavin @ 2021-03-17 11:10 UTC (permalink / raw)
To: Khem Raj; +Cc: OE-core, Andrei Gherzan
[-- Attachment #1: Type: text/plain, Size: 4576 bytes --]
Please Khem, send these patches upstream first.
Alex
On Wed, 17 Mar 2021 at 01:32, Khem Raj <raj.khem@gmail.com> wrote:
> Fixes
>
> [YOCTO #14281]
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> Cc: Andrei Gherzan <andrei@gherzan.com>
> ---
> .../webkitgtk/musl-lower-stack-usage.patch | 51 +++++++++++++++++++
> meta/recipes-sato/webkit/webkitgtk_2.30.5.bb | 1 +
> 2 files changed, 52 insertions(+)
> create mode 100644
> meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
>
> diff --git
> a/meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
> b/meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
> new file mode 100644
> index 0000000000..3d66766d9a
> --- /dev/null
> +++ b/meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
> @@ -0,0 +1,51 @@
> +reduce thread stack and heap usage for javascriptcore on musl
> +
> +default sizes for musl are smaller compared to glibc, this matches
> +to musl defaults, avoid stack overflow crashes in jscore
> +
> +Upstream-Status: Pending
> +Signed-off-by: Khem Raj <raj.khem@gmail.com>
> +
> +--- a/Source/JavaScriptCore/runtime/OptionsList.h
> ++++ b/Source/JavaScriptCore/runtime/OptionsList.h
> +@@ -75,6 +75,18 @@ constexpr bool enableWebAssemblyStreamin
> + // On instantiation of the first VM instance, the Options will be write
> protected
> + // and cannot be modified thereafter.
> +
> ++#if OS(LINUX) && !defined(__GLIBC__)
> ++// non-glibc options on linux ( musl )
> ++constexpr unsigned jscMaxPerThreadStack = 80 * KB;
> ++constexpr unsigned jscSoftReservedZoneSize = 32 * KB;
> ++constexpr unsigned jscReservedZoneSize = 16 * KB;
> ++#else
> ++//default
> ++constexpr unsigned jscMaxPerThreadStack = 4 * MB;
> ++constexpr unsigned jscSoftReservedZoneSize = 128 * KB;
> ++constexpr unsigned jscReservedZoneSize = 64 * KB;
> ++#endif
> ++
> + #define FOR_EACH_JSC_OPTION(v) \
> + v(Bool, useKernTCSM, defaultTCSMValue(), Normal, "Note: this needs
> to go before other options since they depend on this value.") \
> + v(Bool, validateOptions, false, Normal, "crashes if mis-typed JSC
> options were passed to the VM") \
> +@@ -90,9 +102,9 @@ constexpr bool enableWebAssemblyStreamin
> + \
> + v(Bool, reportMustSucceedExecutableAllocations, false, Normal,
> nullptr) \
> + \
> +- v(Unsigned, maxPerThreadStackUsage, 5 * MB, Normal, "Max allowed
> stack usage by the VM") \
> +- v(Unsigned, softReservedZoneSize, 128 * KB, Normal, "A buffer
> greater than reservedZoneSize that reserves space for stringifying
> exceptions.") \
> +- v(Unsigned, reservedZoneSize, 64 * KB, Normal, "The amount of stack
> space we guarantee to our clients (and to interal VM code that does not
> call out to clients).") \
> ++ v(Unsigned, maxPerThreadStackUsage, jscMaxPerThreadStack, Normal,
> "Max allowed stack usage by the VM") \
> ++ v(Unsigned, softReservedZoneSize, jscSoftReservedZoneSize, Normal,
> "A buffer greater than reservedZoneSize that reserves space for
> stringifying exceptions.") \
> ++ v(Unsigned, reservedZoneSize, jscReservedZoneSize, Normal, "The
> amount of stack space we guarantee to our clients (and to interal VM code
> that does not call out to clients).") \
> + \
> + v(Bool, crashOnDisallowedVMEntry, ASSERT_ENABLED, Normal, "Forces a
> crash if we attempt to enter the VM when disallowed") \
> + v(Bool, crashIfCantAllocateJITMemory, false, Normal, nullptr) \
> +@@ -601,7 +613,7 @@ public:
> + bool init(const char*);
> + bool isInRange(unsigned);
> + const char* rangeString() const { return (m_state > InitError) ?
> m_rangeString : s_nullRangeStr; }
> +-
> ++
> + void dump(PrintStream& out) const;
> +
> + private:
> diff --git a/meta/recipes-sato/webkit/webkitgtk_2.30.5.bb
> b/meta/recipes-sato/webkit/webkitgtk_2.30.5.bb
> index d0a41f48c7..36d33f550d 100644
> --- a/meta/recipes-sato/webkit/webkitgtk_2.30.5.bb
> +++ b/meta/recipes-sato/webkit/webkitgtk_2.30.5.bb
> @@ -20,6 +20,7 @@ SRC_URI = "
> https://www.webkitgtk.org/releases/${BPN}-${PV}.tar.xz \
> file://include_xutil.patch \
> file://reduce-memory-overheads.patch \
>
> file://0001-Extend-atomics-check-to-include-1-byte-CAS-test.patch \
> + file://musl-lower-stack-usage.patch \
> "
>
> SRC_URI[sha256sum] =
> "7d0dab08e3c5ae07bec80b2822ef42e952765d5724cac86eb23999bfed5a7f1f"
> --
> 2.31.0
>
>
>
>
>
[-- Attachment #2: Type: text/html, Size: 5915 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] webkitgtk: Reduce stack and heap sizes for jsc on musl
2021-03-17 0:31 [PATCH] webkitgtk: Reduce stack and heap sizes for jsc on musl Khem Raj
2021-03-17 11:10 ` [OE-core] " Alexander Kanavin
@ 2021-03-17 16:05 ` Andrei Gherzan
2021-03-17 20:31 ` Khem Raj
1 sibling, 1 reply; 5+ messages in thread
From: Andrei Gherzan @ 2021-03-17 16:05 UTC (permalink / raw)
To: Khem Raj, openembedded
Hi,
On Wed, 17 Mar 2021, at 00:31, Khem Raj wrote:
> Fixes
>
> [YOCTO #14281]
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> Cc: Andrei Gherzan <andrei@gherzan.com>
> ---
> .../webkitgtk/musl-lower-stack-usage.patch | 51 +++++++++++++++++++
> meta/recipes-sato/webkit/webkitgtk_2.30.5.bb | 1 +
> 2 files changed, 52 insertions(+)
> create mode 100644
> meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
>
> diff --git
> a/meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
> b/meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
> new file mode 100644
> index 0000000000..3d66766d9a
> --- /dev/null
> +++ b/meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
> @@ -0,0 +1,51 @@
> +reduce thread stack and heap usage for javascriptcore on musl
> +
> +default sizes for musl are smaller compared to glibc, this matches
> +to musl defaults, avoid stack overflow crashes in jscore
Tested and it works as expected. I was fixing it a bit hacky doing something similar to https://github.com/yaegashi/muslstack but this is cleaner.
I've backported your patch for dunfell too (rebased the patch).
Andrei
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [OE-core] [PATCH] webkitgtk: Reduce stack and heap sizes for jsc on musl
2021-03-17 11:10 ` [OE-core] " Alexander Kanavin
@ 2021-03-17 20:27 ` Khem Raj
0 siblings, 0 replies; 5+ messages in thread
From: Khem Raj @ 2021-03-17 20:27 UTC (permalink / raw)
To: Alexander Kanavin; +Cc: OE-core, Andrei Gherzan
On Wed, Mar 17, 2021 at 4:10 AM Alexander Kanavin
<alex.kanavin@gmail.com> wrote:
>
> Please Khem, send these patches upstream first.
>
its widely discussed problem in webkit and musl circuits, the patch
here is carried by almost all musl distros in some form.
see https://bugs.webkit.org/show_bug.cgi?id=187485
unfortunately, there is no final solution yet which is acceptable
upstream as such.
> Alex
>
> On Wed, 17 Mar 2021 at 01:32, Khem Raj <raj.khem@gmail.com> wrote:
>>
>> Fixes
>>
>> [YOCTO #14281]
>>
>> Signed-off-by: Khem Raj <raj.khem@gmail.com>
>> Cc: Andrei Gherzan <andrei@gherzan.com>
>> ---
>> .../webkitgtk/musl-lower-stack-usage.patch | 51 +++++++++++++++++++
>> meta/recipes-sato/webkit/webkitgtk_2.30.5.bb | 1 +
>> 2 files changed, 52 insertions(+)
>> create mode 100644 meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
>>
>> diff --git a/meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch b/meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
>> new file mode 100644
>> index 0000000000..3d66766d9a
>> --- /dev/null
>> +++ b/meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
>> @@ -0,0 +1,51 @@
>> +reduce thread stack and heap usage for javascriptcore on musl
>> +
>> +default sizes for musl are smaller compared to glibc, this matches
>> +to musl defaults, avoid stack overflow crashes in jscore
>> +
>> +Upstream-Status: Pending
>> +Signed-off-by: Khem Raj <raj.khem@gmail.com>
>> +
>> +--- a/Source/JavaScriptCore/runtime/OptionsList.h
>> ++++ b/Source/JavaScriptCore/runtime/OptionsList.h
>> +@@ -75,6 +75,18 @@ constexpr bool enableWebAssemblyStreamin
>> + // On instantiation of the first VM instance, the Options will be write protected
>> + // and cannot be modified thereafter.
>> +
>> ++#if OS(LINUX) && !defined(__GLIBC__)
>> ++// non-glibc options on linux ( musl )
>> ++constexpr unsigned jscMaxPerThreadStack = 80 * KB;
>> ++constexpr unsigned jscSoftReservedZoneSize = 32 * KB;
>> ++constexpr unsigned jscReservedZoneSize = 16 * KB;
>> ++#else
>> ++//default
>> ++constexpr unsigned jscMaxPerThreadStack = 4 * MB;
>> ++constexpr unsigned jscSoftReservedZoneSize = 128 * KB;
>> ++constexpr unsigned jscReservedZoneSize = 64 * KB;
>> ++#endif
>> ++
>> + #define FOR_EACH_JSC_OPTION(v) \
>> + v(Bool, useKernTCSM, defaultTCSMValue(), Normal, "Note: this needs to go before other options since they depend on this value.") \
>> + v(Bool, validateOptions, false, Normal, "crashes if mis-typed JSC options were passed to the VM") \
>> +@@ -90,9 +102,9 @@ constexpr bool enableWebAssemblyStreamin
>> + \
>> + v(Bool, reportMustSucceedExecutableAllocations, false, Normal, nullptr) \
>> + \
>> +- v(Unsigned, maxPerThreadStackUsage, 5 * MB, Normal, "Max allowed stack usage by the VM") \
>> +- v(Unsigned, softReservedZoneSize, 128 * KB, Normal, "A buffer greater than reservedZoneSize that reserves space for stringifying exceptions.") \
>> +- v(Unsigned, reservedZoneSize, 64 * KB, Normal, "The amount of stack space we guarantee to our clients (and to interal VM code that does not call out to clients).") \
>> ++ v(Unsigned, maxPerThreadStackUsage, jscMaxPerThreadStack, Normal, "Max allowed stack usage by the VM") \
>> ++ v(Unsigned, softReservedZoneSize, jscSoftReservedZoneSize, Normal, "A buffer greater than reservedZoneSize that reserves space for stringifying exceptions.") \
>> ++ v(Unsigned, reservedZoneSize, jscReservedZoneSize, Normal, "The amount of stack space we guarantee to our clients (and to interal VM code that does not call out to clients).") \
>> + \
>> + v(Bool, crashOnDisallowedVMEntry, ASSERT_ENABLED, Normal, "Forces a crash if we attempt to enter the VM when disallowed") \
>> + v(Bool, crashIfCantAllocateJITMemory, false, Normal, nullptr) \
>> +@@ -601,7 +613,7 @@ public:
>> + bool init(const char*);
>> + bool isInRange(unsigned);
>> + const char* rangeString() const { return (m_state > InitError) ? m_rangeString : s_nullRangeStr; }
>> +-
>> ++
>> + void dump(PrintStream& out) const;
>> +
>> + private:
>> diff --git a/meta/recipes-sato/webkit/webkitgtk_2.30.5.bb b/meta/recipes-sato/webkit/webkitgtk_2.30.5.bb
>> index d0a41f48c7..36d33f550d 100644
>> --- a/meta/recipes-sato/webkit/webkitgtk_2.30.5.bb
>> +++ b/meta/recipes-sato/webkit/webkitgtk_2.30.5.bb
>> @@ -20,6 +20,7 @@ SRC_URI = "https://www.webkitgtk.org/releases/${BPN}-${PV}.tar.xz \
>> file://include_xutil.patch \
>> file://reduce-memory-overheads.patch \
>> file://0001-Extend-atomics-check-to-include-1-byte-CAS-test.patch \
>> + file://musl-lower-stack-usage.patch \
>> "
>>
>> SRC_URI[sha256sum] = "7d0dab08e3c5ae07bec80b2822ef42e952765d5724cac86eb23999bfed5a7f1f"
>> --
>> 2.31.0
>>
>>
>>
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] webkitgtk: Reduce stack and heap sizes for jsc on musl
2021-03-17 16:05 ` Andrei Gherzan
@ 2021-03-17 20:31 ` Khem Raj
0 siblings, 0 replies; 5+ messages in thread
From: Khem Raj @ 2021-03-17 20:31 UTC (permalink / raw)
To: Andrei Gherzan; +Cc: openembedded
On Wed, Mar 17, 2021 at 9:06 AM Andrei Gherzan <andrei@gherzan.com> wrote:
>
> Hi,
>
> On Wed, 17 Mar 2021, at 00:31, Khem Raj wrote:
> > Fixes
> >
> > [YOCTO #14281]
> >
> > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > Cc: Andrei Gherzan <andrei@gherzan.com>
> > ---
> > .../webkitgtk/musl-lower-stack-usage.patch | 51 +++++++++++++++++++
> > meta/recipes-sato/webkit/webkitgtk_2.30.5.bb | 1 +
> > 2 files changed, 52 insertions(+)
> > create mode 100644
> > meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
> >
> > diff --git
> > a/meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
> > b/meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
> > new file mode 100644
> > index 0000000000..3d66766d9a
> > --- /dev/null
> > +++ b/meta/recipes-sato/webkit/webkitgtk/musl-lower-stack-usage.patch
> > @@ -0,0 +1,51 @@
> > +reduce thread stack and heap usage for javascriptcore on musl
> > +
> > +default sizes for musl are smaller compared to glibc, this matches
> > +to musl defaults, avoid stack overflow crashes in jscore
>
> Tested and it works as expected. I was fixing it a bit hacky doing something similar to https://github.com/yaegashi/muslstack but this is cleaner.
>
Thanks for testing, I have sent a v2 which should be better. I would
rather not use muslstack utility as it papers over real issues. I
think real fix would
be in webkit to use pthread_attr_setstacksize() instead of hardcoding
the values, but I will let some experts in webkit to take it on.
> I've backported your patch for dunfell too (rebased the patch).
>
> Andrei
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-03-17 20:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-17 0:31 [PATCH] webkitgtk: Reduce stack and heap sizes for jsc on musl Khem Raj
2021-03-17 11:10 ` [OE-core] " Alexander Kanavin
2021-03-17 20:27 ` Khem Raj
2021-03-17 16:05 ` Andrei Gherzan
2021-03-17 20:31 ` Khem Raj
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.