From: David Howells <dhowells@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: dhowells@redhat.com,
Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
"hugh.dickins" <hugh.dickins@tiscali.co.uk>,
lkml <linux-kernel@vger.kernel.org>,
linux-arch <linux-arch@vger.kernel.org>
Subject: Re: [RFC][PATCH] kmap_atomic_push
Date: Thu, 08 Oct 2009 23:12:41 +0100 [thread overview]
Message-ID: <13417.1255039961@redhat.com> (raw)
In-Reply-To: <1255016123.17055.17.camel@laptop>
Peter Zijlstra <peterz@infradead.org> wrote:
> The below patchlet changes the kmap_atomic interface to a stack based
> one that doesn't require the KM_types anymore.
>
> This significantly simplifies some code (more still than are present in
> this patch -- ie. pte_map_nested can go now)
> ...
> What do people think?
Brrr.
This makes FRV much worse. kmap_atomic() used to take a compile-time constant
value - which meant that the switch-statement inside it was mostly optimised
away. kmap_atomic() would be rendered down to very few instructions. Now
it'll be a huge jump table plus all those few instructions repeated because
the selector is now dynamic.
What I would prefer to see is something along the lines of local_irq_save()
and local_irq_restore(), where the displaced value gets stored on the machine
stack. In FRV, I could then represent kmap_atomic() as:
static inline void *kmap_atomic_push(struct page *page,
kmap_save_t *save)
{
unsigned long paddr, damlr, dampr;
int type;
pagefault_disable();
dampr = page_to_phys(page);
dampr |= xAMPRx_L | xAMPRx_M | xAMPRx_S | xAMPRx_SS_16Kb | xAMPRx_V;
asm volatile("movgs dampr6,%0 \n"
"movgs %0,dampr6"
: "=r"(save->dampr) : "r"(dampr) : "memory");
asm("movsg damlr6,%0" : "=r"(damlr));
return (void *) damlr;
}
However, since we occasionally want a second kmap slot, we could also add:
typedef struct { unsigned long dampr; } kmap_save_t;
static inline void *kmap2_atomic_push(struct page *page,
kmap_save_t *save)
{
unsigned long paddr, damlr, dampr;
int type;
pagefault_disable();
dampr = page_to_phys(page);
dampr |= xAMPRx_L | xAMPRx_M | xAMPRx_S | xAMPRx_SS_16Kb | xAMPRx_V;
asm volatile("movgs dampr7,%0 \n"
"movgs %0,dampr7"
: "=r"(save->dampr) : "r"(dampr) : "memory");
asm("movsg damlr7,%0" : "=r"(damlr));
return (void *) damlr;
}
And the reverse ops would be:
static inline void kmap_atomic_pop(kmap_save_t *save)
{
asm volatile("movgs %0,dampr6"
:: "r"(save->dampr) : "memory");
pagefault_enable();
}
static inline void kmap2_atomic_pop(kmap_save_t *save)
{
asm volatile("movgs %0,dampr7"
:: "r"(save->dampr) : "memory");
pagefault_enable();
}
And I would avoid the need to lock fake TLB entries in the shallow TLB.
If it's too much trouble for an arch to extract the current kmap setting from
the MMU or the page tables, *those* could be mirrored in per-CPU data.
Do we have any code that uses two slots and then calls more code that
ultimately requires further slots? In other words, do we need more than two
slots?
> David, frv has a 'funny' issue in that it treats __KM_CACHE special from
> the other ones, something which isn't possibly anymore. Do you see
> another option than to add kmap_atomic_push_cache() for frv?
The four __KM_xxx slots are special and must not be committed to this stack.
They're used by assembly code directly for certain tasks, such as maintaining
the TLB-lookup state. Your changes are guaranteed to break MMU-mode FRV.
That said, there's no reason these four slots *have* to be administered
through kmap_atomic(). A kmap_frv() could be made instead for them.
David
next prev parent reply other threads:[~2009-10-08 22:12 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-08 15:35 [RFC][PATCH] kmap_atomic_push Peter Zijlstra
2009-10-08 15:44 ` Linus Torvalds
2009-10-08 15:53 ` Ingo Molnar
2009-10-08 15:53 ` Ingo Molnar
2009-10-08 16:29 ` Peter Zijlstra
2009-10-08 16:29 ` Peter Zijlstra
2009-10-08 16:50 ` Linus Torvalds
2009-10-08 18:02 ` Hugh Dickins
2009-10-08 22:27 ` jim owens
2009-10-08 22:32 ` Peter Zijlstra
2009-10-08 22:57 ` Peter Zijlstra
2009-10-08 22:57 ` Peter Zijlstra
2009-10-09 12:15 ` jim owens
2009-10-09 12:15 ` jim owens
2009-10-08 22:12 ` David Howells [this message]
2009-10-08 22:12 ` David Howells
2009-10-08 22:29 ` Peter Zijlstra
2009-10-08 22:58 ` David Howells
2009-10-08 22:42 ` Peter Zijlstra
2009-10-12 18:10 ` Andi Kleen
2009-10-12 18:10 ` Andi Kleen
2009-10-12 18:30 ` Linus Torvalds
2009-10-12 18:40 ` Andi Kleen
2009-10-12 18:40 ` Andi Kleen
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=13417.1255039961@redhat.com \
--to=dhowells@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hugh.dickins@tiscali.co.uk \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
/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