diff for duplicates of <1489534821.2733.47.camel@linux.intel.com> diff --git a/a/1.txt b/N1/1.txt index 5b5b562..d731b55 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -3,11 +3,11 @@ On Wed, 2017-03-08 at 15:26 +0800, Huang, Ying wrote: > > A variation of get_swap_page(), get_huge_swap_page(), is added to > allocate a swap cluster (HPAGE_PMD_NR swap slots) based on the swap -> cluster allocation function.A A A fair simple algorithm is used, that is, +> cluster allocation function. A fair simple algorithm is used, that is, > only the first swap device in priority list will be tried to allocate -> the swap cluster.A A The function will fail if the trying is not +> the swap cluster. The function will fail if the trying is not > successful, and the caller will fallback to allocate a single swap slot -> instead.A A This works good enough for normal cases. +> instead. This works good enough for normal cases. > > This will be used for the THP (Transparent Huge Page) swap support. > Where get_huge_swap_page() will be used to allocate one swap cluster for @@ -15,7 +15,7 @@ On Wed, 2017-03-08 at 15:26 +0800, Huang, Ying wrote: > > Because of the algorithm adopted, if the difference of the number of the > free swap clusters among multiple swap devices is significant, it is -> possible that some THPs are split earlier than necessary.A A For example, +> possible that some THPs are split earlier than necessary. For example, > this could be caused by big size difference among multiple swap devices. > > Cc: Andrea Arcangeli <aarcange@redhat.com> @@ -26,28 +26,28 @@ On Wed, 2017-03-08 at 15:26 +0800, Huang, Ying wrote: > Cc: Rik van Riel <riel@redhat.com> > Signed-off-by: "Huang, Ying" <ying.huang@intel.com> > --- -> A include/linux/swap.h | 19 ++++++++++++++++++- -> A mm/swap_slots.cA A A A A A |A A 5 +++-- -> A mm/swapfile.cA A A A A A A A | 16 ++++++++++++---- -> A 3 files changed, 33 insertions(+), 7 deletions(-) +> include/linux/swap.h | 19 ++++++++++++++++++- +> mm/swap_slots.c | 5 +++-- +> mm/swapfile.c | 16 ++++++++++++---- +> 3 files changed, 33 insertions(+), 7 deletions(-) > > diff --git a/include/linux/swap.h b/include/linux/swap.h > index 278e1349a424..e3a7609a8989 100644 > --- a/include/linux/swap.h > +++ b/include/linux/swap.h > @@ -388,7 +388,7 @@ static inline long get_nr_swap_pages(void) -> A extern void si_swapinfo(struct sysinfo *); -> A extern swp_entry_t get_swap_page(void); -> A extern swp_entry_t get_swap_page_of_type(int); +> extern void si_swapinfo(struct sysinfo *); +> extern swp_entry_t get_swap_page(void); +> extern swp_entry_t get_swap_page_of_type(int); > -extern int get_swap_pages(int n, swp_entry_t swp_entries[]); > +extern int get_swap_pages(int n, swp_entry_t swp_entries[], bool huge); -> A extern int add_swap_count_continuation(swp_entry_t, gfp_t); -> A extern void swap_shmem_alloc(swp_entry_t); -> A extern int swap_duplicate(swp_entry_t); +> extern int add_swap_count_continuation(swp_entry_t, gfp_t); +> extern void swap_shmem_alloc(swp_entry_t); +> extern int swap_duplicate(swp_entry_t); > @@ -527,6 +527,23 @@ static inline swp_entry_t get_swap_page(void) -> A -> A #endif /* CONFIG_SWAP */ -> A +> +> #endif /* CONFIG_SWAP */ +> > +#ifdef CONFIG_THP_SWAP_CLUSTER > +static inline swp_entry_t get_huge_swap_page(void) > +{ @@ -65,93 +65,87 @@ On Wed, 2017-03-08 at 15:26 +0800, Huang, Ying wrote: > +} > +#endif > + -> A #ifdef CONFIG_MEMCG -> A static inline int mem_cgroup_swappiness(struct mem_cgroup *memcg) -> A { +> #ifdef CONFIG_MEMCG +> static inline int mem_cgroup_swappiness(struct mem_cgroup *memcg) +> { > diff --git a/mm/swap_slots.c b/mm/swap_slots.c > index 9b5bc86f96ad..075bb39e03c5 100644 > --- a/mm/swap_slots.c > +++ b/mm/swap_slots.c > @@ -258,7 +258,8 @@ static int refill_swap_slots_cache(struct swap_slots_cache *cache) -> A -> A cache->cur = 0; -> A if (swap_slot_cache_active) +> +> cache->cur = 0; +> if (swap_slot_cache_active) > - cache->nr = get_swap_pages(SWAP_SLOTS_CACHE_SIZE, cache->slots); > + cache->nr = get_swap_pages(SWAP_SLOTS_CACHE_SIZE, cache->slots, -> + A A A false); -> A -> A return cache->nr; -> A } +> + false); +> +> return cache->nr; +> } > @@ -334,7 +335,7 @@ swp_entry_t get_swap_page(void) -> A return entry; -> A } -> A +> return entry; +> } +> > - get_swap_pages(1, &entry); > + get_swap_pages(1, &entry, false); -> A -> A return entry; -> A } +> +> return entry; +> } > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 91876c33114b..7241c937e52b 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -904,11 +904,12 @@ static unsigned long scan_swap_map(struct swap_info_struct *si, -> A -> A } -> A +> +> } +> > -int get_swap_pages(int n_goal, swp_entry_t swp_entries[]) > +int get_swap_pages(int n_goal, swp_entry_t swp_entries[], bool huge) -> A { -> A struct swap_info_struct *si, *next; -> A long avail_pgs; -> A int n_ret = 0; +> { +> struct swap_info_struct *si, *next; +> long avail_pgs; +> int n_ret = 0; > + int nr_pages = huge_cluster_nr_entries(huge); -> A -> A avail_pgs = atomic_long_read(&nr_swap_pages); -> A if (avail_pgs <= 0) +> +> avail_pgs = atomic_long_read(&nr_swap_pages); +> if (avail_pgs <= 0) > @@ -920,6 +921,10 @@ int get_swap_pages(int n_goal, swp_entry_t swp_entries[]) -> A if (n_goal > avail_pgs) -> A n_goal = avail_pgs; -> A +> if (n_goal > avail_pgs) +> n_goal = avail_pgs; +> > + n_goal *= nr_pages; -I think if (n_goal > 1) when huge is true,A +I think if (n_goal > 1) when huge is true, n_goal should be set to huge_cluster_nr_entries(huge) here or we could have an invalid check below. We probably should add a comment to get_swap_pages on how we treat -n_goal when huge is true. A Maybe say we will always treat -n_goal as SWAPFILE_CLUSTER when huge is true.A +n_goal when huge is true. Maybe say we will always treat +n_goal as SWAPFILE_CLUSTER when huge is true. > + if (avail_pgs < n_goal) > + goto noswap; > + -> A atomic_long_sub(n_goal, &nr_swap_pages); -> A -> A spin_lock(&swap_avail_lock); +> atomic_long_sub(n_goal, &nr_swap_pages); +> +> spin_lock(&swap_avail_lock); > @@ -946,10 +951,13 @@ int get_swap_pages(int n_goal, swp_entry_t swp_entries[]) -> A spin_unlock(&si->lock); -> A goto nextsi; -> A } +> spin_unlock(&si->lock); +> goto nextsi; +> } > - n_ret = scan_swap_map_slots(si, SWAP_HAS_CACHE, -> - A A A A n_goal, swp_entries); +> - n_goal, swp_entries); > + if (likely(nr_pages == 1)) if (likely(!huge)) is probably more readable > + n_ret = scan_swap_map_slots(si, SWAP_HAS_CACHE, -> + A A A A n_goal, swp_entries); +> + n_goal, swp_entries); > + else > + n_ret = swap_alloc_huge_cluster(si, swp_entries); -> A spin_unlock(&si->lock); +> spin_unlock(&si->lock); Thanks. Tim - --- -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> diff --git a/a/content_digest b/N1/content_digest index e065bcd..3ef2390 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -21,11 +21,11 @@ "> \n" "> A variation of get_swap_page(), get_huge_swap_page(), is added to\n" "> allocate a swap cluster (HPAGE_PMD_NR swap slots) based on the swap\n" - "> cluster allocation function.A A A fair simple algorithm is used, that is,\n" + "> cluster allocation function.\302\240\302\240A fair simple algorithm is used, that is,\n" "> only the first swap device in priority list will be tried to allocate\n" - "> the swap cluster.A A The function will fail if the trying is not\n" + "> the swap cluster.\302\240\302\240The function will fail if the trying is not\n" "> successful, and the caller will fallback to allocate a single swap slot\n" - "> instead.A A This works good enough for normal cases.\n" + "> instead.\302\240\302\240This works good enough for normal cases.\n" "> \n" "> This will be used for the THP (Transparent Huge Page) swap support.\n" "> Where get_huge_swap_page() will be used to allocate one swap cluster for\n" @@ -33,7 +33,7 @@ "> \n" "> Because of the algorithm adopted, if the difference of the number of the\n" "> free swap clusters among multiple swap devices is significant, it is\n" - "> possible that some THPs are split earlier than necessary.A A For example,\n" + "> possible that some THPs are split earlier than necessary.\302\240\302\240For example,\n" "> this could be caused by big size difference among multiple swap devices.\n" "> \n" "> Cc: Andrea Arcangeli <aarcange@redhat.com>\n" @@ -44,28 +44,28 @@ "> Cc: Rik van Riel <riel@redhat.com>\n" "> Signed-off-by: \"Huang, Ying\" <ying.huang@intel.com>\n" "> ---\n" - "> A include/linux/swap.h | 19 ++++++++++++++++++-\n" - "> A mm/swap_slots.cA A A A A A |A A 5 +++--\n" - "> A mm/swapfile.cA A A A A A A A | 16 ++++++++++++----\n" - "> A 3 files changed, 33 insertions(+), 7 deletions(-)\n" + "> \302\240include/linux/swap.h | 19 ++++++++++++++++++-\n" + "> \302\240mm/swap_slots.c\302\240\302\240\302\240\302\240\302\240\302\240|\302\240\302\2405 +++--\n" + "> \302\240mm/swapfile.c\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240| 16 ++++++++++++----\n" + "> \302\2403 files changed, 33 insertions(+), 7 deletions(-)\n" "> \n" "> diff --git a/include/linux/swap.h b/include/linux/swap.h\n" "> index 278e1349a424..e3a7609a8989 100644\n" "> --- a/include/linux/swap.h\n" "> +++ b/include/linux/swap.h\n" "> @@ -388,7 +388,7 @@ static inline long get_nr_swap_pages(void)\n" - "> A extern void si_swapinfo(struct sysinfo *);\n" - "> A extern swp_entry_t get_swap_page(void);\n" - "> A extern swp_entry_t get_swap_page_of_type(int);\n" + "> \302\240extern void si_swapinfo(struct sysinfo *);\n" + "> \302\240extern swp_entry_t get_swap_page(void);\n" + "> \302\240extern swp_entry_t get_swap_page_of_type(int);\n" "> -extern int get_swap_pages(int n, swp_entry_t swp_entries[]);\n" "> +extern int get_swap_pages(int n, swp_entry_t swp_entries[], bool huge);\n" - "> A extern int add_swap_count_continuation(swp_entry_t, gfp_t);\n" - "> A extern void swap_shmem_alloc(swp_entry_t);\n" - "> A extern int swap_duplicate(swp_entry_t);\n" + "> \302\240extern int add_swap_count_continuation(swp_entry_t, gfp_t);\n" + "> \302\240extern void swap_shmem_alloc(swp_entry_t);\n" + "> \302\240extern int swap_duplicate(swp_entry_t);\n" "> @@ -527,6 +527,23 @@ static inline swp_entry_t get_swap_page(void)\n" - "> A \n" - "> A #endif /* CONFIG_SWAP */\n" - "> A \n" + "> \302\240\n" + "> \302\240#endif /* CONFIG_SWAP */\n" + "> \302\240\n" "> +#ifdef CONFIG_THP_SWAP_CLUSTER\n" "> +static inline swp_entry_t get_huge_swap_page(void)\n" "> +{\n" @@ -83,95 +83,89 @@ "> +}\n" "> +#endif\n" "> +\n" - "> A #ifdef CONFIG_MEMCG\n" - "> A static inline int mem_cgroup_swappiness(struct mem_cgroup *memcg)\n" - "> A {\n" + "> \302\240#ifdef CONFIG_MEMCG\n" + "> \302\240static inline int mem_cgroup_swappiness(struct mem_cgroup *memcg)\n" + "> \302\240{\n" "> diff --git a/mm/swap_slots.c b/mm/swap_slots.c\n" "> index 9b5bc86f96ad..075bb39e03c5 100644\n" "> --- a/mm/swap_slots.c\n" "> +++ b/mm/swap_slots.c\n" "> @@ -258,7 +258,8 @@ static int refill_swap_slots_cache(struct swap_slots_cache *cache)\n" - "> A \n" - "> A \tcache->cur = 0;\n" - "> A \tif (swap_slot_cache_active)\n" + "> \302\240\n" + "> \302\240\tcache->cur = 0;\n" + "> \302\240\tif (swap_slot_cache_active)\n" "> -\t\tcache->nr = get_swap_pages(SWAP_SLOTS_CACHE_SIZE, cache->slots);\n" "> +\t\tcache->nr = get_swap_pages(SWAP_SLOTS_CACHE_SIZE, cache->slots,\n" - "> +\t\t\t\t\tA A A false);\n" - "> A \n" - "> A \treturn cache->nr;\n" - "> A }\n" + "> +\t\t\t\t\t\302\240\302\240\302\240false);\n" + "> \302\240\n" + "> \302\240\treturn cache->nr;\n" + "> \302\240}\n" "> @@ -334,7 +335,7 @@ swp_entry_t get_swap_page(void)\n" - "> A \t\t\treturn entry;\n" - "> A \t}\n" - "> A \n" + "> \302\240\t\t\treturn entry;\n" + "> \302\240\t}\n" + "> \302\240\n" "> -\tget_swap_pages(1, &entry);\n" "> +\tget_swap_pages(1, &entry, false);\n" - "> A \n" - "> A \treturn entry;\n" - "> A }\n" + "> \302\240\n" + "> \302\240\treturn entry;\n" + "> \302\240}\n" "> diff --git a/mm/swapfile.c b/mm/swapfile.c\n" "> index 91876c33114b..7241c937e52b 100644\n" "> --- a/mm/swapfile.c\n" "> +++ b/mm/swapfile.c\n" "> @@ -904,11 +904,12 @@ static unsigned long scan_swap_map(struct swap_info_struct *si,\n" - "> A \n" - "> A }\n" - "> A \n" + "> \302\240\n" + "> \302\240}\n" + "> \302\240\n" "> -int get_swap_pages(int n_goal, swp_entry_t swp_entries[])\n" "\n" "\n" "> +int get_swap_pages(int n_goal, swp_entry_t swp_entries[], bool huge)\n" - "> A {\n" - "> A \tstruct swap_info_struct *si, *next;\n" - "> A \tlong avail_pgs;\n" - "> A \tint n_ret = 0;\n" + "> \302\240{\n" + "> \302\240\tstruct swap_info_struct *si, *next;\n" + "> \302\240\tlong avail_pgs;\n" + "> \302\240\tint n_ret = 0;\n" "> +\tint nr_pages = huge_cluster_nr_entries(huge);\n" - "> A \n" - "> A \tavail_pgs = atomic_long_read(&nr_swap_pages);\n" - "> A \tif (avail_pgs <= 0)\n" + "> \302\240\n" + "> \302\240\tavail_pgs = atomic_long_read(&nr_swap_pages);\n" + "> \302\240\tif (avail_pgs <= 0)\n" "> @@ -920,6 +921,10 @@ int get_swap_pages(int n_goal, swp_entry_t swp_entries[])\n" - "> A \tif (n_goal > avail_pgs)\n" - "> A \t\tn_goal = avail_pgs;\n" - "> A \n" + "> \302\240\tif (n_goal > avail_pgs)\n" + "> \302\240\t\tn_goal = avail_pgs;\n" + "> \302\240\n" "> +\tn_goal *= nr_pages;\n" "\n" - "I think if (n_goal > 1) when huge is true,A \n" + "I think if (n_goal > 1) when huge is true,\302\240\n" "n_goal should be set to huge_cluster_nr_entries(huge) here\n" "or we could have an invalid check below. We probably\n" "should add a comment to get_swap_pages on how we treat\n" - "n_goal when huge is true. A Maybe say we will always treat\n" - "n_goal as SWAPFILE_CLUSTER when huge is true.A \n" + "n_goal when huge is true. \302\240Maybe say we will always treat\n" + "n_goal as SWAPFILE_CLUSTER when huge is true.\302\240\n" "\n" "> +\tif (avail_pgs < n_goal)\n" "> +\t\tgoto noswap;\n" "> +\n" - "> A \tatomic_long_sub(n_goal, &nr_swap_pages);\n" - "> A \n" - "> A \tspin_lock(&swap_avail_lock);\n" + "> \302\240\tatomic_long_sub(n_goal, &nr_swap_pages);\n" + "> \302\240\n" + "> \302\240\tspin_lock(&swap_avail_lock);\n" "> @@ -946,10 +951,13 @@ int get_swap_pages(int n_goal, swp_entry_t swp_entries[])\n" - "> A \t\t\tspin_unlock(&si->lock);\n" - "> A \t\t\tgoto nextsi;\n" - "> A \t\t}\n" + "> \302\240\t\t\tspin_unlock(&si->lock);\n" + "> \302\240\t\t\tgoto nextsi;\n" + "> \302\240\t\t}\n" "> -\t\tn_ret = scan_swap_map_slots(si, SWAP_HAS_CACHE,\n" - "> -\t\t\t\t\tA A A A n_goal, swp_entries);\n" + "> -\t\t\t\t\t\302\240\302\240\302\240\302\240n_goal, swp_entries);\n" "> +\t\tif (likely(nr_pages == 1))\n" "\n" "if (likely(!huge)) is probably more readable\n" "\n" "> +\t\t\tn_ret = scan_swap_map_slots(si, SWAP_HAS_CACHE,\n" - "> +\t\t\t\t\t\tA A A A n_goal, swp_entries);\n" + "> +\t\t\t\t\t\t\302\240\302\240\302\240\302\240n_goal, swp_entries);\n" "> +\t\telse\n" "> +\t\t\tn_ret = swap_alloc_huge_cluster(si, swp_entries);\n" - "> A \t\tspin_unlock(&si->lock);\n" + "> \302\240\t\tspin_unlock(&si->lock);\n" "\n" "Thanks.\n" "\n" - "Tim\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>" + Tim -1d0c6cf1653c042bfd683bf63d06014c0e799700dceadb9ad4415fcf7f48a835 +099fa56a377aeb53f5d94c363b357f3b0c9b57d317e4ef725b69e8bbcaf21ea7
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.