From: Hugh Dickins <hugh@veritas.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>,
Christoph Lameter <cl@linux-foundation.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
linux-mm@kvack.org
Subject: [PATCH 5/7] mm: replace some BUG_ONs by VM_BUG_ONs
Date: Thu, 20 Nov 2008 01:20:09 +0000 (GMT) [thread overview]
Message-ID: <Pine.LNX.4.64.0811200117370.19216@blonde.site> (raw)
In-Reply-To: <Pine.LNX.4.64.0811200108230.19216@blonde.site>
The swap code is over-provisioned with BUG_ONs on assorted page flags,
mostly dating back to 2.3. They're good documentation, and guard against
developer error, but a waste of space on most systems: change them to
VM_BUG_ONs, conditional on CONFIG_DEBUG_VM. Just delete the PagePrivate
ones: they're later, from 2.5.69, but even less interesting now.
Signed-off-by: Hugh Dickins <hugh@veritas.com>
---
Could be taken further: this now looks like a random selection
which caught my eye at some point working in these files.
This patch clashes trivially in __delete_from_swap_cache with
memcg-memswap-controller-core.patch, which I'm assuming comes
later: sorry, but you'll have no difficulty in fixing it up.
mm/page_io.c | 4 ++--
mm/swap_state.c | 19 +++++++++----------
mm/swapfile.c | 8 +++-----
3 files changed, 14 insertions(+), 17 deletions(-)
--- mmclean4/mm/page_io.c 2008-04-17 03:49:44.000000000 +0100
+++ mmclean5/mm/page_io.c 2008-11-19 15:26:26.000000000 +0000
@@ -125,8 +125,8 @@ int swap_readpage(struct file *file, str
struct bio *bio;
int ret = 0;
- BUG_ON(!PageLocked(page));
- BUG_ON(PageUptodate(page));
+ VM_BUG_ON(!PageLocked(page));
+ VM_BUG_ON(PageUptodate(page));
bio = get_swap_bio(GFP_KERNEL, page_private(page), page,
end_swap_bio_read);
if (bio == NULL) {
--- mmclean4/mm/swap_state.c 2008-10-24 09:28:26.000000000 +0100
+++ mmclean5/mm/swap_state.c 2008-11-19 15:26:26.000000000 +0000
@@ -72,10 +72,10 @@ int add_to_swap_cache(struct page *page,
{
int error;
- BUG_ON(!PageLocked(page));
- BUG_ON(PageSwapCache(page));
- BUG_ON(PagePrivate(page));
- BUG_ON(!PageSwapBacked(page));
+ VM_BUG_ON(!PageLocked(page));
+ VM_BUG_ON(PageSwapCache(page));
+ VM_BUG_ON(!PageSwapBacked(page));
+
error = radix_tree_preload(gfp_mask);
if (!error) {
page_cache_get(page);
@@ -108,10 +108,9 @@ int add_to_swap_cache(struct page *page,
*/
void __delete_from_swap_cache(struct page *page)
{
- BUG_ON(!PageLocked(page));
- BUG_ON(!PageSwapCache(page));
- BUG_ON(PageWriteback(page));
- BUG_ON(PagePrivate(page));
+ VM_BUG_ON(!PageLocked(page));
+ VM_BUG_ON(!PageSwapCache(page));
+ VM_BUG_ON(PageWriteback(page));
radix_tree_delete(&swapper_space.page_tree, page_private(page));
set_page_private(page, 0);
@@ -134,8 +133,8 @@ int add_to_swap(struct page * page, gfp_
swp_entry_t entry;
int err;
- BUG_ON(!PageLocked(page));
- BUG_ON(!PageUptodate(page));
+ VM_BUG_ON(!PageLocked(page));
+ VM_BUG_ON(!PageUptodate(page));
for (;;) {
entry = get_swap_page();
--- mmclean4/mm/swapfile.c 2008-10-24 09:28:26.000000000 +0100
+++ mmclean5/mm/swapfile.c 2008-11-19 15:26:26.000000000 +0000
@@ -333,7 +333,7 @@ int can_share_swap_page(struct page *pag
{
int count;
- BUG_ON(!PageLocked(page));
+ VM_BUG_ON(!PageLocked(page));
count = page_mapcount(page);
if (count <= 1 && PageSwapCache(page))
count += page_swapcount(page);
@@ -350,8 +350,7 @@ static int remove_exclusive_swap_page_co
struct swap_info_struct * p;
swp_entry_t entry;
- BUG_ON(PagePrivate(page));
- BUG_ON(!PageLocked(page));
+ VM_BUG_ON(!PageLocked(page));
if (!PageSwapCache(page))
return 0;
@@ -432,7 +431,6 @@ void free_swap_and_cache(swp_entry_t ent
if (page) {
int one_user;
- BUG_ON(PagePrivate(page));
one_user = (page_count(page) == 2);
/* Only cache user (+us), or swap space full? Free it! */
/* Also recheck PageSwapCache after page is locked (above) */
@@ -1209,7 +1207,7 @@ int page_queue_congested(struct page *pa
{
struct backing_dev_info *bdi;
- BUG_ON(!PageLocked(page)); /* It pins the swap_info_struct */
+ VM_BUG_ON(!PageLocked(page)); /* It pins the swap_info_struct */
if (PageSwapCache(page)) {
swp_entry_t entry = { .val = page_private(page) };
--
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:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2008-11-20 1:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-20 1:10 [PATCH 0/7] mm: cleanups Hugh Dickins
2008-11-20 1:11 ` [PATCH 1/7] mm: remove cgroup_mm_owner_callbacks Hugh Dickins
2008-11-20 1:23 ` Paul Menage
2008-11-20 1:26 ` Hugh Dickins
2008-11-20 16:41 ` Balbir Singh
2008-11-20 1:14 ` [PATCH 2/7] mm: remove AOP_WRITEPAGE_ACTIVATE Hugh Dickins
2008-11-20 1:16 ` [PATCH 3/7] mm: remove GFP_HIGHUSER_PAGECACHE Hugh Dickins
2008-11-20 16:43 ` Mel Gorman
2008-11-20 18:58 ` Hugh Dickins
2008-11-21 10:46 ` Mel Gorman
2008-11-20 1:17 ` [PATCH 4/7] mm: add Set,ClearPageSwapCache stubs Hugh Dickins
2008-11-20 18:08 ` Christoph Lameter
2008-11-20 1:20 ` Hugh Dickins [this message]
2008-11-20 18:09 ` [PATCH 5/7] mm: replace some BUG_ONs by VM_BUG_ONs Christoph Lameter
2008-11-20 1:22 ` [PATCH 6/7] mm: add_active_or_unevictable into rmap Hugh Dickins
2008-11-20 2:08 ` Rik van Riel
2008-11-20 15:18 ` Lee Schermerhorn
2008-11-23 21:51 ` [PATCH 8/7] mm: further cleanup page_add_new_anon_rmap Hugh Dickins
2008-11-23 21:56 ` Rik van Riel
2008-11-23 22:18 ` Hugh Dickins
2008-11-23 22:41 ` Rik van Riel
2008-11-20 1:24 ` [PATCH 7/7] mm: make page_lock_anon_vma static Hugh Dickins
2008-11-21 8:29 ` KOSAKI Motohiro
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=Pine.LNX.4.64.0811200117370.19216@blonde.site \
--to=hugh@veritas.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux-foundation.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=nickpiggin@yahoo.com.au \
/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