Received: by 2002:ab2:7444:0:b0:1ef:eae8:a797 with SMTP id f4csp61363lqn; Fri, 15 Mar 2024 12:49:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUSFb2AheasNVE8TzqOdAc1z+//RwgMTzD1LYEEZhiy3tR577XwXhPpHpVrMdmE6nvFuqoutQdo0MLj7GTq05z2FJb+JacZDbzvYQnQzw== X-Google-Smtp-Source: AGHT+IHRE+yhIJN8hC6pQ8PTJ95oMLJRNtxQBHDgg6/9j21eVuOF4Dgjkv1/l1TvnN+bSYWIiq7k X-Received: by 2002:a05:6808:1205:b0:3c2:1f28:2482 with SMTP id a5-20020a056808120500b003c21f282482mr5090954oil.29.1710532146076; Fri, 15 Mar 2024 12:49:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710532146; cv=pass; d=google.com; s=arc-20160816; b=UoKdiviEAwZI/dqYXB0PJPYxHo+xIiCPXewTz8jetYf+L/b+18//8C9MwkeM0D583j trC3JjTm+WtHaCQJzq1CQK0fCgqc3CANYoiSuktMj7aP7VdT7xma0/Y915i4nkfXvIbs r8VjctlwJg6+WM2SQNrv2RiFXjzs3x/liu/mWEFBT/PIqCh7TxSAAaCnJvPLsGCOgXEY nnElSYrNc45BydLQPhPIlLvoQQTzKjh8gzAgL9L+1zNxGrh7dRxlhSDYgbloYgOyHb+i DUMJyT9IKaPwOwNpiTJECZ9O3sCCwgwCJAbcQAQ/XFzPAVzfk+fNs3MAeqRyMUw2AmNu uvFg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=VlGf4GFti6vD/YWUm4P47DagUILrU1/1U0j4t5nl/Cs=; fh=++oAUr07K5VR/FRMD0dsJy+S3BcAbLltIXsxW6DbstI=; b=cG1JldO20RGk/tfLBGcWNbmZUif3hFVR/yOvx253tikMAKQcnFO6Ew0oc7MwKgCm5k 8dJGavdxYhsiEr7ysbYr1NtL2Fs9Tn9svhrlPfSIFPDyN8HiGJ1Ignl5TXBz6jWSJcxy LqGtY6jl/Wo3AwbXbsmuq+6ApfNgo9Vfzvg83jzgGPYzWKGyK9D3kqy6VH1AcdjokilF 7bJmXTHFF0jahOo/OOsLU0Ef5R4TJeAFbccTLgQmVcmwjivC16TEfARQra8AZy5HhoFB 0rt2/iFg5ofqUvRBIS1ado/NtXCMvNtAVjFirn15rOkHQf72WdnXti0BVkw4Zg9fFT9J 2yjw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-104856-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104856-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d7-20020a05622a05c700b0042f3074099esi4328962qtb.495.2024.03.15.12.49.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 12:49:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104856-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-104856-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104856-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A64531C21BB0 for ; Fri, 15 Mar 2024 19:49:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D7C754907; Fri, 15 Mar 2024 19:47:40 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0C4035476B; Fri, 15 Mar 2024 19:47:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710532059; cv=none; b=OLI07F328kei0o1UeLk9APlus1nNlIWPSoeeNWa4Ru17eWlVasNq5CYj1fnfVjod7NkXjBipPIYf6qG/e9PPZdvFW3s0MGSZAPP0GAe37/iBLdbuMjwvrTn1weD6JYdN00SlKQM6GOKrn2kvgI7LC0l4cWe6bOpFduYW23nTN94= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710532059; c=relaxed/simple; bh=TKtZ4GMb3j4H7p68J48yfBViqU7V2Ym8JFbsgI4d8Pc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=SRJZsthxFLCqo4BhQVdNV9C0KVkDPeb6N8RnDnC/9yxZv/9IvERRiRJ1WpqvLIhs7721uh7gJH0hVotdrK3C2yLRsZdDQIqOlvcsdQN1U1n8cT8A07jpkG8GCOx+vhY6+Sgo8342reFWyREU3WydVXrzvHXyqDBmM0YdT2u6k88= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 60D92C15; Fri, 15 Mar 2024 12:48:11 -0700 (PDT) Received: from [10.57.11.35] (unknown [10.57.11.35]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BE7DD3F73F; Fri, 15 Mar 2024 12:47:31 -0700 (PDT) Message-ID: <4300a3e5-061d-4daf-b277-631bfc16ff85@arm.com> Date: Fri, 15 Mar 2024 19:47:29 +0000 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: [RFC PATCH v2 4/7] sched/fair: Use CFS util_avg_uclamp for utilization and frequency To: Dietmar Eggemann , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Juri Lelli , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , "Rafael J. Wysocki" , Viresh Kumar Cc: Qais Yousef , Morten Rasmussen , Lukasz Luba , Christian Loehle , linux-kernel@vger.kernel.org, David Dai , Saravana Kannan , linux-pm@vger.kernel.org References: <4f755ae12895bbc74a74bac56bf2ef0f30413a32.1706792708.git.hongyan.xia2@arm.com> <5bb38524-fd13-477f-adde-0a9ac01bfeae@arm.com> Content-Language: en-US From: Hongyan Xia In-Reply-To: <5bb38524-fd13-477f-adde-0a9ac01bfeae@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 15/03/2024 12:31, Dietmar Eggemann wrote: > On 01/02/2024 14:12, Hongyan Xia wrote: > > [...] > >> @@ -7685,11 +7697,13 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target) >> static unsigned long >> cpu_util(int cpu, struct task_struct *p, int dst_cpu, int boost) >> { >> - struct cfs_rq *cfs_rq = &cpu_rq(cpu)->cfs; >> - unsigned long util = READ_ONCE(cfs_rq->avg.util_avg); >> + struct rq *rq = cpu_rq(cpu); >> + struct cfs_rq *cfs_rq = &rq->cfs; >> + unsigned long util = root_cfs_util(rq); >> + bool capped = uclamp_rq_is_capped(rq); > > I try to rerun your tests in your 2 ipynbs (cover letter) but this let's > the sum aggr stack go sideways ... > > if 'sched_uclamp_used' then uclamp_rq_is_capped() will call > cpu_util_cfs()->cpu_util() which then calls uclamp_rq_is_capped() > recursively resulting in a stack overflow. > > Do you have a fix for that you can share? For the time I remove the call > to uclamp_rq_is_capped() in cpu_util(). My apologies. This has long ago been fixed and here is the diff: diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 1ebdd0b9ebca..d5dcda036e0d 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3018,9 +3018,8 @@ static inline bool uclamp_rq_is_capped(struct rq *rq) if (!static_branch_likely(&sched_uclamp_used)) return false; - rq_uclamp_util = cpu_util_cfs(cpu_of(rq)) + cpu_util_rt(rq); - rq_real_util = READ_ONCE(rq->cfs.avg.util_avg) + - READ_ONCE(rq->avg_rt.util_avg); + rq_uclamp_util = READ_ONCE(rq->root_cfs_util_uclamp); + rq_real_util = READ_ONCE(rq->cfs.avg.util_avg); return rq_uclamp_util < SCHED_CAPACITY_SCALE && rq_real_util > rq_uclamp_util; > [...] >