All of lore.kernel.org
 help / color / mirror / Atom feed
* Help!  Need to add a flag to ia64 thread flags
@ 2007-06-13 17:02 Lee Schermerhorn
  2007-06-13 17:21 ` Stephane Eranian
  2007-07-26 23:46 ` [PATCH] " Fenghua Yu
  0 siblings, 2 replies; 7+ messages in thread
From: Lee Schermerhorn @ 2007-06-13 17:02 UTC (permalink / raw)
  To: linux-ia64

Stephane:

I need to add a flag to the ia64 thread info flags to support my
automigration work.  I was using TIF_NOTIFY_RESUME which you removed.  I
didn't notice that happening, but even if I did, I couldn't/wouldn't
have objected because my patches are still [maybe always?] out of tree.

Now, I've tried to add an automigration-specific flag, called
TIF_MIGRATION_WORK--to the flags to trigger entry to do_notify_resume()
to handle auto-migration.  However, I'm getting errors from the
assembler in arch/ia64/kernel/fsys.S where ever the instruction:

	and r?=TIF_ALLWORK_MASK,r?

occurs, complaining that "Operand 2 of 'and' should be an 8-bit integer
(-128-127)".  This is worrisome to begin with, as thread information
flags comment says that "pending work-to-be-done flags are in
least-significant 16 bits", while the code currently only supports
"8-bits".  What's more interesting is that I've used bit '7' for the
TIF_MIGRATION_WORK flag.  That should fit in the range (-128 - 127),
right?  Maybe the assembler is confused by sign extension of the signed
8-bit int?

For my testing, I can probably use your 'PERFMON_WORK flag, but that's
probably not a good long term solution.  Any ideas how to proceed longer
term to support >7 pending work flags?

Lee


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Help!  Need to add a flag to ia64 thread flags
  2007-06-13 17:02 Help! Need to add a flag to ia64 thread flags Lee Schermerhorn
@ 2007-06-13 17:21 ` Stephane Eranian
  2007-07-27  0:01   ` Re:[PATCH] Fix uninitialized local variable "covered" in i386 acpi-cpufreq driver Fenghua Yu
  2007-07-26 23:46 ` [PATCH] " Fenghua Yu
  1 sibling, 1 reply; 7+ messages in thread
From: Stephane Eranian @ 2007-06-13 17:21 UTC (permalink / raw)
  To: linux-ia64

Hello Lee,

On Wed, Jun 13, 2007 at 01:02:04PM -0400, Lee Schermerhorn wrote:
> Stephane:
> 
> I need to add a flag to the ia64 thread info flags to support my
> automigration work.  I was using TIF_NOTIFY_RESUME which you removed.  I
> didn't notice that happening, but even if I did, I couldn't/wouldn't
> have objected because my patches are still [maybe always?] out of tree.
> 
Welcome to my world!

I remove TIF_NOTIFY_RESUME because it was unused on all but IA-64.
And there it was used by perfmon (v2.0) which I replace by a more
explicit TIF flag.

> Now, I've tried to add an automigration-specific flag, called
> TIF_MIGRATION_WORK--to the flags to trigger entry to do_notify_resume()
> to handle auto-migration.  However, I'm getting errors from the
> assembler in arch/ia64/kernel/fsys.S where ever the instruction:
> 
> 	and r?=TIF_ALLWORK_MASK,r?
> 
> occurs, complaining that "Operand 2 of 'and' should be an 8-bit integer
> (-128-127)".  This is worrisome to begin with, as thread information
> flags comment says that "pending work-to-be-done flags are in
> least-significant 16 bits", while the code currently only supports
> "8-bits".  What's more interesting is that I've used bit '7' for the
> TIF_MIGRATION_WORK flag.  That should fit in the range (-128 - 127),
> right?  Maybe the assembler is confused by sign extension of the signed
> 8-bit int?
> 
Funny! I went through exactly the same thought process when I remove the TIF
flag. Yes, the instruction say imm8, so you'd expect that a 8-bit constant
would fit. But, if you look closer and especially to the pseudo-code describing
the instruction you'll see that there is sign-extension going on, so the
assembler is not wrong. What I do not understand is what's the point of
sign-extension on a AND (bitwise) operation? 

> For my testing, I can probably use your 'PERFMON_WORK flag, but that's
> probably not a good long term solution.  Any ideas how to proceed longer
> term to support >7 pending work flags?
>

In anycase, there is no solution to your problem but to modify entry.S
to deal with the bit-width limitation, i.e, you need to load the constant
into a register and then do the and. You probably understand now, why
I thought is was easier to remove unused TIF flags....


-- 

-Stephane

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Fix uninitialized local variable "covered" in i386 acpi-cpufreq driver
  2007-06-13 17:02 Help! Need to add a flag to ia64 thread flags Lee Schermerhorn
  2007-06-13 17:21 ` Stephane Eranian
@ 2007-07-26 23:46 ` Fenghua Yu
  2007-07-27  0:12   ` Andrew Morton
  1 sibling, 1 reply; 7+ messages in thread
From: Fenghua Yu @ 2007-07-26 23:46 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton, Linus Torvalds, venkatesh.pallipadi

The local variable "covered" is used without initialization in i386 acpi-cpufreq
driver. The initial value of covered should be 0. The bug will cause memory leak
when hit. The following patch fixes this bug.

Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>

---

 arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
