diff for duplicates of <20130128025917.GA3321@blaptop> diff --git a/a/1.txt b/N1/1.txt index b05f023..762b073 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -59,3 +59,143 @@ own scheme without dependency of swap_lock if it's possible. > all the various frontswap backends. How about this? + +>From 157a3edf49feb93be0595574beb153b322ddf7d2 Mon Sep 17 00:00:00 2001 +From: Minchan Kim <minchan@kernel.org> +Date: Mon, 28 Jan 2013 11:34:00 +0900 +Subject: [PATCH] frontswap: Get rid of swap_lock dependency + +Frontswap initialization routine depends on swap_lock, which want +to be atomic about frontswap's first appearance. +IOW, frontswap is not present and will fail all calls OR frontswap is +fully functional but if new swap_info_struct isn't registered +by enable_swap_info, swap subsystem doesn't start I/O so there is no race +between init procedure and page I/O working on frontswap. + +So let's remove unncessary swap_lock dependency. + +Cc: Dan Magenheimer <dan.magenheimer@oracle.com> +Cc: Konrad Rzeszutek Wilk <konrad@darnok.org> +Signed-off-by: Minchan Kim <minchan@kernel.org> +--- + include/linux/frontswap.h | 6 +++--- + mm/frontswap.c | 7 ++++--- + mm/swapfile.c | 11 +++++------ + 3 files changed, 12 insertions(+), 12 deletions(-) + +diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h +index 3044254..b7e238e 100644 +--- a/include/linux/frontswap.h ++++ b/include/linux/frontswap.h +@@ -22,7 +22,7 @@ extern void frontswap_writethrough(bool); + #define FRONTSWAP_HAS_EXCLUSIVE_GETS + extern void frontswap_tmem_exclusive_gets(bool); + +-extern void __frontswap_init(unsigned type); ++extern void __frontswap_init(unsigned type, unsigned long *map); + extern int __frontswap_store(struct page *page); + extern int __frontswap_load(struct page *page); + extern void __frontswap_invalidate_page(unsigned, pgoff_t); +@@ -120,10 +120,10 @@ static inline void frontswap_invalidate_area(unsigned type) + __frontswap_invalidate_area(type); + } + +-static inline void frontswap_init(unsigned type) ++static inline void frontswap_init(unsigned type, unsigned long *map) + { + if (frontswap_enabled) +- __frontswap_init(type); ++ __frontswap_init(type, map); + } + + #endif /* _LINUX_FRONTSWAP_H */ +diff --git a/mm/frontswap.c b/mm/frontswap.c +index 2890e67..bad21b0 100644 +--- a/mm/frontswap.c ++++ b/mm/frontswap.c +@@ -115,13 +115,14 @@ EXPORT_SYMBOL(frontswap_tmem_exclusive_gets); + /* + * Called when a swap device is swapon'd. + */ +-void __frontswap_init(unsigned type) ++void __frontswap_init(unsigned type, unsigned long *map) + { + struct swap_info_struct *sis = swap_info[type]; + + BUG_ON(sis == NULL); +- if (sis->frontswap_map == NULL) +- return; ++ BUG_ON(sis->frontswap_map); ++ ++ frontswap_map_set(sis, map); + frontswap_ops.init(type); + } + EXPORT_SYMBOL(__frontswap_init); +diff --git a/mm/swapfile.c b/mm/swapfile.c +index dfaff5f..652e4fc 100644 +--- a/mm/swapfile.c ++++ b/mm/swapfile.c +@@ -1497,8 +1497,7 @@ static int setup_swap_extents(struct swap_info_struct *sis, sector_t *span) + } + + static void _enable_swap_info(struct swap_info_struct *p, int prio, +- unsigned char *swap_map, +- unsigned long *frontswap_map) ++ unsigned char *swap_map) + { + int i, prev; + +@@ -1507,7 +1506,6 @@ static void _enable_swap_info(struct swap_info_struct *p, int prio, + else + p->prio = --least_priority; + p->swap_map = swap_map; +- frontswap_map_set(p, frontswap_map); + p->flags |= SWP_WRITEOK; + atomic_long_add(p->pages, &nr_swap_pages); + total_swap_pages += p->pages; +@@ -1530,10 +1528,10 @@ static void enable_swap_info(struct swap_info_struct *p, int prio, + unsigned char *swap_map, + unsigned long *frontswap_map) + { ++ frontswap_init(p->type, frontswap_map); + spin_lock(&swap_lock); + spin_lock(&p->lock); +- _enable_swap_info(p, prio, swap_map, frontswap_map); +- frontswap_init(p->type); ++ _enable_swap_info(p, prio, swap_map); + spin_unlock(&p->lock); + spin_unlock(&swap_lock); + } +@@ -1542,7 +1540,7 @@ static void reinsert_swap_info(struct swap_info_struct *p) + { + spin_lock(&swap_lock); + spin_lock(&p->lock); +- _enable_swap_info(p, p->prio, p->swap_map, frontswap_map_get(p)); ++ _enable_swap_info(p, p->prio, p->swap_map); + spin_unlock(&p->lock); + spin_unlock(&swap_lock); + } +@@ -1651,6 +1649,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) + p->swap_map = NULL; + p->flags = 0; + frontswap_invalidate_area(type); ++ frontswap_map_set(p, NULL); + spin_unlock(&p->lock); + spin_unlock(&swap_lock); + mutex_unlock(&swapon_mutex); +-- +1.7.9.5 + + +> +> Dan +> +> -- +> To unsubscribe, send a message with 'unsubscribe linux-mm' in +> the body to majordomo@kvack.org. For more info on Linux MM, +> see: http://www.linux-mm.org/ . +> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> + +-- +Kind regards, +Minchan Kim diff --git a/a/content_digest b/N1/content_digest index e5e6652..4625b3c 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -83,6 +83,146 @@ "> so I am very open to improvements as long as they work for\n" "> all the various frontswap backends.\n" "\n" - How about this? + "How about this?\n" + "\n" + ">From 157a3edf49feb93be0595574beb153b322ddf7d2 Mon Sep 17 00:00:00 2001\n" + "From: Minchan Kim <minchan@kernel.org>\n" + "Date: Mon, 28 Jan 2013 11:34:00 +0900\n" + "Subject: [PATCH] frontswap: Get rid of swap_lock dependency\n" + "\n" + "Frontswap initialization routine depends on swap_lock, which want\n" + "to be atomic about frontswap's first appearance.\n" + "IOW, frontswap is not present and will fail all calls OR frontswap is\n" + "fully functional but if new swap_info_struct isn't registered\n" + "by enable_swap_info, swap subsystem doesn't start I/O so there is no race\n" + "between init procedure and page I/O working on frontswap.\n" + "\n" + "So let's remove unncessary swap_lock dependency.\n" + "\n" + "Cc: Dan Magenheimer <dan.magenheimer@oracle.com>\n" + "Cc: Konrad Rzeszutek Wilk <konrad@darnok.org>\n" + "Signed-off-by: Minchan Kim <minchan@kernel.org>\n" + "---\n" + " include/linux/frontswap.h | 6 +++---\n" + " mm/frontswap.c | 7 ++++---\n" + " mm/swapfile.c | 11 +++++------\n" + " 3 files changed, 12 insertions(+), 12 deletions(-)\n" + "\n" + "diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h\n" + "index 3044254..b7e238e 100644\n" + "--- a/include/linux/frontswap.h\n" + "+++ b/include/linux/frontswap.h\n" + "@@ -22,7 +22,7 @@ extern void frontswap_writethrough(bool);\n" + " #define FRONTSWAP_HAS_EXCLUSIVE_GETS\n" + " extern void frontswap_tmem_exclusive_gets(bool);\n" + " \n" + "-extern void __frontswap_init(unsigned type);\n" + "+extern void __frontswap_init(unsigned type, unsigned long *map);\n" + " extern int __frontswap_store(struct page *page);\n" + " extern int __frontswap_load(struct page *page);\n" + " extern void __frontswap_invalidate_page(unsigned, pgoff_t);\n" + "@@ -120,10 +120,10 @@ static inline void frontswap_invalidate_area(unsigned type)\n" + " \t\t__frontswap_invalidate_area(type);\n" + " }\n" + " \n" + "-static inline void frontswap_init(unsigned type)\n" + "+static inline void frontswap_init(unsigned type, unsigned long *map)\n" + " {\n" + " \tif (frontswap_enabled)\n" + "-\t\t__frontswap_init(type);\n" + "+\t\t__frontswap_init(type, map);\n" + " }\n" + " \n" + " #endif /* _LINUX_FRONTSWAP_H */\n" + "diff --git a/mm/frontswap.c b/mm/frontswap.c\n" + "index 2890e67..bad21b0 100644\n" + "--- a/mm/frontswap.c\n" + "+++ b/mm/frontswap.c\n" + "@@ -115,13 +115,14 @@ EXPORT_SYMBOL(frontswap_tmem_exclusive_gets);\n" + " /*\n" + " * Called when a swap device is swapon'd.\n" + " */\n" + "-void __frontswap_init(unsigned type)\n" + "+void __frontswap_init(unsigned type, unsigned long *map)\n" + " {\n" + " \tstruct swap_info_struct *sis = swap_info[type];\n" + " \n" + " \tBUG_ON(sis == NULL);\n" + "-\tif (sis->frontswap_map == NULL)\n" + "-\t\treturn;\n" + "+\tBUG_ON(sis->frontswap_map);\n" + "+\n" + "+\tfrontswap_map_set(sis, map);\n" + " \tfrontswap_ops.init(type);\n" + " }\n" + " EXPORT_SYMBOL(__frontswap_init);\n" + "diff --git a/mm/swapfile.c b/mm/swapfile.c\n" + "index dfaff5f..652e4fc 100644\n" + "--- a/mm/swapfile.c\n" + "+++ b/mm/swapfile.c\n" + "@@ -1497,8 +1497,7 @@ static int setup_swap_extents(struct swap_info_struct *sis, sector_t *span)\n" + " }\n" + " \n" + " static void _enable_swap_info(struct swap_info_struct *p, int prio,\n" + "-\t\t\t\tunsigned char *swap_map,\n" + "-\t\t\t\tunsigned long *frontswap_map)\n" + "+\t\t\t\tunsigned char *swap_map)\n" + " {\n" + " \tint i, prev;\n" + " \n" + "@@ -1507,7 +1506,6 @@ static void _enable_swap_info(struct swap_info_struct *p, int prio,\n" + " \telse\n" + " \t\tp->prio = --least_priority;\n" + " \tp->swap_map = swap_map;\n" + "-\tfrontswap_map_set(p, frontswap_map);\n" + " \tp->flags |= SWP_WRITEOK;\n" + " \tatomic_long_add(p->pages, &nr_swap_pages);\n" + " \ttotal_swap_pages += p->pages;\n" + "@@ -1530,10 +1528,10 @@ static void enable_swap_info(struct swap_info_struct *p, int prio,\n" + " \t\t\t\tunsigned char *swap_map,\n" + " \t\t\t\tunsigned long *frontswap_map)\n" + " {\n" + "+\tfrontswap_init(p->type, frontswap_map);\n" + " \tspin_lock(&swap_lock);\n" + " \tspin_lock(&p->lock);\n" + "-\t_enable_swap_info(p, prio, swap_map, frontswap_map);\n" + "-\tfrontswap_init(p->type);\n" + "+\t_enable_swap_info(p, prio, swap_map);\n" + " \tspin_unlock(&p->lock);\n" + " \tspin_unlock(&swap_lock);\n" + " }\n" + "@@ -1542,7 +1540,7 @@ static void reinsert_swap_info(struct swap_info_struct *p)\n" + " {\n" + " \tspin_lock(&swap_lock);\n" + " \tspin_lock(&p->lock);\n" + "-\t_enable_swap_info(p, p->prio, p->swap_map, frontswap_map_get(p));\n" + "+\t_enable_swap_info(p, p->prio, p->swap_map);\n" + " \tspin_unlock(&p->lock);\n" + " \tspin_unlock(&swap_lock);\n" + " }\n" + "@@ -1651,6 +1649,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)\n" + " \tp->swap_map = NULL;\n" + " \tp->flags = 0;\n" + " \tfrontswap_invalidate_area(type);\n" + "+\tfrontswap_map_set(p, NULL);\n" + " \tspin_unlock(&p->lock);\n" + " \tspin_unlock(&swap_lock);\n" + " \tmutex_unlock(&swapon_mutex);\n" + "-- \n" + "1.7.9.5\n" + "\n" + "\n" + "> \n" + "> Dan\n" + "> \n" + "> --\n" + "> To unsubscribe, send a message with 'unsubscribe linux-mm' in\n" + "> the body to majordomo@kvack.org. For more info on Linux MM,\n" + "> see: http://www.linux-mm.org/ .\n" + "> Don't email: <a href=mailto:\"dont@kvack.org\"> email@kvack.org </a>\n" + "\n" + "-- \n" + "Kind regards,\n" + Minchan Kim -01c3bbb33c1906351eecb157b0ac78cd8ca7ec7b30302a2e6bdac8d983926e42 +a21395b43a0a4e98433c685b26ad5dac1bcc47180a98924d3fa3b7f95a7994a2
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.