Re: [PATCH] Optimize out pte_chain take two

Andrew Morton
2002-07-10T00:21:11Z

Dave McCracken wrote:
>
> Here's a version of my pte_chain removal patch that does not use anonymous
> unions, so it'll compile with gcc 2.95. Once again, it's based on Rik's
> rmap-2.5.25-akpmtested.

Seems sane and simple, thanks.

This bit is icky:

+ union {
+ struct pte_chain * _pte_chain; /* Reverse pte mapping pointer.
* protected by PG_chainlock */
+ pte_t * _pte_direct;
+ } _pte_union;
...
+
+#define pte__chain _pte_union._pte_chain
+#define pte_direct _pte_union._pte_direct

You could instead make it just a void * and have:

static inline struct pte_chain *page_pte_chain(struct page *page)
{
#ifdef DEBUG_RMAP
BUG_ON(PageDirect(page));
#endif
return page->rmap_thingy;
}

static inline pte_t *page_pte_direct(struct page *page)
{
#ifdef DEBUG_RMAP
BUG_ON(!PageDirect(page));
#endif
return page->rmap_thingy;
}

static inline void
set_page_pte_chain(struct page *page, struct pte_chain *pte_chain)
{
#ifdef DEBUG_RMAP
BUG_ON(PageDirect(page));
#endif
page->rmap_thingy = pte_chain;
}

static inline void
set_page_pte_direct(struct page *page, pte_t *ptep)
{
#ifdef DEBUG_RMAP
BUG_ON(!PageDirect(page));
#endif
page->rmap_thingy = ptep;
}

I think it's neater. But then, I'm a convicted C++ weenie.

-