Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 May 2020 13:02:45 +0300
From:      Andriy Gapon <avg@FreeBSD.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        FreeBSD Current <freebsd-current@freebsd.org>
Subject:   Re: CHANGE_PV_LIST_LOCK_TO_PHYS is not correct when !NUMA ?
Message-ID:  <881b2aa7-b9df-da64-25b6-783f076115c4@FreeBSD.org>
In-Reply-To: <20200509165010.GI44519@kib.kiev.ua>
References:  <0d7db402-621e-cc6b-2918-2078f63e2a9b@FreeBSD.org> <20200508161500.GC44519@kib.kiev.ua> <6485ab77-a3d0-8916-9431-74e4da1e3ea7@FreeBSD.org> <20200509161325.GH44519@kib.kiev.ua> <d8876981-4775-0548-e49e-2f9171a2db10@FreeBSD.org> <20200509165010.GI44519@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On 09/05/2020 19:50, Konstantin Belousov wrote:
> On Sat, May 09, 2020 at 07:16:27PM +0300, Andriy Gapon wrote:
>> On 09/05/2020 19:13, Konstantin Belousov wrote:
>>> On Sat, May 09, 2020 at 06:52:24PM +0300, Andriy Gapon wrote:
>>>> I tried this change:
>>>> diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
>>>> index 4deed86a76d1a..b834b7f0388b7 100644
>>>> --- a/sys/amd64/amd64/pmap.c
>>>> +++ b/sys/amd64/amd64/pmap.c
>>>> @@ -345,7 +345,7 @@ pmap_pku_mask_bit(pmap_t pmap)
>>>>  #define	NPV_LIST_LOCKS	MAXCPU
>>>>
>>>>  #define	PHYS_TO_PV_LIST_LOCK(pa)	\
>>>> -			(&pv_list_locks[pa_index(pa) % NPV_LIST_LOCKS])
>>>> +			(&pv_list_locks[((pa) >> PDRSHIFT) % NPV_LIST_LOCKS])
>>>>  #endif
>>>>
>>>>  #define	CHANGE_PV_LIST_LOCK_TO_PHYS(lockp, pa)	do {	\
>>>>
>>>> It fixed the original problem, but I got a new panic.
>>>> "DI already started" in pmap_remove() -> pmap_delayed_invl_start_u().
>>>> I guess that !NUMA variant does not get much testing, so I'll probably just
>>>> stick with the default.
>>> Why didn't you just removed the KASSERT from pa_index ?
>>
>> Well, I thought it might be useful in the NUMA case.
>> pa_index() definition is shared between both cases.
> Might be define the macro two times, for NUMA/non-NUMA.  non-NUMA case
> does not need the assert, because users take it mod NPV_LIST_LOCKS.

Yes, this works.
Thank you!

diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 4deed86a76d1a..8dd236acc8205 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -323,12 +323,12 @@ pmap_pku_mask_bit(pmap_t pmap)
 #endif

 #undef pa_index
+#ifdef NUMA
 #define	pa_index(pa)	({					\
 	KASSERT((pa) <= vm_phys_segs[vm_phys_nsegs - 1].end,	\
 	    ("address %lx beyond the last segment", (pa)));	\
 	(pa) >> PDRSHIFT;					\
 })
-#ifdef NUMA
 #define	pa_to_pmdp(pa)	(&pv_table[pa_index(pa)])
 #define	pa_to_pvh(pa)	(&(pa_to_pmdp(pa)->pv_page))
 #define	PHYS_TO_PV_LIST_LOCK(pa)	({			\
@@ -340,6 +340,7 @@ pmap_pku_mask_bit(pmap_t pmap)
 	_lock;							\
 })
 #else
+#define	pa_index(pa)	((pa) >> PDRSHIFT)
 #define	pa_to_pvh(pa)	(&pv_table[pa_index(pa)])

 #define	NPV_LIST_LOCKS	MAXCPU


-- 
Andriy Gapon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?881b2aa7-b9df-da64-25b6-783f076115c4>