* [PATCH v4 0/4] metag,parisc: Stack limit patches
@ 2014-05-14 12:52 James Hogan
[not found] ` <1400071968-21581-1-git-send-email-james.hogan-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: James Hogan @ 2014-05-14 12:52 UTC (permalink / raw)
To: Helge Deller
Cc: James Hogan, James E.J. Bottomley, Arnd Bergmann,
John David Anglin, linux-arch-u79uwXL29TY76Z2rM5mHXA,
linux-metag-u79uwXL29TY76Z2rM5mHXA,
linux-parisc-u79uwXL29TY76Z2rM5mHXA
Patch 1 is a metag bug fix for v3.15 & stable.
Patch 2 depends on patch 1, and makes the stack limit configurable.
Helge: I don't object if you want to take this patch yourself since it
was originally yours, so long as it goes after patch 1 (which I'll try
and get into v3.15-rc6).
Patch 3 depends on patch 1, and removes the RLIMIT_STACK default value
for metag. I'll take this through metag tree for v3.16.
Patch 4 depends on patch 3 and the corresponding parisc patch and
removes the ability to override the default hard RLIMIT_STACK. Depending
on when the parisc patch reaches mainline I'll try and get this in for
v3.16.
Helge Deller (1):
parisc,metag: Do not hardcode maximum userspace stack size
James Hogan (3):
metag: Reduce maximum stack size to 256MB
metag: Remove _STK_LIM_MAX override
asm-generic: remove _STK_LIM_MAX
arch/metag/include/asm/processor.h | 2 ++
arch/metag/include/uapi/asm/Kbuild | 2 +-
arch/metag/include/uapi/asm/resource.h | 7 -------
arch/parisc/include/asm/processor.h | 5 +++++
arch/parisc/kernel/sys_parisc.c | 6 +++---
fs/exec.c | 6 +++---
include/asm-generic/resource.h | 2 +-
include/uapi/asm-generic/resource.h | 7 -------
mm/Kconfig | 15 +++++++++++++++
9 files changed, 30 insertions(+), 22 deletions(-)
delete mode 100644 arch/metag/include/uapi/asm/resource.h
Cc: Helge Deller <deller-Mmb7MZpHnFY@public.gmane.org>
Cc: "James E.J. Bottomley" <jejb-6jwH94ZQLHl74goWV3ctuw@public.gmane.org>
Cc: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Cc: John David Anglin <dave.anglin-CzeTG9NwML0@public.gmane.org>
Cc: linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-metag-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-parisc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
--
1.9.3
--
To unsubscribe from this list: send the line "unsubscribe linux-metag" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v4 2/4] parisc,metag: Do not hardcode maximum userspace stack size
[not found] ` <1400071968-21581-1-git-send-email-james.hogan-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
@ 2014-05-14 12:52 ` James Hogan
2014-05-14 19:22 ` [PATCH v4 0/4] metag,parisc: Stack limit patches Helge Deller
1 sibling, 0 replies; 4+ messages in thread
From: James Hogan @ 2014-05-14 12:52 UTC (permalink / raw)
To: Helge Deller
Cc: James Hogan, James E.J. Bottomley,
linux-parisc-u79uwXL29TY76Z2rM5mHXA,
linux-metag-u79uwXL29TY76Z2rM5mHXA, John David Anglin
From: Helge Deller <deller-Mmb7MZpHnFY@public.gmane.org>
This patch affects only architectures where the stack grows upwards
(currently parisc and metag only). On those do not hardcode the maximum
initial stack size to 1GB for 32-bit processes, but make it configurable
via a config option.
The main problem with the hardcoded stack size is, that we have two
memory regions which grow upwards: stack and heap. To keep most of the
memory available for heap in a flexmap memory layout, it makes no sense
to hard allocate up to 1GB of the memory for stack which can't be used
as heap then.
This patch makes the stack size for 32-bit processes configurable and
uses 80MB as default value which has been in use during the last few
years on parisc and which hasn't showed any problems yet.
Signed-off-by: Helge Deller <deller-Mmb7MZpHnFY@public.gmane.org>
Signed-off-by: James Hogan <james.hogan-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
Cc: "James E.J. Bottomley" <jejb-6jwH94ZQLHl74goWV3ctuw@public.gmane.org>
Cc: linux-parisc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-metag-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: John David Anglin <dave.anglin-CzeTG9NwML0@public.gmane.org>
---
v4 (James Hogan):
- split out the metag stable fix, otherwise identical.
v3 (James Hogan):
- fix so that 64-bit parisc processes still use the 1GB limit.
CONFIG_STACK_GROWSUP arches should provide a STACK_SIZE_MAX in their
asm/processor.h, and for parisc it depends on USER_WIDE_MODE (whether
the current process is 64-bit).
v2 (James Hogan):
- updated description to mention BUG on metag.
- added custom range limit for METAG.
- moved Kconfig symbol to mm/Kconfig and reworded.
- fixed "matag" typo.
---
arch/metag/include/asm/processor.h | 2 +-
arch/parisc/include/asm/processor.h | 5 ++++-
arch/parisc/kernel/sys_parisc.c | 6 +++---
mm/Kconfig | 15 +++++++++++++++
4 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/arch/metag/include/asm/processor.h b/arch/metag/include/asm/processor.h
index 3be8581af495..a8a37477c66e 100644
--- a/arch/metag/include/asm/processor.h
+++ b/arch/metag/include/asm/processor.h
@@ -23,7 +23,7 @@
#define STACK_TOP (TASK_SIZE - PAGE_SIZE)
#define STACK_TOP_MAX STACK_TOP
/* Maximum virtual space for stack */
-#define STACK_SIZE_MAX (1 << 28) /* 256 MB */
+#define STACK_SIZE_MAX (CONFIG_MAX_STACK_SIZE_MB*1024*1024)
/* This decides where the kernel will search for a free chunk of vm
* space during mmap's.
diff --git a/arch/parisc/include/asm/processor.h b/arch/parisc/include/asm/processor.h
index 86522ef09d52..d951c9681ab3 100644
--- a/arch/parisc/include/asm/processor.h
+++ b/arch/parisc/include/asm/processor.h
@@ -55,7 +55,10 @@
#define STACK_TOP TASK_SIZE
#define STACK_TOP_MAX DEFAULT_TASK_SIZE
-#define STACK_SIZE_MAX (1 << 30) /* 1 GB */
+/* Allow bigger stacks for 64-bit processes */
+#define STACK_SIZE_MAX (USER_WIDE_MODE \
+ ? (1 << 30) /* 1 GB */ \
+ : (CONFIG_MAX_STACK_SIZE_MB*1024*1024))
#endif
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index 31ffa9b55322..e1ffea2f9a0b 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -72,10 +72,10 @@ static unsigned long mmap_upper_limit(void)
{
unsigned long stack_base;
- /* Limit stack size to 1GB - see setup_arg_pages() in fs/exec.c */
+ /* Limit stack size - see setup_arg_pages() in fs/exec.c */
stack_base = rlimit_max(RLIMIT_STACK);
- if (stack_base > (1 << 30))
- stack_base = 1 << 30;
+ if (stack_base > STACK_SIZE_MAX)
+ stack_base = STACK_SIZE_MAX;
return PAGE_ALIGN(STACK_TOP - stack_base);
}
diff --git a/mm/Kconfig b/mm/Kconfig
index ebe5880c29d6..1b5a95f0fa01 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -581,3 +581,18 @@ config PGTABLE_MAPPING
config GENERIC_EARLY_IOREMAP
bool
+
+config MAX_STACK_SIZE_MB
+ int "Maximum user stack size for 32-bit processes (MB)"
+ default 80
+ range 8 256 if METAG
+ range 8 2048
+ depends on STACK_GROWSUP && (!64BIT || COMPAT)
+ help
+ This is the maximum stack size in Megabytes in the VM layout of 32-bit
+ user processes when the stack grows upwards (currently only on parisc
+ and metag arch). The stack will be located at the highest memory
+ address minus the given value, unless the RLIMIT_STACK hard limit is
+ changed to a smaller value in which case that is used.
+
+ A sane initial value is 80 MB.
--
1.9.3
--
To unsubscribe from this list: send the line "unsubscribe linux-metag" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v4 0/4] metag,parisc: Stack limit patches
[not found] ` <1400071968-21581-1-git-send-email-james.hogan-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2014-05-14 12:52 ` [PATCH v4 2/4] parisc,metag: Do not hardcode maximum userspace stack size James Hogan
@ 2014-05-14 19:22 ` Helge Deller
[not found] ` <5373C28C.3040106-Mmb7MZpHnFY@public.gmane.org>
1 sibling, 1 reply; 4+ messages in thread
From: Helge Deller @ 2014-05-14 19:22 UTC (permalink / raw)
To: James Hogan
Cc: James E.J. Bottomley, Arnd Bergmann, John David Anglin,
linux-arch-u79uwXL29TY76Z2rM5mHXA,
linux-metag-u79uwXL29TY76Z2rM5mHXA,
linux-parisc-u79uwXL29TY76Z2rM5mHXA
Hi James,
On 05/14/2014 02:52 PM, James Hogan wrote:
> Patch 1 is a metag bug fix for v3.15 & stable.
>
> Patch 2 depends on patch 1, and makes the stack limit configurable.
> Helge: I don't object if you want to take this patch yourself since it
> was originally yours, so long as it goes after patch 1 (which I'll try
> and get into v3.15-rc6).
Thanks for cleaning it up!
I'd really prefer if you could push the whole series through your tree.
That way you can easily ensure the correct sequence.
IMHO, it would be nice if all four patches would still go into 3.15, esp.
since it affects our platforms (parisc & metag) only.
Helge
>
> Patch 3 depends on patch 1, and removes the RLIMIT_STACK default value
> for metag. I'll take this through metag tree for v3.16.
>
> Patch 4 depends on patch 3 and the corresponding parisc patch and
> removes the ability to override the default hard RLIMIT_STACK. Depending
> on when the parisc patch reaches mainline I'll try and get this in for
> v3.16.
>
> Helge Deller (1):
> parisc,metag: Do not hardcode maximum userspace stack size
>
> James Hogan (3):
> metag: Reduce maximum stack size to 256MB
> metag: Remove _STK_LIM_MAX override
> asm-generic: remove _STK_LIM_MAX
>
> arch/metag/include/asm/processor.h | 2 ++
> arch/metag/include/uapi/asm/Kbuild | 2 +-
> arch/metag/include/uapi/asm/resource.h | 7 -------
> arch/parisc/include/asm/processor.h | 5 +++++
> arch/parisc/kernel/sys_parisc.c | 6 +++---
> fs/exec.c | 6 +++---
> include/asm-generic/resource.h | 2 +-
> include/uapi/asm-generic/resource.h | 7 -------
> mm/Kconfig | 15 +++++++++++++++
> 9 files changed, 30 insertions(+), 22 deletions(-)
> delete mode 100644 arch/metag/include/uapi/asm/resource.h
>
> Cc: Helge Deller <deller-Mmb7MZpHnFY@public.gmane.org>
> Cc: "James E.J. Bottomley" <jejb-6jwH94ZQLHl74goWV3ctuw@public.gmane.org>
> Cc: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
> Cc: John David Anglin <dave.anglin-CzeTG9NwML0@public.gmane.org>
> Cc: linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: linux-metag-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: linux-parisc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>
--
To unsubscribe from this list: send the line "unsubscribe linux-metag" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4 0/4] metag,parisc: Stack limit patches
[not found] ` <5373C28C.3040106-Mmb7MZpHnFY@public.gmane.org>
@ 2014-05-14 23:25 ` James Hogan
0 siblings, 0 replies; 4+ messages in thread
From: James Hogan @ 2014-05-14 23:25 UTC (permalink / raw)
To: Helge Deller
Cc: James E.J. Bottomley, Arnd Bergmann, John David Anglin,
linux-arch-u79uwXL29TY76Z2rM5mHXA,
linux-metag-u79uwXL29TY76Z2rM5mHXA,
linux-parisc-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 2728 bytes --]
Hi Helge,
On 14/05/14 20:22, Helge Deller wrote:
> On 05/14/2014 02:52 PM, James Hogan wrote:
>> Patch 1 is a metag bug fix for v3.15 & stable.
>>
>> Patch 2 depends on patch 1, and makes the stack limit configurable.
>> Helge: I don't object if you want to take this patch yourself since it
>> was originally yours, so long as it goes after patch 1 (which I'll try
>> and get into v3.15-rc6).
>
> Thanks for cleaning it up!
> I'd really prefer if you could push the whole series through your tree.
> That way you can easily ensure the correct sequence.
Okay, no problem, and I see the parisc patch is already in mainline.
> IMHO, it would be nice if all four patches would still go into 3.15, esp.
> since it affects our platforms (parisc & metag) only.
Right. That doesn't sound unreasonable since patch 2 restores default
80MB stacks for parisc, patch 3 may prevent confusing userland, and
patch 4 is just an obvious cleanup as a result of earlier patches.
Cheers
James
>
> Helge
>
>>
>> Patch 3 depends on patch 1, and removes the RLIMIT_STACK default value
>> for metag. I'll take this through metag tree for v3.16.
>>
>> Patch 4 depends on patch 3 and the corresponding parisc patch and
>> removes the ability to override the default hard RLIMIT_STACK. Depending
>> on when the parisc patch reaches mainline I'll try and get this in for
>> v3.16.
>>
>> Helge Deller (1):
>> parisc,metag: Do not hardcode maximum userspace stack size
>>
>> James Hogan (3):
>> metag: Reduce maximum stack size to 256MB
>> metag: Remove _STK_LIM_MAX override
>> asm-generic: remove _STK_LIM_MAX
>>
>> arch/metag/include/asm/processor.h | 2 ++
>> arch/metag/include/uapi/asm/Kbuild | 2 +-
>> arch/metag/include/uapi/asm/resource.h | 7 -------
>> arch/parisc/include/asm/processor.h | 5 +++++
>> arch/parisc/kernel/sys_parisc.c | 6 +++---
>> fs/exec.c | 6 +++---
>> include/asm-generic/resource.h | 2 +-
>> include/uapi/asm-generic/resource.h | 7 -------
>> mm/Kconfig | 15 +++++++++++++++
>> 9 files changed, 30 insertions(+), 22 deletions(-)
>> delete mode 100644 arch/metag/include/uapi/asm/resource.h
>>
>> Cc: Helge Deller <deller-Mmb7MZpHnFY@public.gmane.org>
>> Cc: "James E.J. Bottomley" <jejb-6jwH94ZQLHl74goWV3ctuw@public.gmane.org>
>> Cc: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
>> Cc: John David Anglin <dave.anglin-CzeTG9NwML0@public.gmane.org>
>> Cc: linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> Cc: linux-metag-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> Cc: linux-parisc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-05-14 23:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-14 12:52 [PATCH v4 0/4] metag,parisc: Stack limit patches James Hogan
[not found] ` <1400071968-21581-1-git-send-email-james.hogan-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2014-05-14 12:52 ` [PATCH v4 2/4] parisc,metag: Do not hardcode maximum userspace stack size James Hogan
2014-05-14 19:22 ` [PATCH v4 0/4] metag,parisc: Stack limit patches Helge Deller
[not found] ` <5373C28C.3040106-Mmb7MZpHnFY@public.gmane.org>
2014-05-14 23:25 ` James Hogan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).