Commit 0871420f authored by David S. Miller's avatar David S. Miller

sparc64: Add tsb-ratio sysctl.

Add a sysctl to tweak the RSS limit used to decide when to grow
the TSB for an address space.

In order to avoid expensive divides and multiplies only simply
positive and negative powers of two are supported.

The function computed takes the number of TSB translations that will
fit at one time in the TSB of a given size, and either adds or
subtracts a percentage of entries.  This final value is the
RSS limit.

See tsb_size_to_rss_limit().
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 27137e52
...@@ -265,6 +265,18 @@ void __init pgtable_cache_init(void) ...@@ -265,6 +265,18 @@ void __init pgtable_cache_init(void)
} }
} }
int sysctl_tsb_ratio = -2;
static unsigned long tsb_size_to_rss_limit(unsigned long new_size)
{
unsigned long num_ents = (new_size / sizeof(struct tsb));
if (sysctl_tsb_ratio < 0)
return num_ents - (num_ents >> -sysctl_tsb_ratio);
else
return num_ents + (num_ents >> sysctl_tsb_ratio);
}
/* When the RSS of an address space exceeds tsb_rss_limit for a TSB, /* When the RSS of an address space exceeds tsb_rss_limit for a TSB,
* do_sparc64_fault() invokes this routine to try and grow it. * do_sparc64_fault() invokes this routine to try and grow it.
* *
...@@ -295,19 +307,14 @@ void tsb_grow(struct mm_struct *mm, unsigned long tsb_index, unsigned long rss) ...@@ -295,19 +307,14 @@ void tsb_grow(struct mm_struct *mm, unsigned long tsb_index, unsigned long rss)
new_cache_index = 0; new_cache_index = 0;
for (new_size = 8192; new_size < max_tsb_size; new_size <<= 1UL) { for (new_size = 8192; new_size < max_tsb_size; new_size <<= 1UL) {
unsigned long n_entries = new_size / sizeof(struct tsb); new_rss_limit = tsb_size_to_rss_limit(new_size);
if (new_rss_limit > rss)
n_entries = (n_entries * 3) / 4;
if (n_entries > rss)
break; break;
new_cache_index++; new_cache_index++;
} }
if (new_size == max_tsb_size) if (new_size == max_tsb_size)
new_rss_limit = ~0UL; new_rss_limit = ~0UL;
else
new_rss_limit = ((new_size / sizeof(struct tsb)) * 3) / 4;
retry_tsb_alloc: retry_tsb_alloc:
gfp_flags = GFP_KERNEL; gfp_flags = GFP_KERNEL;
......
...@@ -121,6 +121,10 @@ extern int sg_big_buff; ...@@ -121,6 +121,10 @@ extern int sg_big_buff;
#include <asm/system.h> #include <asm/system.h>
#endif #endif
#ifdef CONFIG_SPARC64
extern int sysctl_tsb_ratio;
#endif
#ifdef __hppa__ #ifdef __hppa__
extern int pwrsw_enabled; extern int pwrsw_enabled;
extern int unaligned_enabled; extern int unaligned_enabled;
...@@ -451,6 +455,16 @@ static struct ctl_table kern_table[] = { ...@@ -451,6 +455,16 @@ static struct ctl_table kern_table[] = {
.proc_handler = &proc_dointvec, .proc_handler = &proc_dointvec,
}, },
#endif #endif
#ifdef CONFIG_SPARC64
{
.ctl_name = CTL_UNNUMBERED,
.procname = "tsb-ratio",
.data = &sysctl_tsb_ratio,
.maxlen = sizeof (int),
.mode = 0644,
.proc_handler = &proc_dointvec,
},
#endif
#ifdef __hppa__ #ifdef __hppa__
{ {
.ctl_name = KERN_HPPA_PWRSW, .ctl_name = KERN_HPPA_PWRSW,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment