From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 019BB34B1B0 for ; Fri, 20 Feb 2026 14:03:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771596191; cv=none; b=Us3DkOWzZoBsHd4jLDacIRuMAPxfEYarYiH0mkc7oMbbWXTsd04WJBcEYcFdb5K8MwwS0WYl1bXifKpoz0M+m1B4DF2HbAPucXs5SDe3O3gjJmCK5D+hoVThxwJK8Tyb1wrWyC3bImZe6ueNqps9vc38Tz2c2gCHkldkwtAkYUQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771596191; c=relaxed/simple; bh=na12x+C9IaBCMTEeLOYP87TgLkQe368XgBS02ZIOEWU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=m5DjqJRNRFwOds4YF5XcKOplxqxvrTh4ts13tYRq0qy4J997wFnd+pS/zBhEj3sc/gnnojhBthCdz8F2zftamYoIjCl50Vbizkcar4aQ457HfV8luZhqR9r8ZuPLFBs3n8ts6qwJmWausWb3A50A6FNsO3DXPXtXrS31wE/xmrg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=geJNgHvU; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="geJNgHvU" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=DxNneeiOSkymJvPPVS/2cJSp8ycBarFBWcijlzNDUtA=; b=geJNgHvUsdjmewCeLboetab0EY j37n00okuTdEBfq4MgYR+bnJq8QNV89be/q+zjWnva7x97h0l5StC16QiWVtfqqoEgK+TCbLV6rc2 j/WJAeolRiK7RXaeteaEfkq7H4QXhXg53+TML8KxJK//p6quImx38bmu37vEwIX1lnGnqSSK+Q4J5 pzmf4W0nVJN1gLGwfMKHOgi8KFhCyibK2YfHaGoX2e1rzuUHPFh5y5QaWPa7yU/42W+VxZpb97hg+ d7lSJ7bng04HRSyeYZxfDJ02WnUqkrH5tFSfvRmgFulP2v2/KLgaY6q/BG/eWryigb+Bq/ILnhd3i MPph2CzA==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vtR5d-00000009aq9-3oX7; Fri, 20 Feb 2026 14:02:42 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 11017301BD5; Fri, 20 Feb 2026 15:02:41 +0100 (CET) Date: Fri, 20 Feb 2026 15:02:41 +0100 From: Peter Zijlstra To: Tim Chen Cc: Ingo Molnar , K Prateek Nayak , "Gautham R . Shenoy" , Vincent Guittot , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Madadi Vineeth Reddy , Hillf Danton , Shrikanth Hegde , Jianyong Wu , Yangyu Chen , Tingyin Duan , Vern Hao , Vern Hao , Len Brown , Aubrey Li , Zhao Liu , Chen Yu , Chen Yu , Adam Li , Aaron Lu , Tim Chen , Josh Don , Gavin Guo , Qais Yousef , Libo Chen , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 08/21] sched/cache: Calculate the percpu sd task LLC preference Message-ID: <20260220140241.GT1395416@noisy.programming.kicks-ass.net> References: <41f8e91b70060e7697840163b80c3dc097aabb34.1770760558.git.tim.c.chen@linux.intel.com> <20260220110222.GP1395266@noisy.programming.kicks-ass.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260220110222.GP1395266@noisy.programming.kicks-ass.net> On Fri, Feb 20, 2026 at 12:02:22PM +0100, Peter Zijlstra wrote: > On Tue, Feb 10, 2026 at 02:18:48PM -0800, Tim Chen wrote: > > static void account_llc_enqueue(struct rq *rq, struct task_struct *p) > > { > > + struct sched_domain *sd; > > int pref_llc; > > > > pref_llc = p->preferred_llc; > > - if (pref_llc < 0) > > + if (!valid_llc_id(pref_llc)) > > return; > > > > rq->nr_llc_running++; > > rq->nr_pref_llc_running += (pref_llc == task_llc(p)); > > + > > + scoped_guard (rcu) { > > + sd = rcu_dereference(rq->sd); > > + if (valid_llc_buf(sd, pref_llc)) > > + sd->pf[pref_llc]++; > > + } > > } > > > > static void account_llc_dequeue(struct rq *rq, struct task_struct *p) > > { > > + struct sched_domain *sd; > > int pref_llc; > > > > pref_llc = p->preferred_llc; > > - if (pref_llc < 0) > > + if (!valid_llc_id(pref_llc)) > > return; > > > > rq->nr_llc_running--; > > rq->nr_pref_llc_running -= (pref_llc == task_llc(p)); > > + > > + scoped_guard (rcu) { > > + sd = rcu_dereference(rq->sd); > > + if (valid_llc_buf(sd, pref_llc)) { > > + /* > > + * There is a race condition between dequeue > > + * and CPU hotplug. After a task has been enqueued > > + * on CPUx, a CPU hotplug event occurs, and all online > > + * CPUs (including CPUx) rebuild their sched_domains > > + * and reset statistics to zero (including sd->pf). > > + * This can cause temporary undercount and we have to > > + * check for such underflow in sd->pf. > > + * > > + * This undercount is temporary and accurate accounting > > + * will resume once the rq has a chance to be idle. > > + */ > > + if (sd->pf[pref_llc]) > > + sd->pf[pref_llc]--; > > + } > > + } > > } > > FWIW, enqueue/dequeue must be with rq->lock held, and thus preemption > disabled and IRQs off. That RCU section is completely pointless. That is, use rcu_dereference_all() and observe the warning go away.