All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andi Kleen <ak@suse.de>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fix x86_64-mm-cpa-cache-flush.patch in 2.6.22-rc4-mm2
Date: Fri, 29 Jun 2007 00:20:10 -0400	[thread overview]
Message-ID: <20070629042010.GA22678@Krystal> (raw)
In-Reply-To: <20070625212553.ec2caba9.akpm@linux-foundation.org>

> Seems that Andi has changed
> ftp://ftp.firstfloor.org/pub/ak/x86_64/quilt/patches/cpa-cache-flush so
> hopefully these fixes will not be needed any more..
> 

Hrm, actually, something is very wrong with this patch. Please see
comments below.


...
> Index: linux/arch/x86_64/mm/pageattr.c
> ===================================================================
> --- linux.orig/arch/x86_64/mm/pageattr.c
> +++ linux/arch/x86_64/mm/pageattr.c
> @@ -234,7 +235,10 @@ void global_flush_tlb(void)
>  	flush_map(&l);
>  
>  	list_for_each_entry_safe(pg, next, &l, lru) {
> +		if (page_private(pg) != 0)
> +			continue;
>  		ClearPagePrivate(pg);
> +		clear_bit(PG_arch_1, &pg->flags);


First issue:

clear_bit should be before the if (page_private(pg) != 0). As a result,
in the current patch, the flush won't be done the second time flags
are changed in a page, because the bit would only be cleared when each
pte within the page are set back to normal page attributes.

I would also suggest putting a list_del before the if (page_private(pg)
!= 0). It is not required, but would make sure the pointers are
poisoned.

>  		__free_page(pg);
>  	} 
>  } 
> Index: linux/arch/i386/mm/pageattr.c
> ===================================================================
> --- linux.orig/arch/i386/mm/pageattr.c
> +++ linux/arch/i386/mm/pageattr.c
> @@ -82,7 +82,7 @@ static void flush_kernel_map(void *arg)
>  	struct page *p;
>  
>  	/* High level code is not ready for clflush yet */
> -	if (0 && cpu_has_clflush) {
> +	if (cpu_has_clflush) {
>  		list_for_each_entry (p, lh, lru)
>  			cache_flush_page(p);
>  	} else if (boot_cpu_data.x86_model >= 4)
> @@ -136,6 +136,12 @@ static inline void revert_page(struct pa
>  			    ref_prot));
>  }
>  
> +static inline void save_page(struct page *kpte_page)
> +{
> +	if (!test_and_set_bit(PG_arch_1, &kpte_page->flags))
> +		list_add(&kpte_page->lru, &df_list);
> +}
> +
>  static int
>  __change_page_attr(struct page *page, pgprot_t prot)
>  { 
> @@ -150,6 +156,9 @@ __change_page_attr(struct page *page, pg
>  	if (!kpte)
>  		return -EINVAL;
>  	kpte_page = virt_to_page(kpte);
> +	BUG_ON(PageLRU(kpte_page));
> +	BUG_ON(PageCompound(kpte_page));
> +
>  	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL)) { 
>  		if (!pte_huge(*kpte)) {
>  			set_pte_atomic(kpte, mk_pte(page, prot)); 
> @@ -179,11 +188,11 @@ __change_page_attr(struct page *page, pg
>  	 * time (not via split_large_page) and in turn we must not
>  	 * replace it with a largepage.
>  	 */
> +
> +	save_page(kpte_page);
>  	if (!PageReserved(kpte_page)) {
>  		if (cpu_has_pse && (page_private(kpte_page) == 0)) {
> -			ClearPagePrivate(kpte_page);
>  			paravirt_release_pt(page_to_pfn(kpte_page));
> -			list_add(&kpte_page->lru, &df_list);
>  			revert_page(kpte_page, address);
>  		}
>  	}
> @@ -236,6 +245,10 @@ void global_flush_tlb(void)
>  	spin_unlock_irq(&cpa_lock);
>  	flush_map(&l);
>  	list_for_each_entry_safe(pg, next, &l, lru) {
> +		if (page_private(pg) != 0)
> +			continue;
> +		ClearPagePrivate(pg);
> +		clear_bit(PG_arch_1, &pg->flags);

Same two issues pointed for x86_64 applies here: clear_bit and a
list_del should be put before the if statement.

Mathieu

>  		__free_page(pg);
>  	}
>  }


-- 
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

  parent reply	other threads:[~2007-06-29  4:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-19 17:09 Problem with global_flush_tlb() on i386 in 2.6.22-rc4-mm2 Mathieu Desnoyers
2007-06-19 20:01 ` Problem with global_flush_tlb() on i386 (x86_64? too) " Mathieu Desnoyers
2007-06-19 21:10   ` [PATCH] Workaround change_page_attr() and global_flush_tlb() df_list inconsistency on i386 Mathieu Desnoyers
2007-06-20  9:01   ` Problem with global_flush_tlb() on i386 (x86_64? too) in 2.6.22-rc4-mm2 Andi Kleen
2007-06-20 16:46     ` Mathieu Desnoyers
2007-06-20 17:53       ` Andi Kleen
2007-06-20 18:14         ` Mathieu Desnoyers
2007-06-20 19:39         ` [PATCH] fix x86_64-mm-cpa-cache-flush.patch " Mathieu Desnoyers
     [not found]           ` <20070625212553.ec2caba9.akpm@linux-foundation.org>
2007-06-29  4:20             ` Mathieu Desnoyers [this message]
2007-06-20  1:23 ` Problem with global_flush_tlb() on i386 " Anthony Liguori
2007-06-20  1:32   ` Mathieu Desnoyers
2007-06-20  1:49   ` Mathieu Desnoyers

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=20070629042010.GA22678@Krystal \
    --to=mathieu.desnoyers@polymtl.ca \
    --cc=ak@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.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 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.