Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1160943 > unrolled thread

[PATCH v2 2/4] x86, mwaitt: make delay method configurable

Started byHuang Rui <ray.huang@amd.com>
First post2015-06-09 05:20 +0200
Last post2015-06-09 11:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 2/4] x86, mwaitt: make delay method configurable Huang Rui <ray.huang@amd.com> - 2015-06-09 05:20 +0200
    Re: [PATCH v2 2/4] x86, mwaitt: make delay method configurable Borislav Petkov <bp@suse.de> - 2015-06-09 11:10 +0200

#1160943 — [PATCH v2 2/4] x86, mwaitt: make delay method configurable

FromHuang Rui <ray.huang@amd.com>
Date2015-06-09 05:20 +0200
Subject[PATCH v2 2/4] x86, mwaitt: make delay method configurable
Message-ID<pzieZ-2kK-9@gated-at.bofh.it>
This patch introduces a kernel parameter (delay), user is able to configure
it at boot loader to choose different types of delay method.

Default schema is to use TSC delay. This update can be more flexiable to
add new delay method.

Suggested-by: Suravee Suthikulanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Huang Rui <ray.huang@amd.com>
---
 arch/x86/include/asm/delay.h |    7 +++++++
 arch/x86/kernel/setup.c      |   19 +++++++++++++++++++
 arch/x86/lib/delay.c         |   12 +++++++++++-
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/delay.h b/arch/x86/include/asm/delay.h
index 9b3b4f2..99873ec 100644
--- a/arch/x86/include/asm/delay.h
+++ b/arch/x86/include/asm/delay.h
@@ -5,4 +5,11 @@
 
 void use_tsc_delay(void);
 
+extern unsigned long boot_option_delay;
+
+enum delay_type {
+	DELAY_LOOP=0,
+	DELAY_TSC,
+};
+
 #endif /* _ASM_X86_DELAY_H */
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 0b10698..cc2886d 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -111,6 +111,7 @@
 #include <asm/mce.h>
 #include <asm/alternative.h>
 #include <asm/prom.h>
+#include <asm/delay.h>
 
 /*
  * max_low_pfn_mapped: highest direct mapped pfn under 4GB
@@ -844,6 +845,24 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
 	return 0;
 }
 
+static int __init delay_setup(char *str)
+{
+	if (!str)
+		return -EINVAL;
+
+	if (!strcmp(str, "tsc")) {
+		pr_info("using tsc delay\n");
+		boot_option_delay = DELAY_TSC;
+	} else if (!strcmp(str, "loop")) {
+		pr_info("using loop delay\n");
+		boot_option_delay = DELAY_LOOP;
+	} else
+		return -1;
+
+	return 0;
+}
+early_param("delay", delay_setup);
+
 /*
  * Determine if we were loaded by an EFI loader.  If so, then we have also been
  * passed the efi memmap, systab, etc., so we should use these data structures
diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c
index 39d6a3d..1a6952e 100644
--- a/arch/x86/lib/delay.c
+++ b/arch/x86/lib/delay.c
@@ -25,6 +25,8 @@
 # include <asm/smp.h>
 #endif
 
+unsigned long boot_option_delay = DELAY_TSC;
+
 /* simple loop based delay: */
 static void delay_loop(unsigned long loops)
 {
@@ -94,7 +96,15 @@ static void (*delay_fn)(unsigned long) = delay_loop;
 
 void use_tsc_delay(void)
 {
-	delay_fn = delay_tsc;
+	switch (boot_option_delay) {
+	case DELAY_LOOP:
+		delay_fn = delay_loop;
+		return;
+	case DELAY_TSC:
+	default:
+		delay_fn = delay_tsc;
+		return;
+	}
 }
 
 int read_current_timer(unsigned long *timer_val)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1161143

FromBorislav Petkov <bp@suse.de>
Date2015-06-09 11:10 +0200
Message-ID<pznHI-1XB-3@gated-at.bofh.it>
In reply to#1160943
On Tue, Jun 09, 2015 at 11:13:39AM +0800, Huang Rui wrote:
> This patch introduces a kernel parameter (delay), user is able to configure
> it at boot loader to choose different types of delay method.
> 
> Default schema is to use TSC delay. This update can be more flexiable to
> add new delay method.
> 
> Suggested-by: Suravee Suthikulanit <suravee.suthikulpanit@amd.com>
> Signed-off-by: Huang Rui <ray.huang@amd.com>
> ---
>  arch/x86/include/asm/delay.h |    7 +++++++
>  arch/x86/kernel/setup.c      |   19 +++++++++++++++++++
>  arch/x86/lib/delay.c         |   12 +++++++++++-
>  3 files changed, 37 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/include/asm/delay.h b/arch/x86/include/asm/delay.h
> index 9b3b4f2..99873ec 100644
> --- a/arch/x86/include/asm/delay.h
> +++ b/arch/x86/include/asm/delay.h
> @@ -5,4 +5,11 @@
>  
>  void use_tsc_delay(void);
>  
> +extern unsigned long boot_option_delay;
> +
> +enum delay_type {
> +	DELAY_LOOP=0,
> +	DELAY_TSC,
> +};
> +
>  #endif /* _ASM_X86_DELAY_H */
> diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
> index 0b10698..cc2886d 100644
> --- a/arch/x86/kernel/setup.c
> +++ b/arch/x86/kernel/setup.c
> @@ -111,6 +111,7 @@
>  #include <asm/mce.h>
>  #include <asm/alternative.h>
>  #include <asm/prom.h>
> +#include <asm/delay.h>
>  
>  /*
>   * max_low_pfn_mapped: highest direct mapped pfn under 4GB
> @@ -844,6 +845,24 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
>  	return 0;
>  }
>  
> +static int __init delay_setup(char *str)
> +{
> +	if (!str)
> +		return -EINVAL;
> +
> +	if (!strcmp(str, "tsc")) {
> +		pr_info("using tsc delay\n");
> +		boot_option_delay = DELAY_TSC;
> +	} else if (!strcmp(str, "loop")) {
> +		pr_info("using loop delay\n");
> +		boot_option_delay = DELAY_LOOP;
> +	} else
> +		return -1;

What Peter said.

And we did talk about this already in the last review. You guys want to
drop all those kernel parameters and use MWAITX delay by default when:

1. HW supports MWAITX

*and*

2. delay fits in u32.

Kernel parameters is a bad bad idea.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web