All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrea Arcangeli <andrea@suse.de>
To: Linus Torvalds <torvalds@osdl.org>,
	Jeff Garzik <jgarzik@pobox.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Christoph Hellwig <hch@infradead.org>,
	William Lee Irwin III <wli@holomorphy.com>,
	Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org
Subject: Re: can device drivers return non-ram via vm_ops->nopage?
Date: Mon, 22 Mar 2004 01:34:29 +0100	[thread overview]
Message-ID: <20040322003429.GE3649@dualathlon.random> (raw)
In-Reply-To: <20040321235854.H26708@flint.arm.linux.org.uk>

On Sun, Mar 21, 2004 at 11:58:54PM +0000, Russell King wrote:
> On Sun, Mar 21, 2004 at 03:51:31PM -0800, Linus Torvalds wrote:
> > That might be the minimal fix, since it would basically involve:
> >  - change whatever offensive "virt_to_page()" calls into 
> >    "dma_map_to_page()".
> >  - implement "dma_map_to_page()" for all architectures.
> > 
> > Would that make people happy?
> 
> Unfortunately this doesn't make dwmw2 happy - he claims to have machines
> which implement dma_alloc_coherent using RAM which doesn't have any
> struct page associated with it.

I would suggest to add a ->nopage_dma (or whatever other name for an
additional callback in the vm_ops) that will return a non pageable "pfn"
number (not a page_t*).  This is all the VM needs to setup the pte
properly, this callback will not know anything about the pageable stuff
(i.e. it will not have to call page_add_rmap or stuff like that).

I definitely agree a driver currently has no way to work safe if it
returns non-ram via ->nopage and it must use remap_file_pages, but OTOH
I don't like remap_file_pages myself, it's a lot nicer to use paging
even for mapping non-ram, even if you don't use scatter gather, even if
you've just an huge block of contigous physical ram, at the very least
for the scheduler latencies in a loop under the page_table_lock.

nopage_dma will be like this:

do_no_page_dma(vma, ...)
{
	pfn = vma->vm_ops->nopage_dma()
	if (pfn_valid(pfn)) {
		/*
		 * going from valid pfn to page is always ok
		 * the other way around not
		 */
		page = pfn_to_page(pfn);
		BUG_ON(page->mapping);
		if (!PageReserved(page))
			mm->rss++;
	}
	setup the pte using the pfn here, no vm accounting or pte tracking
	required since it's either non valid pfn or reserved page that
	will be ignored by the zap_pte stuff
}

do_no_page()
{
	if (!vma->vm_ops || !vma->vm_ops->nopage)
		return do_anonymous_page(mm, vma, page_table,
					pmd, write_access, address);
	if (vma->vm_ops->nopage_dma)
		return do_no_page_dma(...)
}

Then the mmu VM troubles are over, how you keep the cache of this pte
view coherent with the iommu view isn't something solvable by the mmu,
but certainly you can add whatever cache flushing callback in teh
do_no_page_dma core, that's a slow path so you can play with it from any
arch adding whatever needed library calls.

btw, on a slightly related note, I don't think this is safe in
get_user_pages in 2.6:

				if (!PageReserved(pages[i]))
					page_cache_get(pages[i]);

