public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Venki Pallipadi <venkatesh.pallipadi@intel.com>
To: Rene Herman <rene.herman@keyaccess.nl>
Cc: "Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com>,
	Ingo Molnar <mingo@elte.hu>, Dave Airlie <airlied@gmail.com>,
	"Li, Shaohua" <shaohua.li@intel.com>,
	Yinghai Lu <yhlu.kernel@gmail.com>,
	Andreas Herrmann <andreas.herrmann3@amd.com>,
	Arjan van de Ven <arjan@infradead.org>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	"Siddha, Suresh B" <suresh.b.siddha@intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: AGP and PAT (induced?) problem (on AMD family 6)
Date: Tue, 19 Aug 2008 16:28:01 -0700	[thread overview]
Message-ID: <20080819232801.GA24610@linux-os.sc.intel.com> (raw)
In-Reply-To: <48AB1D62.6030406@keyaccess.nl>

On Tue, Aug 19, 2008 at 12:22:10PM -0700, Rene Herman wrote:
> On 19-08-08 21:07, Venki Pallipadi wrote:
> 
> > On Tue, Aug 19, 2008 at 07:19:44AM -0700, Rene Herman wrote:
> 
> >> I believe the 14 seconds for first shutdown to 5 later might be
> >> telling. Sounds like something might have fixed up uncached
> >> entries.
> >>
> >> I'd really like a reply from the AGP or PAT side right about now.
> >
> > Hmm. Looks like there are more than 16000 entries in the PAT list!
> >
> > This delay may be due to the overhead of parsing this linked list
> > everytime for a new entry, rather than any problem with cache setting
> > itself.
> >
> > I am working on a patch to optimize this pat list parsing for the
> > simple case. Should be able to send it out later today, for testing.
> 
> Thanks for the reply. It's with 64MB of AGP memory which I guess is at
> the low end these days. Would your reply mean that basically everyone on
> 2.6.27 should now be experiencing this?
> 
> I noticed it was PAT related due to Shaohua Li's:
> 
> http://marc.info/?l=linux-kernel&m=121783222306075&w=2
> 
> which lists very different times (patch there did not help any).
> 
> As another by the way, probably not surprising but I earlier also tried
>   both unmounting and completely compiling out debugfs just in case I
> was seeing a debugging related sysmptom. No help either.
> 
> It's evening here so I'll probably not be able to test until tomorrow.
> 

Below is the patch I am testing. Let me know if this patch helps.

Thanks,
Venki


Test patch. Adds cached_entry to list add routine, in order to speed up the
lookup for sequential reserve_memtype calls.

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>

---
 arch/x86/mm/pat.c |   33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

Index: linux-2.6/arch/x86/mm/pat.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/pat.c	2008-08-19 15:21:07.000000000 -0700
+++ linux-2.6/arch/x86/mm/pat.c	2008-08-19 16:00:52.000000000 -0700
@@ -207,6 +207,9 @@ static int chk_conflict(struct memtype *
 	return -EBUSY;
 }
 
+static struct memtype *cached_entry;
+static u64 cached_start;
+
 /*
  * req_type typically has one of the:
  * - _PAGE_CACHE_WB
@@ -280,11 +283,17 @@ int reserve_memtype(u64 start, u64 end, 
 
 	spin_lock(&memtype_lock);
 
+	if (cached_entry && start >= cached_start)
+		entry = cached_entry;
+	else
+		entry = list_entry(&memtype_list, struct memtype, nd);
+
 	/* Search for existing mapping that overlaps the current range */
 	where = NULL;
