From owner-dev-commits-src-main@freebsd.org Tue Jan 12 08:54:06 2021 Return-Path: Delivered-To: dev-commits-src-main@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 756464CF3BD; Tue, 12 Jan 2021 08:54:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DFPWf2tK9z4d9D; Tue, 12 Jan 2021 08:54:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 55D882A39B; Tue, 12 Jan 2021 08:54:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 10C8s6C7075399; Tue, 12 Jan 2021 08:54:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10C8s6Gr075398; Tue, 12 Jan 2021 08:54:06 GMT (envelope-from git) Date: Tue, 12 Jan 2021 08:54:06 GMT Message-Id: <202101120854.10C8s6Gr075398@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 44121a0fbee0 - main - amd64: fix tlb shootdown when all cpus are passed in the bitmap MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 44121a0fbee0272e23bfb90601d177ba9e9cda9b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jan 2021 08:54:06 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=44121a0fbee0272e23bfb90601d177ba9e9cda9b commit 44121a0fbee0272e23bfb90601d177ba9e9cda9b Author: Mateusz Guzik AuthorDate: 2021-01-12 08:47:32 +0000 Commit: Mateusz Guzik CommitDate: 2021-01-12 08:47:32 +0000 amd64: fix tlb shootdown when all cpus are passed in the bitmap Right now the routine leaves the current CPU in the map, later tripping on an assert when filling in the scoreboard: panic: IPI scoreboard is zero, initiator 1 target 1 Instead pre-check if all CPUs are present in the map and remember that outcome for later. Fixes: 7eaea04a5bb1dc86 ("amd64: compare TLB shootdown target to all_cpus") Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D28111 --- sys/amd64/amd64/mp_machdep.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 794a11bf1276..aa62c2086fa4 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -660,6 +660,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask, pmap_t pmap, vm_offset_t addr1, cpuset_t other_cpus, mask1; uint32_t generation, *p_cpudone; int cpu; + bool is_all; /* * It is not necessary to signal other CPUs while booting or @@ -673,14 +674,10 @@ smp_targeted_tlb_shootdown(cpuset_t mask, pmap_t pmap, vm_offset_t addr1, /* * Check for other cpus. Return if none. */ - if (!CPU_CMP(&mask, &all_cpus)) { - if (mp_ncpus <= 1) - goto local_cb; - } else { - CPU_CLR(PCPU_GET(cpuid), &mask); - if (CPU_EMPTY(&mask)) - goto local_cb; - } + is_all = !CPU_CMP(&mask, &all_cpus); + CPU_CLR(PCPU_GET(cpuid), &mask); + if (CPU_EMPTY(&mask)) + goto local_cb; /* * Initiator must have interrupts enabled, which prevents @@ -719,7 +716,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_CMP(&mask, &all_cpus)) { + if (is_all) { ipi_all_but_self(IPI_INVLOP); other_cpus = all_cpus; CPU_CLR(PCPU_GET(cpuid), &other_cpus);