diff for duplicates of <20161110162540.GA12743@node.shutemov.name> diff --git a/a/1.txt b/N1/1.txt index df0e786..9ce197f 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -100,3 +100,69 @@ That's not what I intended initially for this option, but... It's more about cost of allocation than memory pressure. -----8<----- + +>From 287ab05c09bfd49c7356ca74b6fea36d8131edaf Mon Sep 17 00:00:00 2001 +From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> +Date: Mon, 17 Oct 2016 14:44:47 +0300 +Subject: [PATCH] shmem: avoid huge pages for small files + +Huge pages are detrimental for small file: they causes noticible +overhead on both allocation performance and memory footprint. + +This patch aimed to address this issue by avoiding huge pages until +file grown to size of huge page if the filesystem mounted with +huge=within_size option. + +This would cover most of the cases where huge pages causes regressions +in performance. + +The limit doesn't affect khugepaged behaviour: it still can collapse +pages based on its settings. + +Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> +--- + Documentation/vm/transhuge.txt | 7 ++++++- + mm/shmem.c | 6 ++---- + 2 files changed, 8 insertions(+), 5 deletions(-) + +diff --git a/Documentation/vm/transhuge.txt b/Documentation/vm/transhuge.txt +index 2ec6adb5a4ce..14c911c56f4a 100644 +--- a/Documentation/vm/transhuge.txt ++++ b/Documentation/vm/transhuge.txt +@@ -208,11 +208,16 @@ You can control hugepage allocation policy in tmpfs with mount option + - "always": + Attempt to allocate huge pages every time we need a new page; + ++ This option can lead to significant overhead if filesystem is used to ++ store small files. ++ + - "never": + Do not allocate huge pages; + + - "within_size": +- Only allocate huge page if it will be fully within i_size. ++ Only allocate huge page if size of the file more than size of huge ++ page. This helps to avoid overhead for small files. ++ + Also respect fadvise()/madvise() hints; + + - "advise: +diff --git a/mm/shmem.c b/mm/shmem.c +index ad7813d73ea7..3589d36c7c63 100644 +--- a/mm/shmem.c ++++ b/mm/shmem.c +@@ -1681,10 +1681,8 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, + case SHMEM_HUGE_NEVER: + goto alloc_nohuge; + case SHMEM_HUGE_WITHIN_SIZE: +- off = round_up(index, HPAGE_PMD_NR); +- i_size = round_up(i_size_read(inode), PAGE_SIZE); +- if (i_size >= HPAGE_PMD_SIZE && +- i_size >> PAGE_SHIFT >= off) ++ i_size = i_size_read(inode); ++ if (index >= HPAGE_PMD_NR || i_size >= HPAGE_PMD_SIZE) + goto alloc_huge; + /* fallthrough */ + case SHMEM_HUGE_ADVISE: +-- + Kirill A. Shutemov diff --git a/a/content_digest b/N1/content_digest index 9f95b4d..91f89ae 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -116,6 +116,72 @@ "\n" "It's more about cost of allocation than memory pressure.\n" "\n" - -----8<----- + "-----8<-----\n" + "\n" + ">From 287ab05c09bfd49c7356ca74b6fea36d8131edaf Mon Sep 17 00:00:00 2001\n" + "From: \"Kirill A. Shutemov\" <kirill.shutemov@linux.intel.com>\n" + "Date: Mon, 17 Oct 2016 14:44:47 +0300\n" + "Subject: [PATCH] shmem: avoid huge pages for small files\n" + "\n" + "Huge pages are detrimental for small file: they causes noticible\n" + "overhead on both allocation performance and memory footprint.\n" + "\n" + "This patch aimed to address this issue by avoiding huge pages until\n" + "file grown to size of huge page if the filesystem mounted with\n" + "huge=within_size option.\n" + "\n" + "This would cover most of the cases where huge pages causes regressions\n" + "in performance.\n" + "\n" + "The limit doesn't affect khugepaged behaviour: it still can collapse\n" + "pages based on its settings.\n" + "\n" + "Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>\n" + "---\n" + " Documentation/vm/transhuge.txt | 7 ++++++-\n" + " mm/shmem.c | 6 ++----\n" + " 2 files changed, 8 insertions(+), 5 deletions(-)\n" + "\n" + "diff --git a/Documentation/vm/transhuge.txt b/Documentation/vm/transhuge.txt\n" + "index 2ec6adb5a4ce..14c911c56f4a 100644\n" + "--- a/Documentation/vm/transhuge.txt\n" + "+++ b/Documentation/vm/transhuge.txt\n" + "@@ -208,11 +208,16 @@ You can control hugepage allocation policy in tmpfs with mount option\n" + " - \"always\":\n" + " Attempt to allocate huge pages every time we need a new page;\n" + " \n" + "+ This option can lead to significant overhead if filesystem is used to\n" + "+ store small files.\n" + "+\n" + " - \"never\":\n" + " Do not allocate huge pages;\n" + " \n" + " - \"within_size\":\n" + "- Only allocate huge page if it will be fully within i_size.\n" + "+ Only allocate huge page if size of the file more than size of huge\n" + "+ page. This helps to avoid overhead for small files.\n" + "+\n" + " Also respect fadvise()/madvise() hints;\n" + " \n" + " - \"advise:\n" + "diff --git a/mm/shmem.c b/mm/shmem.c\n" + "index ad7813d73ea7..3589d36c7c63 100644\n" + "--- a/mm/shmem.c\n" + "+++ b/mm/shmem.c\n" + "@@ -1681,10 +1681,8 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,\n" + " \t\tcase SHMEM_HUGE_NEVER:\n" + " \t\t\tgoto alloc_nohuge;\n" + " \t\tcase SHMEM_HUGE_WITHIN_SIZE:\n" + "-\t\t\toff = round_up(index, HPAGE_PMD_NR);\n" + "-\t\t\ti_size = round_up(i_size_read(inode), PAGE_SIZE);\n" + "-\t\t\tif (i_size >= HPAGE_PMD_SIZE &&\n" + "-\t\t\t\t\ti_size >> PAGE_SHIFT >= off)\n" + "+\t\t\ti_size = i_size_read(inode);\n" + "+\t\t\tif (index >= HPAGE_PMD_NR || i_size >= HPAGE_PMD_SIZE)\n" + " \t\t\t\tgoto alloc_huge;\n" + " \t\t\t/* fallthrough */\n" + " \t\tcase SHMEM_HUGE_ADVISE:\n" + "-- \n" + Kirill A. Shutemov -a84ed9e991a58e53da11724dee152b29244f09a776b92e552dd23ec4b93f9b1e +0c5a2ac80b2c0e852974317717acf31d862a2276f72f4484c65eb4412dc02519
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.