All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: hughd@google.com, akpm@linux-foundation.org, willy@infradead.org
Cc: linux-mm@kvack.org, p.raghav@samsung.com, dave@stgolabs.net,
	a.manzanares@samsung.com, yosryahmed@google.com,
	mcgrof@kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC v2 4/5] shmem: skip page split if we're not reclaiming
Date: Wed, 22 Feb 2023 18:44:11 -0800	[thread overview]
Message-ID: <20230223024412.3522465-5-mcgrof@kernel.org> (raw)
In-Reply-To: <20230223024412.3522465-1-mcgrof@kernel.org>

In theory when info->flags & VM_LOCKED we should not be getting
shem_writepage() called so we should be verifying this with a
WARN_ON_ONCE(). Since we should not be swapping then best to ensure
we also don't do the folio split earlier too. So just move the check
early to avoid folio splits in case its a dubious call.

We also have a similar early bail when !total_swap_pages so just move
that earlier to avoid the possible folio split in the same situation.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 mm/shmem.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 626eb1a0856c..a49b31d38627 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1349,6 +1349,12 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
 		goto redirty;
 	}
 
+	if (WARN_ON_ONCE(info->flags & VM_LOCKED))
+		goto redirty;
+
+	if (!total_swap_pages)
+		goto redirty;
+
 	/*
 	 * If /sys/kernel/mm/transparent_hugepage/shmem_enabled is "always" or
 	 * "force", drivers/gpu/drm/i915/gem/i915_gem_shmem.c gets huge pages,
@@ -1364,10 +1370,6 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
 	}
 
 	index = folio->index;
-	if (info->flags & VM_LOCKED)
-		goto redirty;
-	if (!total_swap_pages)
-		goto redirty;
 
 	/*
 	 * This is somewhat ridiculous, but without plumbing a SWAP_MAP_FALLOC
-- 
2.39.1


  parent reply	other threads:[~2023-02-23  2:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-23  2:44 [RFC v2 0/5] tmpfs: add the option to disable swap Luis Chamberlain
2023-02-23  2:44 ` [RFC v2 1/5] shmem: remove check for folio lock on writepage() Luis Chamberlain
2023-02-23  2:44 ` [RFC v2 2/5] shmem: set shmem_writepage() variables early Luis Chamberlain
2023-02-23  2:44 ` [RFC v2 3/5] shmem: move reclaim check early on writepages() Luis Chamberlain
2023-02-23  2:44 ` Luis Chamberlain [this message]
2023-02-23  2:44 ` [RFC v2 5/5] shmem: add support to ignore swap Luis Chamberlain
2023-02-23 12:26   ` Christian Brauner
2023-02-23 15:16     ` Christoph Hellwig
2023-02-23 16:09       ` Christian Brauner
2023-02-23 19:43         ` Luis Chamberlain

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=20230223024412.3522465-5-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=a.manzanares@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave@stgolabs.net \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=p.raghav@samsung.com \
    --cc=willy@infradead.org \
    --cc=yosryahmed@google.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 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.