From: Hugh Dickins <hughd@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Tim Chen <tim.c.chen@linux.intel.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH 14/14] tmpfs: no need to use i_lock
Date: Mon, 30 May 2011 17:55:44 -0700 (PDT) [thread overview]
Message-ID: <alpine.LSU.2.00.1105301754050.5482@sister.anvils> (raw)
In-Reply-To: <alpine.LSU.2.00.1105301726180.5482@sister.anvils>
2.6.36's 7e496299d4d2 to make tmpfs scalable with percpu_counter used
inode->i_lock in place of sbinfo->stat_lock around i_blocks updates;
but that was adverse to scalability, and unnecessary, since info->lock
is already held there in the fast paths.
Remove those uses of i_lock, and add info->lock in the three error
paths where it's then needed across shmem_free_blocks(). It's not
actually needed across shmem_unacct_blocks(), but they're so often
paired that it looks wrong to split them apart.
Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
---
mm/shmem.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
--- linux.orig/mm/shmem.c 2011-05-30 14:25:32.665536626 -0700
+++ linux/mm/shmem.c 2011-05-30 15:03:41.680887254 -0700
@@ -241,9 +241,7 @@ static void shmem_free_blocks(struct ino
struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
if (sbinfo->max_blocks) {
percpu_counter_add(&sbinfo->used_blocks, -pages);
- spin_lock(&inode->i_lock);
inode->i_blocks -= pages*BLOCKS_PER_PAGE;
- spin_unlock(&inode->i_lock);
}
}
@@ -432,9 +430,7 @@ static swp_entry_t *shmem_swp_alloc(stru
sbinfo->max_blocks - 1) >= 0)
return ERR_PTR(-ENOSPC);
percpu_counter_inc(&sbinfo->used_blocks);
- spin_lock(&inode->i_lock);
inode->i_blocks += BLOCKS_PER_PAGE;
- spin_unlock(&inode->i_lock);
}
spin_unlock(&info->lock);
@@ -1420,9 +1416,7 @@ repeat:
shmem_acct_block(info->flags))
goto nospace;
percpu_counter_inc(&sbinfo->used_blocks);
- spin_lock(&inode->i_lock);
inode->i_blocks += BLOCKS_PER_PAGE;
- spin_unlock(&inode->i_lock);
} else if (shmem_acct_block(info->flags))
goto nospace;
@@ -1433,8 +1427,10 @@ repeat:
spin_unlock(&info->lock);
filepage = shmem_alloc_page(gfp, info, idx);
if (!filepage) {
+ spin_lock(&info->lock);
shmem_unacct_blocks(info->flags, 1);
shmem_free_blocks(inode, 1);
+ spin_unlock(&info->lock);
error = -ENOMEM;
goto failed;
}
@@ -1448,8 +1444,10 @@ repeat:
current->mm, GFP_KERNEL);
if (error) {
page_cache_release(filepage);
+ spin_lock(&info->lock);
shmem_unacct_blocks(info->flags, 1);
shmem_free_blocks(inode, 1);
+ spin_unlock(&info->lock);
filepage = NULL;
goto failed;
}
@@ -1479,10 +1477,10 @@ repeat:
* be done automatically.
*/
if (ret) {
- spin_unlock(&info->lock);
- page_cache_release(filepage);
shmem_unacct_blocks(info->flags, 1);
shmem_free_blocks(inode, 1);
+ spin_unlock(&info->lock);
+ page_cache_release(filepage);
filepage = NULL;
if (error)
goto failed;
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2011-05-31 0:55 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-31 0:33 [PATCH 0/14] mm: tmpfs and trunc changes, affecting drm Hugh Dickins
2011-05-31 0:35 ` [PATCH 1/14] mm: invalidate_mapping_pages flush cleancache Hugh Dickins
2011-05-31 15:49 ` Dan Magenheimer
2011-05-31 17:05 ` Hugh Dickins
2011-05-31 21:08 ` Chris Mason
2011-05-31 22:01 ` Hugh Dickins
2011-05-31 0:36 ` [PATCH 2/14] mm: move vmtruncate_range to truncate.c Hugh Dickins
2011-06-01 0:36 ` Christoph Hellwig
2011-05-31 0:39 ` [PATCH 3/14] tmpfs: take control of its truncate_range Hugh Dickins
2011-06-01 0:39 ` Christoph Hellwig
2011-06-01 16:58 ` Hugh Dickins
2011-06-03 5:16 ` Christoph Hellwig
2011-06-06 5:37 ` Hugh Dickins
2011-05-31 0:40 ` [PATCH 4/14] tmpfs: add shmem_read_mapping_page_gfp Hugh Dickins
2011-06-01 0:42 ` Christoph Hellwig
2011-06-01 17:02 ` Hugh Dickins
2011-05-31 0:42 ` [PATCH 5/14] drm/ttm: use shmem_read_mapping_page Hugh Dickins
2011-05-31 0:43 ` [PATCH 6/14] drm/i915: " Hugh Dickins
2011-05-31 0:45 ` [PATCH 7/14] drm/i915: adjust to new truncate_range Hugh Dickins
2011-06-01 0:43 ` Christoph Hellwig
2011-06-01 17:04 ` Hugh Dickins
2011-05-31 0:46 ` [PATCH 8/14] drm/i915: more struct_mutex locking Hugh Dickins
2011-05-31 0:48 ` [PATCH 9/14] mm: cleanup descriptions of filler arg Hugh Dickins
2011-05-31 0:49 ` [PATCH 10/14] mm: truncate functions are in truncate.c Hugh Dickins
2011-05-31 0:51 ` [PATCH 11/14] mm: tidy vmtruncate_range and related functions Hugh Dickins
2011-05-31 0:52 ` [PATCH 12/14] mm: consistent truncate and invalidate loops Hugh Dickins
2011-05-31 0:54 ` [PATCH 13/14] mm: pincer in truncate_inode_pages_range Hugh Dickins
2011-05-31 0:55 ` Hugh Dickins [this message]
2011-05-31 16:08 ` [PATCH 14/14] tmpfs: no need to use i_lock Tim Chen
2011-06-06 4:21 [PATCH 0/14] mm: tmpfs and trunc changes, affecting drm Hugh Dickins
2011-06-06 4:42 ` [PATCH 14/14] tmpfs: no need to use i_lock Hugh Dickins
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.LSU.2.00.1105301754050.5482@sister.anvils \
--to=hughd@google.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=tim.c.chen@linux.intel.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