From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FCD82D3755 for ; Tue, 4 Nov 2025 10:48:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762253311; cv=none; b=GgxIc5T+YpXtMmqFgb6FV/HY42wrJ5R8OK5UJC/zNbGetTXWq11ehZtByg+E/AvhLkjPRXXlQxT+u6PHnOGmBq9urZsnO54L0wRaRuGuMBYEfvlkWO+OLe8CMva+QkJxd6ceA2sARy3nqzt+G8s5GubipfM0s4g1/Nw0o03yzK8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762253311; c=relaxed/simple; bh=Hmp+MPQ4mlYdyreLmsc+OLgViXFnt/2D+OykVxVkYhI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LdeuXaDAIpuM/E1V/LNYasOZ+q/vwvICF/1F2GWqBeGCqzWs9gqJeoZ1PNjivIh3eUCQHJ3K5Laqt2h4SUT47BEvBv7YqmEoU0005aUHZBSldN6i076YbkYxeHKBcyOlGTUFmmxt535s/AuSZLdSw0W7mXZH340qzeeRymbDjMI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=fbl+wo0K; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fbl+wo0K" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762253308; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dIfn73tjUwqWO8Gl7RwmTiA/lmsiR1Al6xpPdEJ0nQQ=; b=fbl+wo0KKST9/UREY3N1Mz4YXRb10we4QOTaFjYIdu6xUlXlHrQ6wMPjNeyXcjoBvfVOvr LzGzAXcppU79woJF3h4vLfXMlbROC0YmUlfsEaJmRHfzrGYICxo5n7y63tAxDJrcJblGnt i2fXsu98+2CfQnYDZxTImegC4nG8TxM= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-p2a2GF73MJiwda97K6Kajw-1; Tue, 04 Nov 2025 05:48:21 -0500 X-MC-Unique: p2a2GF73MJiwda97K6Kajw-1 X-Mimecast-MFC-AGG-ID: p2a2GF73MJiwda97K6Kajw_1762253295 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7EA6A195608D; Tue, 4 Nov 2025 10:48:14 +0000 (UTC) Received: from eda-pc.redhat.com (unknown [10.45.224.83]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0FA1F18004D8; Tue, 4 Nov 2025 10:48:11 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Waiman Long Cc: Gabriele Monaco Subject: [PATCH v14 2/7] timers: Add the available mask in timer migration Date: Tue, 4 Nov 2025 11:47:34 +0100 Message-ID: <20251104104740.70512-3-gmonaco@redhat.com> In-Reply-To: <20251104104740.70512-1-gmonaco@redhat.com> References: <20251104104740.70512-1-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Keep track of the CPUs available for timer migration in a cpumask. This prepares the ground to generalise the concept of unavailable CPUs. Reviewed-by: Frederic Weisbecker Signed-off-by: Gabriele Monaco --- kernel/time/timer_migration.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/kernel/time/timer_migration.c b/kernel/time/timer_migration.c index 78700f90944f0..39f734dbbb0fc 100644 --- a/kernel/time/timer_migration.c +++ b/kernel/time/timer_migration.c @@ -422,6 +422,12 @@ static unsigned int tmigr_crossnode_level __read_mostly; static DEFINE_PER_CPU(struct tmigr_cpu, tmigr_cpu); +/* + * CPUs available for timer migration. + * Protected by cpuset_mutex (with cpus_read_lock held) or cpus_write_lock. + */ +static cpumask_var_t tmigr_available_cpumask; + #define TMIGR_NONE 0xFF #define BIT_CNT 8 @@ -1443,6 +1449,7 @@ static int tmigr_clear_cpu_available(unsigned int cpu) int migrator; u64 firstexp; + cpumask_clear_cpu(cpu, tmigr_available_cpumask); raw_spin_lock_irq(&tmc->lock); tmc->available = false; WRITE_ONCE(tmc->wakeup, KTIME_MAX); @@ -1456,7 +1463,7 @@ static int tmigr_clear_cpu_available(unsigned int cpu) raw_spin_unlock_irq(&tmc->lock); if (firstexp != KTIME_MAX) { - migrator = cpumask_any_but(cpu_online_mask, cpu); + migrator = cpumask_any(tmigr_available_cpumask); work_on_cpu(migrator, tmigr_trigger_active, NULL); } @@ -1471,6 +1478,7 @@ static int tmigr_set_cpu_available(unsigned int cpu) if (WARN_ON_ONCE(!tmc->tmgroup)) return -EINVAL; + cpumask_set_cpu(cpu, tmigr_available_cpumask); raw_spin_lock_irq(&tmc->lock); trace_tmigr_cpu_available(tmc); tmc->idle = timer_base_is_idle(); @@ -1798,6 +1806,11 @@ static int __init tmigr_init(void) if (ncpus == 1) return 0; + if (!zalloc_cpumask_var(&tmigr_available_cpumask, GFP_KERNEL)) { + ret = -ENOMEM; + goto err; + } + /* * Calculate the required hierarchy levels. Unfortunately there is no * reliable information available, unless all possible CPUs have been -- 2.43.0