From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: shared memory problem on ARM v5TE using threads
Date: Fri, 4 Dec 2009 16:38:50 +0000 [thread overview]
Message-ID: <20091204163850.GC20386@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <4B1931B3.90301@denx.de>
On Fri, Dec 04, 2009 at 04:58:43PM +0100, Heiko Schocher wrote:
> Hello Russell King,
>
> Russell King - ARM Linux wrote:
> > On Fri, Dec 04, 2009 at 02:42:12PM +0100, Heiko Schocher wrote:
> >> Hello Russell King,
> >>
> >> Russell King - ARM Linux wrote:
> >>> On Fri, Dec 04, 2009 at 12:23:45PM +0100, Heiko Schocher wrote:
> >>>> [4] Log from Demoprogramm, not working
> >>> I think this is messed up - this is not from your first script but your
> >>> second script which starts four independent read processes.
> >>>
> >>> I determined this because:
> >>> (1) the read thread addresses are mostly the same
> >>> (2) there are four "Read form in_msg" strings, which you only print
> >>> once at the start of the program.
> >> Ups, sorry for the confusion, here 2 logs with the right values:
> >
> > I don't remember whether 2.6.28 has highmem. Can you check whether you're
> > using highmem please?
>
> No, there is no HIGHMEM in the defconfig, if you mean this config option.
>
> You can find the complete defconfig here:
>
> http://git.denx.de/?p=linux-2.6-denx.git;a=blob;f=arch/arm/configs/suen3_defconfig;h=905f9bc6a36c03ab41b97a292fca5b3a0011a2a0;hb=3dc3e4dc957f216ec5cdcd2a770f5c4b0cefca4a
Please apply this patch and re-run your program. Expect a fair bit of
output - the last 50 or so lines from the kernel messages should cover
everything that's required. Also useful would be the output from the
program giving the addresses of the shm regions.
(This patch is a little messy because it contains a bit of restructuring
for 2.6.32 bug fixing...)
diff --git a/arch/arm/mm/fault-armv.c b/arch/arm/mm/fault-armv.c
index 7296022..c457920 100644
--- a/arch/arm/mm/fault-armv.c
+++ b/arch/arm/mm/fault-armv.c
@@ -27,6 +27,8 @@
static unsigned long shared_pte_mask = L_PTE_MT_BUFFERABLE;
+#define is_debug() (strcmp(current->comm, "shmtest2") == 0)
+
/*
* We take the easy way out of this problem - we make the
* PTE uncacheable. However, we leave the write buffer on.
@@ -36,33 +38,18 @@ static unsigned long shared_pte_mask = L_PTE_MT_BUFFERABLE;
* Therefore those configurations which might call adjust_pte (those
* without CONFIG_CPU_CACHE_VIPT) cannot support split page_table_lock.
*/
-static int adjust_pte(struct vm_area_struct *vma, unsigned long address)
+static int do_adjust_pte(struct vm_area_struct *vma, unsigned long address,
+ pte_t *ptep)
{
- pgd_t *pgd;
- pmd_t *pmd;
- pte_t *pte, entry;
+ pte_t entry = *ptep;
int ret;
- pgd = pgd_offset(vma->vm_mm, address);
- if (pgd_none(*pgd))
- goto no_pgd;
- if (pgd_bad(*pgd))
- goto bad_pgd;
-
- pmd = pmd_offset(pgd, address);
- if (pmd_none(*pmd))
- goto no_pmd;
- if (pmd_bad(*pmd))
- goto bad_pmd;
-
- pte = pte_offset_map(pmd, address);
- entry = *pte;
-
/*
* If this page is present, it's actually being shared.
*/
ret = pte_present(entry);
-
+if (is_debug()) printk("%s:%d: vma %p addr %lx pte %08lx\n",
+ current->comm, current->pid, vma, address, pte_val(entry));
/*
* If this page isn't present, or is already setup to
* fault (ie, is old), we can safely ignore any issues.
@@ -74,23 +61,36 @@ static int adjust_pte(struct vm_area_struct *vma, unsigned long address)
(pfn << PAGE_SHIFT) + PAGE_SIZE);
pte_val(entry) &= ~L_PTE_MT_MASK;
pte_val(entry) |= shared_pte_mask;
- set_pte_at(vma->vm_mm, address, pte, entry);
+ set_pte_at(vma->vm_mm, address, ptep, entry);
flush_tlb_page(vma, address);
+if (is_debug()) printk("%s:%d: modified %08lx\n", current->comm, current->pid, pte_val(entry));
}
- pte_unmap(pte);
return ret;
+}
+
+static int adjust_pte(struct vm_area_struct *vma, unsigned long address)
+{
+ pgd_t *pgd;
+ pmd_t *pmd;
+ pte_t *pte;
+ int ret;
-bad_pgd:
- pgd_ERROR(*pgd);
- pgd_clear(pgd);
-no_pgd:
- return 0;
-
-bad_pmd:
- pmd_ERROR(*pmd);
- pmd_clear(pmd);
-no_pmd:
- return 0;
+ pgd = pgd_offset(vma->vm_mm, address);
+ if (pgd_none_or_clear_bad(pgd))
+ return 0;
+
+ pmd = pmd_offset(pgd, address);
+ if (pmd_none_or_clear_bad(pmd))
+ return 0;
+
+ /*
+ * This may be called while another page table is mapped.
+ */
+ pte = pte_offset_map_nested(pmd, address);
+ ret = do_adjust_pte(vma, address, pte);
+ pte_unmap_nested(pte);
+
+ return ret;
}
static void
@@ -105,6 +105,9 @@ make_coherent(struct address_space *mapping, struct vm_area_struct *vma, unsigne
pgoff = vma->vm_pgoff + ((addr - vma->vm_start) >> PAGE_SHIFT);
+if (is_debug()) printk("%s:%d: %p %p %lx %lx %lx\n",
+ current->comm, current->pid, mapping, vma, pgoff, addr, pfn);
+
/*
* If we have any shared mappings that are in the same mm
* space, then we need to handle them specially to maintain
@@ -125,6 +128,7 @@ make_coherent(struct address_space *mapping, struct vm_area_struct *vma, unsigne
aliases += adjust_pte(mpnt, mpnt->vm_start + offset);
}
flush_dcache_mmap_unlock(mapping);
+if (is_debug()) printk("%s:%d: aliases %d\n", current->comm, current->pid, aliases);
if (aliases)
adjust_pte(vma, addr);
else
next prev parent reply other threads:[~2009-12-04 16:38 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-04 11:23 shared memory problem on ARM v5TE using threads Heiko Schocher
2009-12-04 12:26 ` Joerg Wagner
2009-12-04 13:13 ` Russell King - ARM Linux
2009-12-04 13:42 ` Heiko Schocher
2009-12-04 15:42 ` Russell King - ARM Linux
2009-12-04 15:58 ` Heiko Schocher
2009-12-04 16:38 ` Russell King - ARM Linux [this message]
2009-12-04 16:59 ` Russell King - ARM Linux
2009-12-04 17:53 ` Heiko Schocher
2009-12-04 19:13 ` Russell King - ARM Linux
2009-12-04 19:35 ` Heiko Schocher
2009-12-06 13:53 ` Ronen Shitrit
2009-12-06 14:16 ` Russell King - ARM Linux
2009-12-07 7:54 ` Ronen Shitrit
2009-12-07 8:33 ` Heiko Schocher
2009-12-07 11:31 ` saeed bishara
2009-12-07 11:42 ` Russell King - ARM Linux
2009-12-07 12:16 ` Ronen Shitrit
2009-12-07 12:27 ` Heiko Schocher
2009-12-07 12:42 ` Ronen Shitrit
2009-12-07 15:24 ` Nicolas Pitre
2009-12-07 12:24 ` Heiko Schocher
2009-12-07 12:55 ` Ronen Shitrit
2009-12-07 14:52 ` Russell King - ARM Linux
2009-12-07 15:37 ` Nicolas Pitre
2009-12-07 17:05 ` Russell King - ARM Linux
2009-12-07 17:33 ` Nicolas Pitre
2009-12-07 17:56 ` Russell King - ARM Linux
2009-12-13 11:48 ` Ronen Shitrit
2009-12-13 12:00 ` Russell King - ARM Linux
2009-12-13 12:06 ` Russell King - ARM Linux
2009-12-13 15:42 ` Ronen Shitrit
2009-12-14 13:13 ` christian pellegrin
2009-12-14 14:46 ` Ronen Shitrit
2009-12-14 17:48 ` christian pellegrin
2009-12-14 20:14 ` Nicolas Pitre
2009-12-15 7:50 ` saeed bishara
2009-12-15 11:01 ` christian pellegrin
2009-12-15 15:31 ` christian pellegrin
2009-12-15 17:18 ` Russell King - ARM Linux
2009-12-16 14:08 ` Ronen Shitrit
2009-12-15 17:14 ` Russell King - ARM Linux
2009-12-16 16:35 ` christian pellegrin
2009-12-16 17:38 ` christian pellegrin
2009-12-17 7:35 ` Ronen Shitrit
2009-12-18 20:22 ` Nicolas Pitre
2009-12-18 20:44 ` Russell King - ARM Linux
2009-12-18 21:23 ` Nicolas Pitre
2009-12-18 21:57 ` Russell King - ARM Linux
2009-12-19 11:24 ` christian pellegrin
2009-12-19 11:27 ` [PATCH] Fix coherency problems on ARM v5 with L2 PIPT cache Christian Pellegrin
2009-12-14 19:59 ` shared memory problem on ARM v5TE using threads Nicolas Pitre
2009-12-15 10:33 ` christian pellegrin
2009-12-18 18:45 ` Pavel Machek
2009-12-18 19:00 ` Nicolas Pitre
2009-12-20 19:51 ` Pavel Machek
2009-12-20 22:32 ` Nicolas Pitre
2009-12-21 7:40 ` Pavel Machek
2009-12-18 19:16 ` Russell King - ARM Linux
2009-12-20 19:56 ` Pavel Machek
2009-12-17 11:31 ` Heiko Schocher
2009-12-18 8:08 ` christian pellegrin
2009-12-07 15:40 ` Russell King - ARM Linux
2009-12-07 15:57 ` Nicolas Pitre
2009-12-07 16:06 ` Ronen Shitrit
2009-12-07 17:17 ` Russell King - ARM Linux
2009-12-04 17:25 ` Nicolas Pitre
2009-12-04 17:31 ` Russell King - ARM Linux
2009-12-04 17:47 ` Heiko Schocher
2009-12-04 17:56 ` Nicolas Pitre
2009-12-04 19:33 ` Heiko Schocher
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=20091204163850.GC20386@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).