From owner-freebsd-current@freebsd.org Sun May 10 10:25:44 2020 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 91E5A2E21A9 for ; Sun, 10 May 2020 10:25:44 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 49KgFN2SRNz434W; Sun, 10 May 2020 10:25:44 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id 04AAPbRX072155 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 10 May 2020 13:25:40 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 04AAPbRX072155 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id 04AAPbla072154; Sun, 10 May 2020 13:25:37 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 10 May 2020 13:25:37 +0300 From: Konstantin Belousov To: Andriy Gapon Cc: FreeBSD Current Subject: Re: CHANGE_PV_LIST_LOCK_TO_PHYS is not correct when !NUMA ? Message-ID: <20200510102537.GE68906@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> <20200509165010.GI44519@kib.kiev.ua> <881b2aa7-b9df-da64-25b6-783f076115c4@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <881b2aa7-b9df-da64-25b6-783f076115c4@FreeBSD.org> X-Spam-Status: No, score=-0.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED,PLING_QUERY autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 49KgFN2SRNz434W X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 May 2020 10:25:44 -0000 On Sun, May 10, 2020 at 01:02:45PM +0300, Andriy Gapon wrote: > 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 Looks good to me.