From: Linus Torvalds <torvalds@linux-foundation.org>
To: Nick Piggin <npiggin@suse.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
akpm@linux-foundation.org, linux-mm@kvack.org,
Christoph Hellwig <hch@infradead.org>
Subject: Re: [patch 3/8] mm: merge nopfn into fault
Date: Fri, 25 May 2007 09:36:26 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.0.98.0705250924320.26602@woody.linux-foundation.org> (raw)
In-Reply-To: <20070525111818.GA3881@wotan.suse.de>
On Fri, 25 May 2007, Nick Piggin wrote:
>
> What do you think? Any better?
Yes, I think this is getting there. It made the error returns generally
much simpler.
That said, I think it has room for more improvement. Why not make the
return value just be a bitmask, rather than having two separate "bytes" of
data.
For example, you now do:
> +
> +/*
> + * VM_FAULT_ERROR is set for the error cases, to make some tests simpler.
> + */
> +#define VM_FAULT_ERROR 0x20
> +
> +#define VM_FAULT_OOM (0x00 | VM_FAULT_ERROR)
> +#define VM_FAULT_SIGBUS (0x01 | VM_FAULT_ERROR)
> #define VM_FAULT_MINOR 0x02
> #define VM_FAULT_MAJOR 0x03
And it would be so much cleaner (I think) to just realize:
- successful VM faults are always either major or minor, so having two
different values for them is silly (it comes from the fact that we did
_not_ have a bitmask). JUst make a "MAJOR" bit, and if it's clear, then
it's not major, of course!
- rather than have one bit to say "we had an error", just make each error
be a bit of its own. We don't have that many (two, to be exact), so you
actually don't even use any more bits, but it means that you can do:
#define VM_FAULT_OOM 0x0001
#define VM_FAULT_SIGBUS 0x0002
#define VM_FAULT_MAJOR 0x0004
#define VM_FAULT_WRITE 0x0008
#define VM_FAULT_NONLINEAR 0x0010
#define VM_FAULT_NOPAGE 0x0020 /* We did our own pfn map */
#define VM_FAULT_LOCKED 0x0040 /* Returned a locked page */
/* Helper defines: */
#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS)
and you're done. No magic semantics: you just always return a set of
result flags.
So now the _user_ would simply do something like
unsigned int flags;
flags = vma->vm_ops->fault(...);
if (flags & VM_FAULT_ERROR)
return flags;
if (flags & VM_FAULT_MAJOR)
increment_major_faults();
else
increment_minor_faults();
/* Did the fault handler do it all already? All done! */
if (flags & VM_FAULT_NOPAGE)
return 0;
page = fault->page;
.. install page ..
/*
* If the fault handler returned a locked page, we should now
* unlock it
*/
if (flags & VM_FAULT_LOCKED)
unlock_page(page);
/* All done! */
return 0;
or something like that. Yeah, the above is simplified, but it's not
*overly* so. And it never worries about "high bytes" and "low bytes", and
it never worries about a certain set of bits meaning one thing, and
another set meaning somethign else. Isn't that just much simpler for
everybody?
Linus
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2007-05-25 16:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-18 7:37 [patch 3/8] mm: merge nopfn into fault akpm, Nick Piggin
2007-05-18 15:23 ` Linus Torvalds
2007-05-19 1:46 ` Nick Piggin
2007-05-23 23:40 ` Benjamin Herrenschmidt
2007-05-24 1:42 ` Nick Piggin
2007-05-24 2:04 ` Linus Torvalds
2007-05-24 2:16 ` Nick Piggin
2007-05-24 3:17 ` Benjamin Herrenschmidt
2007-05-24 3:26 ` Benjamin Herrenschmidt
2007-05-24 3:37 ` Linus Torvalds
2007-05-24 3:45 ` Nick Piggin
2007-05-24 10:07 ` Christoph Hellwig
2007-05-24 10:15 ` Benjamin Herrenschmidt
2007-05-24 3:48 ` Benjamin Herrenschmidt
2007-05-25 11:18 ` Nick Piggin
2007-05-25 16:36 ` Linus Torvalds [this message]
2007-05-26 7:34 ` Nick Piggin
2007-05-26 8:03 ` Nick Piggin
2007-05-26 15:44 ` Linus Torvalds
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=alpine.LFD.0.98.0705250924320.26602@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=hch@infradead.org \
--cc=linux-mm@kvack.org \
--cc=npiggin@suse.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox