linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: Hugh Dickins <hughd@google.com>
Cc: Zdenek Kabelac <zkabelac@redhat.com>,
	linux-mm@kvack.org, dm-devel@redhat.com
Subject: [PATCH] shmfs: don't allocate pages on read
Date: Tue, 21 Jul 2020 05:12:54 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LRH.2.02.2007210510230.6959@file01.intranet.prod.int.rdu2.redhat.com> (raw)

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1479 bytes --]

Hi

Do we still need the patch a0ee5ec520ede?

We are using the loop device for testing and when we read something from 
the loop device, it allocates the pages on the underlying shmfs 
filesystem. See this example:

# mkdir -p /mnt/test
# mount -t tmpfs /dev/null /mnt/test
# cd /mnt/test
# truncate -s 1GiB file
# du -hs file
0       file
# losetup /dev/loop0 file
# du -hs file
1,1M    file
# dd if=/dev/loop0 of=/dev/null
2097152+0 zĂĄznamĹŻ pĹ™ečteno
2097152+0 zĂĄznamĹŻ zapsĂĄno
1073741824 bajtĹŻ (1,1 GB, 1,0 GiB) zkopĂ­rovĂĄno, 4,06865 s, 264 MB/s
# du -hs file
1,0G    file

This patch turns off the allocation on read.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 mm/shmem.c |    8 --------
 1 file changed, 8 deletions(-)

Index: linux-2.6/mm/shmem.c
===================================================================
--- linux-2.6.orig/mm/shmem.c	2020-06-29 14:50:06.000000000 +0200
+++ linux-2.6/mm/shmem.c	2020-07-16 19:22:58.000000000 +0200
@@ -2507,14 +2507,6 @@ static ssize_t shmem_file_read_iter(stru
 	ssize_t retval = 0;
 	loff_t *ppos = &iocb->ki_pos;
 
-	/*
-	 * Might this read be for a stacking filesystem?  Then when reading
-	 * holes of a sparse file, we actually need to allocate those pages,
-	 * and even mark them dirty, so it cannot exceed the max_blocks limit.
-	 */
-	if (!iter_is_iovec(to))
-		sgp = SGP_CACHE;
-
 	index = *ppos >> PAGE_SHIFT;
 	offset = *ppos & ~PAGE_MASK;
 

                 reply	other threads:[~2020-07-21  9:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LRH.2.02.2007210510230.6959@file01.intranet.prod.int.rdu2.redhat.com \
    --to=mpatocka@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=hughd@google.com \
    --cc=linux-mm@kvack.org \
    --cc=zkabelac@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).