Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2327820ybi; Sun, 28 Jul 2019 06:41:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6XQmh9vzhkvLjqxIbY9E7f7YGw7pIYuQPgXKlK06KTCSKPWZ/yHuQItcF3GZku6hQbaye X-Received: by 2002:a17:90a:8d0c:: with SMTP id c12mr103396187pjo.140.1564321288051; Sun, 28 Jul 2019 06:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564321288; cv=none; d=google.com; s=arc-20160816; b=vR0P3qjBQTbRpCOuOZ9sBDzQGId71/LrPAura1FkNkYuArIuMheN6YIidm4fT1wk1w zuOyuJB5Oz8dAN+EPKB6q+grm+W5vAXnDhgKOY7NLAk4MpcdN/BMeRPrzDdCXIkaJPnH 9uAd1f1HSdw1+obHbkRi9hFH4fZ5mMKHB78FGZJZa77AoBwH9kyiCrw4CSaJkKV2G2DV cE/lof/MhBCfNLV0QvDXg2Dw/W70LGtUBmI2HAerZ2PfrqwpLV1J/x2cfWS3nWJaolHG 8NVik7FRYT3pyulupwFq9VTOvjIBn94k1wQv/pebg6CaIkkd/BVUi0TJm4PWUeGkbwIi wiqg== 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=SLmZ459eobj2ljNRx1DC0sbZRK/G/uP5oQJaaWujXNY=; b=0WutTnZEjIkeK/MgRTGtalF4z69l1n5roX4sqLt26zcUQyi1lOKX2td8Kkm4aJ+/jo +q5ZsK8xgwhiaZkm/rmZID2z0L5LI62friaOyNgwaZ7FHeB1g9UWMxq4Jix+qIHSl5yh m8vW2snQ877iEzZw9MoaruPnkbABM5/YGHMXHdY4VdCDNs5MSNjuYdUipZg05GFvbp84 YdsMXLaDO6QW9taGnd2/7bGU9145in4JsVl4XPkCuDsIj1pACu8zQxTitcT+mBm3foYi XSawU8hBQCoHN1vFlcNoXINoct7qPZ0xHlzKMn5o8J5D6RAZ1ANFnmWhmgx3P47eSZnI bg6A== 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 a24si24813729pfi.205.2019.07.28.06.41.12; Sun, 28 Jul 2019 06:41:28 -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 S1726103AbfG1Nk1 (ORCPT + 99 others); Sun, 28 Jul 2019 09:40:27 -0400 Received: from foss.arm.com ([217.140.110.172]:32796 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726032AbfG1Nk1 (ORCPT ); Sun, 28 Jul 2019 09:40:27 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2389C344; Sun, 28 Jul 2019 06:40:26 -0700 (PDT) Received: from [10.163.1.126] (unknown [10.163.1.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DD10B3F71A; Sun, 28 Jul 2019 06:40:19 -0700 (PDT) Subject: Re: [PATCH v9 13/21] mm: pagewalk: Add test_p?d callbacks To: Steven Price , linux-mm@kvack.org Cc: Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Peter Zijlstra , Thomas Gleixner , Will Deacon , x86@kernel.org, "H. Peter Anvin" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Rutland , "Liang, Kan" , Andrew Morton References: <20190722154210.42799-1-steven.price@arm.com> <20190722154210.42799-14-steven.price@arm.com> From: Anshuman Khandual Message-ID: Date: Sun, 28 Jul 2019 19:11:00 +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: <20190722154210.42799-14-steven.price@arm.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 07/22/2019 09:12 PM, Steven Price wrote: > It is useful to be able to skip parts of the page table tree even when > walking without VMAs. Add test_p?d callbacks similar to test_walk but > which are called just before a table at that level is walked. If the > callback returns non-zero then the entire table is skipped. > > Signed-off-by: Steven Price > --- > include/linux/mm.h | 11 +++++++++++ > mm/pagewalk.c | 24 ++++++++++++++++++++++++ > 2 files changed, 35 insertions(+) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index b22799129128..325a1ca6f820 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1447,6 +1447,11 @@ void unmap_vmas(struct mmu_gather *tlb, struct vm_area_struct *start_vma, > * value means "do page table walk over the current vma," > * and a negative one means "abort current page table walk > * right now." 1 means "skip the current vma." > + * @test_pmd: similar to test_walk(), but called for every pmd. > + * @test_pud: similar to test_walk(), but called for every pud. > + * @test_p4d: similar to test_walk(), but called for every p4d. > + * Returning 0 means walk this part of the page tables, > + * returning 1 means to skip this range. > * @mm: mm_struct representing the target process of page table walk > * @vma: vma currently walked (NULL if walking outside vmas) > * @private: private data for callbacks' usage > @@ -1471,6 +1476,12 @@ struct mm_walk { > struct mm_walk *walk); > int (*test_walk)(unsigned long addr, unsigned long next, > struct mm_walk *walk); > + int (*test_pmd)(unsigned long addr, unsigned long next, > + pmd_t *pmd_start, struct mm_walk *walk); > + int (*test_pud)(unsigned long addr, unsigned long next, > + pud_t *pud_start, struct mm_walk *walk); > + int (*test_p4d)(unsigned long addr, unsigned long next, > + p4d_t *p4d_start, struct mm_walk *walk); > struct mm_struct *mm; > struct vm_area_struct *vma; > void *private; > diff --git a/mm/pagewalk.c b/mm/pagewalk.c > index 1cbef99e9258..6bea79b95be3 100644 > --- a/mm/pagewalk.c > +++ b/mm/pagewalk.c > @@ -32,6 +32,14 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, > unsigned long next; > int err = 0; > > + if (walk->test_pmd) { > + err = walk->test_pmd(addr, end, pmd_offset(pud, 0UL), walk); > + if (err < 0) > + return err; > + if (err > 0) > + return 0; > + } Though this attempts to match semantics with test_walk() and be comprehensive just wondering what are the real world situations when page walking need to be aborted based on error condition at a given page table level.