Re: [patch] cache pipe buf page address for non-highmem arch

Andrew Morton
2007-03-28T23:34:25Z

On Wed, 28 Mar 2007 16:21:04 -0700
Zach Brown <zach.brown@oracle.com> wrote:

> > Does this look OK?
>
> Almost...
>
> > #ifdef CONFIG_HIGHMEM
> > static inline void pipe_kunmap_atomic(void *addr, enum km_type type)
> > #else /* CONFIG_HIGHMEM */
> > static inline void pipe_kunmap_atomic(struct page *page, enum
> > km_type type)
>

OK, I give up. What are you telling me here?

<compiles it>

argh, enum km_type isn't defined if !CONFIG_HIGHMEM, which is extravagantly
dumb.

From: Andrew Morton <akpm@linux-foundation.org>

Cc: "Ken Chen" <kenchen@google.com>
Cc: Zach Brown <zach.brown@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

fs/pipe.c | 31 +++++++++++++++++++++++++------
1 files changed, 25 insertions(+), 6 deletions(-)

diff -puN fs/pipe.c~cache-pipe-buf-page-address-for-non-highmem-arch-fix-tidy fs/pipe.c
--- a/fs/pipe.c~cache-pipe-buf-page-address-for-non-highmem-arch-fix-tidy
+++ a/fs/pipe.c
@@ -22,17 +22,36 @@
#include <asm/ioctls.h>

#ifdef CONFIG_HIGHMEM
-#define pipe_kmap kmap
-#define pipe_kmap_atomic kmap_atomic
-#define pipe_kunmap kunmap
-#define pipe_kunmap_atomic kunmap_atomic
+static inline void *pipe_kmap(struct page *page)
+{
+ return kmap(page);
+}
+
+static inline void pipe_kunmap(struct page *page)
+{
+ kunmap(page);
+}
+
+static inline void *pipe_kmap_atomic(struct page *page, enum km_type type)
+{
+ return kmap_atomic(page, type);
+}
+
+static inline void pipe_kunmap_atomic(void *addr, enum km_type type)
+{
+ kunmap_atomic(addr, type);
+}
#else /* CONFIG_HIGHMEM */
static inline void *pipe_kmap(struct page *page)
{
- return (void *) page->private;
+ return (void *)page->private;
}
+
+static inline void pipe_kunmap(struct page *page)
+{
+}
+
#define pipe_kmap_atomic(page, type) pipe_kmap(page)
-#define pipe_kunmap(page) do { } while (0)
#define pipe_kunmap_atomic(page, type) do { } while (0)
#endif

_