From patchwork Sat Sep 21 10:08:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Raphael Tiovalen X-Patchwork-Id: 1988130 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=EUsu/d2L; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Z1tb4src; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X9lgk3TLvz1y38 for ; Sat, 21 Sep 2024 20:22:42 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HSgxCQKXXArsVHNNSDn6+JEWyzi5L2WigLK4RKnXOXg=; b=EUsu/d2LCFC+/Z 4HBzXD/xoARlRAvvMMPmx1XnMGWwowUgpeI0EEP1ir1d/vGfEGUFjq6Bp3GEgbemPkpamC3IS4BJv dDQ3TIEWbMeDjgKUWcvv3Sz0iL6Ie8uipSu2cALm7OKOO7l6tWFwRKke4yp4wzsCFRbkiFkFHv4w1 tGVF+SVcgAWbjkh5q3OXZVSlDFPgWvLm+ks7ZVNGhaMn7g1OuBmbbOtSSWC1j52SMbKLqA2wUwPHi 5cDOxOZG/a9IU7JdfIBIs33aGWdWzeUEjHexho3+98Cnu0frex26K3+zc3+rTDyamaxZSscI22NlL eNZgmBNlxqAxccZocRtA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1srxGD-0000000Dbpl-0dpf; Sat, 21 Sep 2024 10:22:41 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1srx2f-0000000DaUl-0smZ for kvm-riscv@lists.infradead.org; Sat, 21 Sep 2024 10:08:42 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2059112f0a7so26386755ad.3 for ; Sat, 21 Sep 2024 03:08:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726913320; x=1727518120; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=od5yEkBBSMRl70l2ICtIaZs6wNRd82e2Lcyy8jXXe5k=; b=Z1tb4srcOX+BH3K65bSDIzyak1+5vKVHytkb73OpdDUqU7gjMin33jQR5ku3tNk1T1 hkM/ddNfa38wK0rzLk9SOO3FzHU7ugtsb92mJYQ7x1HtEH2+5j9njG4dLly2vUwABr1P I2irC+jl5/ZpN68/MhIs+oN7bdJCgO/tWFGU7f9ahqq4cNi3VIJlkTpRirdKorqOpfjV 9/DCPbjl6ZXERl7zdgPR0ZerDLTbquwxW5pQ+d6xxxwa1W5LkC6W27/3KiZuqv+Z/Zbb rtkiW6zCUCVtKUy8P571qyG/lI54r6UYIg1fJrKVbnimZgFyS/5B+2C+TcqRfC0K03f/ 6qkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726913320; x=1727518120; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=od5yEkBBSMRl70l2ICtIaZs6wNRd82e2Lcyy8jXXe5k=; b=CqlUv6xH6Jt3Bpq6gyoEwiVe2xAZjTnw/K1jUbCE0tOtAPlpeUBgQtxngjuB/7n0W1 dA+wkdy4EDNi+qLNkWmrHVnYB9pqI1sYelq4LZAFSbvTMEeewWjDN80DyBnHedhTZioJ nFsFcT6Fs87Vau+J9J7VIDwqLrUinnCoZcJWDACJUjx7LZ71l2RjHY7hpyl0XPsAePv4 R1PI4UnPTId49v/fHaxW9LuZQ3KKHxquFGg1fwIKVjyCrJTHZ7kzkNs7ynpkqaw7ETnq 5XvXzZ9PqZIZvj32X44ePKrge3boDAXs9V0rW43MNgAhRvMAJL85RjHqlJCCeXiBxPa4 iz4Q== X-Forwarded-Encrypted: i=1; AJvYcCU0Iiiv2k+6MvRuEmHBTa3sbH04Mg/v+STVdCuvIS+AF4sBCj/RrPjj5YAsKFI2yzzJxexJvzZBssE=@lists.infradead.org X-Gm-Message-State: AOJu0YzFYAEhF3D2U58SXI9NhEHEkTRIimPRQAsC7TXC3JdFFr4DBy+A O50m868oiDCC08lbdIMU7cu4lGrfoUs7AmHIzh6IPmis25wYNv+P X-Google-Smtp-Source: AGHT+IGKS/E2gA+YQYbl1PX33pehG2KROtr1xdO2y1XDw/0CD4KQ3nWvvjMzor0huCIvufYAmqbyyg== X-Received: by 2002:a17:90b:3c83:b0:2cb:4c32:a7e4 with SMTP id 98e67ed59e1d1-2dd7f4270ccmr7201493a91.15.1726913320042; Sat, 21 Sep 2024 03:08:40 -0700 (PDT) Received: from JRT-PC.. ([203.116.176.98]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dd6ee7c03fsm5680024a91.11.2024.09.21.03.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2024 03:08:39 -0700 (PDT) From: James Raphael Tiovalen To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Cc: andrew.jones@linux.dev, atishp@rivosinc.com, cade.richard@berkeley.edu, James Raphael Tiovalen Subject: [kvm-unit-tests PATCH v5 3/5] lib/on-cpus: Add helper method to clear the function from on_cpu_info Date: Sat, 21 Sep 2024 18:08:21 +0800 Message-ID: <20240921100824.151761-4-jamestiotio@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240921100824.151761-1-jamestiotio@gmail.com> References: <20240921100824.151761-1-jamestiotio@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240921_030841_275133_C3F08F94 X-CRM114-Status: GOOD ( 10.89 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When a CPU abruptly stops during some test, the CPU will not have the chance to go back to the do_idle() loop and set the on_cpu_info[cpu].func variable to NULL. Add a helper method for some test mana [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:631 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [jamestiotio(at)gmail.com] X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When a CPU abruptly stops during some test, the CPU will not have the chance to go back to the do_idle() loop and set the on_cpu_info[cpu].func variable to NULL. Add a helper method for some test manager CPU to clear this function. This would re-enable on_cpu_async and allow future tests to use the on-cpus API again. Signed-off-by: James Raphael Tiovalen --- lib/on-cpus.h | 1 + lib/on-cpus.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/on-cpus.h b/lib/on-cpus.h index 4bc6236d..497ff9d1 100644 --- a/lib/on-cpus.h +++ b/lib/on-cpus.h @@ -13,5 +13,6 @@ void on_cpu(int cpu, void (*func)(void *data), void *data); void on_cpus(void (*func)(void *data), void *data); void on_cpumask_async(const cpumask_t *mask, void (*func)(void *data), void *data); void on_cpumask(const cpumask_t *mask, void (*func)(void *data), void *data); +void on_cpu_clear_func(int cpu); #endif /* _ON_CPUS_H_ */ diff --git a/lib/on-cpus.c b/lib/on-cpus.c index 89214933..cc73690a 100644 --- a/lib/on-cpus.c +++ b/lib/on-cpus.c @@ -171,3 +171,14 @@ void on_cpus(void (*func)(void *data), void *data) { on_cpumask(&cpu_present_mask, func, data); } + +void on_cpu_clear_func(int cpu) +{ + for (;;) { + if (get_on_cpu_info(cpu)) + break; + } + + on_cpu_info[cpu].func = NULL; + put_on_cpu_info(cpu); +}