lkml.org 
[lkml]   [2003]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: hash table sizes
> Speaking of which, no one's bothered fixing the X crashes on i386
> discontigmem. Untested patch below.
>
>
> -- 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-25 19:54:31.000000000 -0800
> @@ -85,13 +85,19 @@ extern struct pglist_data *node_data[];
> })
> #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
> /*
> - * 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)
> +#define pfn_valid(pfn) \
> +({ \
> + unsigned long __pfn__ = pfn; \
> + u8 __nid__ = pfn_to_nid(__pfn__); \
> + pg_data_t *__pgdat__; \
> + __pgdat__ = __nid__ < MAX_NUMNODES ? NODE_DATA(__nid__) : NULL; \
> + __pgdat__ && \
> + __pfn__ >= __pgdat__->node_start_pfn && \
> + __pfn__ - __pgdat__->node_start_pfn \
> + < __pgdat__->node_spanned_pages; \
> +})
>
> /*
> * generic node memory support, the following assumptions apply:

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;
}

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.

-
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/

\
 
 \ /
  Last update: 2005-03-22 13:58    [W:0.049 / U:1.320 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site