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 6F1F63D8126 for ; Tue, 21 Apr 2026 14:22:21 +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=1776781342; cv=none; b=Oz0j/iyrXoPRER7G0osAFG7/P0grro3pLsQzrBqC5WX1k9OqZfUt5GdxS9Pd0ATRmzvPyeAoDH24AZKMUBLuthCihuLhYyFb2/i+S9h3Hv+zeIhwE3JbohN3nxnm324zsYpkiRP/JGpoeEtSe1TlHO0AISTLgxBD/HzIZcq9HVA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776781342; c=relaxed/simple; bh=r+fOxns+jmr0M0EyFWMcq/R4Njx5zASRZz9Y1X+qpvY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=pGVc2/v0LGfqpSnpYt024ed7HMdIiHPEXiEkAiX1gn4TYNj47vlFOe1pDrXyrWN/8fSZvHlZH56GyeB4ABJ2O1xALUKeowwp1g6w+2rU3GyUwFCttX2xw6sY+TTOrLaFjrcdhL7x26lZdc0tlQ1y0b8PLzwsQAxnaAYoEHgae8g= 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=E4JF5UZD; 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="E4JF5UZD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776781340; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dWjWRROifEq97+No/LV67J9L8ZDl4T0+6eN/kJ0ejKE=; b=E4JF5UZDkBMkH2Xc7sWg3Nb7AEoCbZEry5jZfxFNzGq+7MeTdtGKa4/O+3J4819cbk814L 8FPf/NW2KZvHTxV1Ht3Qdvf11bdDGhUxaTJv7ULMw/ItEuFoxLyI2knsKST6sHYcu0BEdG iNNnmD1LMYzADsDB1aubJ+mmxxZgUBs= Received: from mx-prod-mc-01.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-36-t9Gcpr49M6KwwY5DsipUnQ-1; Tue, 21 Apr 2026 10:22:18 -0400 X-MC-Unique: t9Gcpr49M6KwwY5DsipUnQ-1 X-Mimecast-MFC-AGG-ID: t9Gcpr49M6KwwY5DsipUnQ_1776781333 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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 98BA819560B9; Tue, 21 Apr 2026 14:22:11 +0000 (UTC) Received: from [10.22.81.187] (unknown [10.22.81.187]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 187903000C26; Tue, 21 Apr 2026 14:22:02 +0000 (UTC) Message-ID: <149748c4-7fbd-47a5-acc9-c480033e1907@redhat.com> Date: Tue, 21 Apr 2026 10:22:02 -0400 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 05/23] tick: Pass timer tick job to an online HK CPU in tick_cpu_dying() To: Thomas Gleixner , Tejun Heo , Johannes Weiner , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Catalin Marinas , Will Deacon , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Guenter Roeck , Frederic Weisbecker , "Paul E. McKenney" , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Chen Ridong , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-hwmon@vger.kernel.org, rcu@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, Costa Shulyupin , Qiliang Yuan References: <20260421030351.281436-1-longman@redhat.com> <20260421030351.281436-6-longman@redhat.com> <87zf2wbsli.ffs@tglx> Content-Language: en-US From: Waiman Long In-Reply-To: <87zf2wbsli.ffs@tglx> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 On 4/21/26 4:55 AM, Thomas Gleixner wrote: > On Mon, Apr 20 2026 at 23:03, Waiman Long wrote: >> In tick_cpu_dying(), if the dying CPU is the current timekeeper, >> it has to pass the job over to another CPU. The current code passes >> it to another online CPU. However, that CPU may not be a timer tick >> housekeeping CPU. If that happens, another CPU will have to manually >> take it over again later. Avoid this unnecessary work by directly >> assigning an online housekeeping CPU. >> >> Use READ_ONCE/WRITE_ONCE() to access tick_do_timer_cpu in case the >> non-HK CPUs may not be in stop machine in the future. > 'may not be in the future' is yet more handwaving without > content. Please write your change logs in a way so that people who have > not spent months on this can follow. > >> @@ -394,12 +395,19 @@ int tick_cpu_dying(unsigned int dying_cpu) >> { >> /* >> * If the current CPU is the timekeeper, it's the only one that can >> - * safely hand over its duty. Also all online CPUs are in stop >> - * machine, guaranteed not to be idle, therefore there is no >> + * safely hand over its duty. Also all online housekeeping CPUs are >> + * in stop machine, guaranteed not to be idle, therefore there is no >> * concurrency and it's safe to pick any online successor. >> */ >> - if (tick_do_timer_cpu == dying_cpu) >> - tick_do_timer_cpu = cpumask_first(cpu_online_mask); >> + if (READ_ONCE(tick_do_timer_cpu) == dying_cpu) { >> + unsigned int new_cpu; >> + >> + guard(rcu)(); > What's this guard for? > >> + new_cpu = cpumask_first_and(cpu_online_mask, housekeeping_cpumask(HK_TYPE_TICK)); > Why has this to use housekeeping_cpumask() and does not use > tick_nohz_full_mask? The RCU guard is for accessing the HK_TYPE_TICK(HK_TYPE_KERNEL_NOISE) cpumask. tick_nohz_full_mask cpumask is actually the inverse of HK_TYPE_TICK cpumask. Yes, I could use cpumask_first_andnot() with tick_nohz_full_mask. If we make tick_nohz_full_mask an RCU protected pointer, we still need the guard. Cheers, Longman