From: William Lee Irwin III <wli@holomorphy.com>
To: "Martin J. Bligh" <mbligh@aracnet.com>
Cc: Rik van Riel <riel@redhat.com>, Jack Steiner <steiner@sgi.com>,
Anton Blanchard <anton@samba.org>,
Jes Sorensen <jes@trained-monkey.org>,
Alexander Viro <viro@math.psu.edu>, Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org, jbarnes@sgi.com
Subject: Re: hash table sizes
Date: Wed, 26 Nov 2003 01:51:14 -0800 [thread overview]
Message-ID: <20031126095114.GH8039@holomorphy.com> (raw)
In-Reply-To: <1590000.1069823671@[10.10.2.4]>
On Tue, Nov 25, 2003 at 09:14:32PM -0800, Martin J. Bligh wrote:
> Would it not be rather more readable as something along the lines of:
> static inline int pfn_valid (int pfn) {
> int nid = pfn_to_nid(pfn);
> pg_data_t *pgdat;
>
> if (nid >= MAX_NUMNODES)
> return 0; /* node invalid */
> pgdat = NODE_DATA(nid);
> if (!pgdat)
> return 0; /* pgdat invalid */
> if (pfn < pgdat->node_start_pfn)
> return 0; /* before start of node */
> if (pfn - pgdat->node_start_pfn >= pgdat->node_spanned_pages)
> return 0; /* past end of node */
> return 1;
> }
This header at least used to be included before the relevant structures
were declared (to all appearances, some macros have been converted to
inlines since last I looked).
On Tue, Nov 25, 2003 at 09:14:32PM -0800, Martin J. Bligh wrote:
> However, I'm curious as to why this crashes X, as I don't see how this
> code change makes a difference in practice. I didn't think we had any i386
> NUMA with memory holes between nodes at the moment, though perhaps the x440
> does.
> M.
> PS. No, I haven't tested my rephrasing of your patch either.
mmap() of framebuffers. It takes the box out, not just X. There are
holes just below 4GB regardless. This has actually been reported by
rml and some others.
False positives on pfn_valid() result in manipulations of purported page
structures beyond the bounds of actual allocated pgdat->node_mem_map[]'s,
potentially either corrupting memory or accessing areas outside memory's
limits (the case causing oopsen).
Insubstantially modified version of the above below (it looks fine, I
was just typing from memory). Compiletested only.
-- wli
diff -prauN linux-2.6.0-test10/include/asm-i386/mmzone.h pfn_valid-2.6.0-test10/include/asm-i386/mmzone.h
--- linux-2.6.0-test10/include/asm-i386/mmzone.h 2003-11-23 17:31:56.000000000 -0800
+++ pfn_valid-2.6.0-test10/include/asm-i386/mmzone.h 2003-11-26 01:40:36.000000000 -0800
@@ -84,14 +84,30 @@ extern struct pglist_data *node_data[];
+ __zone->zone_start_pfn; \
})
#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
+
+static inline int pfn_to_nid(unsigned long);
/*
- * pfn_valid should be made as fast as possible, and the current definition
- * is valid for machines that are NUMA, but still contiguous, which is what
- * is currently supported. A more generalised, but slower definition would
- * be something like this - mbligh:
- * ( pfn_to_pgdat(pfn) && ((pfn) < node_end_pfn(pfn_to_nid(pfn))) )
+ * pfn_valid must absolutely be correct, regardless of speed concerns.
*/
-#define pfn_valid(pfn) ((pfn) < num_physpages)
+static inline int pfn_valid(unsigned long pfn)
+{
+ u8 nid = pfn_to_nid(pfn);
+ pg_data_t *pgdat;
+
+ if (nid < MAX_NUMNODES)
+ pgdat = NODE_DATA(nid);
+ else
+ return 0;
+
+ if (!pgdat)
+ return 0;
+ else if (pfn < pgdat->node_start_pfn)
+ return 0;
+ else if (pfn - pgdat->node_start_pfn >= pgdat->node_spanned_pages)
+ return 0;
+ else
+ return 1;
+}
/*
* generic node memory support, the following assumptions apply:
next prev parent reply other threads:[~2003-11-26 9:51 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-25 13:35 hash table sizes Jes Sorensen
2003-11-25 13:42 ` William Lee Irwin III
2003-11-25 13:54 ` Jes Sorensen
2003-11-25 16:25 ` Thomas Schlichter
2003-11-25 17:52 ` Antonio Vargas
2003-11-25 17:54 ` William Lee Irwin III
2003-11-25 20:48 ` Jack Steiner
2003-11-25 21:07 ` Andrew Morton
2003-11-25 21:14 ` Jesse Barnes
2003-11-25 21:24 ` Andrew Morton
2003-11-26 2:14 ` David S. Miller
2003-11-26 5:27 ` Matt Mackall
2003-11-28 14:15 ` Jes Sorensen
2003-11-28 14:52 ` Jack Steiner
2003-11-28 16:22 ` Jes Sorensen
2003-11-28 19:35 ` Jack Steiner
2003-11-28 21:18 ` Jörn Engel
2003-12-01 9:46 ` Jes Sorensen
2003-12-01 21:06 ` Anton Blanchard
2003-12-01 22:57 ` Martin J. Bligh
2003-11-25 21:16 ` Anton Blanchard
2003-11-25 23:11 ` Jack Steiner
2003-11-26 3:39 ` Rik van Riel
2003-11-26 3:59 ` William Lee Irwin III
2003-11-26 4:25 ` Andrew Morton
2003-11-26 4:23 ` William Lee Irwin III
2003-11-26 5:14 ` Martin J. Bligh
2003-11-26 9:51 ` William Lee Irwin III [this message]
2003-11-26 16:17 ` Martin J. Bligh
2003-11-26 7:25 ` Anton Blanchard
-- strict thread matches above, loose matches on Subject: below --
2003-11-26 5:53 Zhang, Yanmin
2003-11-29 10:39 Manfred Spraul
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=20031126095114.GH8039@holomorphy.com \
--to=wli@holomorphy.com \
--cc=akpm@osdl.org \
--cc=anton@samba.org \
--cc=jbarnes@sgi.com \
--cc=jes@trained-monkey.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbligh@aracnet.com \
--cc=riel@redhat.com \
--cc=steiner@sgi.com \
--cc=viro@math.psu.edu \
/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