From: Borislav Petkov <bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org>
To: Andy Lutomirski <luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] x86: Add a turbo mode sysctl
Date: Fri, 1 Apr 2016 18:05:56 +0200 [thread overview]
Message-ID: <20160401160556.GB25391@pd.tnic> (raw)
In-Reply-To: <cd6157244ae75145e2529a1d73f6174cd829ac9c.1459525715.git.luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
On Fri, Apr 01, 2016 at 08:49:53AM -0700, Andy Lutomirski wrote:
> Sadly, hardware turbo mode buttons are few and far between in these
> degenerate times. Add a software control at /proc/sys/turbo_mode.
>
> Unfortunately, Linux graphical environments have become very
> heavy-weight and are essentially unusable on non-Turbo systems. The
> VT console works very well, though.
>
> Due to KVM limitations, turbo mode is permanently on in a KVM guest.
>
> Signed-off-by: Andy Lutomirski <luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> ---
> arch/x86/mm/pat.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 61 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
> index faec01e7a17d..f703d8b1ed20 100644
> --- a/arch/x86/mm/pat.c
> +++ b/arch/x86/mm/pat.c
> @@ -69,6 +69,8 @@ static int __init pat_debug_setup(char *str)
> }
> __setup("debugpat", pat_debug_setup);
>
> +static int turbo_mode = 1;
> +
> #ifdef CONFIG_X86_PAT
> /*
> * X86 PAT uses page flags arch_1 and uncached together to keep track of
> @@ -176,6 +178,62 @@ static enum page_cache_mode pat_get_cache_mode(unsigned pat_val, char *msg)
>
> #undef CM
>
> +#define PAT(x, y) ((u64)PAT_ ## y << ((x)*8))
> +
> +static void update_local_turbo_mode(void *dummy)
> +{
> + unsigned long cr0 = read_cr0();
> +
> + /*
> + * KVM doesn't properly handle CD.
> + *
> + * XXX: this may interact poorly with CPU hotplug.
> + */
> +
> + if (turbo_mode)
> + write_cr0(cr0 & ~X86_CR0_CD);
> + else
> + write_cr0(cr0 | X86_CR0_CD);
Good!
> +}
> +
> +static void update_turbo_mode(void)
> +{
> + on_each_cpu(update_local_turbo_mode, NULL, 1);
> +
> + if (!turbo_mode)
> + wbinvd();
> +}
> +
> +static int turbo_mode_handler(struct ctl_table *table, int write,
> + void __user *buffer, size_t *lenp,
> + loff_t *ppos)
> +{
> + int error;
> +
> + error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
> + if (error)
> + return error;
> +
> + if (write)
> + update_turbo_mode();
> +
> + return 0;
> +}
> +
> +static int zero, one = 1;
> +static struct ctl_table turbo_mode_table[] = {
> + {
> + .procname = "turbo_mode",
I'd call that "make_shit_faster". Other than that, ACK!
> + .data = &turbo_mode,
> + .maxlen = sizeof(int),
> + .mode = 0644,
> + .proc_handler = turbo_mode_handler,
> + .extra1 = &zero,
> + .extra2 = &one,
> + },
> + {}
> +};
> +
> /*
> * Update the cache mode to pgprot translation tables according to PAT
> * configuration.
> @@ -196,8 +254,6 @@ void pat_init_cache_modes(u64 pat)
> pr_info("x86/PAT: Configuration [0-7]: %s\n", pat_msg);
> }
>
> -#define PAT(x, y) ((u64)PAT_ ## y << ((x)*8))
> -
> static void pat_bsp_init(u64 pat)
> {
> u64 tmp_pat;
> @@ -1096,6 +1152,9 @@ static int __init pat_memtype_list_init(void)
> debugfs_create_file("pat_memtype_list", S_IRUSR,
> arch_debugfs_dir, NULL, &memtype_fops);
> }
> +
> + register_sysctl_table(turbo_mode_table);
> +
> return 0;
> }
>
> --
> 2.5.5
>
>
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
next prev parent reply other threads:[~2016-04-01 16:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-01 15:49 [PATCH] x86: Add a turbo mode sysctl Andy Lutomirski
[not found] ` <cd6157244ae75145e2529a1d73f6174cd829ac9c.1459525715.git.luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-04-01 16:05 ` Borislav Petkov [this message]
2016-04-01 16:07 ` kbuild test robot
2016-04-01 16:10 ` Thomas Gleixner
2016-04-02 20:21 ` Andy Lutomirski
[not found] ` <CALCETrUfy-yZ6FD7J3AwhP7KB5eZ+YRMrKS_CyNDLvJwmiC49g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-04-03 9:55 ` Thomas Gleixner
2016-04-03 10:12 ` Borislav Petkov
2016-04-04 6:48 ` Nikolay Borisov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160401160556.GB25391@pd.tnic \
--to=bp-gina5biwoiwzqb+pc5nmwq@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).