Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp2022101img; Wed, 27 Feb 2019 09:10:14 -0800 (PST) X-Google-Smtp-Source: AHgI3IaDFCbCwaJxmG3CjYqLcj8RMK7R9ki31OubjggbZgxlUur13hrh9NF8Bh0dNr0AJk4quDRJ X-Received: by 2002:a17:902:b58a:: with SMTP id a10mr3170433pls.24.1551287414399; Wed, 27 Feb 2019 09:10:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551287414; cv=none; d=google.com; s=arc-20160816; b=rkgZvVvGhanSVWK9pPn/0qHtgRTFqRMbF7fPiVgeyiaR4tFIIXh19CowsXT8b/LB5s thxqE51x6JpqKMvQP3yWR3HOumvrKzoHsFaOvN3TwRIn8mINOlRMGtYqC16djmWIjg/n UXQaIAWM4a1MrUf4keSg6bWsivKhlrlAIsY8yP9ooBUvf7ua7KV04rKk724xhA+sl4iA b2I56GSqH8ZHKQlA92RXU8jdWT4T9mW6H8mQ+4EjbNaK6QhZ3Rk3/KtPyZ9ePU4yEJYx IQybHAA7RSvMo6H3DQpXkGMRI0g+77WCcf0z82GPc2XQqIU7jovDvU4RjTNxhsB8TB8V iCRA== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=5+qDYU4THjLPvNOaZc1aA0s7EjXEEdRbPiGSrygYMH0=; b=XoXS/RJaeQtXNRkqv2T6QAe7KHvW59ZiXrb1Ip0LiSQ0WMJz8H0bI2xcAV9ha7lohk L28F5MebRy7aI+yVmTW0Cq62gJMaW9W0tuslwlRi+Vsj0EV4vZe0Pis3Ey2jSALPFzdw BG+VIUAl0bJWyySN99XLSJKmxxwx4TifrMvqKOaIN4b85MyDFMVSUFjVTndbP37gLIej 864FcaEcqgLu0YTf0STRo9k3dxVpVow8EVGO8lGqmN7yi0Nv5JhmHKdFmUTpZfx54oKo yZfmPjtCj/FjOW9Bt36i7e1yFrYrFkdLD3x5sr/WdOP5e0FshkH+BwqnsdWg6NJyutWx wWxg== 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 r10si15195075pgr.489.2019.02.27.09.09.59; Wed, 27 Feb 2019 09:10:14 -0800 (PST) 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 S1730563AbfB0RIR (ORCPT + 99 others); Wed, 27 Feb 2019 12:08:17 -0500 Received: from foss.arm.com ([217.140.101.70]:36702 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727488AbfB0RIO (ORCPT ); Wed, 27 Feb 2019 12:08:14 -0500 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 980A81715; Wed, 27 Feb 2019 09:08:14 -0800 (PST) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5D5B83F738; Wed, 27 Feb 2019 09:08:11 -0800 (PST) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , 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" Subject: [PATCH v3 28/34] mm: pagewalk: Add test_p?d callbacks Date: Wed, 27 Feb 2019 17:06:02 +0000 Message-Id: <20190227170608.27963-29-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190227170608.27963-1-steven.price@arm.com> References: <20190227170608.27963-1-steven.price@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 4ae3634a9118..581f31c6b6d9 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1429,6 +1429,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 @@ -1453,6 +1458,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 57946bcd810c..ff2fc8490435 100644 --- a/mm/pagewalk.c +++ b/mm/pagewalk.c @@ -49,6 +49,14 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, int err = 0; int depth = real_depth(3); + if (walk->test_pmd) { + err = walk->test_pmd(addr, end, pmd_offset(pud, 0), walk); + if (err < 0) + return err; + if (err > 0) + return 0; + } + pmd = pmd_offset(pud, addr); do { again: @@ -100,6 +108,14 @@ static int walk_pud_range(p4d_t *p4d, unsigned long addr, unsigned long end, int err = 0; int depth = real_depth(2); + if (walk->test_pud) { + err = walk->test_pud(addr, end, pud_offset(p4d, 0), walk); + if (err < 0) + return err; + if (err > 0) + return 0; + } + pud = pud_offset(p4d, addr); do { again: @@ -143,6 +159,14 @@ static int walk_p4d_range(pgd_t *pgd, unsigned long addr, unsigned long end, int err = 0; int depth = real_depth(1); + if (walk->test_p4d) { + err = walk->test_p4d(addr, end, p4d_offset(pgd, 0), walk); + if (err < 0) + return err; + if (err > 0) + return 0; + } + p4d = p4d_offset(pgd, addr); do { next = p4d_addr_end(addr, end); -- 2.20.1