From patchwork Fri Apr 2 19:35:14 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: 90467 X-Patchwork-Delegate: varenet@parisc-linux.org 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 o32JZJcI016811 for ; Fri, 2 Apr 2010 19:35:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754047Ab0DBTfS (ORCPT ); Fri, 2 Apr 2010 15:35:18 -0400 Received: from hiauly1.hia.nrc.ca ([132.246.100.193]:2777 "EHLO hiauly1.hia.nrc.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753473Ab0DBTfR (ORCPT ); Fri, 2 Apr 2010 15:35:17 -0400 Received: by hiauly1.hia.nrc.ca (Postfix, from userid 1000) id 781AF4E77; Fri, 2 Apr 2010 15:35:15 -0400 (EDT) Date: Fri, 2 Apr 2010 15:35:14 -0400 From: John David Anglin To: NIIBE Yutaka Cc: linux-parisc@vger.kernel.org, pkg-gauche-devel@lists.alioth.debian.org, 561203@bugs.debian.org Subject: Re: threads and fork on machine with VIPT-WB cache Message-ID: <20100402193514.GA9860@hiauly1.hia.nrc.ca> Reply-To: John David Anglin References: <4BA43CE5.4020807@fsij.org> <87hbo4ek8l.fsf@thialfi.karme.de> <4BB18B46.2070203@fsij.org> <4BB53D26.60601@fsij.org> <4BB5594C.8050505@fsij.org> <1270179025.18981.19.camel@mulgrave.site> <4BB568FB.1090908@fsij.org> <4BB5A557.2000405@fsij.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4BB5A557.2000405@fsij.org> Organization: nrc.ca User-Agent: Mutt/1.5.16 (2007-06-09) 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]); Fri, 02 Apr 2010 19:35:19 +0000 (UTC) diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h index a27d2e2..a5d730f 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,7 +457,7 @@ 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; @@ -467,6 +468,8 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, } while (cmpxchg((unsigned long *) ptep, old, new) != old); #else pte_t old_pte = *ptep; + if (atomic_read(&mm->mm_users) > 1) + flush_cache_page(vma, addr, pte_pfn(old_pte)); 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); }