From nobody Tue Dec 2 02:04:08 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 E2E47349AFD for ; Thu, 20 Nov 2025 14:57:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763650636; cv=none; b=sm6L/DcyTRXJYQDMtFHlKs6+i30JC0R1vjBXuoIDBAzBmguW66qxHkjbUe2r4CEqVk1EQdY6HN8QEVQdm7ZM0G38pQHhZL91lhKcL1nIQcF80W4vDKzI5ZToMnSVu6QNlt3UKl2cDz+97FarK88yxPNYwknbxDLCrqFopJ7qSkw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763650636; c=relaxed/simple; bh=4/D7Bw3D6xDLOPZsHKmCj+mIDuIw1eXsSNTHAEwfxJg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y1wvAwPuoE3NQpQ7rSEO7KulpiTXd99pUTvammRf/fQDP6/KaFStOPJskMDZWSNVK+gJqfKj2dbkjSlvI5VL7Pe5msEaumItcNLMbwu49j+RZb8LcIVdfdP0ffcr2SAGkFpPe8msTLjuGp1ezORax3m4PsfXuRjcFa5C6K/YObo= 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=aGNgkqB1; arc=none smtp.client-ip=170.10.129.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="aGNgkqB1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763650633; 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=numuwaFI+F7zbSK932lSQwemMwSkH0n/z54t+5TkbXA=; b=aGNgkqB1u3MfrE8tFIi87UOJQlHB3+1hTsyncL/FfQd2ROWAr7KGDKJhNnznu+KZwFeEEp B3WD9jRWVXqTmjfQTiyEy03wQHTZ4bis7H4VgbWPkMJagE2dRXgD+i1Q5d3gH5boXtW/Gr jMgjFrvH6g48WEm191hfH1gVrNjzkNA= Received: from mx-prod-mc-03.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-477-r4X80HhSNDiI6xKcg5BwJg-1; Thu, 20 Nov 2025 09:57:09 -0500 X-MC-Unique: r4X80HhSNDiI6xKcg5BwJg-1 X-Mimecast-MFC-AGG-ID: r4X80HhSNDiI6xKcg5BwJg_1763650627 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6CE45195605B; Thu, 20 Nov 2025 14:57:07 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.45.224.239]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D4ECC1940E88; Thu, 20 Nov 2025 14:57:04 +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 v16 2/7] timers/migration: Add mask for CPUs available in the hierarchy Date: Thu, 20 Nov 2025 15:56:48 +0100 Message-ID: <20251120145653.296659-3-gmonaco@redhat.com> In-Reply-To: <20251120145653.296659-1-gmonaco@redhat.com> References: <20251120145653.296659-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: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Thomas Gleixner 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 2cfebed35e22..3325ca7989b3 100644 --- a/kernel/time/timer_migration.c +++ b/kernel/time/timer_migration.c @@ -424,6 +424,12 @@ static struct tmigr_group *tmigr_root; =20 static DEFINE_PER_CPU(struct tmigr_cpu, tmigr_cpu); =20 +/* + * 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 =20 @@ -1433,6 +1439,7 @@ static int tmigr_clear_cpu_available(unsigned int cpu) int migrator; u64 firstexp; =20 + cpumask_clear_cpu(cpu, tmigr_available_cpumask); raw_spin_lock_irq(&tmc->lock); tmc->available =3D false; WRITE_ONCE(tmc->wakeup, KTIME_MAX); @@ -1446,7 +1453,7 @@ static int tmigr_clear_cpu_available(unsigned int cpu) raw_spin_unlock_irq(&tmc->lock); =20 if (firstexp !=3D KTIME_MAX) { - migrator =3D cpumask_any_but(cpu_online_mask, cpu); + migrator =3D cpumask_any(tmigr_available_cpumask); work_on_cpu(migrator, tmigr_trigger_active, NULL); } =20 @@ -1461,6 +1468,7 @@ static int tmigr_set_cpu_available(unsigned int cpu) if (WARN_ON_ONCE(!tmc->tmgroup)) return -EINVAL; =20 + cpumask_set_cpu(cpu, tmigr_available_cpumask); raw_spin_lock_irq(&tmc->lock); trace_tmigr_cpu_available(tmc); tmc->idle =3D timer_base_is_idle(); @@ -1805,6 +1813,11 @@ static int __init tmigr_init(void) if (ncpus =3D=3D 1) return 0; =20 + if (!zalloc_cpumask_var(&tmigr_available_cpumask, GFP_KERNEL)) { + ret =3D -ENOMEM; + goto err; + } + /* * Calculate the required hierarchy levels. Unfortunately there is no * reliable information available, unless all possible CPUs have been --=20 2.51.1