Message ID | 1241430874-12667-1-git-send-email-hannes@cmpxchg.org (mailing list archive) |
---|---|
State | RFC, archived |
Headers |
Return-path: <linux-media-owner@vger.kernel.org> Envelope-to: mchehab@infradead.org Delivery-date: Mon, 04 May 2009 09:56:25 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra.chehab.org with IMAP (fetchmail-6.3.6) for <mchehab@localhost> (single-drop); Mon, 04 May 2009 07:01:33 -0300 (BRT) Received: from vger.kernel.org ([209.132.176.167]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1M0uuO-0006Ge-UE; Mon, 04 May 2009 09:56:25 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752863AbZEDJ4V (ORCPT <rfc822; kmpark@infradead.org> + 1 other); Mon, 4 May 2009 05:56:21 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754348AbZEDJ4V (ORCPT <rfc822;linux-media-outgoing>); Mon, 4 May 2009 05:56:21 -0400 Received: from cmpxchg.org ([85.214.51.133]:49972 "EHLO cmpxchg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753554AbZEDJ4R (ORCPT <rfc822;linux-media@vger.kernel.org>); Mon, 4 May 2009 05:56:17 -0400 From: Johannes Weiner <hannes@cmpxchg.org> To: Andrew Morton <akpm@linux-foundation.org> Cc: Magnus Damm <magnus.damm@gmail.com>, linux-media@vger.kernel.org, Hans Verkuil <hverkuil@xs4all.nl>, Paul Mundt <lethal@linux-sh.org>, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [patch 1/3] mm: introduce follow_pte() Date: Mon, 4 May 2009 11:54:32 +0200 Message-Id: <1241430874-12667-1-git-send-email-hannes@cmpxchg.org> X-Mailer: git-send-email 1.6.2.1.135.gde769 In-Reply-To: <20090501181449.GA8912@cmpxchg.org> References: <20090501181449.GA8912@cmpxchg.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org |
Commit Message
Johannes Weiner
May 4, 2009, 9:54 a.m. UTC
A generic readonly page table lookup helper to map an address space
and an address from it to a pte.
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
mm/memory.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
Comments
On Mon, 4 May 2009 11:54:32 +0200 Johannes Weiner <hannes@cmpxchg.org> wrote: > A generic readonly page table lookup helper to map an address space > and an address from it to a pte. umm, OK. Is there actually some point to these three patches? If so, what is it? -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, May 05, 2009 at 12:24:42PM -0700, Andrew Morton wrote: > On Mon, 4 May 2009 11:54:32 +0200 > Johannes Weiner <hannes@cmpxchg.org> wrote: > > > A generic readonly page table lookup helper to map an address space > > and an address from it to a pte. > > umm, OK. > > Is there actually some point to these three patches? If so, what is it? Magnus needs to check for physical contiguity of a VMAs backing pages to support zero-copy exportation of video data to userspace. This series implements follow_pfn() so he can walk the VMA backing pages and ensure their PFNs are in linear order. [ This patch can be collapsed with 2/3, I just thought it would be easier to read the diffs when having them separate. ] 1/3 and 2/3: factor out the page table walk from follow_phys() into follow_pte(). 3/3: implement follow_pfn() on top of follow_pte(). -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, 5 May 2009 22:38:07 +0200 Johannes Weiner <hannes@cmpxchg.org> wrote: > On Tue, May 05, 2009 at 12:24:42PM -0700, Andrew Morton wrote: > > On Mon, 4 May 2009 11:54:32 +0200 > > Johannes Weiner <hannes@cmpxchg.org> wrote: > > > > > A generic readonly page table lookup helper to map an address space > > > and an address from it to a pte. > > > > umm, OK. > > > > Is there actually some point to these three patches? If so, what is it? > > Magnus needs to check for physical contiguity of a VMAs backing pages > to support zero-copy exportation of video data to userspace. > > This series implements follow_pfn() so he can walk the VMA backing > pages and ensure their PFNs are in linear order. > > [ This patch can be collapsed with 2/3, I just thought it would be > easier to read the diffs when having them separate. ] > > 1/3 and 2/3: factor out the page table walk from follow_phys() into > follow_pte(). > > 3/3: implement follow_pfn() on top of follow_pte(). So we could bundle these patches with Magnus's patchset, or we could consider these three patches as a cleanup or something. Given that 3/3 introduces an unused function, I'm inclined to sit tight and await Magnus's work. -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, May 05, 2009 at 02:05:17PM -0700, Andrew Morton wrote: > On Tue, 5 May 2009 22:38:07 +0200 > Johannes Weiner <hannes@cmpxchg.org> wrote: > > > On Tue, May 05, 2009 at 12:24:42PM -0700, Andrew Morton wrote: > > > On Mon, 4 May 2009 11:54:32 +0200 > > > Johannes Weiner <hannes@cmpxchg.org> wrote: > > > > > > > A generic readonly page table lookup helper to map an address space > > > > and an address from it to a pte. > > > > > > umm, OK. > > > > > > Is there actually some point to these three patches? If so, what is it? > > > > Magnus needs to check for physical contiguity of a VMAs backing pages > > to support zero-copy exportation of video data to userspace. > > > > This series implements follow_pfn() so he can walk the VMA backing > > pages and ensure their PFNs are in linear order. > > > > [ This patch can be collapsed with 2/3, I just thought it would be > > easier to read the diffs when having them separate. ] > > > > 1/3 and 2/3: factor out the page table walk from follow_phys() into > > follow_pte(). > > > > 3/3: implement follow_pfn() on top of follow_pte(). > > So we could bundle these patches with Magnus's patchset, or we could > consider these three patches as a cleanup or something. > > Given that 3/3 introduces an unused function, I'm inclined to sit tight > and await Magnus's work. Yeah, I didn't see the video guys responding on Magnus' patch yet, so let's wait for them. Magnus, the actual conversion of your code should be trivial, could you respin it on top of these three patches using follow_pfn() then? Thanks, Hannes -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, May 6, 2009 at 6:21 AM, Johannes Weiner <hannes@cmpxchg.org> wrote: > On Tue, May 05, 2009 at 02:05:17PM -0700, Andrew Morton wrote: >> On Tue, 5 May 2009 22:38:07 +0200 >> Johannes Weiner <hannes@cmpxchg.org> wrote: >> > On Tue, May 05, 2009 at 12:24:42PM -0700, Andrew Morton wrote: >> > > On Mon, 4 May 2009 11:54:32 +0200 >> > > Johannes Weiner <hannes@cmpxchg.org> wrote: >> > > >> > > > A generic readonly page table lookup helper to map an address space >> > > > and an address from it to a pte. >> > > >> > > umm, OK. >> > > >> > > Is there actually some point to these three patches? If so, what is it? >> > >> > Magnus needs to check for physical contiguity of a VMAs backing pages >> > to support zero-copy exportation of video data to userspace. >> > >> > This series implements follow_pfn() so he can walk the VMA backing >> > pages and ensure their PFNs are in linear order. >> > >> > [ This patch can be collapsed with 2/3, I just thought it would be >> > easier to read the diffs when having them separate. ] >> > >> > 1/3 and 2/3: factor out the page table walk from follow_phys() into >> > follow_pte(). >> > >> > 3/3: implement follow_pfn() on top of follow_pte(). >> >> So we could bundle these patches with Magnus's patchset, or we could >> consider these three patches as a cleanup or something. >> >> Given that 3/3 introduces an unused function, I'm inclined to sit tight >> and await Magnus's work. > > Yeah, I didn't see the video guys responding on Magnus' patch yet, so > let's wait for them. > > Magnus, the actual conversion of your code should be trivial, could > you respin it on top of these three patches using follow_pfn() then? So I tested the patches in -mm (1/3, 2/3, 3/3) together with the zero copy patch and everything seems fine. Feel free to add acks from me, least for patch 1/3 and 3/3 - i know too little about the generic case to say anything about 2/3. Acked-by: Magnus Damm <damm@igel.co.jp> I'll send V3 of my zero copy patch in a little while. Thanks a lot for the help! Cheers, / magnus -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/mm/memory.c b/mm/memory.c index cf6873e..a621319 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3009,6 +3009,43 @@ int in_gate_area_no_task(unsigned long addr) #endif /* __HAVE_ARCH_GATE_AREA */ +static int follow_pte(struct mm_struct *mm, unsigned long address, + pte_t **ptepp, spinlock_t **ptlp) +{ + pgd_t *pgd; + pud_t *pud; + pmd_t *pmd; + pte_t *ptep; + + pgd = pgd_offset(mm, address); + if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd))) + goto out; + + pud = pud_offset(pgd, address); + if (pud_none(*pud) || unlikely(pud_bad(*pud))) + goto out; + + pmd = pmd_offset(pud, address); + if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd))) + goto out; + + /* We cannot handle huge page PFN maps. Luckily they don't exist. */ + if (pmd_huge(*pmd)) + goto out; + + ptep = pte_offset_map_lock(mm, pmd, address, ptlp); + if (!ptep) + goto out; + if (!pte_present(*ptep)) + goto unlock; + *ptepp = ptep; + return 0; +unlock: + pte_unmap_unlock(ptep, *ptlp); +out: + return -EINVAL; +} + #ifdef CONFIG_HAVE_IOREMAP_PROT int follow_phys(struct vm_area_struct *vma, unsigned long address, unsigned int flags,