Re: landisk: simply asid lookup

2016-10-17 Thread Jeremie Courreges-Anglas
Philip Guenther  writes:

> It used to be that access to a process's vmspace (and thus its pmap where 
> the ASID can be found) was only via a thread's p_vmspace member.  Now that 
> the process itself has a copy of that, the loops in the sh code that 
> iterated across threads to find a valid pointer can be eliminated.
>
> ok?

Looks fine to me fwiw, I don't have a landisk machine.

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



landisk: simply asid lookup

2016-10-14 Thread Philip Guenther

It used to be that access to a process's vmspace (and thus its pmap where 
the ASID can be found) was only via a thread's p_vmspace member.  Now that 
the process itself has a copy of that, the loops in the sh code that 
iterated across threads to find a valid pointer can be eliminated.

ok?


Philip Guenther

Index: arch/sh/sh/pmap.c
===
RCS file: /data/src/openbsd/src/sys/arch/sh/sh/pmap.c,v
retrieving revision 1.26
diff -u -p -r1.26 pmap.c
--- arch/sh/sh/pmap.c   15 Sep 2016 02:00:17 -  1.26
+++ arch/sh/sh/pmap.c   13 Oct 2016 04:44:41 -
@@ -1067,7 +1067,6 @@ int
 __pmap_asid_alloc(void)
 {
struct process *pr;
-   struct proc *p;
int i, j, k, n, map, asid;
 
/* Search free ASID */
@@ -1092,14 +1091,9 @@ __pmap_asid_alloc(void)
 * too many processes.
 */
LIST_FOREACH(pr, , ps_list) {
-   /* find a thread that still has the process vmspace attached */
-   TAILQ_FOREACH(p, >ps_threads, p_thr_link)
-   if (p->p_vmspace != NULL)
-   break;
-   if (p == NULL)
-   continue;
-   if ((asid = p->p_vmspace->vm_map.pmap->pm_asid) > 0) {
-   pmap_t pmap = p->p_vmspace->vm_map.pmap;
+   pmap_t pmap = pr->ps_vmspace->vm_map.pmap;
+
+   if ((asid = pmap->pm_asid) > 0) {
pmap->pm_asid = -1;
__pmap_asid.hint = asid;
/* Invalidate all old ASID entry */
Index: arch/sh/sh/db_interface.c
===
RCS file: /data/src/openbsd/src/sys/arch/sh/sh/db_interface.c,v
retrieving revision 1.8
diff -u -p -r1.8 db_interface.c
--- arch/sh/sh/db_interface.c   18 May 2016 20:21:13 -  1.8
+++ arch/sh/sh/db_interface.c   13 Oct 2016 00:36:31 -
@@ -368,15 +368,10 @@ __db_procname_by_asid(int asid)
 {
static char notfound[] = "---";
struct process *pr;
-   struct proc *p;
 
LIST_FOREACH(pr, , ps_list) {
-   /* find a thread that still has the process vmspace attached */
-   TAILQ_FOREACH(p, >ps_threads, p_thr_link)
-   if (p->p_vmspace != NULL)
-   break;
-   if (p != NULL && p->p_vmspace->vm_map.pmap->pm_asid == asid)
+   if (pr->ps_vmspace->vm_map.pmap->pm_asid == asid)
return (p->p_comm);
}
 
return (notfound);