From: Andrew Morton <akpm@linux-foundation.org>
To: Jesse Barnes <jesse.barnes@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>,
linux-kernel@vger.kernel.org,
Justin Piszcz <jpiszcz@lucidpixels.com>,
"Eric W. Biederman" <ebiederm@xmission.com>
Subject: Re: [PATCH] trim memory not covered by WB MTRRs
Date: Thu, 7 Jun 2007 17:20:50 -0700 [thread overview]
Message-ID: <20070607172050.ead923b4.akpm@linux-foundation.org> (raw)
In-Reply-To: <200706061229.24486.jesse.barnes@intel.com>
On Wed, 6 Jun 2007 12:29:23 -0700
Jesse Barnes <jesse.barnes@intel.com> wrote:
> --- a/arch/i386/kernel/cpu/mtrr/if.c
> +++ b/arch/i386/kernel/cpu/mtrr/if.c
> @@ -12,7 +12,7 @@
> #include "mtrr.h"
>
> /* RED-PEN: this is accessed without any locking */
> -extern unsigned int *usage_table;
> +extern unsigned int usage_table[];
>
>
> --- a/arch/i386/kernel/cpu/mtrr/main.c
> +++ b/arch/i386/kernel/cpu/mtrr/main.c
> @@ -47,7 +47,7 @@
>
> u32 num_var_ranges = 0;
>
> -unsigned int *usage_table;
> +unsigned int usage_table[NUM_VAR_RANGES];
> static DEFINE_MUTEX(mtrr_mutex);
didn't it feel all dirty when you had to do that?
From: Andrew Morton <akpm@linux-foundation.org>
- Move the declaration into a header file
- "usage_table" is a dumb name for an mtrr-specific kernel-wide identifier.
There appear to beseveral other poorly-chosen identifiers in mtrr.
Cc: Andi Kleen <ak@suse.de>
Cc: Jesse Barnes <jesse.barnes@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
arch/i386/kernel/cpu/mtrr/if.c | 8 ++------
arch/i386/kernel/cpu/mtrr/main.c | 17 +++++++++--------
arch/i386/kernel/cpu/mtrr/mtrr.h | 2 ++
3 files changed, 13 insertions(+), 14 deletions(-)
diff -puN arch/i386/kernel/cpu/mtrr/if.c~i386-x86_64-trim-memory-not-covered-by-wb-mtrrs-fix arch/i386/kernel/cpu/mtrr/if.c
--- a/arch/i386/kernel/cpu/mtrr/if.c~i386-x86_64-trim-memory-not-covered-by-wb-mtrrs-fix
+++ a/arch/i386/kernel/cpu/mtrr/if.c
@@ -11,10 +11,6 @@
#include <asm/mtrr.h>
#include "mtrr.h"
-/* RED-PEN: this is accessed without any locking */
-extern unsigned int usage_table[];
-
-
#define FILE_FCOUNT(f) (((struct seq_file *)((f)->private_data))->private)
static const char *const mtrr_strings[MTRR_NUM_TYPES] =
@@ -396,7 +392,7 @@ static int mtrr_seq_show(struct seq_file
for (i = 0; i < max; i++) {
mtrr_if->get(i, &base, &size, &type);
if (size == 0)
- usage_table[i] = 0;
+ mtrr_usage_table[i] = 0;
else {
if (size < (0x100000 >> PAGE_SHIFT)) {
/* less than 1MB */
@@ -410,7 +406,7 @@ static int mtrr_seq_show(struct seq_file
len += seq_printf(seq,
"reg%02i: base=0x%05lx000 (%4luMB), size=%4lu%cB: %s, count=%d\n",
i, base, base >> (20 - PAGE_SHIFT), size, factor,
- mtrr_attrib_to_str(type), usage_table[i]);
+ mtrr_attrib_to_str(type), mtrr_usage_table[i]);
}
}
return 0;
diff -puN arch/i386/kernel/cpu/mtrr/main.c~i386-x86_64-trim-memory-not-covered-by-wb-mtrrs-fix arch/i386/kernel/cpu/mtrr/main.c
--- a/arch/i386/kernel/cpu/mtrr/main.c~i386-x86_64-trim-memory-not-covered-by-wb-mtrrs-fix
+++ a/arch/i386/kernel/cpu/mtrr/main.c
@@ -47,7 +47,7 @@
u32 num_var_ranges = 0;
-unsigned int usage_table[NUM_VAR_RANGES];
+unsigned int mtrr_usage_table[NUM_VAR_RANGES];
static DEFINE_MUTEX(mtrr_mutex);
u64 size_or_mask, size_and_mask;
@@ -127,7 +127,7 @@ static void __init init_table(void)
max = num_var_ranges;
for (i = 0; i < max; i++)
- usage_table[i] = 1;
+ mtrr_usage_table[i] = 1;
}
struct set_mtrr_data {
@@ -381,7 +381,7 @@ int mtrr_add_page(unsigned long base, un
goto out;
}
if (increment)
- ++usage_table[i];
+ ++mtrr_usage_table[i];
error = i;
goto out;
}
@@ -390,12 +390,13 @@ int mtrr_add_page(unsigned long base, un
if (i >= 0) {
set_mtrr(i, base, size, type);
if (likely(replace < 0))
- usage_table[i] = 1;
+ mtrr_usage_table[i] = 1;
else {
- usage_table[i] = usage_table[replace] + !!increment;
+ mtrr_usage_table[i] = mtrr_usage_table[replace] +
+ !!increment;
if (unlikely(replace != i)) {
set_mtrr(replace, 0, 0, 0);
- usage_table[replace] = 0;
+ mtrr_usage_table[replace] = 0;
}
}
} else
@@ -525,11 +526,11 @@ int mtrr_del_page(int reg, unsigned long
printk(KERN_WARNING "mtrr: MTRR %d not used\n", reg);
goto out;
}
- if (usage_table[reg] < 1) {
+ if (mtrr_usage_table[reg] < 1) {
printk(KERN_WARNING "mtrr: reg: %d has count=0\n", reg);
goto out;
}
- if (--usage_table[reg] < 1)
+ if (--mtrr_usage_table[reg] < 1)
set_mtrr(reg, 0, 0, 0);
error = reg;
out:
diff -puN arch/i386/kernel/cpu/mtrr/mtrr.h~i386-x86_64-trim-memory-not-covered-by-wb-mtrrs-fix arch/i386/kernel/cpu/mtrr/mtrr.h
--- a/arch/i386/kernel/cpu/mtrr/mtrr.h~i386-x86_64-trim-memory-not-covered-by-wb-mtrrs-fix
+++ a/arch/i386/kernel/cpu/mtrr/mtrr.h
@@ -97,3 +97,5 @@ void mtrr_state_warn(void);
const char *mtrr_attrib_to_str(int x);
void mtrr_wrmsr(unsigned, unsigned, unsigned);
+/* RED-PEN: this is accessed without any locking */
+extern unsigned int mtrr_usage_table[];
_
next prev parent reply other threads:[~2007-06-08 0:21 UTC|newest]
Thread overview: 118+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-06 19:29 Jesse Barnes
2007-06-06 20:26 ` Justin Piszcz
2007-06-06 20:28 ` Jesse Barnes
2007-06-06 20:31 ` Jesse Barnes
2007-06-06 20:37 ` Justin Piszcz
2007-06-06 20:50 ` Jesse Barnes
2007-06-06 21:26 ` Justin Piszcz
2007-06-06 21:53 ` Justin Piszcz
2007-06-06 22:03 ` Justin Piszcz
2007-06-06 22:05 ` Jesse Barnes
2007-06-06 22:07 ` Justin Piszcz
2007-06-06 22:13 ` Justin Piszcz
2007-06-06 22:24 ` Jesse Barnes
2007-06-06 22:26 ` Justin Piszcz
2007-06-06 22:28 ` Jesse Barnes
2007-06-06 22:31 ` Justin Piszcz
2007-06-06 22:35 ` Justin Piszcz
2007-06-06 22:37 ` Randy Dunlap
2007-06-06 22:46 ` Justin Piszcz
2007-06-06 22:54 ` Justin Piszcz
2007-06-06 23:11 ` Randy Dunlap
2007-06-06 23:15 ` Justin Piszcz
2007-06-06 23:34 ` Jesse Barnes
2007-06-07 8:10 ` Justin Piszcz
2007-06-06 22:39 ` Justin Piszcz
2007-06-06 22:57 ` Justin Piszcz
2007-06-06 23:20 ` Jesse Barnes
2007-06-06 23:24 ` Justin Piszcz
2007-06-06 23:27 ` Jesse Barnes
2007-06-07 8:51 ` Andi Kleen
2007-06-07 8:53 ` Justin Piszcz
2007-06-07 9:55 ` Satyam Sharma
2007-06-07 17:33 ` Jesse Barnes
2007-06-07 7:45 ` Eric W. Biederman
2007-06-07 17:30 ` Jesse Barnes
2007-06-08 23:13 ` Eric W. Biederman
2007-06-12 15:39 ` Jesse Barnes
2007-06-07 8:16 ` Andi Kleen
2007-06-07 17:35 ` Jesse Barnes
2007-06-07 17:40 ` Justin Piszcz
2007-06-07 14:41 ` Pavel Machek
2007-06-08 0:20 ` Andrew Morton [this message]
2007-06-08 1:33 ` Jesse Barnes
2007-06-08 21:15 ` Andrew Morton
2007-06-08 21:28 ` Jesse Barnes
2007-06-13 1:11 ` Eric W. Biederman
2007-06-13 2:29 ` Jesse Barnes
2007-06-13 22:19 ` Eric W. Biederman
2007-06-20 11:22 ` Helge Hafting
2007-06-20 14:37 ` Andi Kleen
2007-06-07 22:30 Jesse Barnes
2007-06-07 22:50 ` Justin Piszcz
2007-06-07 22:53 ` Justin Piszcz
2007-06-07 23:00 ` Justin Piszcz
2007-06-08 8:20 ` Justin Piszcz
2007-06-12 14:50 ` Pavel Machek
2007-06-12 15:29 ` Jesse Barnes
2007-06-12 15:48 ` Andi Kleen
2007-06-12 21:30 ` Pavel Machek
2007-06-12 21:31 ` Justin Piszcz
2007-06-12 21:38 ` Ray Lee
2007-06-12 21:55 ` Pavel Machek
2007-06-13 0:25 ` Ray Lee
2007-06-13 8:22 ` Pavel Machek
2007-06-14 19:38 ` Pim Zandbergen
2007-06-14 20:26 ` Justin Piszcz
2007-06-14 21:18 ` Jesse Barnes
2007-06-14 21:21 ` Justin Piszcz
2007-06-14 21:26 ` Jesse Barnes
2007-06-15 10:21 ` Pim Zandbergen
2007-06-15 16:20 ` Jesse Barnes
2007-06-21 14:24 ` Pim Zandbergen
2007-06-21 14:28 ` Justin Piszcz
2007-06-25 16:31 ` Pim Zandbergen
2007-06-25 16:34 ` Justin Piszcz
2007-06-15 10:17 ` Pim Zandbergen
2007-06-15 10:34 ` Justin Piszcz
2007-06-15 17:28 ` Jesse Barnes
2007-06-20 13:55 ` Pim Zandbergen
2007-06-21 19:40 ` Yinghai Lu
2007-06-21 19:56 ` Jesse Barnes
[not found] <fa.i7vJP3lxWAlyOLjcsqOWPKlixD8@ifi.uio.no>
[not found] ` <fa.3ijVoClbWNHWrMhDABWjNPxp+wo@ifi.uio.no>
[not found] ` <fa.ZqgSvRGj/scOmd0AwnU6e21Gcwc@ifi.uio.no>
[not found] ` <fa.oNsjw768fkDpx3oef91fjAQs1Iw@ifi.uio.no>
[not found] ` <fa.x8ZCt4n0yXI1llhRq4wfjNfqK4w@ifi.uio.no>
2007-06-08 1:57 ` Robert Hancock
[not found] <8tyOc-8f0-17@gated-at.bofh.it>
2007-06-13 6:52 ` Bodo Eggert
2007-06-13 16:19 ` Dave Jones
2007-06-25 21:34 Jesse Barnes
2007-06-25 21:45 ` Justin Piszcz
2007-06-25 22:01 ` Andrew Morton
2007-06-25 22:05 ` Jesse Barnes
2007-06-25 22:29 ` Justin Piszcz
2007-06-25 23:34 ` Andi Kleen
2007-06-25 23:36 ` Jesse Barnes
2007-06-26 0:54 ` Eric W. Biederman
2007-06-26 3:29 ` Jesse Barnes
2007-06-26 3:30 ` Jesse Barnes
2007-06-26 15:03 ` Andi Kleen
2007-06-26 15:07 ` Jesse Barnes
2007-06-26 15:18 ` Jesse Barnes
2007-06-26 15:39 ` Andi Kleen
2007-06-26 15:54 ` Yinghai Lu
2007-06-26 16:06 ` Eric W. Biederman
2007-06-26 17:38 ` Andi Kleen
2007-06-26 18:55 ` Yinghai Lu
2007-06-26 15:02 ` Andi Kleen
2007-06-26 15:38 ` Jesse Barnes
2007-06-27 10:44 ` Pim Zandbergen
2007-06-27 11:22 ` Andi Kleen
2007-06-27 11:40 ` Pim Zandbergen
2007-06-27 11:44 ` Justin Piszcz
2007-06-27 14:22 ` Mauro Giachero
2007-06-27 15:04 ` Jesse Barnes
2007-06-27 16:00 ` Pim Zandbergen
2007-06-27 16:07 ` Jesse Barnes
2007-06-27 16:22 ` Jesse Barnes
2007-06-27 17:02 ` Pim Zandbergen
2007-06-27 17:06 ` Jesse Barnes
2007-06-27 17:17 ` Pim Zandbergen
2007-07-05 12:12 ` Pavel Machek
2007-07-05 12:16 ` Justin Piszcz
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=20070607172050.ead923b4.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=ebiederm@xmission.com \
--cc=jesse.barnes@intel.com \
--cc=jpiszcz@lucidpixels.com \
--cc=linux-kernel@vger.kernel.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
Powered by JetHome