Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3475689yba; Tue, 23 Apr 2019 04:36:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyqeNx4JNxY+CSPQYXrvKyP5aMcjH/FpBXKWiapbCS4OyaM2gvNKQgA1U+nGQ/gvv3JmJP+ X-Received: by 2002:a63:6942:: with SMTP id e63mr23787532pgc.102.1556019402813; Tue, 23 Apr 2019 04:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556019402; cv=none; d=google.com; s=arc-20160816; b=rIxvYVtnXobVpN6ZeLhSn/17VyVQInIEaSMTRqO+7QBudo5oEo4DlC2hSNy2+Qc7JS Wp4yFmm+zfn3JfdHr6Yu2X+z4LFiEHJv1iQ+KSPEns0XFlLCc1IKiSIjxxG0Qs9lMNeF nAFyg67bY5c9HM51hq9J1guV/ihwJwpYcCOxcoprOKlzh6whRa6d3TSr5mKLmdzdpLam yIoWI1TzbeBuPZHLclpznLt9yT5VUVlVzgdtFes8GVnuO9/WrYhyNJOzP5UYF5fi7AOO ThUuac7cQSahRSQaQY/+RLhWJaaIRmmNxDAlGGHu19uJM7pmu916IdHrLmlCj2X4asw6 En/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=1IUR02oKZi1S2hadwNoroaCT+OypaFRyLXAVAo95G1o=; b=Ji7bryBThR17ClibnpgCSFvCI482u6aqPQCQKwiiO3jgUR1LibMK7U0FLHiwO4E3ej E79ChgjyHdApJffE15/NgJTky0nh8taCGcVPqzsAUJiSnqtEagfJMnyG3a36IzmJT2sI 4/NtyOdhhFdGEfsxiirMgqTWGAT9GGJEVLM9CF8ZGa3iVDf4iMvaR59UnqW3PIoxc95f FfwJ6B9YKFa4/tb9v+gk4YDlFnT9y5UrmPzblou9QXpD15xnKmUh7cDb7f+tyvW+oKR0 D/KDn4JAq6PBptD4W+eJq+jcqMF8cWGiJCjgCYhtnxh6sSx41GNzPxXoolbiXZsziDWM H9QQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j23si8524929pll.272.2019.04.23.04.36.28; Tue, 23 Apr 2019 04:36:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727580AbfDWLfP (ORCPT + 99 others); Tue, 23 Apr 2019 07:35:15 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54964 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726033AbfDWLfO (ORCPT ); Tue, 23 Apr 2019 07:35:14 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B672DA78; Tue, 23 Apr 2019 04:35:13 -0700 (PDT) Received: from [10.163.1.68] (unknown [10.163.1.68]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6DC143F557; Tue, 23 Apr 2019 04:35:00 -0700 (PDT) Subject: Re: [PATCH v12 00/31] Speculative page faults To: Laurent Dufour , akpm@linux-foundation.org, mhocko@kernel.org, peterz@infradead.org, kirill@shutemov.name, ak@linux.intel.com, dave@stgolabs.net, jack@suse.cz, Matthew Wilcox , aneesh.kumar@linux.ibm.com, benh@kernel.crashing.org, mpe@ellerman.id.au, paulus@samba.org, Thomas Gleixner , Ingo Molnar , hpa@zytor.com, Will Deacon , Sergey Senozhatsky , sergey.senozhatsky.work@gmail.com, Andrea Arcangeli , Alexei Starovoitov , kemi.wang@intel.com, Daniel Jordan , David Rientjes , Jerome Glisse , Ganesh Mahendran , Minchan Kim , Punit Agrawal , vinayak menon , Yang Shi , zhong jiang , Haiyan Song , Balbir Singh , sj38.park@gmail.com, Michel Lespinasse , Mike Rapoport Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, haren@linux.vnet.ibm.com, npiggin@gmail.com, paulmck@linux.vnet.ibm.com, Tim Chen , linuxppc-dev@lists.ozlabs.org, x86@kernel.org References: <20190416134522.17540-1-ldufour@linux.ibm.com> From: Anshuman Khandual Message-ID: Date: Tue, 23 Apr 2019 17:05:02 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190416134522.17540-1-ldufour@linux.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/16/2019 07:14 PM, Laurent Dufour wrote: > In pseudo code, this could be seen as: > speculative_page_fault() > { > vma = find_vma_rcu() > check vma sequence count > check vma's support > disable interrupt > check pgd,p4d,...,pte > save pmd and pte in vmf > save vma sequence counter in vmf > enable interrupt > check vma sequence count > handle_pte_fault(vma) > .. > page = alloc_page() > pte_map_lock() > disable interrupt > abort if sequence counter has changed > abort if pmd or pte has changed > pte map and lock > enable interrupt > if abort > free page > abort Would not it be better if the 'page' allocated here can be passed on to handle_pte_fault() below so that in the fallback path it does not have to enter the buddy again ? Of course it will require changes to handle_pte_fault() to accommodate a pre-allocated non-NULL struct page to operate on or free back into the buddy if fallback path fails for some other reason. This will probably make SPF path less overhead for cases where it has to fallback on handle_pte_fault() after pte_map_lock() in speculative_page_fault(). > ... > put_vma(vma) > } > > arch_fault_handler() > { > if (speculative_page_fault(&vma)) > goto done > again: > lock(mmap_sem) > vma = find_vma(); > handle_pte_fault(vma); > if retry > unlock(mmap_sem) > goto again; > done: > handle fault error > } - Anshuman