From patchwork Mon Apr 5 02:51:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 90596 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o352pvZD011360 for ; Mon, 5 Apr 2010 02:51:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754019Ab0DECv5 (ORCPT ); Sun, 4 Apr 2010 22:51:57 -0400 Received: from hiauly1.hia.nrc.ca ([132.246.100.193]:2900 "EHLO hiauly1.hia.nrc.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754014Ab0DECv4 (ORCPT ); Sun, 4 Apr 2010 22:51:56 -0400 Received: by hiauly1.hia.nrc.ca (Postfix, from userid 1000) id DE1D55160; Sun, 4 Apr 2010 22:51:54 -0400 (EDT) Subject: Re: threads and fork on machine with VIPT-WB cache To: gniibe@fsij.org (NIIBE Yutaka) Date: Sun, 4 Apr 2010 22:51:53 -0400 (EDT) From: "John David Anglin" Cc: James.Bottomley@HansenPartnership.com, linux-parisc@vger.kernel.org, pkg-gauche-devel@lists.alioth.debian.org, 561203@bugs.debian.org In-Reply-To: <4BB9312D.6030409@fsij.org> from "NIIBE Yutaka" at Apr 5, 2010 09:39:09 am X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Message-Id: <20100405025154.DE1D55160@hiauly1.hia.nrc.ca> Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 05 Apr 2010 02:51:58 +0000 (UTC) diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h index a27d2e2..b140d5c 100644 --- a/arch/parisc/include/asm/pgtable.h +++ b/arch/parisc/include/asm/pgtable.h @@ -14,6 +14,7 @@ #include #include #include +extern void flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long pfn); /* * kern_addr_valid(ADDR) tests if ADDR is pointing to valid kernel @@ -456,17 +457,22 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, return old_pte; } -static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep) +static inline void ptep_set_wrprotect(struct vm_area_struct *vma, struct mm_struct *mm, unsigned long addr, pte_t *ptep) { #ifdef CONFIG_SMP unsigned long new, old; +#endif + pte_t old_pte = *ptep; + + if (atomic_read(&mm->mm_users) > 1) + flush_cache_page(vma, addr, pte_pfn(old_pte)); +#ifdef CONFIG_SMP do { old = pte_val(*ptep); new = pte_val(pte_wrprotect(__pte (old))); } while (cmpxchg((unsigned long *) ptep, old, new) != old); #else - pte_t old_pte = *ptep; set_pte_at(mm, addr, ptep, pte_wrprotect(old_pte)); #endif } diff --git a/mm/memory.c b/mm/memory.c index 09e4b1b..21c2916 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -616,7 +616,7 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, * in the parent and the child */ if (is_cow_mapping(vm_flags)) { - ptep_set_wrprotect(src_mm, addr, src_pte); + ptep_set_wrprotect(vma, src_mm, addr, src_pte); pte = pte_wrprotect(pte); }