diff for duplicates of <20161114140957.GA9950@node.shutemov.name> diff --git a/a/1.txt b/N1/1.txt index b44d028..4f16cfd 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -154,3 +154,93 @@ The patch relaxes condition: only require file size >= HPAGE_PMD_SIZE. I missed that. -----8<----- +>From b2158fdd8523e3e35a548857a1cb02fe6bcd1ea4 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 slowdown +comparing to small pages. + +Later we can consider huge=within_size as the default for tmpfs. + +Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> +--- + Documentation/vm/transhuge.txt | 8 ++++++-- + mm/shmem.c | 12 +++--------- + 2 files changed, 9 insertions(+), 11 deletions(-) + +diff --git a/Documentation/vm/transhuge.txt b/Documentation/vm/transhuge.txt +index 2ec6adb5a4ce..7703e9c241ca 100644 +--- a/Documentation/vm/transhuge.txt ++++ b/Documentation/vm/transhuge.txt +@@ -206,13 +206,17 @@ You can control hugepage allocation policy in tmpfs with mount option + "huge=". It can have following values: + + - "always": +- Attempt to allocate huge pages every time we need a new page; ++ 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..ef8fdadd0626 100644 +--- a/mm/shmem.c ++++ b/mm/shmem.c +@@ -1677,14 +1677,11 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, + goto alloc_huge; + switch (sbinfo->huge) { + loff_t i_size; +- pgoff_t off; + 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: +@@ -3856,7 +3853,6 @@ bool shmem_huge_enabled(struct vm_area_struct *vma) + struct inode *inode = file_inode(vma->vm_file); + struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); + loff_t i_size; +- pgoff_t off; + + if (shmem_huge == SHMEM_HUGE_FORCE) + return true; +@@ -3868,10 +3864,8 @@ bool shmem_huge_enabled(struct vm_area_struct *vma) + case SHMEM_HUGE_ALWAYS: + return true; + case SHMEM_HUGE_WITHIN_SIZE: +- off = round_up(vma->vm_pgoff, HPAGE_PMD_NR); + i_size = round_up(i_size_read(inode), PAGE_SIZE); +- if (i_size >= HPAGE_PMD_SIZE && +- i_size >> PAGE_SHIFT >= off) ++ if (i_size >= HPAGE_PMD_SIZE) + return true; + case SHMEM_HUGE_ADVISE: + /* TODO: implement fadvise() hints */ +-- + Kirill A. Shutemov diff --git a/a/content_digest b/N1/content_digest index 0c03422..8d80a29 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -172,6 +172,96 @@ "\n" "I missed that.\n" "\n" - -----8<----- + "-----8<-----\n" + ">From b2158fdd8523e3e35a548857a1cb02fe6bcd1ea4 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 slowdown\n" + "comparing to small pages.\n" + "\n" + "Later we can consider huge=within_size as the default for tmpfs.\n" + "\n" + "Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>\n" + "---\n" + " Documentation/vm/transhuge.txt | 8 ++++++--\n" + " mm/shmem.c | 12 +++---------\n" + " 2 files changed, 9 insertions(+), 11 deletions(-)\n" + "\n" + "diff --git a/Documentation/vm/transhuge.txt b/Documentation/vm/transhuge.txt\n" + "index 2ec6adb5a4ce..7703e9c241ca 100644\n" + "--- a/Documentation/vm/transhuge.txt\n" + "+++ b/Documentation/vm/transhuge.txt\n" + "@@ -206,13 +206,17 @@ You can control hugepage allocation policy in tmpfs with mount option\n" + " \"huge=\". It can have following values:\n" + " \n" + " - \"always\":\n" + "- Attempt to allocate huge pages every time we need a new page;\n" + "+ Attempt to allocate huge pages every time we need a new page.\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..ef8fdadd0626 100644\n" + "--- a/mm/shmem.c\n" + "+++ b/mm/shmem.c\n" + "@@ -1677,14 +1677,11 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,\n" + " \t\t\tgoto alloc_huge;\n" + " \t\tswitch (sbinfo->huge) {\n" + " \t\t\tloff_t i_size;\n" + "-\t\t\tpgoff_t off;\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" + "@@ -3856,7 +3853,6 @@ bool shmem_huge_enabled(struct vm_area_struct *vma)\n" + " \tstruct inode *inode = file_inode(vma->vm_file);\n" + " \tstruct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);\n" + " \tloff_t i_size;\n" + "-\tpgoff_t off;\n" + " \n" + " \tif (shmem_huge == SHMEM_HUGE_FORCE)\n" + " \t\treturn true;\n" + "@@ -3868,10 +3864,8 @@ bool shmem_huge_enabled(struct vm_area_struct *vma)\n" + " \t\tcase SHMEM_HUGE_ALWAYS:\n" + " \t\t\treturn true;\n" + " \t\tcase SHMEM_HUGE_WITHIN_SIZE:\n" + "-\t\t\toff = round_up(vma->vm_pgoff, 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\tif (i_size >= HPAGE_PMD_SIZE)\n" + " \t\t\t\treturn true;\n" + " \t\tcase SHMEM_HUGE_ADVISE:\n" + " \t\t\t/* TODO: implement fadvise() hints */\n" + "-- \n" + Kirill A. Shutemov -a2a7c695f975915f041c3a37fffc85be38a866cf2ed42894acd70ccbc3dbcf7a +e2c02c91e792e5c1a2682020a94ad7c3c68e40f782ef3e58aa554a16a2e8b87b
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.