All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-kernel@vger.kernel.org, mingo@redhat.com, hpa@zytor.com,
	paulus@samba.org, acme@redhat.com, efault@gmx.de,
	npiggin@suse.de, tglx@linutronix.de, mingo@elte.hu
Cc: linux-tip-commits@vger.kernel.org,
	"hugh.dickins" <hugh.dickins@tiscali.co.uk>
Subject: Re: [tip:perfcounters/core] x86: Add NMI types for kmap_atomic
Date: Mon, 15 Jun 2009 16:46:05 +0200	[thread overview]
Message-ID: <1245077165.6800.497.camel@laptop> (raw)
In-Reply-To: <tip-3ff0141aa3a03ca3388b40b36167d0a37919f3fd@git.kernel.org>

On Mon, 2009-06-15 at 14:07 +0000, tip-bot for Peter Zijlstra wrote:
> Commit-ID:  3ff0141aa3a03ca3388b40b36167d0a37919f3fd
> Gitweb:     http://git.kernel.org/tip/3ff0141aa3a03ca3388b40b36167d0a37919f3fd
> Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
> AuthorDate: Mon, 15 Jun 2009 12:40:41 +0200
> Committer:  Ingo Molnar <mingo@elte.hu>
> CommitDate: Mon, 15 Jun 2009 15:57:52 +0200
> 
> x86: Add NMI types for kmap_atomic
> 
> Two new kmap_atomic slots for NMI context. And teach pte_offset_map()
> about NMI context.
> 
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> CC: Nick Piggin <npiggin@suse.de>
> Cc: Mike Galbraith <efault@gmx.de>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Signed-off-by: Ingo Molnar <mingo@elte.hu>
> 
> 
> ---
>  arch/x86/include/asm/kmap_types.h |    4 +++-
>  arch/x86/include/asm/pgtable_32.h |    5 +++--
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/include/asm/kmap_types.h b/arch/x86/include/asm/kmap_types.h
> index 5759c16..ff00a44 100644
> --- a/arch/x86/include/asm/kmap_types.h
> +++ b/arch/x86/include/asm/kmap_types.h
> @@ -21,7 +21,9 @@ D(9)	KM_IRQ0,
>  D(10)	KM_IRQ1,
>  D(11)	KM_SOFTIRQ0,
>  D(12)	KM_SOFTIRQ1,
> -D(13)	KM_TYPE_NR
> +D(13)	KM_NMI,
> +D(14)	KM_NMI_PTE,
> +D(15)	KM_TYPE_NR
>  };
>  
>  #undef D
> diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
> index 31bd120..8546497 100644
> --- a/arch/x86/include/asm/pgtable_32.h
> +++ b/arch/x86/include/asm/pgtable_32.h
> @@ -49,13 +49,14 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
>  #endif
>  
>  #if defined(CONFIG_HIGHPTE)
> +#define __KM_PTE	(in_nmi() ? KM_NMI_PTE : KM_PTE0)
>  #define pte_offset_map(dir, address)					\
> -	((pte_t *)kmap_atomic_pte(pmd_page(*(dir)), KM_PTE0) +		\
> +	((pte_t *)kmap_atomic_pte(pmd_page(*(dir)), __KM_PTE) +		\
>  	 pte_index((address)))
>  #define pte_offset_map_nested(dir, address)				\
>  	((pte_t *)kmap_atomic_pte(pmd_page(*(dir)), KM_PTE1) +		\
>  	 pte_index((address)))
> -#define pte_unmap(pte) kunmap_atomic((pte), KM_PTE0)
> +#define pte_unmap(pte) kunmap_atomic((pte), __KM_PTE)
>  #define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
>  #else
>  #define pte_offset_map(dir, address)					\

I just realized this has a kmap_atomic bug in... 

The below would fix it, but that's getting rather ugly :-/,
alternatively I would have to introduce something like
pte_offset_map_irq() which would make the irq/nmi detection and leave
the regular code paths alone, however that would mean either duplicating
the gup_fast() pagewalk or passing down a pte function pointer, which
would only duplicate the gup_pte_range() bit, neither is really
attractive...

Index: linux-2.6/arch/x86/include/asm/kmap_types.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/kmap_types.h
+++ linux-2.6/arch/x86/include/asm/kmap_types.h
@@ -19,11 +19,12 @@ D(7)	KM_PTE0,
 D(8)	KM_PTE1,
 D(9)	KM_IRQ0,
 D(10)	KM_IRQ1,
-D(11)	KM_SOFTIRQ0,
-D(12)	KM_SOFTIRQ1,
-D(13)	KM_NMI,
-D(14)	KM_NMI_PTE,
-D(15)	KM_TYPE_NR
+D(11)	KM_IRQ_PTE,
+D(12)	KM_SOFTIRQ0,
+D(13)	KM_SOFTIRQ1,
+D(14)	KM_NMI,
+D(15)	KM_NMI_PTE,
+D(16)	KM_TYPE_NR
 };
 
 #undef D
Index: linux-2.6/arch/x86/include/asm/pgtable_32.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/pgtable_32.h
+++ linux-2.6/arch/x86/include/asm/pgtable_32.h
@@ -49,7 +49,10 @@ extern void set_pmd_pfn(unsigned long, u
 #endif
 
 #if defined(CONFIG_HIGHPTE)
-#define __KM_PTE	(in_nmi() ? KM_NMI_PTE : KM_PTE0)
+#define __KM_PTE			\
+	(in_nmi() ? KM_NMI_PTE : 	\
+	 in_irq() ? KM_IRQ_PTE :	\
+	 KM_PTE0)
 #define pte_offset_map(dir, address)					\
 	((pte_t *)kmap_atomic_pte(pmd_page(*(dir)), __KM_PTE) +		\
 	 pte_index((address)))




       reply	other threads:[~2009-06-15 14:46 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <tip-3ff0141aa3a03ca3388b40b36167d0a37919f3fd@git.kernel.org>
2009-06-15 14:46 ` Peter Zijlstra [this message]
2009-06-15 15:30   ` [tip:perfcounters/core] x86: Add NMI types for kmap_atomic Hugh Dickins
2009-06-15 15:41     ` Peter Zijlstra
2009-06-15 15:52       ` Ingo Molnar
2009-06-15 16:02         ` Hugh Dickins
2009-06-15 18:04       ` Peter Zijlstra
2009-06-15 18:15         ` Ingo Molnar
2009-06-15 18:19           ` Peter Zijlstra
2009-06-15 18:25             ` Ingo Molnar
2009-06-15 18:30               ` Peter Zijlstra
2009-06-15 18:42                 ` Ingo Molnar
2009-06-15 18:47                   ` Peter Zijlstra
2009-06-15 18:52                     ` Ingo Molnar
2009-06-15 19:00                       ` Peter Zijlstra
2009-06-16  8:13                         ` Ingo Molnar
2009-06-16 12:38                           ` Hugh Dickins
2009-06-17  7:58                             ` Peter Zijlstra
2009-06-17  8:43                               ` Tejun Heo
2009-06-17  9:05                                 ` Peter Zijlstra
2009-06-17  7:44                           ` Peter Zijlstra
2009-06-17 12:28                             ` Ingo Molnar
2009-06-15 18:42         ` Andrew Morton
2009-06-15 18:45           ` Peter Zijlstra

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=1245077165.6800.497.camel@laptop \
    --to=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=efault@gmx.de \
    --cc=hpa@zytor.com \
    --cc=hugh.dickins@tiscali.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=npiggin@suse.de \
    --cc=paulus@samba.org \
    --cc=tglx@linutronix.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 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.