diff for duplicates of <1493311682.3209.150.camel@linux.intel.com> diff --git a/a/1.txt b/N1/1.txt index 8617a75..b3f6d0f 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -9,26 +9,26 @@ On Thu, 2017-04-27 at 09:21 +0800, Huang, Ying wrote: > > > Date: Thu, 23 Feb 2017 13:05:20 +0800 > > > Subject: [PATCH -v5] mm, swap: Sort swap entries before free > > > -> > > A +> > > > > > --- -> > > A mm/swapfile.c | 43 ++++++++++++++++++++++++++++++++++++++----- -> > > A 1 file changed, 38 insertions(+), 5 deletions(-) +> > > mm/swapfile.c | 43 ++++++++++++++++++++++++++++++++++++++----- +> > > 1 file changed, 38 insertions(+), 5 deletions(-) > > > diff --git a/mm/swapfile.c b/mm/swapfile.c > > > index 71890061f653..10e75f9e8ac1 100644 > > > --- a/mm/swapfile.c > > > +++ b/mm/swapfile.c > > > @@ -37,6 +37,7 @@ -> > > A #include <linux/swapfile.h> -> > > A #include <linux/export.h> -> > > A #include <linux/swap_slots.h> +> > > #include <linux/swapfile.h> +> > > #include <linux/export.h> +> > > #include <linux/swap_slots.h> > > > +#include <linux/sort.h> -> > > A -> > > A #include <asm/pgtable.h> -> > > A #include <asm/tlbflush.h> +> > > +> > > #include <asm/pgtable.h> +> > > #include <asm/tlbflush.h> > > > @@ -1065,20 +1066,52 @@ void swapcache_free(swp_entry_t entry) -> > > A } -> > > A } -> > > A +> > > } +> > > } +> > > > > > +static int swp_entry_cmp(const void *ent1, const void *ent2) > > > +{ > > > + const swp_entry_t *e1 = ent1, *e2 = ent2; @@ -36,25 +36,25 @@ On Thu, 2017-04-27 at 09:21 +0800, Huang, Ying wrote: > > > + return (int)(swp_type(*e1) - swp_type(*e2)); > > > +} > > > + -> > > A void swapcache_free_entries(swp_entry_t *entries, int n) -> > > A { -> > > A struct swap_info_struct *p, *prev; +> > > void swapcache_free_entries(swp_entry_t *entries, int n) +> > > { +> > > struct swap_info_struct *p, *prev; > > > - int i; > > > + int i, m; > > > + swp_entry_t entry; > > > + unsigned int prev_swp_type; > > I think it will be clearer to name prev_swp_type as first_swp_type > > as this is the swp type of the first entry. -> Yes.A A That is better!A A Will do that. +> Yes. That is better! Will do that. > > > > > > -> > > A -> > > A if (n <= 0) -> > > A return; -> > > A -> > > A prev = NULL; -> > > A p = NULL; +> > > +> > > if (n <= 0) +> > > return; +> > > +> > > prev = NULL; +> > > p = NULL; > > > - for (i = 0; i < n; ++i) { > > > - p = swap_info_get_cont(entries[i], prev); > > > - if (p) @@ -97,24 +97,24 @@ On Thu, 2017-04-27 at 09:21 +0800, Huang, Ying wrote: > > > + if (swp_type(entry) == prev_swp_type) > > > + continue; > > The if/continue statement seems incorrect. When swp_type(entry) == prev_swp_type -> > we also need to free entry. A The if/continue statement should be deleted. +> > we also need to free entry. The if/continue statement should be deleted. > > > > Say we have 3 entries with swp_type > > 1,2,1 > > > > We will get prev_swp_type as 1 and free the first entry -> > and sort the remaining two. A The last entry with +> > and sort the remaining two. The last entry with > > swp_type 1 will not be freed. > The first loop in the function will scan all elements of the array, so -> the first and third entry will be freed in the first loop.A A Then the the -> second and the third entry will be sorted.A A But all entries with the +> the first and third entry will be freed in the first loop. Then the the +> second and the third entry will be sorted. But all entries with the > same swap type (device) of the first entry needn't to be freed again. > The key point is that we will scan all elements of the array in the > first loop, record the first entry that has different swap type > (device). I was under the wrong impression that the code break from the first -loop when it finds a different swp type. A Yes, we should skip the +loop when it finds a different swp type. Yes, we should skip the free in the second loop if the first loop scan the whole list. Thanks. @@ -130,15 +130,9 @@ Tim > > > + p = swap_info_get_cont(entry, prev); > > > + if (likely(p)) > > > + swap_entry_free(p, entry); -> > > A prev = p; -> > > A } -> > > A if (p) +> > > prev = p; +> > > } +> > > if (p) > > 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 d310ca2..d00722c 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -33,26 +33,26 @@ "> > > Date: Thu, 23 Feb 2017 13:05:20 +0800\n" "> > > Subject: [PATCH -v5] mm, swap: Sort swap entries before free\n" "> > > \n" - "> > > A \n" + "> > > \302\240\n" "> > > ---\n" - "> > > A mm/swapfile.c | 43 ++++++++++++++++++++++++++++++++++++++-----\n" - "> > > A 1 file changed, 38 insertions(+), 5 deletions(-)\n" + "> > > \302\240mm/swapfile.c | 43 ++++++++++++++++++++++++++++++++++++++-----\n" + "> > > \302\2401 file changed, 38 insertions(+), 5 deletions(-)\n" "> > > diff --git a/mm/swapfile.c b/mm/swapfile.c\n" "> > > index 71890061f653..10e75f9e8ac1 100644\n" "> > > --- a/mm/swapfile.c\n" "> > > +++ b/mm/swapfile.c\n" "> > > @@ -37,6 +37,7 @@\n" - "> > > A #include <linux/swapfile.h>\n" - "> > > A #include <linux/export.h>\n" - "> > > A #include <linux/swap_slots.h>\n" + "> > > \302\240#include <linux/swapfile.h>\n" + "> > > \302\240#include <linux/export.h>\n" + "> > > \302\240#include <linux/swap_slots.h>\n" "> > > +#include <linux/sort.h>\n" - "> > > A \n" - "> > > A #include <asm/pgtable.h>\n" - "> > > A #include <asm/tlbflush.h>\n" + "> > > \302\240\n" + "> > > \302\240#include <asm/pgtable.h>\n" + "> > > \302\240#include <asm/tlbflush.h>\n" "> > > @@ -1065,20 +1066,52 @@ void swapcache_free(swp_entry_t entry)\n" - "> > > A \t}\n" - "> > > A }\n" - "> > > A \n" + "> > > \302\240\t}\n" + "> > > \302\240}\n" + "> > > \302\240\n" "> > > +static int swp_entry_cmp(const void *ent1, const void *ent2)\n" "> > > +{\n" "> > > +\tconst swp_entry_t *e1 = ent1, *e2 = ent2;\n" @@ -60,25 +60,25 @@ "> > > +\treturn (int)(swp_type(*e1) - swp_type(*e2));\n" "> > > +}\n" "> > > +\n" - "> > > A void swapcache_free_entries(swp_entry_t *entries, int n)\n" - "> > > A {\n" - "> > > A \tstruct swap_info_struct *p, *prev;\n" + "> > > \302\240void swapcache_free_entries(swp_entry_t *entries, int n)\n" + "> > > \302\240{\n" + "> > > \302\240\tstruct swap_info_struct *p, *prev;\n" "> > > -\tint i;\n" "> > > +\tint i, m;\n" "> > > +\tswp_entry_t entry;\n" "> > > +\tunsigned int prev_swp_type;\n" "> > I think it will be clearer to name prev_swp_type as first_swp_type\n" "> > as this is the swp type of the first entry.\n" - "> Yes.A A That is better!A A Will do that.\n" + "> Yes.\302\240\302\240That is better!\302\240\302\240Will do that.\n" "> \n" "> > \n" "> > > \n" - "> > > A \n" - "> > > A \tif (n <= 0)\n" - "> > > A \t\treturn;\n" - "> > > A \n" - "> > > A \tprev = NULL;\n" - "> > > A \tp = NULL;\n" + "> > > \302\240\n" + "> > > \302\240\tif (n <= 0)\n" + "> > > \302\240\t\treturn;\n" + "> > > \302\240\n" + "> > > \302\240\tprev = NULL;\n" + "> > > \302\240\tp = NULL;\n" "> > > -\tfor (i = 0; i < n; ++i) {\n" "> > > -\t\tp = swap_info_get_cont(entries[i], prev);\n" "> > > -\t\tif (p)\n" @@ -121,24 +121,24 @@ "> > > +\t\tif (swp_type(entry) == prev_swp_type)\n" "> > > +\t\t\tcontinue;\n" "> > The if/continue statement seems incorrect. When swp_type(entry) == prev_swp_type\n" - "> > we also need to free entry. A The if/continue statement should be deleted.\n" + "> > we also need to free entry. \302\240The if/continue statement should be deleted.\n" "> > \n" "> > Say we have 3 entries with swp_type\n" "> > 1,2,1\n" "> > \n" "> > We will get prev_swp_type as 1 and free the first entry\n" - "> > and sort the remaining two. A The last entry with\n" + "> > and sort the remaining two. \302\240The last entry with\n" "> > swp_type 1 will not be freed.\n" "> The first loop in the function will scan all elements of the array, so\n" - "> the first and third entry will be freed in the first loop.A A Then the the\n" - "> second and the third entry will be sorted.A A But all entries with the\n" + "> the first and third entry will be freed in the first loop.\302\240\302\240Then the the\n" + "> second and the third entry will be sorted.\302\240\302\240But all entries with the\n" "> same swap type (device) of the first entry needn't to be freed again.\n" "> The key point is that we will scan all elements of the array in the\n" "> first loop, record the first entry that has different swap type\n" "> (device).\n" "\n" "I was under the wrong impression that the code break from the first\n" - "loop when it finds a different swp type. A Yes, we should skip the\n" + "loop when it finds a different swp type. \302\240Yes, we should skip the\n" "free in the second loop if the first loop scan the whole list.\n" "\n" "Thanks.\n" @@ -154,17 +154,11 @@ "> > > +\t\tp = swap_info_get_cont(entry, prev);\n" "> > > +\t\tif (likely(p))\n" "> > > +\t\t\tswap_entry_free(p, entry);\n" - "> > > A \t\tprev = p;\n" - "> > > A \t}\n" - "> > > A \tif (p)\n" + "> > > \302\240\t\tprev = p;\n" + "> > > \302\240\t}\n" + "> > > \302\240\tif (p)\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 -7c3a73856cd8b2b3909d720c11dad81516c4140457405a05e527389278963005 +c7395fe427fa2452685ba1a4efd102f214cdcad15a0a30a13034ffb9e91c1de4
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.