From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.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 E34041A8F8B for ; Mon, 23 Dec 2024 12:58:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734958696; cv=none; b=iDsptIq0MW2kH6A2oJYaI/nbBWMpRybxRbOu+ekfn8io73Ol1+eFPZT/+xpaQ5orlfjhsFPxeQrsCELWY8DnWrGDUSpi0hdcp6v58YYkeq1jD3BacN1PEEJCkwvpcaEi7XHP/02GHYhhw4qkU+9RGST5PvC22RBzvqrnjFdJAPE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734958696; c=relaxed/simple; bh=0PyPZW/HXe1ak8Nd1rtfP9mFQ5nXjYRh1OgSyRQo5XU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Kk19NqdSZOjRwVU/z61HjuOTUuRoPGba88AusdPi1Dz1IBloTYlQ5+9r8pTVjz1cb/04iEGda159X5F5dzI8ex9h+tgVYM8+O8Z2Wff/kD9+1x1j/+DWaqxWoIr/CFXTd+/KU7JoSBrq/7bt1niRzeM8WKiyNxzQzPZf9ExmgCY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=UiKuVz8z; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="UiKuVz8z" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2161eb95317so38378125ad.1 for ; Mon, 23 Dec 2024 04:58:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1734958693; x=1735563493; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=NEMC0IpZ8hP3bqxMdZXlrEunwgSzCpRsNjpk4vw6Fs8=; b=UiKuVz8zsSjb8C/4TSbVLd8GMcB9KqC+aqgvLQzVcX5RPoeShrQpU2cxIpTLk09+in eGYygPESkp1TAKzXxV7Yl4nqioULBku0bW8/HECQE3ccctbmiQ/SwReRVfKU6id/B4co CGDelqz4HT7a9dgvS15n3I9dlStT+b2p1820fzGJNj9MIpjo4PRS8unmP2si+/mqpJwQ XZVdfKEZUkMEGPLDK0dsvYvsDQTUSHDFSsk8UDA8V1RV6TpM7G24QkHkazrAvfGaV7MJ Xx2iSDsMiceXsIp9Oc/I2bE4ebUH3IEBpFrG7IOcyK8VibEgT7jS+kpYx3wJ2n5YoslL z/QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734958693; x=1735563493; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=NEMC0IpZ8hP3bqxMdZXlrEunwgSzCpRsNjpk4vw6Fs8=; b=Sh4Eiq3PeXV3+xncaKOFJ1Anvfarweofqtw7DkS2Pnv00MJoK46WSWT4zdnNSjtiUL 4Z7fbxKeNFqeKju0iS94dDJzSnfd2KtWs4Aieyq9Fyod/uumcn8g1cw1ErppTu2WPiaE f3t9rg39eRjs1v/09jU7Z4cw2VKSLX5qbv7xBg96bBe6s7pH5i21T4104Ilrr8U4xeEA Aaj/QFdJ7Zvtoh0E1ecKk4DFxlyf9wjSpOEM8dEIqLKsoSEVZ5+uwj6Fs8TOYEuReoAc C9vweaX8FLGUSVHNm90Iw9RkStGh9mfSrWAHt6Ca8F0Q9mU45WNMzsXmIUXtImWzXyfb R01w== X-Forwarded-Encrypted: i=1; AJvYcCUrZvoyaSqEs/7tAfSIBDBmfGhbeCc0u0irkp76diLlwdD1bTIIR1AAf15p2ytCoBM8UVastP31jLA/Gg8=@vger.kernel.org X-Gm-Message-State: AOJu0Yzdm4Sgyl40IF3z/Tmv5f3Bzd1hoNG/dtD8KtLc3ywe/xRgb8Pl T1meT09I++jMgVJjFqlFhFg5y0OfpuMkO5+Dj/vxJk9aRmcebSdP1xaOVrizjE0= X-Gm-Gg: ASbGncun4wRnlpp1SRuFwZ5diziPuQ4WGvrJiJSNLWY6svxrOpvcLVLqkQ+wiOHYXRe Eia5KQtf0fqj+EstF++QS9T9wUQojXFHil4XfvQTAKy7IfwH10a0AIx/pNQXZ91oDdw0f7NU2ta TF0ScFrOlMgTsZG8bZnmjg1G7Iw3YEDtZhyn6s4YGWXyNvD8uY03Z9P6K48yQ1cx2/uyRhnZl+K nD7TYZv/ae33Yc+Mdk4PgubxI6RWG4VaifczX9rvvVX/dgyamEblLrBAINR6GX5qYi01OzcDSkU csI= X-Google-Smtp-Source: AGHT+IFLAgmqPwheEtexe36tVc7JO6SrXkSvjJTNK5zvnOPa7ctBE//RYtgtJPQ9A3oOk1CLEHOv+g== X-Received: by 2002:a17:902:e88b:b0:216:3436:b87e with SMTP id d9443c01a7336-219e6f14504mr173267025ad.44.1734958693240; Mon, 23 Dec 2024 04:58:13 -0800 (PST) Received: from [10.5.84.6] ([139.177.225.250]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9704f5sm72500675ad.100.2024.12.23.04.58.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Dec 2024 04:58:12 -0800 (PST) Message-ID: Date: Mon, 23 Dec 2024 20:58:07 +0800 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 3/3] sched/fair: Ensure select housekeeping cpus in task_numa_find_cpu To: K Prateek Nayak , mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com Cc: chengming.zhou@linux.dev, linux-kernel@vger.kernel.org References: <20241216122357.1276382-1-zhouchuyi@bytedance.com> <20241216122357.1276382-4-zhouchuyi@bytedance.com> From: Chuyi Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 在 2024/12/18 14:21, K Prateek Nayak 写道: > Hello Chuyi, > > On 12/16/2024 5:53 PM, Chuyi Zhou wrote: >> [..snip..] >> @@ -2081,6 +2081,12 @@ numa_type numa_classify(unsigned int >> imbalance_pct, >>       return node_fully_busy; >>   } >> +static inline bool numa_migrate_test_cpu(struct task_struct *p, int cpu) >> +{ >> +    return cpumask_test_cpu(cpu, p->cpus_ptr) && >> +            housekeeping_cpu(cpu, HK_TYPE_DOMAIN); >> +} >> + >>   #ifdef CONFIG_SCHED_SMT >>   /* Forward declarations of select_idle_sibling helpers */ >>   static inline bool test_idle_cores(int cpu); >> @@ -2168,7 +2174,7 @@ static void task_numa_assign(struct >> task_numa_env *env, >>           /* Find alternative idle CPU. */ >>           for_each_cpu_wrap(cpu, cpumask_of_node(env->dst_nid), start >> + 1) { > > Can we just do: > >     for_each_cpu_and(cpu, cpumask_of_node(env->dst_nid), > housekeeping_cpumask(HK_TYPE_DOMAIN)) { >         ... >     } > > and avoid adding numa_migrate_test_cpu(). Thoughts? Make sense, but now there doesn't seem to be an API like for_each_cpu_wrap_and(). Do you think the following is better? diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 855df103f4dd..4792ef672738 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2167,9 +2167,9 @@ static void task_numa_assign(struct task_numa_env *env, int start = env->dst_cpu; /* Find alternative idle CPU. */ - for_each_cpu_wrap(cpu, cpumask_of_node(env->dst_nid), start + 1) { + for_each_cpu_and(cpu, cpumask_of_node(env->dst_nid), housekeeping_cpumask(HK_TYPE_DOMAIN)) { if (cpu == env->best_cpu || !idle_cpu(cpu) || - !cpumask_test_cpu(cpu, env->p->cpus_ptr)) { + cpu == start || !cpumask_test_cpu(cpu, env->p->cpus_ptr)) { continue; } Thanks. > >>               if (cpu == env->best_cpu || !idle_cpu(cpu) || >> -                !cpumask_test_cpu(cpu, env->p->cpus_ptr)) { >> +                !numa_migrate_test_cpu(env->p, cpu)) { >>                   continue; >>               } >> @@ -2480,7 +2486,7 @@ static void task_numa_find_cpu(struct >> task_numa_env *env, >>       for_each_cpu(cpu, cpumask_of_node(env->dst_nid)) { > > Same modifications can be made for this outer loop. >