-	list_for_each_entry(entry, &memtype_list, nd) {
+	list_for_each_entry_continue(entry, &memtype_list, nd) {
 		if (end <= entry->start) {
 			where = entry->nd.prev;
+			cached_entry = list_entry(where, struct memtype, nd);
 			break;
 		} else if (start <= entry->start) { /* end > entry->start */
 			err = chk_conflict(new, entry, new_type);
@@ -292,6 +301,8 @@ int reserve_memtype(u64 start, u64 end, 
 				dprintk("Overlap at 0x%Lx-0x%Lx\n",
 					entry->start, entry->end);
 				where = entry->nd.prev;
+				cached_entry = list_entry(where,
+							struct memtype, nd);
 			}
 			break;
 		} else if (start < entry->end) { /* start > entry->start */
@@ -299,7 +310,20 @@ int reserve_memtype(u64 start, u64 end, 
 			if (!err) {
 				dprintk("Overlap at 0x%Lx-0x%Lx\n",
 					entry->start, entry->end);
-				where = &entry->nd;
+				cached_entry = list_entry(entry->nd.prev,
+							struct memtype, nd);
+
+				/*
+				 * Move to right position in the linked
+				 * list to add this new entry
+				 */
+				list_for_each_entry_continue(entry,
+							&memtype_list, nd) {
+					if (start <= entry->start) {
+						where = entry->nd.prev;
+						break;
+					}
+				}
 			}
 			break;
 		}
@@ -314,6 +338,8 @@ int reserve_memtype(u64 start, u64 end, 
 		return err;
 	}
 
+	cached_start = start;
+
 	if (where)
 		list_add(&new->nd, where);
 	else
@@ -343,6 +369,9 @@ int free_memtype(u64 start, u64 end)
 	spin_lock(&memtype_lock);
 	list_for_each_entry(entry, &memtype_list, nd) {
 		if (entry->start == start && entry->end == end) {
+			if (cached_entry == entry || cached_start == start)
+				cached_entry = NULL;
+
 			list_del(&entry->nd);
 			kfree(entry);
 			err = 0;

  reply	other threads:[~2008-08-19 23:28 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-04 16:30 AGP and PAT (induced?) problem (on AMD family 6) Rene Herman
2008-08-06 13:51 ` Andreas Herrmann
2008-08-06 20:57   ` Rene Herman
2008-08-11  9:46     ` Rene Herman
2008-08-15 14:22 ` Ingo Molnar
2008-08-15 15:24   ` Rene Herman
2008-08-19 10:11     ` Rene Herman
2008-08-19 10:26       ` Ingo Molnar
2008-08-19 14:19         ` Rene Herman
2008-08-19 19:07           ` Venki Pallipadi
2008-08-19 19:22             ` Rene Herman
2008-08-19 23:28               ` Venki Pallipadi [this message]
2008-08-20 10:09                 ` Ingo Molnar
2008-08-20 10:04             ` Ingo Molnar
2008-08-20 10:50               ` Rene Herman
2008-08-20 14:27                 ` Rene Herman
2008-08-20 19:41                   ` Venki Pallipadi
2008-08-20 21:40                     ` Rene Herman
2008-08-20 21:46                       ` Dave Airlie
2008-08-20 22:16                         ` Venki Pallipadi
2008-08-21  3:42                           ` Andi Kleen
2008-08-21 21:13                             ` Suresh Siddha
2008-08-22  2:12                               ` Andi Kleen
2008-08-21 12:06                           ` Ingo Molnar
2008-08-21 17:15                             ` Rene Herman
2008-08-21 22:10                               ` [PATCH] x86: {reverve,free}_memtype() take a physical address Rene Herman
2008-08-21 22:16                                 ` Pallipadi, Venkatesh
2008-08-21 22:26                                   ` Rene Herman
2008-08-21 22:57                                     ` Pallipadi, Venkatesh
2008-08-21 23:06                                       ` Rene Herman
2008-08-21 23:02                               ` [PATCH] x86: have set_memory_array_{uc,wb} coalesce memtypes Rene Herman
2008-08-22  4:15                                 ` Ingo Molnar
2008-08-22 19:08                                   ` Venki Pallipadi
2008-08-22 20:15                                     ` Rene Herman
2008-08-23 15:33                                       ` Ingo Molnar
2008-08-22 20:02                                   ` Rene Herman
2008-09-10 19:52                                     ` AGP PAT issue Rene Herman
2008-09-11  8:17                                       ` Ingo Molnar
2008-09-11  8:30                                         ` Rene Herman
2008-09-13  0:26                                           ` Pallipadi, Venkatesh
2008-09-13  0:44                                             ` Rene Herman
2008-10-09 15:53                                               ` Thomas Hellstrom
2008-10-13 17:10                                                 ` Pallipadi, Venkatesh
2008-10-13 19:26                                                   ` Thomas Hellström
2008-08-20 21:02                 ` AGP and PAT (induced?) problem (on AMD family 6) Dave Airlie
2008-08-20 21:16                   ` Rene Herman

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=20080819232801.GA24610@linux-os.sc.intel.com \
    --to=venkatesh.pallipadi@intel.com \
    --cc=airlied@gmail.com \
    --cc=andreas.herrmann3@amd.com \
    --cc=arjan@infradead.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rene.herman@keyaccess.nl \
    --cc=shaohua.li@intel.com \
    --cc=suresh.b.siddha@intel.com \
    --cc=tglx@linutronix.de \
    --cc=yhlu.kernel@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox