From owner-dev-commits-src-all@freebsd.org Tue Jan 12 05:59:31 2021 Return-Path: Delivered-To: dev-commits-src-all@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 3F6884C9CD7; Tue, 12 Jan 2021 05:59:31 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DFKfC1C0gz4S47; Tue, 12 Jan 2021 05:59:30 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wr1-x430.google.com with SMTP id c5so1149891wrp.6; Mon, 11 Jan 2021 21:59:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=PjtN12IpIlQm2yTH7PLkO1IBl1ROoAlBPgvS2UOM380=; b=YER0LyDaZ/b0uksov98wP2GIOezttGCUKqFRaZOcQugfUxTALwkc5bKsh7/7XSfxFY nVWA6U1lKpLmZwk6XFXjaPmbGHLgF1nZ881bL0L67X02XjtwMKSpuRwvyo6lmz4X0q+q FcKFCbYNB4KSqVfHGB9b9Mme3Mvq1PKdV+ZdO0hW/tbFUV7zNIFCtsY/kk6SZ9nN1dgW SV26xrhpi0ELi/eGEQCGrnpyAyBmeLMEHxOoJk5y7kXjV58m+BzxtrHwep/eNp130hOT wFW6nyDdheAoTDOmMkSFc7+shrSNY4/vq5Ey5zU6WC0dTgSusuxZWNOhQX9pFGH3o6IM 9zCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=PjtN12IpIlQm2yTH7PLkO1IBl1ROoAlBPgvS2UOM380=; b=m+ORqdcLJnl2cMnc/KKRFepJLrq98WxoepNYSKOrlgEpBjMJu2/Lgp3k2cUhhXIoLI 3IXyF+R3TNrDej9ygOXh466QH8ImHmM6JIlAgXphta35R0RuMud23j06o4RgAbXUx8IQ CTCZ14QenowYpDsyMwj0B3NZ3ZE6ZlvTTTANScKfuB0jJQnMXQiiQXyDj+VeVAsKpRT4 oxJ1Y9y0XNk56TUHJL0zqgu0hme61hWnm5trtMB7XqZRZXD90kyYHx0/Ot4pzCevWpDl be8YEK7ZwoCp7R3uXkYcFbEMp6ARSmEu7IJde4gJ4CPglaZg/4s5DYWJXX+FT6rSpXNw ABQA== X-Gm-Message-State: AOAM533/LEUgt11gvwtDpdcl9nshHc/Vhof/JHxK0XCu5wKvD3LN2JvE 7NZ2ODmmrXWScINMeFMYqxg9g4XddRKjx0H3pUcuXpUJkT0= X-Google-Smtp-Source: ABdhPJzvpyKL32Fjmjp6HC9glxM09tS5xB5jZ1u7h7/TrLy7kq5lEUuIQCOGTQYjdfsxZNcvK47s8bohAOplB2ocP7k= X-Received: by 2002:a5d:4e92:: with SMTP id e18mr2525339wru.66.1610431169148; Mon, 11 Jan 2021 21:59:29 -0800 (PST) MIME-Version: 1.0 Received: by 2002:adf:f811:0:0:0:0:0 with HTTP; Mon, 11 Jan 2021 21:59:28 -0800 (PST) In-Reply-To: <202101120110.10C1A6mg069684@gitrepo.freebsd.org> References: <202101120110.10C1A6mg069684@gitrepo.freebsd.org> From: Mateusz Guzik Date: Tue, 12 Jan 2021 06:59:28 +0100 Message-ID: Subject: Re: git: 7eaea04a5bb1 - main - amd64: compare TLB shootdown target to all_cpus To: Andrew Gallatin Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4DFKfC1C0gz4S47 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jan 2021 05:59:31 -0000 This makes my 2 core vm crash on boot: Launching APs: 1 Timecounter "TSC-low" frequency 1346899854 Hz quality 1000 panic: IPI scoreboard is zero, initiator 1 target 1 cpuid = 1 time = 1 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xffffffff80fb7600 vpanic() at vpanic+0x181/frame 0xffffffff80fb7650 panic() at panic+0x43/frame 0xffffffff80fb76b0 smp_targeted_tlb_shootdown() at smp_targeted_tlb_shootdown+0x434/frame 0xffffffff80fb7730 pmap_invalidate_range() at pmap_invalidate_range+0x16f/frame 0xffffffff80fb77a0 vm_thread_stack_create() at vm_thread_stack_create+0x45/frame 0xffffffff80fb78e0 kstack_import() at kstack_import+0x4e/frame 0xffffffff80fb7910 cache_alloc() at cache_alloc+0x3bf/frame 0xffffffff80fb7970 cache_alloc_retry() at cache_alloc_retry+0x25/frame 0xffffffff80fb79b0 vm_thread_new() at vm_thread_new+0x3d/frame 0xffffffff80fb79d0 thread_alloc() at thread_alloc+0x50/frame 0xffffffff80fb7a00 kthread_add() at kthread_add+0x42/frame 0xffffffff80fb7aa0 kproc_kthread_add() at kproc_kthread_add+0xaf/frame 0xffffffff80fb7bc0 intr_event_add_handler() at intr_event_add_handler+0x227/frame 0xffffffff80fb7c30 start_softintr() at start_softintr+0xea/frame 0xffffffff80fb7c60 mi_startup() at mi_startup+0xec/frame 0xffffffff80fb7cb0 btext() at btext+0x2c KDB: enter: panic On 1/12/21, Andrew Gallatin wrote: > The branch main has been updated by gallatin: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=7eaea04a5bb1dc86c43ce046311e1c1a042994d3 > > commit 7eaea04a5bb1dc86c43ce046311e1c1a042994d3 > Author: Andrew Gallatin > AuthorDate: 2021-01-12 01:03:37 +0000 > Commit: Andrew Gallatin > CommitDate: 2021-01-12 01:09:32 +0000 > > amd64: compare TLB shootdown target to all_cpus > > On amd64, the pmap code passes all_cpus to > smp_targeted_tlb_shootdown() when unmapping from the > kernel pmap. This function has an optimized path to send IPIs > to all but itself, which it intends to do when the target > is all cpus. However, we need to compare the target cpu mask > with all_cpus, rather than using CPU_ISFULLSET(). Comparing with > CPU_ISFULLSET() will only work when we have MAXCPU cpus active in > the system, otherwise, we'll be sending repeated IPIs, rather than > a single IPI to all CPUs but ourself. > > Fixing this should reduce the time spent in native_lapic_ipi_wait() > as we will be sending ipis in parallel, rather than one-by-one. > This is confirmed by dtrace. > > Reviewed by: alc, jhb, kib, markj > Sponsored by: Netflix > Differential Revision: https://reviews.freebsd.org/D28102 > --- > sys/amd64/amd64/mp_machdep.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c > index 63777014e151..794a11bf1276 100644 > --- a/sys/amd64/amd64/mp_machdep.c > +++ b/sys/amd64/amd64/mp_machdep.c > @@ -673,7 +673,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask, pmap_t pmap, > vm_offset_t addr1, > /* > * Check for other cpus. Return if none. > */ > - if (CPU_ISFULLSET(&mask)) { > + if (!CPU_CMP(&mask, &all_cpus)) { > if (mp_ncpus <= 1) > goto local_cb; > } else { > @@ -719,7 +719,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask, pmap_t pmap, > vm_offset_t addr1, > * (zeroing slot) and reading from it below (wait for > * acknowledgment). > */ > - if (CPU_ISFULLSET(&mask)) { > + if (!CPU_CMP(&mask, &all_cpus)) { > ipi_all_but_self(IPI_INVLOP); > other_cpus = all_cpus; > CPU_CLR(PCPU_GET(cpuid), &other_cpus); > -- Mateusz Guzik