Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752531AbdGFP3h (ORCPT ); Thu, 6 Jul 2017 11:29:37 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:32805 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752461AbdGFP3f (ORCPT ); Thu, 6 Jul 2017 11:29:35 -0400 Subject: Re: [RFC v5 09/11] mm: Try spin lock in speculative path To: Peter Zijlstra Cc: paulmck@linux.vnet.ibm.com, akpm@linux-foundation.org, kirill@shutemov.name, ak@linux.intel.com, mhocko@kernel.org, dave@stgolabs.net, jack@suse.cz, Matthew Wilcox , 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, Tim Chen References: <1497635555-25679-1-git-send-email-ldufour@linux.vnet.ibm.com> <1497635555-25679-10-git-send-email-ldufour@linux.vnet.ibm.com> <20170705185023.xlqko7wgepwsny5g@hirez.programming.kicks-ass.net> <3af22f3b-03ab-1d37-b2b1-b616adde7eb6@linux.vnet.ibm.com> <20170706144852.fwtuygj4ikcjmqat@hirez.programming.kicks-ass.net> From: Laurent Dufour Date: Thu, 6 Jul 2017 17:29:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <20170706144852.fwtuygj4ikcjmqat@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17070615-0020-0000-0000-0000039B89E6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070615-0021-0000-0000-0000421F057C Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-06_09:,, 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-1707060268 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1929 Lines: 50 On 06/07/2017 16:48, Peter Zijlstra wrote: > On Thu, Jul 06, 2017 at 03:46:59PM +0200, Laurent Dufour wrote: >> On 05/07/2017 20:50, Peter Zijlstra wrote: >>> On Fri, Jun 16, 2017 at 07:52:33PM +0200, Laurent Dufour wrote: >>>> @@ -2294,8 +2295,19 @@ static bool pte_map_lock(struct vm_fault *vmf) >>>> if (vma_has_changed(vmf->vma, vmf->sequence)) >>>> goto out; >>>> >>>> - pte = pte_offset_map_lock(vmf->vma->vm_mm, vmf->pmd, >>>> - vmf->address, &ptl); > >>>> + ptl = pte_lockptr(vmf->vma->vm_mm, vmf->pmd); >>>> + pte = pte_offset_map(vmf->pmd, vmf->address); >>>> + if (unlikely(!spin_trylock(ptl))) { >>>> + pte_unmap(pte); >>>> + goto out; >>>> + } >>>> + >>>> if (vma_has_changed(vmf->vma, vmf->sequence)) { >>>> pte_unmap_unlock(pte, ptl); >>>> goto out; >>> >>> Right, so if you look at my earlier patches you'll see I did something >>> quite disgusting here. >>> >>> Not sure that wants repeating, but I cannot remember why I thought this >>> deadlock didn't exist anymore. >> >> Regarding the deadlock I did face it on my Power victim node, so I guess it >> is still there, and the stack traces are quiet explicit. >> Am I missing something here ? > > No, you are right in that the deadlock is quite real. What I cannot > remember is what made me think to remove the really 'wonderful' code I > had to deal with it. > > That said, you might want to look at how often you terminate the > speculation because of your trylock failing. If that shows up at all we > might need to do something about it. Based on the benchmarks I run, it doesn't fail so much often, but I was thinking about adding some counters here. The system is accounting for major page faults and minor ones, respectively current->maj_flt and current->min_flt. I was wondering if an additional type like async_flt will be welcome or if there is another smarter way to get that metric. Feel free to advise. Thanks Laurent.