there's nothing preventing munmap to free the page while somebody does
I/O on the page via get_user_pages.

  reply	other threads:[~2004-03-22  0:33 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-20 13:30 can device drivers return non-ram via vm_ops->nopage? Andrea Arcangeli
2004-03-20 14:40 ` William Lee Irwin III
2004-03-20 15:06   ` Andrea Arcangeli
2004-03-20 15:27     ` William Lee Irwin III
2004-03-20 15:44     ` Russell King
2004-03-20 15:57       ` Andrea Arcangeli
2004-03-20 16:15         ` Russell King
2004-03-20 16:25           ` Andrea Arcangeli
2004-03-20 16:57             ` William Lee Irwin III
2004-03-20 17:48             ` Andrea Arcangeli
2004-03-20 19:03               ` Andrea Arcangeli
2004-03-20 15:58       ` Jaroslav Kysela
2004-03-20 16:09         ` Russell King
2004-03-20 19:44           ` Jaroslav Kysela
2004-03-20 22:23             ` Russell King
2004-03-20 22:45               ` William Lee Irwin III
2004-03-20 23:54                 ` Russell King
2004-03-21  0:22                   ` Zwane Mwaikambo
2004-03-22  4:46                     ` Benjamin Herrenschmidt
2004-03-22 18:23                       ` Richard Curnow
2004-03-21  0:23                   ` William Lee Irwin III
2004-03-21  9:52                   ` Arjan van de Ven
2004-03-21 10:39                   ` Jaroslav Kysela
2004-03-22  4:43             ` Benjamin Herrenschmidt
2004-03-20 20:13     ` Andrew Morton
2004-03-20 20:28       ` Andrea Arcangeli
2004-03-20 20:50       ` William Lee Irwin III
2004-03-20 22:26         ` Russell King
2004-03-20 22:45           ` William Lee Irwin III
2004-03-21 20:45             ` David Woodhouse
2004-03-21 20:49               ` Christoph Hellwig
2004-03-21 20:57                 ` David Woodhouse
2004-03-21 21:53                   ` Linus Torvalds
2004-03-21 22:17                     ` Jeff Garzik
2004-03-21 22:23                     ` David Woodhouse
2004-03-21 22:23                     ` Russell King
2004-03-21 22:34                       ` Jeff Garzik
2004-03-21 22:42                         ` David Woodhouse
2004-03-21 23:06                           ` Jeff Garzik
2004-03-21 22:51                         ` Russell King
2004-03-21 23:09                           ` Jeff Garzik
2004-03-21 23:11                           ` Linus Torvalds
2004-03-21 23:22                             ` Jeff Garzik
2004-03-21 23:51                               ` Linus Torvalds
2004-03-21 23:58                                 ` Russell King
2004-03-22  0:34                                   ` Andrea Arcangeli [this message]
2004-03-22  3:05                                     ` Linus Torvalds
2004-03-23 17:59                                   ` Andy Whitcroft
2004-03-23 17:58                                     ` David Woodhouse
2004-03-23 18:11                                     ` William Lee Irwin III
2004-03-22  0:02                                 ` David Woodhouse
2004-03-22  3:28                                   ` Linus Torvalds
2004-03-22  0:10                                 ` Jeff Garzik
2004-03-22  0:20                                   ` Russell King
2004-03-22  0:33                                     ` Jeff Garzik
2004-03-22  4:57                                     ` Benjamin Herrenschmidt
2004-03-21 23:45                             ` Russell King
2004-03-22  0:23                               ` William Lee Irwin III
2004-03-22  0:29                                 ` Jeff Garzik
2004-03-22  1:28                                   ` William Lee Irwin III
2004-03-22  3:45                                   ` William Lee Irwin III
2004-03-22  4:41                                     ` James Bottomley
2004-03-22  4:46                                       ` William Lee Irwin III
2004-03-22  4:56                                         ` James Bottomley
2004-03-22  5:26                                           ` Benjamin Herrenschmidt
2004-03-22 11:58                                             ` Andrea Arcangeli
2004-03-22 12:05                                               ` Russell King
2004-03-22 12:34                                                 ` Andrea Arcangeli
2004-03-22  9:30                                       ` Russell King
2004-03-22 15:04                                         ` James Bottomley
2004-03-22 15:15                                           ` Russell King
2004-03-22 15:27                                             ` James Bottomley
2004-03-22 21:50                                               ` Benjamin Herrenschmidt
2004-03-22 22:18                                                 ` Jeff Garzik
2004-03-22 22:35                                                   ` William Lee Irwin III
2004-03-22 23:57                                                     ` Benjamin Herrenschmidt
2004-03-23  0:22                                                       ` David Woodhouse
2004-03-23  2:07                                                       ` William Lee Irwin III
2004-03-23  9:28                                                         ` Russell King
2004-03-23  9:34                                                           ` David Woodhouse
2004-03-23 10:04                                                             ` Russell King
2004-03-23 10:05                                                               ` William Lee Irwin III
2004-03-23 11:29                                                               ` Benjamin Herrenschmidt
2004-03-23 11:35                                                         ` Andrea Arcangeli
2004-03-23 11:44                                                           ` William Lee Irwin III
2004-03-23 12:34                                                             ` Andrea Arcangeli
2004-03-23 12:40                                                               ` Russell King
2004-03-23 15:25                                                                 ` Linus Torvalds
2004-03-23 15:36                                                                   ` Andrea Arcangeli
2004-03-23 15:46                                                                     ` Linus Torvalds
2004-03-23 15:50                                                                     ` Russell King
2004-03-23 22:10                                                                     ` Benjamin Herrenschmidt
2004-03-25 20:25                                                                 ` Russell King
2004-03-28 10:17                                                                   ` Russell King
2004-03-23 12:49                                                               ` William Lee Irwin III
2004-03-22 23:19                                                   ` Russell King
2004-03-22 23:35                                                     ` Jeff Garzik
2004-03-23  2:26                                                       ` James Bottomley
2004-03-22  6:36           ` William Lee Irwin III
2004-03-20 17:39 ` Linus Torvalds
2004-03-20 17:56   ` Andrea Arcangeli
2004-03-20 18:22   ` William Lee Irwin III
2004-03-21  3:13   ` Chris Wedgwood
2004-03-21  6:23     ` Christoph Hellwig
2004-03-21  7:00       ` Chris Wedgwood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040322003429.GE3649@dualathlon.random \
    --to=andrea@suse.de \
    --cc=akpm@osdl.org \
    --cc=dwmw2@infradead.org \
    --cc=hch@infradead.org \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=wli@holomorphy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.