Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759556AbXJLJDj (ORCPT ); Fri, 12 Oct 2007 05:03:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754488AbXJLJDa (ORCPT ); Fri, 12 Oct 2007 05:03:30 -0400 Received: from viefep18-int.chello.at ([213.46.255.22]:64937 "EHLO viefep15-int.chello.at" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753563AbXJLJD3 (ORCPT ); Fri, 12 Oct 2007 05:03:29 -0400 Subject: [PATCH] mm: avoid dirtying shared mappings on mlock From: Peter Zijlstra To: Suleiman Souhlal Cc: Andrew Morton , linux-kernel@vger.kernel.org, Suleiman Souhlal , linux-mm , hugh In-Reply-To: <69AF9B2A-6AA7-4078-B0A2-BE3D4914AEDC@FreeBSD.org> References: <11854939641916-git-send-email-ssouhlal@FreeBSD.org> <20070726172330.d3409b57.akpm@linux-foundation.org> <1185518010.15205.36.camel@lappy> <69AF9B2A-6AA7-4078-B0A2-BE3D4914AEDC@FreeBSD.org> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-wiKc4oSMgthoYDncv+YZ" Date: Fri, 12 Oct 2007 11:03:25 +0200 Message-Id: <1192179805.27435.6.camel@twins> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1920 Lines: 57 --=-wiKc4oSMgthoYDncv+YZ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Subject: mm: avoid dirtying shared mappings on mlock Suleiman noticed that shared mappings get dirtied when mlocked. Avoid this by teaching make_pages_present about this case. Signed-off-by: Peter Zijlstra Acked-by: Suleiman Souhlal --- mm/memory.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) Index: linux-2.6/mm/memory.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-2.6.orig/mm/memory.c +++ linux-2.6/mm/memory.c @@ -2719,7 +2719,12 @@ int make_pages_present(unsigned long add vma =3D find_vma(current->mm, addr); if (!vma) return -1; - write =3D (vma->vm_flags & VM_WRITE) !=3D 0; + /* + * We want to touch writable mappings with a write fault in order + * to break COW, except for shared mappings because these don't COW + * and we would not want to dirty them for nothing. + */ + write =3D (vma->vm_flags & (VM_WRITE|VM_SHARED)) =3D=3D VM_WRITE; BUG_ON(addr >=3D end); BUG_ON(end > vma->vm_end); len =3D DIV_ROUND_UP(end, PAGE_SIZE) - addr/PAGE_SIZE; --=-wiKc4oSMgthoYDncv+YZ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBHDzhdXA2jU0ANEf4RAn8rAJ9khXjsR7JcWWTW2jb4djrhInvFkACdEQ3a LKTBRB+oYBWtkLOYtEu9TtM= =bub7 -----END PGP SIGNATURE----- --=-wiKc4oSMgthoYDncv+YZ-- - 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/