From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 028783932F2 for ; Fri, 15 May 2026 06:50:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778827806; cv=none; b=Dp6lYBM11visbiCHHpHy85TRr1/s6/m+BQdQf/Ol29bUnf18poH0/Bl1LyebQD3qURdaSkQG0SOdrZTbWj2hjjDX80wHrYnLGYzhG/QKWO7tNsKoFazGtd2WMVrg129277a41Dm6jFGI4OjGCbyrMEaTNPHg7itqxRO2FMMMAeU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778827806; c=relaxed/simple; bh=Mknb0wSl/zuzvo8J/YObdtLL8WIywq8O1YiEjHNnccQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=bWCDEbf0IUZ+JJgjzlXWqI/r9e7qUIkgu2mgdvX54AbZeP+7fa4kI4uWMoOo8u4qFS0LrOaFc6yoLTTVnSalO5CKgoAZxmQs9QExkafrBxydOUfyuImo/WzknWHur/2IdfSs7DwoBh35u0N1kWneZxlZ1WSxNekj2Ovkp0qYp80= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Z/IxU3Ao; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Z/IxU3Ao" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64EJ73Vp575999; Fri, 15 May 2026 06:49:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=9sl3UI fIllvsq8AEMv+phu2d9/kDXpgVWv7P3z27/Fc=; b=Z/IxU3AoyTVIy2XMBdPrdE GDNLO0IEz58kP/gl3qDp4qvapm6sDzopXcehBIqZhObbmqtN8u/i58cZJgRqzIwP I1kXzz8NS/muUPLSOZRpBkyKUZ5y4Mk2qK2vBmrg0wAkp4TYRm1Wf/QVrUEuTFaQ +wthIo7p1V0HbaOqlSgC0LGV1Yrl0zI3fdG+tmOQpRF/iNL8/WbTBrlmQkCB/RzU k5Tb9BWShds6807GXtxsWseRq50ZI3THIM7Yj6J8H1qtaNFaJXt7IPwwnq82kJ5k lJijKQDcNm0RoLI4IlURNWN1sz3w9fV+xRSflJC7MSS1oTkY8pN9PvuYQ8SOVGYA == Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e5m92hqhn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 May 2026 06:49:23 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64F6O9ST013373; Fri, 15 May 2026 06:49:22 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e5kvcj3h6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 May 2026 06:49:22 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64F6nLut45547790 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 May 2026 06:49:21 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 305372004F; Fri, 15 May 2026 06:49:21 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6595D20043; Fri, 15 May 2026 06:49:17 +0000 (GMT) Received: from [9.124.209.124] (unknown [9.124.209.124]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 15 May 2026 06:49:17 +0000 (GMT) Message-ID: <4b04aade-8474-4e37-991e-16f2faedaf0c@linux.ibm.com> Date: Fri, 15 May 2026 12:19:16 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/5] sched/fair: Drop redundant RCU read lock in NOHZ kick path To: Andrea Righi , K Prateek Nayak , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot Cc: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Christian Loehle , Phil Auld , Koba Ko , Felix Abecassis , Balbir Singh , Joel Fernandes , linux-kernel@vger.kernel.org References: <20260509180955.1840064-1-arighi@nvidia.com> <20260509180955.1840064-2-arighi@nvidia.com> From: Shrikanth Hegde Content-Language: en-US In-Reply-To: <20260509180955.1840064-2-arighi@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE1MDA2NCBTYWx0ZWRfX9egxMvIkqRNv LIZ8JDV4yphrwCx3BXSooaf4iXsvd03Vmv+Hiv0pg3b0HZUX02lfdTzX4TdNrsN4aNv4QBnc+ks kc2uYlJcY+qziL7ps/1TEGW4rqJ9nroGiWnSh3Ux41HfTEIcfX8z2RiMphFRIy8M1p8a84rGqSp AewY6tQk/+KNi8OeVWDSgjX/w0R3VPo8Lg3J3H//HatDK3JyW5sjXPkfJDmbC+b2F1y77keaWeL 85UBFp+AwyP0cNhvEQRoZ2P3kc/CxXzNo5yKPpAU2kGewGEBAvld8VY0T/YjviseeMUbt/4tbEW XQUVFIc8xsA5Pr0hUBqEeeaN/AGHBruxZwZFlQ2Pdh49FI8+RBPwxabIaGm1Y1oQGYmkgF8tk33 uMO4ZWJHrt9WYLO6mPevztikmpO4KvRi0qrLQm2WpY7nQ1jmhx4QxVfmVZ0fefuuCxQDeQU9bCI z+tXoTUvu2FdG9HPPtA== X-Proofpoint-ORIG-GUID: _wxNChFswpf07i68vdHPPlCuAShxhQiu X-Authority-Analysis: v=2.4 cv=aNnAb79m c=1 sm=1 tr=0 ts=6a06c1f4 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=KKAkSRfTAAAA:8 a=7CQSdrXTAAAA:8 a=zd2uoN0lAAAA:8 a=Ikd4Dj_1AAAA:8 a=N5nGaBOGbmYiavW_MYMA:9 a=QEXdDO2ut3YA:10 a=cvBusfyB2V15izCimMoJ:22 a=a-qgeE7W1pNrGK8U0ZQC:22 X-Proofpoint-GUID: tjZjeXDj8HM_tbSN5XiNcofIDXQhjTuE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-15_01,2026-05-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 clxscore=1015 adultscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605150064 On 5/9/26 11:37 PM, Andrea Righi wrote: > nohz_balancer_kick() is reached from sched_balance_trigger(), which is > called from sched_tick(). sched_tick() runs with IRQs disabled, so the > additional rcu_read_lock/unlock() used around sched_domain accesses in > this path is redundant. Rely on the existing IRQ-disabled context (and > the rcu_dereference_all() checking) instead. > > The same applies to set_cpu_sd_state_idle(), called from the idle entry > path with IRQs disabled, and to set_cpu_sd_state_busy(), reachable via > nohz_balance_exit_idle() from two contexts: nohz_balancer_kick() (IRQs > disabled, as above) and sched_cpu_deactivate() (the CPUHP_AP_ACTIVE > teardown, which runs under cpus_write_lock(), so it cannot race with > sched-domain rebuilds). In both cases the rcu_dereference_all() > validation is sufficient. > > No functional change intended. > For this patch, few more comments below. Reviewed-by: Shrikanth Hegde > Cc: Vincent Guittot > Cc: Dietmar Eggemann > Suggested-by: K Prateek Nayak > Reviewed-by: K Prateek Nayak > Signed-off-by: Andrea Righi > @@ -12868,17 +12860,13 @@ static void nohz_balancer_kick(struct rq *rq) > static void set_cpu_sd_state_busy(int cpu) > { > struct sched_domain *sd; > - > - rcu_read_lock(); > sd = rcu_dereference_all(per_cpu(sd_llc, cpu)); > > if (!sd || !sd->nohz_idle) > - goto unlock; > + return; > sd->nohz_idle = 0; > > atomic_inc(&sd->shared->nr_busy_cpus); > -unlock: > - rcu_read_unlock(); > } > > void nohz_balance_exit_idle(struct rq *rq) > @@ -12897,17 +12885,13 @@ void nohz_balance_exit_idle(struct rq *rq) > static void set_cpu_sd_state_idle(int cpu) > { > struct sched_domain *sd; > - > - rcu_read_lock(); > sd = rcu_dereference_all(per_cpu(sd_llc, cpu)); > > if (!sd || sd->nohz_idle) > - goto unlock; > + return; > sd->nohz_idle = 1; > > atomic_dec(&sd->shared->nr_busy_cpus); > -unlock: > - rcu_read_unlock(); > } > > /* I was looking at other users of sd_llc, i.e test_idle_core and set_idle_core. They have rcu_dereference_all. So callers need not call rcu_read_lock/unlock if the irq disabled/preempt_disabled. One more place would be update_idle_core. I think it is called with interrupt disabled in __schedule path. And in sched_ext, scx_idle_update_selcpu_topology, It seems to be tied to cpu hotplug and by same logic of cpus_write_lock held, one could remove redundant rcu_read_lock there as well. No?