All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Dave Kleikamp <shaggy@austin.ibm.com>
Cc: andrea@novell.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] zap_pte_range should not mark non-uptodate pages dirty
Date: Thu, 21 Oct 2004 14:45:31 -0700	[thread overview]
Message-ID: <20041021144531.22dd0d54.akpm@osdl.org> (raw)
In-Reply-To: <1098393346.7157.112.camel@localhost>

Dave Kleikamp <shaggy@austin.ibm.com> wrote:
>
> Doing O_DIRECT writes to an mmapped file caused pages in the page cache to
> be marked dirty but not uptodate.  This led to a bug in mpage_writepage.
> 

Methinks this merely reduces the probability of the BUG.

> diff -urp linux-2.6.9/mm/memory.c linux/mm/memory.c
> --- linux-2.6.9/mm/memory.c	2004-10-21 10:49:26.598031488 -0500
> +++ linux/mm/memory.c	2004-10-21 16:01:44.902376232 -0500
> @@ -414,7 +414,15 @@ static void zap_pte_range(struct mmu_gat
>  			    && linear_page_index(details->nonlinear_vma,
>  					address+offset) != page->index)
>  				set_pte(ptep, pgoff_to_pte(page->index));
> -			if (pte_dirty(pte))
> +			/*
> +			 * PG_uptodate can be cleared by
> +			 * invalidate_inode_pages2, so we must not try to write
> +			 * not uptodate pages.  Otherwise we risk invalidating
> +			 * underlying O_DIRECT writes, and secondly because
> +			 * pdflush would BUG().  Coherency of mmaps against
> +			 * O_DIRECT still cannot be guaranteed though.
> +			 */
> +			if (pte_dirty(pte) && PageUptodate(page))

	invalidate_inode_pages2 runs ClearPageUptodate() here

>  				set_page_dirty(page);
>  			if (pte_young(pte) && !PageAnon(page))
>  				mark_page_accessed(page);

Maybe we should revisit invalidate_inode_pages2().  It used to be an
invariant that "pages which are mapped into process address space are
always uptodate".  We broke that (good) invariant and we're now seeing
some fallout.  There may be more.

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@osdl.org>
To: Dave Kleikamp <shaggy@austin.ibm.com>
Cc: andrea@novell.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] zap_pte_range should not mark non-uptodate pages dirty
Date: Thu, 21 Oct 2004 14:45:31 -0700	[thread overview]
Message-ID: <20041021144531.22dd0d54.akpm@osdl.org> (raw)
In-Reply-To: <1098393346.7157.112.camel@localhost>

Dave Kleikamp <shaggy@austin.ibm.com> wrote:
>
> Doing O_DIRECT writes to an mmapped file caused pages in the page cache to
> be marked dirty but not uptodate.  This led to a bug in mpage_writepage.
> 

Methinks this merely reduces the probability of the BUG.

> diff -urp linux-2.6.9/mm/memory.c linux/mm/memory.c
> --- linux-2.6.9/mm/memory.c	2004-10-21 10:49:26.598031488 -0500
> +++ linux/mm/memory.c	2004-10-21 16:01:44.902376232 -0500
> @@ -414,7 +414,15 @@ static void zap_pte_range(struct mmu_gat
>  			    && linear_page_index(details->nonlinear_vma,
>  					address+offset) != page->index)
>  				set_pte(ptep, pgoff_to_pte(page->index));
> -			if (pte_dirty(pte))
> +			/*
> +			 * PG_uptodate can be cleared by
> +			 * invalidate_inode_pages2, so we must not try to write
> +			 * not uptodate pages.  Otherwise we risk invalidating
> +			 * underlying O_DIRECT writes, and secondly because
> +			 * pdflush would BUG().  Coherency of mmaps against
> +			 * O_DIRECT still cannot be guaranteed though.
> +			 */
> +			if (pte_dirty(pte) && PageUptodate(page))

	invalidate_inode_pages2 runs ClearPageUptodate() here

>  				set_page_dirty(page);
>  			if (pte_young(pte) && !PageAnon(page))
>  				mark_page_accessed(page);

Maybe we should revisit invalidate_inode_pages2().  It used to be an
invariant that "pages which are mapped into process address space are
always uptodate".  We broke that (good) invariant and we're now seeing
some fallout.  There may be more.
--
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>

  reply	other threads:[~2004-10-21 21:46 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-21 21:15 [PATCH] zap_pte_range should not mark non-uptodate pages dirty Dave Kleikamp
2004-10-21 21:15 ` Dave Kleikamp
2004-10-21 21:45 ` Andrew Morton [this message]
2004-10-21 21:45   ` Andrew Morton
2004-10-21 22:36   ` Andrea Arcangeli
2004-10-21 22:36     ` Andrea Arcangeli
2004-10-21 23:02     ` Andrew Morton
2004-10-21 23:02       ` Andrew Morton
2004-10-21 23:20       ` Andrea Arcangeli
2004-10-21 23:20         ` Andrea Arcangeli
2004-10-21 23:42         ` Andrew Morton
2004-10-21 23:42           ` Andrew Morton
2004-10-22  0:15           ` Andrew Morton
2004-10-22  0:15             ` Andrew Morton
2004-10-22  0:41             ` Andrea Arcangeli
2004-10-22  0:41               ` Andrea Arcangeli
2004-10-22  2:51               ` Rik van Riel
2004-10-22  2:51                 ` Rik van Riel
2004-10-22 16:19                 ` Andrea Arcangeli
2004-10-22 16:19                   ` Andrea Arcangeli
2004-10-22  0:30           ` Andrea Arcangeli
2004-10-22  0:30             ` Andrea Arcangeli
2004-10-22  1:22             ` Andrea Arcangeli
2004-10-22  1:22               ` Andrea Arcangeli
2004-10-22  2:03               ` Andrew Morton
2004-10-22  2:03                 ` Andrew Morton
2004-10-22 16:17                 ` Andrea Arcangeli
2004-10-22 16:17                   ` Andrea Arcangeli
2004-10-22 17:04                   ` Andrea Arcangeli
2004-10-22 17:04                     ` Andrea Arcangeli
2004-10-22 23:24                   ` Andrew Morton
2004-10-22 23:24                     ` Andrew Morton
2004-10-25 13:58                     ` Dave Kleikamp
2004-10-25 13:58                       ` Dave Kleikamp
2004-10-26  0:35                     ` Andrea Arcangeli
2004-10-26  0:35                       ` Andrea Arcangeli
2004-11-09 14:15                     ` Dave Kleikamp
2004-11-09 14:15                       ` Dave Kleikamp
2004-11-09 14:46                       ` Andrea Arcangeli
2004-11-09 14:46                         ` Andrea Arcangeli
2004-11-09 19:51                         ` Andrew Morton
2004-11-09 19:51                           ` Andrew Morton
2004-11-09 19:46                       ` Andrew Morton
2004-11-09 19:46                         ` Andrew Morton

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=20041021144531.22dd0d54.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=andrea@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shaggy@austin.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.