From: "Paul E. McKenney" <paulmck@us.ibm.com>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@digeo.com
Cc: mjbligh@us.ibm.com
Subject: [RFC][PATCH] Fix for latent bug in vmtruncate()
Date: Tue, 13 May 2003 13:58:07 -0700 [thread overview]
Message-ID: <20030513135807.E2929@us.ibm.com> (raw)
The vmtruncate() function shifts down by PAGE_CACHE_SHIFT, then
calls vmtruncate_list(), which deals in terms of PAGE_SHIFT
instead. Currently, no harm done, since PAGE_CACHE_SHIFT and
PAGE_SHIFT are identical. Some day they might not be, hence
this patch.
I also took the liberty of modifying a hand-coded "if" that
seems to optimize for files that are not mapped to instead
use unlikely().
Thoughts?
Thanx, Paul
diff -urN -X dontdiff linux-2.5.69/mm/memory.c linux-2.5.69.vmtruncate/mm/memory.c
--- linux-2.5.69/mm/memory.c Sun May 4 16:53:14 2003
+++ linux-2.5.69.vmtruncate/mm/memory.c Fri May 9 17:29:02 2003
@@ -1108,17 +1108,12 @@
if (inode->i_size < offset)
goto do_expand;
inode->i_size = offset;
+ pgoff = (offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
down(&mapping->i_shared_sem);
- if (list_empty(&mapping->i_mmap) && list_empty(&mapping->i_mmap_shared))
- goto out_unlock;
-
- pgoff = (offset + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
- if (!list_empty(&mapping->i_mmap))
+ if (unlikely(!list_empty(&mapping->i_mmap)))
vmtruncate_list(&mapping->i_mmap, pgoff);
- if (!list_empty(&mapping->i_mmap_shared))
+ if (unlikely(!list_empty(&mapping->i_mmap_shared)))
vmtruncate_list(&mapping->i_mmap_shared, pgoff);
-
-out_unlock:
up(&mapping->i_shared_sem);
truncate_inode_pages(mapping, offset);
goto out_truncate;
WARNING: multiple messages have this Message-ID (diff)
From: "Paul E. McKenney" <paulmck@us.ibm.com>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@digeo.com
Cc: mjbligh@us.ibm.com
Subject: [RFC][PATCH] Fix for latent bug in vmtruncate()
Date: Tue, 13 May 2003 13:58:07 -0700 [thread overview]
Message-ID: <20030513135807.E2929@us.ibm.com> (raw)
The vmtruncate() function shifts down by PAGE_CACHE_SHIFT, then
calls vmtruncate_list(), which deals in terms of PAGE_SHIFT
instead. Currently, no harm done, since PAGE_CACHE_SHIFT and
PAGE_SHIFT are identical. Some day they might not be, hence
this patch.
I also took the liberty of modifying a hand-coded "if" that
seems to optimize for files that are not mapped to instead
use unlikely().
Thoughts?
Thanx, Paul
diff -urN -X dontdiff linux-2.5.69/mm/memory.c linux-2.5.69.vmtruncate/mm/memory.c
--- linux-2.5.69/mm/memory.c Sun May 4 16:53:14 2003
+++ linux-2.5.69.vmtruncate/mm/memory.c Fri May 9 17:29:02 2003
@@ -1108,17 +1108,12 @@
if (inode->i_size < offset)
goto do_expand;
inode->i_size = offset;
+ pgoff = (offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
down(&mapping->i_shared_sem);
- if (list_empty(&mapping->i_mmap) && list_empty(&mapping->i_mmap_shared))
- goto out_unlock;
-
- pgoff = (offset + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
- if (!list_empty(&mapping->i_mmap))
+ if (unlikely(!list_empty(&mapping->i_mmap)))
vmtruncate_list(&mapping->i_mmap, pgoff);
- if (!list_empty(&mapping->i_mmap_shared))
+ if (unlikely(!list_empty(&mapping->i_mmap_shared)))
vmtruncate_list(&mapping->i_mmap_shared, pgoff);
-
-out_unlock:
up(&mapping->i_shared_sem);
truncate_inode_pages(mapping, offset);
goto out_truncate;
--
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/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
next reply other threads:[~2003-05-13 21:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-13 20:58 Paul E. McKenney [this message]
2003-05-13 20:58 ` [RFC][PATCH] Fix for latent bug in vmtruncate() Paul E. McKenney
2003-05-13 22:06 ` William Lee Irwin III
2003-05-13 22:06 ` William Lee Irwin III
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=20030513135807.E2929@us.ibm.com \
--to=paulmck@us.ibm.com \
--cc=akpm@digeo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mjbligh@us.ibm.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.