[patch] 2.6.8-rc2-mm2: compile error with SWAP=n

From: Adrian Bunk
Date: Mon Aug 02 2004 - 17:17:27 EST


On Mon, Aug 02, 2004 at 01:55:27AM -0700, Andrew Morton wrote:
>...
> - Added Rik's token-based load control patch. The VM currently has pretty
> bad performance problems under heavy swapping loads and this patch speeds up
> simple tests most impressively. People who care about these things: please
> test and measure.
>...
> Changes since 2.6.8-rc2-mm1:
>...
> +token-based-thrashing-control.patch
>...
> VM load control.
>...

This breaks compilation with CONFIG_SWAP=n:

<-- snip -->

...
CC kernel/fork.o
kernel/fork.c: In function `mmput':
kernel/fork.c:471: warning: implicit declaration of function `put_swap_token'
...
CC mm/filemap.o
mm/filemap.c: In function `filemap_nopage':
mm/filemap.c:1250: warning: implicit declaration of function `grab_swap_token'
...
CC mm/memory.o
mm/memory.c: In function `do_swap_page':
mm/memory.c:1375: warning: implicit declaration of function `grab_swap_token'
...
CC mm/rmap.o
mm/rmap.c: In function `page_referenced_one':
mm/rmap.c:233: warning: implicit declaration of function `has_swap_token'
...
LD .tmp_vmlinux1
kernel/built-in.o(.text+0x1ccf): In function `mmput':
: undefined reference to `put_swap_token'
mm/built-in.o(.text+0x1542): In function `filemap_nopage':
: undefined reference to `grab_swap_token'
mm/built-in.o(.text+0x131c9): In function `page_referenced_one':
: undefined reference to `has_swap_token'
make: *** [.tmp_vmlinux1] Error 1

<-- snip -->


The bug is obvious:


#ifdef CONFIG_SWAP
...
#ifdef CONFIG_SWAP
...
#else
...
#endif
...
#else
...
#endif


Additional, the dummy grab_swap_token and has_swap_token weren't
correct.


diffstat output:
include/linux/swap.h | 43 +++++++++++++++++++++----------------------
1 files changed, 21 insertions(+), 22 deletions(-)


Signed-off-by: Adrian Bunk <bunk@xxxxxxxxx>

--- linux-2.6.8-rc2-mm2-full/include/linux/swap.h.old 2004-08-02 23:16:52.000000000 +0200
+++ linux-2.6.8-rc2-mm2-full/include/linux/swap.h 2004-08-02 23:21:32.000000000 +0200
@@ -204,28 +204,6 @@
extern struct page * lookup_swap_cache(swp_entry_t);
extern struct page * read_swap_cache_async(swp_entry_t, struct vm_area_struct *vma,
unsigned long addr);
-/* linux/mm/thrash.c */
-#ifdef CONFIG_SWAP
-extern struct mm_struct * swap_token_mm;
-extern void grab_swap_token(void);
-extern void __put_swap_token(struct mm_struct *);
-
-static inline int has_swap_token(struct mm_struct *mm)
-{
- return (mm == swap_token_mm);
-}
-
-static inline void put_swap_token(struct mm_struct *mm)
-{
- if (has_swap_token(mm))
- __put_swap_token(mm);
-}
-#else /* CONFIG_SWAP */
-#define put_swap_token(x) do { } while(0)
-#define grab_swap_token do { } while(0)
-#define has_swap_token 0
-#endif /* CONFIG_SWAP */
-
/* linux/mm/swapfile.c */
extern long total_swap_pages;
extern unsigned int nr_swapfiles;
@@ -250,6 +228,22 @@
#define swap_device_lock(p) spin_lock(&p->sdev_lock)
#define swap_device_unlock(p) spin_unlock(&p->sdev_lock)

+/* linux/mm/thrash.c */
+extern struct mm_struct * swap_token_mm;
+extern void grab_swap_token(void);
+extern void __put_swap_token(struct mm_struct *);
+
+static inline int has_swap_token(struct mm_struct *mm)
+{
+ return (mm == swap_token_mm);
+}
+
+static inline void put_swap_token(struct mm_struct *mm)
+{
+ if (has_swap_token(mm))
+ __put_swap_token(mm);
+}
+
#else /* CONFIG_SWAP */

#define total_swap_pages 0
@@ -287,6 +281,11 @@
return entry;
}

+/* linux/mm/thrash.c */
+#define put_swap_token(x) do { } while(0)
+#define grab_swap_token() do { } while(0)
+#define has_swap_token(x) 0
+
#endif /* CONFIG_SWAP */
#endif /* __KERNEL__*/
#endif /* _LINUX_SWAP_H */

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/