Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752472AbZIGVjO (ORCPT ); Mon, 7 Sep 2009 17:39:14 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752172AbZIGVjN (ORCPT ); Mon, 7 Sep 2009 17:39:13 -0400 Received: from mk-filter-4-a-1.mail.uk.tiscali.com ([212.74.100.55]:9424 "EHLO mk-filter-4-a-1.mail.uk.tiscali.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752170AbZIGVjN (ORCPT ); Mon, 7 Sep 2009 17:39:13 -0400 X-Trace: 255183178/mk-filter-4.mail.uk.tiscali.com/B2C/$b2c-THROTTLED-DYNAMIC/b2c-CUSTOMER-DYNAMIC-IP/79.69.94.54/None/hugh.dickins@tiscali.co.uk X-SBRS: None X-RemoteIP: 79.69.94.54 X-IP-MAIL-FROM: hugh.dickins@tiscali.co.uk X-SMTP-AUTH: X-MUA: X-IP-BHB: Once X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AugEAI8apUpPRV42/2dsb2JhbACBU9dAhBgF X-IronPort-AV: E=Sophos;i="4.44,348,1249254000"; d="scan'208";a="255183178" Date: Mon, 7 Sep 2009 22:38:29 +0100 (BST) From: Hugh Dickins X-X-Sender: hugh@sister.anvils To: Andrew Morton cc: KAMEZAWA Hiroyuki , KOSAKI Motohiro , Linus Torvalds , Nick Piggin , Rik van Riel , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 6/8] mm: fix anonymous dirtying In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1238 Lines: 31 do_anonymous_page() has been wrong to dirty the pte regardless. If it's not going to mark the pte writable, then it won't help to mark it dirty here, and clogs up memory with pages which will need swap instead of being thrown away. Especially wrong if no overcommit is chosen, and this vma is not yet VM_ACCOUNTed - we could exceed the limit and OOM despite no overcommit. Signed-off-by: Hugh Dickins Cc: stable@kernel.org --- mm/memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- mm5/mm/memory.c 2009-09-07 13:16:46.000000000 +0100 +++ mm6/mm/memory.c 2009-09-07 13:16:53.000000000 +0100 @@ -2608,7 +2608,8 @@ static int do_anonymous_page(struct mm_s goto oom_free_page; entry = mk_pte(page, vma->vm_page_prot); - entry = maybe_mkwrite(pte_mkdirty(entry), vma); + if (vma->vm_flags & VM_WRITE) + entry = pte_mkwrite(pte_mkdirty(entry)); page_table = pte_offset_map_lock(mm, pmd, address, &ptl); if (!pte_none(*page_table)) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/