From nobody Wed Oct 8 17:31:55 2025 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 4B2D0EED8 for ; Thu, 26 Jun 2025 11:52:03 +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=1750938725; cv=none; b=kxM6y/PUOEIHZckIjR0QYNyzvUvkuRhqkoNCJTXwiwGtC5Xs71VWtpMKww6ovmibs27NPSWdHtc88nE/sGWHjlnfLqoRN474u1+AYnsGmau3YgMfLTfNA/twhHeotape68BNJaZdgRSqK0x2mPE/ZKw0GbBkleB43NlKU/CNVyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750938725; c=relaxed/simple; bh=ce6iRjn9pul9QG7XorpgiMsYyBmuSyYBT8LejCwxKXc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nQZBvDTldi7wjtgEuC8YU+cZsqUgOOgF00EAkGFsbk2eTjx13/zb9ox3j54sWPbdOH8iLHN1UN+QbH70nJ7NChzwrIUWKLkosrdMEKiQBt0J90Zw4yV1MtPjn4bdA+Fl7iYGGNRRpyo+cRY7p/6i5HZbz1wUzmelFc3oLULrvEE= 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=WeFhqdN7; 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="WeFhqdN7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750938723; 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=rroHzPSM9c/tuaqn61ZWuV8hc+Kj0T3l/+cNWXPhUXM=; b=WeFhqdN7NabQO6xqAR0tpwhtBvd+GkSEuv3vIoa7LN7bU6ECLW6gmngU55fsqF2IyB9z6r g2kG1f+EgTHQxbMumbswALOTw00h+WRTi2Cfj1iO/ujX8OUbN57niIeFONq1+FJ2a2d/N5 w9LjRMNNBniXBtwcF19qTWwZOIQ8A4Y= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-688-5THNaz6lMimD9yU2JDvDwQ-1; Thu, 26 Jun 2025 07:52:00 -0400 X-MC-Unique: 5THNaz6lMimD9yU2JDvDwQ-1 X-Mimecast-MFC-AGG-ID: 5THNaz6lMimD9yU2JDvDwQ_1750938718 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CD8D61809C85; Thu, 26 Jun 2025 11:51:58 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.com (unknown [10.45.226.174]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 58CBC30002C0; Thu, 26 Jun 2025 11:51:55 +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 v7 3/7] timers: Use scoped_guard when setting/clearing the tmigr available flag Date: Thu, 26 Jun 2025 13:48:56 +0200 Message-ID: <20250626114900.106061-4-gmonaco@redhat.com> In-Reply-To: <20250626114900.106061-1-gmonaco@redhat.com> References: <20250626114900.106061-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.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Cleanup tmigr_clear_cpu_available() and tmigr_set_cpu_available() to prepare for easier checks on the available flag. Signed-off-by: Gabriele Monaco --- kernel/time/timer_migration.c | 38 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/kernel/time/timer_migration.c b/kernel/time/timer_migration.c index 2ec003c2bbbea..a51af4acc5e3c 100644 --- a/kernel/time/timer_migration.c +++ b/kernel/time/timer_migration.c @@ -1449,18 +1449,18 @@ static int tmigr_clear_cpu_available(unsigned int c= pu) int migrator; u64 firstexp; =20 - raw_spin_lock_irq(&tmc->lock); - tmc->available =3D false; - WRITE_ONCE(tmc->wakeup, KTIME_MAX); - cpumask_clear_cpu(cpu, tmigr_available_cpumask); + scoped_guard(raw_spinlock_irq, &tmc->lock) { + tmc->available =3D false; + WRITE_ONCE(tmc->wakeup, KTIME_MAX); + cpumask_clear_cpu(cpu, tmigr_available_cpumask); =20 - /* - * CPU has to handle the local events on his own, when on the way to - * offline; Therefore nextevt value is set to KTIME_MAX - */ - firstexp =3D __tmigr_cpu_deactivate(tmc, KTIME_MAX); - trace_tmigr_cpu_unavailable(tmc); - raw_spin_unlock_irq(&tmc->lock); + /* + * CPU has to handle the local events on his own, when on the way to + * offline; Therefore nextevt value is set to KTIME_MAX + */ + firstexp =3D __tmigr_cpu_deactivate(tmc, KTIME_MAX); + trace_tmigr_cpu_unavailable(tmc); + } =20 if (firstexp !=3D KTIME_MAX) { migrator =3D cpumask_any(tmigr_available_cpumask); @@ -1478,14 +1478,14 @@ static int tmigr_set_cpu_available(unsigned int cpu) if (WARN_ON_ONCE(!tmc->tmgroup)) return -EINVAL; =20 - raw_spin_lock_irq(&tmc->lock); - trace_tmigr_cpu_available(tmc); - tmc->idle =3D timer_base_is_idle(); - if (!tmc->idle) - __tmigr_cpu_activate(tmc); - tmc->available =3D true; - cpumask_set_cpu(cpu, tmigr_available_cpumask); - raw_spin_unlock_irq(&tmc->lock); + scoped_guard(raw_spinlock_irq, &tmc->lock) { + trace_tmigr_cpu_available(tmc); + tmc->idle =3D timer_base_is_idle(); + if (!tmc->idle) + __tmigr_cpu_activate(tmc); + tmc->available =3D true; + cpumask_set_cpu(cpu, tmigr_available_cpumask); + } return 0; } =20 --=20 2.49.0