From patchwork Sun Feb 11 13:52:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Costa Shulyupin X-Patchwork-Id: 199452 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1932855dyd; Sun, 11 Feb 2024 05:52:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWxtrRSHtF6wlHGWptcEzPulTIxPl8lB6kpdtyKdCb+FWLWvIogAeEdvqaJVSkhxoJQzEyEuAyeHyUrq60ObaXdSDVW6A== X-Google-Smtp-Source: AGHT+IGB3LhfKe7C0kncCrbO4tsGflfyZPsb/UVy0XWg3lHx306IW0+c4Dne+VmVhst8zmr5JlT0 X-Received: by 2002:a17:906:344e:b0:a38:4c33:cfde with SMTP id d14-20020a170906344e00b00a384c33cfdemr3162158ejb.29.1707659565687; Sun, 11 Feb 2024 05:52:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707659565; cv=pass; d=google.com; s=arc-20160816; b=f2ljfjOgwBtVn7S1nrSJtOHrK56TvF37Y21PezOkm6tPP4k01IvdQVz/977qqdqtqb e8zONlsHuD/iw+bmU/Dc2TfIzD8ID2lpesDHS+bL/xCvaSmfxWDbjJizA2di4/Vzrcgm ajzJeLLUKqIvzrEWOpO8WcGfgYPIPVuMeK6zkaPAn8s6SsiDSyXioVGtGLOHxAuI+f3G LO0Fy3JQwUPM5wAmnUTGcDhBZn90xUkofVL6hMuA0LghA1A3AFQIURvtZJMfLurWzqkP aTACKqNSvN47wXWoELBOu+t22pNHtdc4+3M3PUvzDDVPxOsvC680jTX6iEh+vAla3ojn vLlw== 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:message-id:date:subject:cc:to :from; bh=HlgapUubE5TgwcjYU1S02NneOF2XqCpP/rByk6oNb28=; fh=HFvMJrORokUcQvqBRXJeh4rU4OhupPmCRescomD7rRI=; b=OnnuBXOhjgi7rCqDJz2zF/5TQSjswUKznKNJUKqFY6b5botl9W38yLGlPaIMdhLiyd H2GvI/gnbkeoBSj8T2CfGZo5I893lBsnKY0idFewLq2nj7vri5vj/icGzMLVR2Y/d+X0 C3WLNI0tF25MAKflY7ADT91JkB3AHCY/lP7csqL2RessLECzgnwkIgf+lYzCwGH7h3RN mAFft/yyqTodY5kTFN+faer+stiODnjnINznZXeEY/4lSxJ+PsJm8QIS5uyx3OPOjk4Q byEyJ3UOCF3p6qLssrla+BVlROKLk84pSc+YuXbKrZ3rwB7smKhhKyPvij7rRLiG/xEW AKcg==; 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-60790-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60790-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCUy48ofD09jSykyMUIKfCsRMx37SFWrmmKebWXyah3EcjAyEKM1UqLSE/TkH2loymRAlAuDHVvwhn2oG6oQtHj0XQTIGA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a22-20020a1709065f9600b00a38536ded36si2944470eju.122.2024.02.11.05.52.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 05:52:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60790-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-60790-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60790-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4EA761F24279 for ; Sun, 11 Feb 2024 13:52:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56B645B5D5; Sun, 11 Feb 2024 13:52:30 +0000 (UTC) Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) (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 74FF35A4C7 for ; Sun, 11 Feb 2024 13:52:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707659548; cv=none; b=tJMXn8XAwK2UqxCoSbs82tNABHgvLpdOWYPrLIqiqmYXCxC13uzqs441w547wuq9oJPTWb9vsFp8L4/SCH1rS4cCTW+9CE4NLkRgedLgHpcK6A0TlqgE4AP1l1X8ovLIApvdpIJiHckargsqiaUELUu7cLo6FPI0w7WO4/tH1hw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707659548; c=relaxed/simple; bh=0X++hbDOXD50Nw+a1vwueSJjviqMRnGrd6GZTpX5e70=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Q+SyLdA41bCpfSZuUSKHcOdk0+L3dWFAsS/04fyDffBg+v/9HVm8sUM8T+sTxRjEPow1qNRUldo6oFJZNveV7rp1IkPLkPwfxrDLERqlXIJQnWCdajdA7o0s3C9q+H1TORWvIsqFGcz+n/UTxHdyqMWWPpDAjhAWksLF7p2gasU= 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.219.170 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-yb1-f170.google.com with SMTP id 3f1490d57ef6-dc74aac68a1so2404153276.2 for ; Sun, 11 Feb 2024 05:52:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707659546; x=1708264346; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HlgapUubE5TgwcjYU1S02NneOF2XqCpP/rByk6oNb28=; b=R+CKU7cp6o5fLcNDp10hzMx6jvGGjw6pxNeUO1Qgz8baBl1tMBEls3SG9ps11QJCC1 iymwFhMKPn4B33Di5k2w9iLa4elTmCqBehdWdiQ/SDDL2JX3gx9UAYfG4pGQxAA9REUH c/HN/TwAA7+cZm2z1pCQBwBR1jGBnngelqTNdjhavxByOoFRNF6iymUcEeqB3XJ2avS3 SuMPijrrqOz66dUTqEAoRzD5JweAILHH6eFml9BZdUj3as0V44ZJcysGZqx0Ag7YDIvb kUlTctUV4cr3UDYAg0BxxdKgJ1mo9tqz0lct/2mCE6pDNseXLh1Bg/uLVpYYsT7T3p0j 9c2Q== X-Forwarded-Encrypted: i=1; AJvYcCWajvKLtDkwrd+YYFe4Bspb2njG0Dp1aH/vktFLFKPpkQfQmgMG55+H3lgiRY7LZNL+LWzF29jmBixLf1EeKwZXKcl9GG0JTI3DPvdG X-Gm-Message-State: AOJu0YwhCMOrD3So7cz+NaDhKN+VesW+4kRYVX18UjmfpyIDASzUN6s/ fb0CYD3/Qo4/QYGaZ+krIrDrWatqqgEYy2p/Ap+wr8U1bddPdE96 X-Received: by 2002:a5b:14d:0:b0:dc2:2f7a:6dfe with SMTP id c13-20020a5b014d000000b00dc22f7a6dfemr3336242ybp.52.1707659546261; Sun, 11 Feb 2024 05:52:26 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUCOgrFDt8NAgbrC6IkzrTbQRaS6+30OLoNziOsuE6wbWNWIuQQq4thPr2OaK8VR6lcmU3vE0Zbt2tbdmPf5wJFAsWwmlFisanVmYX2BZBpzNaglp7gktHl0sGGEsbEkVE= Received: from costa-tp.redhat.com ([2a00:a040:1a4:9a9f:19ad:6a8:f94b:c9c]) by smtp.gmail.com with ESMTPSA id ld27-20020a056214419b00b0068688a2964asm2717380qvb.113.2024.02.11.05.52.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 05:52:25 -0800 (PST) From: Costa Shulyupin To: Waiman Long , Thomas Gleixner , linux-kernel@vger.kernel.org Cc: Costa Shulyupin Subject: [PATCH] hrtimer: select housekeeping CPU during migration Date: Sun, 11 Feb 2024 15:52:13 +0200 Message-ID: <20240211135213.2518068-1-costa.shul@redhat.com> X-Mailer: git-send-email 2.43.0 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: 1790610837014934600 because during CPU deactivation a timer can migrate to isolated CPU and break CPU isolation. For reference see function get_nohz_timer_target, which selects CPU for new timers from housekeeping_cpumask(HK_TYPE_TIMER) Inspired by Waiman Long Signed-off-by: Costa Shulyupin Reviewed-by:  Waiman Long Reviewed-by: Frederic Weisbecker --- kernel/time/hrtimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index f82997cf53b6..460d916e24b7 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -2227,7 +2227,7 @@ static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base, int hrtimers_cpu_dying(unsigned int dying_cpu) { struct hrtimer_cpu_base *old_base, *new_base; - int i, ncpu = cpumask_first(cpu_active_mask); + int i, ncpu = cpumask_any_and(cpu_active_mask, housekeeping(HK_TYPE_TIMER)); pr_debug("ncpu=%d, dying_cpu=%d\n", ncpu, dying_cpu); tick_cancel_sched_timer(dying_cpu);