From patchwork Thu Feb 22 20:08:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Costa Shulyupin X-Patchwork-Id: 205040 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp195670dyb; Thu, 22 Feb 2024 12:35:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXPZQuaXbCNg0t0gJDZWNC2gVONBQVCvCSR9Azdw//velV9zQpl6t6wxNi8Isjpy2wpcKiqnaEaCY/JfMydzCSycD9nlA== X-Google-Smtp-Source: AGHT+IEL+45HvClwzHgIyySNct7KKcPvUYzfv2rj0q3yU+wC4Fl7D9HQbZOcvQGpDBtiv9DX9QMC X-Received: by 2002:a17:902:eb8f:b0:1db:b36c:715f with SMTP id q15-20020a170902eb8f00b001dbb36c715fmr24598605plg.24.1708634131013; Thu, 22 Feb 2024 12:35:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708634131; cv=pass; d=google.com; s=arc-20160816; b=NTIIn0yeRM1/RroZrl6cdC2MkmWdYg1oPbekSwi4MDO08I21gaIpDsh8E2WcvOViUz 2G2JJFnXPbSiKL/XYhEfQj22LB4qXcx6AgP64M6Tf7x26ewu2bzZzES/0oJWbf7YGk6B 5zi414uiPcFZlwZBJcSZ/sQ57M3oWXwQ+qomAu8q6A6UFS1/nnIOBuWPulLfcl1m12zb Pst5R1NKkecqLky6qy8wU7DDAe6zXzFwkkC27QvAVdPgSVmMycXXftCExn9I6DrLLGKg H7NwbYY87ifeowTtTKNuQ0XJ/60nAi7z3jApKfl6+kBopLUERPsGEXYaRBSnMxYQtcA2 QXUg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Cf+E8SiQd8DMBNrS3dxIEYFtpcnTw8yGOi5ReErHUfc=; fh=3WgNPOAMQh+V/GQA5Hoa07b0tB0M4kp73FkOHPOQbKE=; b=BtEbq6nfEDj5AEGJh7xvTAdB5koJMIp8gdhr9R/L0UvzDLzn6YSGUx26gkPMx265sX cYRV0tcNN3JJ8rOHwt5hDKnIvMjsjYZ+1q8BEpIPaWANF6K3bw8mOAbxLWfZOeBftQJi U0nG/jltq04bxZtmEZRQTmulwPt+pjuXXpU1R6AYzJNk7b9oqe/qH8UYNZkzWBgrWlHt B7rUCQmTIYlvU6kx13ndy9OTDO/1QDRC65Oq+9cbb2XwnyMBFWR3hwXCwf8xDP/sHiMz 2YZWt7YYAFvuLiiPrmhpNPNntwX66MbsTumyEtx0eEsQ4eqx6q8luYOQNsq6iFQy6Jkk gcMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-77301-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77301-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t3-20020a170902e84300b001d78a87de63si11038656plg.205.2024.02.22.12.35.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:35:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77301-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-77301-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77301-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8E7E8B25355 for ; Thu, 22 Feb 2024 20:09:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C80E56AF9D; Thu, 22 Feb 2024 20:09:06 +0000 (UTC) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4E4114B823 for ; Thu, 22 Feb 2024 20:09:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708632545; cv=none; b=rNt9RBSj/XKRePjmFDbEMpqPGedfFKHap0uQQy346fGKYNBOCEi1jcZJCuUwDDQ/kG4P9xUG1Vp2M2Lhp0ehFHe5vl3P2KNcw958wkepapnBeL7ELIaPTxvlfnmS55nmrU8iqz1uXGBw5pQJuxlirXCrzi2yb+e/FeG/+oc1P9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708632545; c=relaxed/simple; bh=jhhohCcQBUbtJzlS98x9WZ/Tb4NtRWXAlOOqjxveNTc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hVaqCDq4HAhNd0tvVRcONE6FmFnRjWdakRTqBVUan2Rru2ayYMBRH6KovNPhMe/qMmy6CcCOyXCMBen+NyJ7R1fuMtudt0Z4iBUeJFKt8qz9JH6ls0GLK73VetH96HjPCKxTteSgCpIRkt93it9u3Aba/ZngkZ7l2j7IhHQ3c+E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-33d4c0b198aso73161f8f.2 for ; Thu, 22 Feb 2024 12:09:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708632542; x=1709237342; 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=Cf+E8SiQd8DMBNrS3dxIEYFtpcnTw8yGOi5ReErHUfc=; b=MS6S5hgeK6sNrrIVpMv3mDZGLlAl0wV9SR5Vr1A23M9VeJwL7PC/mKl3mpnhLPEw7c 4M7NZNKwrvNl4tVCW7S3SQsvTwwfNVq0N+6APbefQJCYlr9zB9XrP8/mE4uRuOskHcbu BVk6PTxCKMTeqc9IX6/ovE/hKyAfZVtkpmnDmHBzst+2wVFMGdDjYww816VFsof5DX0m hwXq/jFz35vSG1J6elYfaqFvqndsWi7ObmF4fWWLX4GJ90SmTMt+plwBWsyhW+vq0aHz YfgdrHoWbuvw+bVPuwOU5hEy7HUOAS/KwBZcRPanAl6Xkd16gvEmffdEHysmJ1qk4+vw nyVA== X-Forwarded-Encrypted: i=1; AJvYcCUvx6e3oD0rS2Q8ljLBJagTwiVPw9NzBZLkTlG+g27aaJ14/3Blw6xnewDD2C5lkL+RuvIE3S0bYRtk5UomapCtcQe1LyEOTUc/9czT X-Gm-Message-State: AOJu0YxEp2/MVZapV8l0pvczEmIR5ivsgXaDDljEiHiIS5ef+1F5KHyT etNKp9HNFBPeOf/zYZ2F+gbtMqVq1DU4DHHjLEDZN5pLUCIRWYYA X-Received: by 2002:adf:fd11:0:b0:33d:174b:6a3c with SMTP id e17-20020adffd11000000b0033d174b6a3cmr116847wrr.59.1708632541633; Thu, 22 Feb 2024 12:09:01 -0800 (PST) Received: from costa-tp.redhat.com ([2a00:a040:1a4:9a9f:19ad:6a8:f94b:c9c]) by smtp.gmail.com with ESMTPSA id k2-20020a5d6e82000000b0033d4c3b0beesm102978wrz.19.2024.02.22.12.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:09:00 -0800 (PST) From: Costa Shulyupin To: Thomas Gleixner , linux-kernel@vger.kernel.org Cc: Costa Shulyupin , Waiman Long Subject: [PATCH v4] hrtimer: select housekeeping CPU during migration Date: Thu, 22 Feb 2024 22:08:56 +0200 Message-ID: <20240222200856.569036-1-costa.shul@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240219143301.4174966-1-costa.shul@redhat.com> References: <20240219143301.4174966-1-costa.shul@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790610837014934600 X-GMAIL-MSGID: 1791632742963196959 During CPU-down hotplug, hrtimers may migrate to isolated CPUs, compromising CPU isolation. Address this issue by masking valid CPUs for hrtimers using housekeeping_cpumask(HK_TYPE_TIMER). Suggested-by: Waiman Long Signed-off-by: Costa Shulyupin Reviewed-by: Waiman Long --- Changes in v4: - fixed description Changes in v3: - fixed compilation errors Changes in v2: - [v1] https://lore.kernel.org/all/20240211135213.2518068-1-costa.shul@redhat.com/ - reworded and rebased on next --- kernel/time/hrtimer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 5a98b35b0576..1fd106af747d 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -2225,8 +2226,8 @@ static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base, int hrtimers_cpu_dying(unsigned int dying_cpu) { + int i, ncpu = cpumask_any_and(cpu_active_mask, housekeeping_cpumask(HK_TYPE_TIMER)); struct hrtimer_cpu_base *old_base, *new_base; - int i, ncpu = cpumask_first(cpu_active_mask); tick_cancel_sched_timer(dying_cpu);