mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch] intel_cacheinfo: remove MAX_CACHE_LEAVES limit
@ 2005-09-19 19:14 Siddha, Suresh B
  2005-09-20 23:06 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Siddha, Suresh B @ 2005-09-19 19:14 UTC (permalink / raw)
  To: akpm; +Cc: venkatesh.pallipadi, linux-kernel

Remove the MAX_CACHE_LEAVES limit from the routine which calculates the
number of cache levels using cpuid(4)

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>

--- linux-2.6.13/arch/i386/kernel/cpu/intel_cacheinfo.c	2005-08-28 16:41:01.000000000 -0700
+++ linux-2.6.13~/arch/i386/kernel/cpu/intel_cacheinfo.c	2005-09-19 10:37:58.329447344 -0700
@@ -117,7 +117,6 @@ struct _cpuid4_info {
 	cpumask_t shared_cpu_map;
 };
 
-#define MAX_CACHE_LEAVES		4
 static unsigned short			num_cache_leaves;
 
 static int __devinit cpuid4_cache_lookup(int index, struct _cpuid4_info *this_leaf)
@@ -144,20 +143,15 @@ static int __init find_num_cache_leaves(
 {
 	unsigned int		eax, ebx, ecx, edx;
 	union _cpuid4_leaf_eax	cache_eax;
-	int 			i;
-	int 			retval;
+	int 			i = -1;
 
-	retval = MAX_CACHE_LEAVES;
-	/* Do cpuid(4) loop to find out num_cache_leaves */
-	for (i = 0; i < MAX_CACHE_LEAVES; i++) {
+	do {
+		++i;
+		/* Do cpuid(4) loop to find out num_cache_leaves */
 		cpuid_count(4, i, &eax, &ebx, &ecx, &edx);
 		cache_eax.full = eax;
-		if (cache_eax.split.type == CACHE_TYPE_NULL) {
-			retval = i;
-			break;
-		}
-	}
-	return retval;
+	} while (cache_eax.split.type != CACHE_TYPE_NULL);
+	return i;
 }
 
 unsigned int __devinit init_intel_cacheinfo(struct cpuinfo_x86 *c)

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

* Re: [patch] intel_cacheinfo: remove MAX_CACHE_LEAVES limit
  2005-09-19 19:14 [patch] intel_cacheinfo: remove MAX_CACHE_LEAVES limit Siddha, Suresh B
@ 2005-09-20 23:06 ` Andrew Morton
  2005-09-21  0:58   ` Siddha, Suresh B
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2005-09-20 23:06 UTC (permalink / raw)
  To: Siddha, Suresh B; +Cc: venkatesh.pallipadi, linux-kernel

"Siddha, Suresh B" <suresh.b.siddha@intel.com> wrote:
>
> Remove the MAX_CACHE_LEAVES limit from the routine which calculates the
> number of cache levels using cpuid(4)

Why?  Why was the code there originally, and why is it required that it be
removed, and why is it safe to remove it?

(IOW: your description of this patch is inadequate: it describes what was
done, but not why it was done).

Thanks.

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

* Re: [patch] intel_cacheinfo: remove MAX_CACHE_LEAVES limit
  2005-09-20 23:06 ` Andrew Morton
@ 2005-09-21  0:58   ` Siddha, Suresh B
  0 siblings, 0 replies; 3+ messages in thread
From: Siddha, Suresh B @ 2005-09-21  0:58 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Siddha, Suresh B, venkatesh.pallipadi, linux-kernel

On Tue, Sep 20, 2005 at 04:06:04PM -0700, Andrew Morton wrote:
> "Siddha, Suresh B" <suresh.b.siddha@intel.com> wrote:
> >
> > Remove the MAX_CACHE_LEAVES limit from the routine which calculates the
> > number of cache levels using cpuid(4)
> 
> Why?  Why was the code there originally, and why is it required that it be
> removed, and why is it safe to remove it?
> 
> (IOW: your description of this patch is inadequate: it describes what was
> done, but not why it was done).

oops! Initial internal version of Venki's cpuid(4) deterministic cache
parameter identification patch used static arrays of size MAX_CACHE_LEAVES. 
Final patch which made to the base used dynamic array allocation, with this
MAX_CACHE_LEAVES limit hunk still in place. 

cpuid(4) already has a mechanism to find out the number of cache levels
implemented and there is no need for this hardcoded MAX_CACHE_LEAVES limit.

thanks,
suresh

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

end of thread, other threads:[~2005-09-21  0:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-19 19:14 [patch] intel_cacheinfo: remove MAX_CACHE_LEAVES limit Siddha, Suresh B
2005-09-20 23:06 ` Andrew Morton
2005-09-21  0:58   ` Siddha, Suresh B

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome