From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751890AbdECNBe (ORCPT ); Wed, 3 May 2017 09:01:34 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38578 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751176AbdECNBZ (ORCPT ); Wed, 3 May 2017 09:01:25 -0400 Subject: Re: [RFC v3 03/17] mm: Introduce pte_spinlock To: Matthew Wilcox References: <1493308376-23851-1-git-send-email-ldufour@linux.vnet.ibm.com> <1493308376-23851-4-git-send-email-ldufour@linux.vnet.ibm.com> <20170430044700.GF27790@bombadil.infradead.org> Cc: paulmck@linux.vnet.ibm.com, peterz@infradead.org, akpm@linux-foundation.org, kirill@shutemov.name, ak@linux.intel.com, mhocko@kernel.org, dave@stgolabs.net, jack@suse.cz, linux-kernel@vger.kernel.org, linux-mm@kvack.org, haren@linux.vnet.ibm.com, khandual@linux.vnet.ibm.com, npiggin@gmail.com, bsingharora@gmail.com From: Laurent Dufour Date: Wed, 3 May 2017 15:01:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170430044700.GF27790@bombadil.infradead.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17050313-0016-0000-0000-00000490376A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17050313-0017-0000-0000-000027804E99 Message-Id: <1b334821-1929-38ed-5316-2a7d135b812d@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-05-03_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705030242 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30/04/2017 06:47, Matthew Wilcox wrote: > On Thu, Apr 27, 2017 at 05:52:42PM +0200, Laurent Dufour wrote: >> +++ b/mm/memory.c >> @@ -2100,6 +2100,13 @@ static inline void wp_page_reuse(struct vm_fault *vmf) >> pte_unmap_unlock(vmf->pte, vmf->ptl); >> } >> >> +static bool pte_spinlock(struct vm_fault *vmf) >> +{ >> + vmf->ptl = pte_lockptr(vmf->vma->vm_mm, vmf->pmd); >> + spin_lock(vmf->ptl); >> + return true; >> +} > > To me 'pte_spinlock' is a noun, but this is really pte_spin_lock() (a verb). Fair enough. Even pte_trylock() should be more accurate since patch 8/17 changes this function to call spin_trylock(). > Actually, it's really vmf_lock_pte(). We're locking the pte > referred to by this vmf. And so we should probably have a matching > vmf_unlock_pte(vmf) to preserve the abstraction. I'm not sure this will ease the reading. In most of this code, the pte are unlocked through the call to pte_unmap_unlock(). The call to pte_trylock() has been introduced because in few cases there is the need to check the VMA validity before calling spinlock(ptl). The unlock is then managed through pte_unmap_unlock().