index 6f846be..bfb4959 100644
--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -511,7 +511,7 @@ acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu)
 static int acpi_cpufreq_early_init(void)
 {
 	struct acpi_processor_performance *data;
-	cpumask_t covered;
+	cpumask_t covered=0;
 	unsigned int i, j;
 
 	dprintk("acpi_cpufreq_early_init\n");

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re:[PATCH] Fix uninitialized local variable "covered" in i386 acpi-cpufreq driver
  2007-06-13 17:21 ` Stephane Eranian
@ 2007-07-27  0:01   ` Fenghua Yu
  0 siblings, 0 replies; 7+ messages in thread
From: Fenghua Yu @ 2007-07-27  0:01 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Morton, Linus Torvalds, venkatesh.pallipadi, Dave Jones

Updated patch:
Use CPU_MASK_NONE for initil value.

Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>

---

 arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
index 6f846be..14fc5b8 100644
--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -511,7 +511,7 @@ acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu)
 static int acpi_cpufreq_early_init(void)
 {
 	struct acpi_processor_performance *data;
-	cpumask_t covered;
+	cpumask_t covered = CPU_MASK_NONE;
 	unsigned int i, j;
 
 	dprintk("acpi_cpufreq_early_init\n");

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] Fix uninitialized local variable "covered" in i386 acpi-cpufreq driver
  2007-07-26 23:46 ` [PATCH] " Fenghua Yu
@ 2007-07-27  0:12   ` Andrew Morton
  2007-07-27  0:16     ` Andrew Morton
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2007-07-27  0:12 UTC (permalink / raw)
  To: Fenghua Yu; +Cc: linux-kernel, Linus Torvalds, venkatesh.pallipadi

On Thu, 26 Jul 2007 16:46:30 -0700 Fenghua Yu <fenghua.yu@intel.com> wrote:

> The local variable "covered" is used without initialization in i386 acpi-cpufreq
> driver. The initial value of covered should be 0. The bug will cause memory leak
> when hit. The following patch fixes this bug.
> 
> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
> 
> ---
> 
>  arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c |    2 +-
>  1 files changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
> index 6f846be..bfb4959 100644
> --- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
> +++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
> @@ -511,7 +511,7 @@ acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu)
>  static int acpi_cpufreq_early_init(void)
>  {
>  	struct acpi_processor_performance *data;
> -	cpumask_t covered;
> +	cpumask_t covered=0;
>  	unsigned int i, j;
>  
>  	dprintk("acpi_cpufreq_early_init\n");

- please put spaces around "="

- that should have been CPU_MASK_NONE

- that code's way overengineered.  This:

--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c~a
+++ a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -511,7 +511,6 @@ acpi_cpufreq_guess_freq(struct acpi_cpuf
 static int acpi_cpufreq_early_init(void)
 {
 	struct acpi_processor_performance *data;
-	cpumask_t covered;
 	unsigned int i, j;
 
 	dprintk("acpi_cpufreq_early_init\n");
@@ -520,14 +519,13 @@ static int acpi_cpufreq_early_init(void)
 		data = kzalloc(sizeof(struct acpi_processor_performance),
 			       GFP_KERNEL);
 		if (!data) {
-			for_each_cpu_mask(j, covered) {
+			for_each_possible_cpu(j) {
 				kfree(acpi_perf_data[j]);
 				acpi_perf_data[j] = NULL;
 			}
 			return -ENOMEM;
 		}
 		acpi_perf_data[i] = data;
-		cpu_set(i, covered);
 	}
 
 	/* Do initialization in ACPI core */
_

should do the trick (please check it)

- what we have here is an open-coded alloc_percpu().  Hows about
  converting it to alloc_percpu()?

- that function should have been be __init.


How's that for a one-liner? ;)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Fix uninitialized local variable "covered" in i386 acpi-cpufreq driver
  2007-07-27  0:12   ` Andrew Morton
@ 2007-07-27  0:16     ` Andrew Morton
  2007-07-27  0:46       ` Yu, Fenghua
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2007-07-27  0:16 UTC (permalink / raw)
  To: Fenghua Yu, linux-kernel, Linus Torvalds, venkatesh.pallipadi

On Thu, 26 Jul 2007 17:12:22 -0700 Andrew Morton <akpm@linux-foundation.org> wrote:

> How's that for a one-liner? ;)

- the return value from acpi_cpufreq_early_init() gets ignored,
  so the module will still load, but won't work.

- Once that is fixed, the test for !acpi_perf_data[cpu] in
  acpi_cpufreq_cpu_init() can be removed.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH] Fix uninitialized local variable "covered" in i386 acpi-cpufreq driver
  2007-07-27  0:16     ` Andrew Morton
@ 2007-07-27  0:46       ` Yu, Fenghua
  0 siblings, 0 replies; 7+ messages in thread
From: Yu, Fenghua @ 2007-07-27  0:46 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Linus Torvalds, Pallipadi, Venkatesh

>> How's that for a one-liner? ;)

>- the return value from acpi_cpufreq_early_init() gets ignored,
>  so the module will still load, but won't work.

>- Once that is fixed, the test for !acpi_perf_data[cpu] in
>  acpi_cpufreq_cpu_init() can be removed.

We will modify code in those places.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-07-27  0:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-13 17:02 Help! Need to add a flag to ia64 thread flags Lee Schermerhorn
2007-06-13 17:21 ` Stephane Eranian
2007-07-27  0:01   ` Re:[PATCH] Fix uninitialized local variable "covered" in i386 acpi-cpufreq driver Fenghua Yu
2007-07-26 23:46 ` [PATCH] " Fenghua Yu
2007-07-27  0:12   ` Andrew Morton
2007-07-27  0:16     ` Andrew Morton
2007-07-27  0:46       ` Yu, Fenghua

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.