From nobody Thu Feb 12 23:04:44 2026 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 111771BBBF1 for ; Fri, 3 Jan 2025 06:59:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735887588; cv=none; b=PA7CYR6ynsrOSu6yUZgJVZDbNzyyczmylwX5QOI4B7mq47VlpME3z6Mwt1xaFQWgyaYCmrJW226GX7ZxUBNYC+lfJuSW1Hk1ITH4obG/qOIA6WDpxvvVujJnxQF+M1BpXov1ejWGqePnClj6v4WQIbNwSd2Det8nNzGraEaJn20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735887588; c=relaxed/simple; bh=ohLsD+qDL1nmNqxVtGLCqz+g4wP286cVFpWMSMrR9CY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IWgO2JZDHvi9plONqaQAUlLH91HxX00qx1ewm/jObaRcKXUfmjPLlUy4P+iFkLaG7U8MEk1XIyYCw1IJtg2e9VbaSSAij6dml07XfyGO7TRMFsvRQQQ3/hvAh4PQ2oiceMc/A/Q3CbG5hBYtUoyNrk+Agj2RRmSqDfdmDvWhSfM= 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=IIptCwA1; arc=none smtp.client-ip=209.85.214.172 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="IIptCwA1" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2166f1e589cso200987145ad.3 for ; Thu, 02 Jan 2025 22:59:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1735887585; x=1736492385; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MG/wB8SMfVE/PkecyFMpopAK8HOyY3He387122nZY5A=; b=IIptCwA1q+PyQ9+PA3HAW4iR7nYjvJJwXKHNodVTXGGTxd7Wb0G3Utk2jZ3z6G4+wh fyAm+GXkBsPePuSq97EmWqD39d6uHYI7BZa+Yjrs95tqQvBqmOq5A9rOFyS/0K79ACDc tKoZLQI3mUhRgJwjwuln9PD/mcXXI6iTaGxmDbEOEGcD2vk8AEZnZ/i0uAAsHwga9jaS vI8Jx5apgqbewlg6QuAXf6jZHxPgvst5iUeULJSx9gzlZs2pF2xUHM8eDS3XiJZfrMP+ /okum6JQxRkKy0LSZSxrMvQnAzsTBxSDqTSdjyCLeynfrCUvdT1cBKPfQsIRHVU3BKNP +FWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735887585; x=1736492385; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MG/wB8SMfVE/PkecyFMpopAK8HOyY3He387122nZY5A=; b=bat8Xbh84iUTr8yPL7dXqX7DSrZI9PEvX7lNE4suUWvkABk4Tf1RySUQc8oFXw4VGw Pq+32nLR8SCTlPz14OOT0JiAYuLBj3GB91EmUFIqauRd/2gBSIzXmAMhTagH2quySc0k TLUU6cavsvUEy8RVc74oz4YNga9t4xaU/U4XSHRcEzTCYQt9IsqKfu48evYycrfB4EP7 8Pdhbm3UkND+BGK69HHCmFMlhd+dzFip6atOwo5CLU04QAR4gm3Ew/deiDPnNhzTUOWL SPe2SpHcRIBaOs21fWGSDutFTT/jQSaci3Os51qf+aTyqY5HWWJW4fAcE+o+fF5Y/WbK 1FMQ== X-Forwarded-Encrypted: i=1; AJvYcCV97gIuCubTvWQxdB+idlmpZdloQvYluaG/F4lS1IQrX7BdxrlNVHuN5uNkOZLyo3BYHzWWc4vZuk5mFgs=@vger.kernel.org X-Gm-Message-State: AOJu0YySeMxvODorTwZN070ovIApN3pgN6CNSKgVPp/AZZ1KZbJRbW2z lZeaDpPAuaZnoJbNcWbv7yTluG8L3nIXKqRidDHKIrH0yVREX1lcW3ikk0qbREs= X-Gm-Gg: ASbGncvQ9axrQYDdpNIyrZ4rKL+K+Db3qrlPbsylSX3hMoCal9LlnIgOzigjHdyGA1I F631B7VX/nr7Egl4PIgiaYvu63I+vxYU2zdzn6Irr0zZ4wf3pXbJIp66e1Wn9mW/QHnP+/fEHdP 8UB3YVH63UZy7c7Z15bG9q0HsL8QCXpiTyDQC5lt4/mKsrKUrTN1iLLUATBQPHB/75m+PG/vs40 qLLQ40cI2DpSfsRztTRQJriu0ek84ANSTg1RuftIeJJ1yBjpENvejjg36EgN8Bp/1PYEE00PSUa X-Google-Smtp-Source: AGHT+IF999mstoJn5vli8l6HxkNwCN61AxH9dKX6ZqAJLg0ebPqYXV2E/9K2lskmtu7z8tELFG9qpw== X-Received: by 2002:a17:903:238b:b0:216:644f:bc0e with SMTP id d9443c01a7336-219e6ebc9eamr747205755ad.24.1735887585306; Thu, 02 Jan 2025 22:59:45 -0800 (PST) Received: from n37-019-243.byted.org ([180.184.84.173]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9631d1sm238456235ad.42.2025.01.02.22.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jan 2025 22:59:45 -0800 (PST) From: Chuyi Zhou To: 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, longman@redhat.com, riel@surriel.com Cc: chengming.zhou@linux.dev, kprateek.nayak@amd.com, linux-kernel@vger.kernel.org, Chuyi Zhou Subject: [PATCH v2 1/3] sched/fair: Remove unused task_numa_migrate return value Date: Fri, 3 Jan 2025 14:59:28 +0800 Message-Id: <20250103065930.413464-2-zhouchuyi@bytedance.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20250103065930.413464-1-zhouchuyi@bytedance.com> References: <20250103065930.413464-1-zhouchuyi@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Initial NUMA Balancing implementation used the return value of task_numa_migrate() to retry NUMA Balancing in commit 6b9a7460b6ba ("sched/numa: Retry migration of tasks to CPU on a preferred node") however in the same series[1], Mel also included an optimization from Rik which retried NUMA Balancing periodically irrespective the return value from task_numa_migrate() in commit 2739d3eef3a9 ("sched/numa: Retry task_numa_migrate() periodically"). The return value of task_numa_migrate now is unused, remove it. [1] https://lore.kernel.org/all/1381141781-10992-34-git-send-email-mgorman@= suse.de/ Reviewed-by: K Prateek Nayak Signed-off-by: Chuyi Zhou Reviewed-by: Madadi Vineeth Reddy --- kernel/sched/fair.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d5127d9beaea..f544012b9320 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2486,7 +2486,7 @@ static void task_numa_find_cpu(struct task_numa_env *= env, } } =20 -static int task_numa_migrate(struct task_struct *p) +static void task_numa_migrate(struct task_struct *p) { struct task_numa_env env =3D { .p =3D p, @@ -2531,7 +2531,7 @@ static int task_numa_migrate(struct task_struct *p) */ if (unlikely(!sd)) { sched_setnuma(p, task_node(p)); - return -EINVAL; + return; } =20 env.dst_nid =3D p->numa_preferred_nid; @@ -2600,7 +2600,7 @@ static int task_numa_migrate(struct task_struct *p) /* No better CPU than the current one was found. */ if (env.best_cpu =3D=3D -1) { trace_sched_stick_numa(p, env.src_cpu, NULL, -1); - return -EAGAIN; + return; } =20 best_rq =3D cpu_rq(env.best_cpu); @@ -2609,7 +2609,7 @@ static int task_numa_migrate(struct task_struct *p) WRITE_ONCE(best_rq->numa_migrate_on, 0); if (ret !=3D 0) trace_sched_stick_numa(p, env.src_cpu, NULL, env.best_cpu); - return ret; + return; } =20 ret =3D migrate_swap(p, env.best_task, env.best_cpu, env.src_cpu); @@ -2618,7 +2618,6 @@ static int task_numa_migrate(struct task_struct *p) if (ret !=3D 0) trace_sched_stick_numa(p, env.src_cpu, env.best_task, env.best_cpu); put_task_struct(env.best_task); - return ret; } =20 /* Attempt to migrate a task to a CPU on the preferred node. */ --=20 2.20.1 From nobody Thu Feb 12 23:04:44 2026 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 9E1CC1BD504 for ; Fri, 3 Jan 2025 06:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735887592; cv=none; b=SpbW+ADV/Z8B4FrIF+5pMDxCbMzXLUAk78zD7IyEgVYfFW/PxGcOJol6c8d7DVw+9wFE9IYHU6m9R80YiiG0DwTsl6x1IVBrKfr+S/a8xVgZU6xj121d06v+hC3+vqJWRj9sCG7dn3o2IjfNCbubdwYlceRpvyyCCvinbOHX+Q0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735887592; c=relaxed/simple; bh=SuISuTxchex9RJodo04tat69zEAGe+ko1/0ZQdMXDUU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MEBHCokA99vSsdFHD9Po6CBsP3Uo7B07Xh/9sueUf67w9DAo2+mQmy83PD08WjH9+tVy0zy/Ed+rDKS7IoRwEHms7YUPr/nzbr9A6oeyzsFOIIjwTe5w+GYOqZ2Oy87z3pHknCcF4TTVZCzPnxHjMFal3BLTO0VXk8ha71UOq+U= 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=aQxslQDD; arc=none smtp.client-ip=209.85.214.169 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="aQxslQDD" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2163dc5155fso162840275ad.0 for ; Thu, 02 Jan 2025 22:59:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1735887590; x=1736492390; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KKG7eYUurdAiRXTeQw3+Dl2PfUcHaffYGwgJSL+ktjo=; b=aQxslQDDQRcjQ7iJMmnZE33jd6b7Myh4t3zTQt8Ib7BFCu6CdHN+2dcGgP0uQmMjyG EqyVz4UtX9s/DhDessbNf4fcfS471fwm3BeJlZdEPxUob26lsVqPY4eZUz/DjeTCvW+5 jw31R4Mla/zQqKX+PXkG+9wWZ4+Y18kuDf706BiV1kldbYcpbOKAGUapTSuKLwvWVEn7 abduiZ3JL2Te6roYpZfaUUc/gADyHTy3ozwBeng0xOkw4ncdt1TkTjqgUIQZf1zlNfyi /mGAVtZ1z2YNF2a+Ls+5VcUaSQKuJUg3s1RaWfhQCznR/N6vb0HvjkWTJeQ8dZP0wNRm GNIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735887590; x=1736492390; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KKG7eYUurdAiRXTeQw3+Dl2PfUcHaffYGwgJSL+ktjo=; b=GshHOzyuJnLPxh8I0v56qjEYj8sntw8cND3h9k889bu+bh4tsp51js/d3IEXk+ZtPT AZ+bA296YCQab/0kXozHE5tewJ5QIbsXKQkV7gFyfTtnVvgkNs0Atmk7dV1qI2UOnayJ 6LBz+51wiKAsnalKZpGTuYqAUm+lSF50m4qTbvpBGrRrKTQOjtgJjQOm5hJ9sgGr+sPw lanZ20yBGeQdxxxYIvrwsUWILwg4tA4VNVBuXTCsOpmVr+rjcg0u+cw9sBJzb+FwL1l3 9xlFyFpc/770P7efEE2X9Zs9lkIh2kanSwJRcfje2hCNPMKShOg27GyqT8TkFHFWFGj7 QBgw== X-Forwarded-Encrypted: i=1; AJvYcCWcbl1nq4xTllqnkfUjSLK8Eghbdhsm5pkNHcIjOGD2yg5rb4b9pr7eyISgJ+CvqK6xIXAeU6nmb0DHKoI=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+S57bChLtmSnRqbBdOyCYx0mklcMfcHx9xG9zBFOem1wrs6lV UBB0JUbgPQmL4fhiV6hR0idaGDnSIREVo+Rq8wIpa1QrIS8KUMy2NxgevKba7NA= X-Gm-Gg: ASbGncuR7HrIZR50rHttpJ6m4cJytCAX4Qq0AZDxiSZHY88AhSXJj8gvTkTBN2xIXFk qxAQdVIi0frgPhQar0KTB3+zLizvnmLUbXGMlI1luxNRvQCqegPX2z0xJv6XI1AQ/4aduiJSwpS DLpvsNJl7cAXeoNyDIlLR3jtSM/wGNybqsSD0pOcDXwBR3xlmHMoq1AiCEL9PRZNPs6jsYAhrRx ZueRkTxmmYDNgMcPWifvD+hDLo3LeRYEatICNr1jY5+bIVRUBLAPbxI2K4pspEM+lF9Aa3kmNKh X-Google-Smtp-Source: AGHT+IFy+11iMMXujZ9tIzslpzmwO+SFpPDgp38F1xNMmkszZW3EYHGakBzygg6tBclzeHFy8trpBQ== X-Received: by 2002:a17:902:e54e:b0:216:45eb:5e4d with SMTP id d9443c01a7336-219e6e8c529mr692796375ad.6.1735887589934; Thu, 02 Jan 2025 22:59:49 -0800 (PST) Received: from n37-019-243.byted.org ([180.184.84.173]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9631d1sm238456235ad.42.2025.01.02.22.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jan 2025 22:59:49 -0800 (PST) From: Chuyi Zhou To: 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, longman@redhat.com, riel@surriel.com Cc: chengming.zhou@linux.dev, kprateek.nayak@amd.com, linux-kernel@vger.kernel.org, Chuyi Zhou Subject: [PATCH v2 2/3] sched/fair: Ignore isolated cpus in update_numa_stat Date: Fri, 3 Jan 2025 14:59:29 +0800 Message-Id: <20250103065930.413464-3-zhouchuyi@bytedance.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20250103065930.413464-1-zhouchuyi@bytedance.com> References: <20250103065930.413464-1-zhouchuyi@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now update_numa_stats() iterates each cpu in a node to gather load information for the node and attempts to find the idle cpu as a candidate best_cpu within the node. In update_numa_stats() we should take into account the scheduling domain. This is because the "isolcpus" kernel command line option and cpuset iso- late partitions can remove CPUs from load balance. Similar to task wakeup and periodic load balancing, we should not involve isolated CPUs in NUMA balancing. When gathering load information for nodes, we need to ignore the load of isolated CPUs. This change also avoids selecting an isolated CPU as the idle_cpu. Signed-off-by: Chuyi Zhou --- kernel/sched/fair.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index f544012b9320..a0139659fe7a 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2125,6 +2125,11 @@ static void update_numa_stats(struct task_numa_env *= env, for_each_cpu(cpu, cpumask_of_node(nid)) { struct rq *rq =3D cpu_rq(cpu); =20 + /* skip isolated cpus' load */ + if (!rcu_dereference(rq->sd)) + continue; + + ns->weight++; ns->load +=3D cpu_load(rq); ns->runnable +=3D cpu_runnable(rq); ns->util +=3D cpu_util_cfs(cpu); @@ -2144,8 +2149,6 @@ static void update_numa_stats(struct task_numa_env *e= nv, } rcu_read_unlock(); =20 - ns->weight =3D cpumask_weight(cpumask_of_node(nid)); - ns->node_type =3D numa_classify(env->imbalance_pct, ns); =20 if (idle_core >=3D 0) --=20 2.20.1 From nobody Thu Feb 12 23:04:44 2026 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 3C8981BD9F8 for ; Fri, 3 Jan 2025 06:59:55 +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=1735887597; cv=none; b=XDmDVQhEKqTPcav+60C4MPGTseJtps2JabkVK6m2Qz3Iyr+8jaWVVeFNlIHxOyUlyjkcJ/kEWPBSZUqdNe3YkNX13N94mUqPvXJNwWt+2f7jSezYod4erkF5XBRlNkojPw7V0xz4HkieRX19dEt1iIFzL+Zdi3+BoBwGdKZgOAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735887597; c=relaxed/simple; bh=04lNmsNySnVFo9f3O4o4cKfbKTj9UhtSwAYs8oiNvOM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kiRYk2hyJ5ylvjQobU+JHimre1OsrXRd3WpBw0ahpsG3Wil0Tc6m8tLX4cVe9kf5gsfr8zlH6S2Pd9lLPmwjxxsnnAG9LgaNde3x4NYu6Rs0UZXn65tTXCdSnMGuZsob/ffoIMuznuZuCEaHAdMR+j/cvB/6Xkrzsq24eO/JMIU= 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=Bw9ZgU9z; 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="Bw9ZgU9z" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-21649a7bcdcso161354745ad.1 for ; Thu, 02 Jan 2025 22:59:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1735887594; x=1736492394; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tUMl/jt9UeNbHuZ/o30GHqr3MzCzR59KrfQ73K3Jzow=; b=Bw9ZgU9zxglG//mPMHvNs2WpV1H9ZNLBaPyZheySFl7gthR4sDag/JjlLEKyGtf+hG lowWATox2wQ+WiT5d0DC7oiPJALddPWKowYSbcNqClGIBcO5t1NrMYhIFCkUr7bhP4rc IQEUxODQiEZcdwV1WzWju2NrSQpQdvnw81u69Bv1RhGgDOEwcd3bAaJHHtgSvQVP8rFT IqQGA8Qugqjwr0Nd3uc7SvPEr5nlHnK10TZpaEKtDFQoMrd1m21eWIfGUM0/CyzVd/4U eO5EPdGpOyFCDaMAvxF0Fu914VMmW4RJerXweE2nmn0thMo4agzXUuvei12QVExzIf9i p7vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735887594; x=1736492394; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tUMl/jt9UeNbHuZ/o30GHqr3MzCzR59KrfQ73K3Jzow=; b=HFHaOpDdeJfSSx9cG5HjX+dPrqErTDZe6tYEJz4kGy3cA56rXqtfz2GRDiFX1m7WFs jJsLIepCsRMp1hcz7OBUrJUQfTw/4OL0JhlIiRYsx2cR+D5jZIAY4suii0pn7Mt9rjW0 OClqfDrgebycOTA7Qz24EwN01Jxn43XmSofK/og+uoJBqpuN3vJj4oeXvm9wbbABlLni YTSwMIODxOx+mNCOaQhy/qT0kUAQkMELZK6KCiH8kI0X2XQPPAWCHr2IVrhamWojj9rd FokXP1jclUbomykKCtSYK6oORdlJ60/GBnbn0djzx2B7GLM/9Nr/2vpCYBLv+HlvmXaW e2WQ== X-Forwarded-Encrypted: i=1; AJvYcCWox80aQvhoOPT/Z24Ddm27np3unhcyfCAq3mDnRwakNiRXNo+/JPmzC0m7L4IsclL1dfaWmaOlveagKrc=@vger.kernel.org X-Gm-Message-State: AOJu0YzFelw2xaRFomJbk2Z2N2k4PcNSu7VBIPLTnJ4saNBWNdL4uqDK +3WCC+QOjDlYXLx5RAXYAhaqXpXKqdDJJf56knW3D8NskZPd1ruifqXxcnYCmzM= X-Gm-Gg: ASbGncs8a2hqPasUHtavpPzpbYFXTD+n3Ja1MiCeBccZtgFOdubFAqiLHL/HJ1om9WE 81NuotC6MWJQg0w1a9Pe/oBTzWPoVf1SdH6QAX0WBDEv5brstGzSXl3MkEKQ0iHn1YCbe92oNsZ 3BJzik9jTWDInPu1Y19eOHOoLNn+HErNkG13nonM4GqecOShXzH0HjiFZGVKURrNwgUB8z8lEGo xOE4GH5CL5sgZh9qHB7MptNJL1N5kmuynoFEIal8bc1ZvWDtRnUvyh53c9XH9PeGEOuqTWZYGIx X-Google-Smtp-Source: AGHT+IEZ23nYFmqi4FmHpOi3oCdY8Zks+Xzu7vN8ylV7n7PoqALklYP9zENSNb+2GvGRl9ocqjUjzQ== X-Received: by 2002:a17:903:238b:b0:216:39fa:5cb4 with SMTP id d9443c01a7336-219e6eb6234mr717609335ad.25.1735887594548; Thu, 02 Jan 2025 22:59:54 -0800 (PST) Received: from n37-019-243.byted.org ([180.184.84.173]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9631d1sm238456235ad.42.2025.01.02.22.59.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jan 2025 22:59:54 -0800 (PST) From: Chuyi Zhou To: 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, longman@redhat.com, riel@surriel.com Cc: chengming.zhou@linux.dev, kprateek.nayak@amd.com, linux-kernel@vger.kernel.org, Chuyi Zhou Subject: [PATCH v2 3/3] sched/fair: Ensure select housekeeping cpus in task_numa_find_cpu Date: Fri, 3 Jan 2025 14:59:30 +0800 Message-Id: <20250103065930.413464-4-zhouchuyi@bytedance.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20250103065930.413464-1-zhouchuyi@bytedance.com> References: <20250103065930.413464-1-zhouchuyi@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now in task_numa_find_cpu(), we only skip CPUs that are not in the task's cpumask, which could result in migrating the task to an isolated domain if the task's cpumask includes isolated CPUs. This is because cpuset configured partitions are always reflected in each member task's cpumask. However, for isolcpus=3D kernel command line option, the isolated CPUs are simply omitted from sched_domains without further restrictions on tasks' cpumasks. This change replaces the set of CPUs allowed to migrate the task from p->cpus_ptr by the intersection of p->cpus_ptr and housekeeping_cpumask(HK_TYPE_DOMAIN). Signed-off-by: Chuyi Zhou --- kernel/sched/fair.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index a0139659fe7a..05782b563609 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2081,6 +2081,12 @@ numa_type numa_classify(unsigned int imbalance_pct, return node_fully_busy; } =20 +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 *en= v, /* Find alternative idle CPU. */ for_each_cpu_wrap(cpu, cpumask_of_node(env->dst_nid), start + 1) { if (cpu =3D=3D env->best_cpu || !idle_cpu(cpu) || - !cpumask_test_cpu(cpu, env->p->cpus_ptr)) { + !numa_migrate_test_cpu(env->p, cpu)) { continue; } =20 @@ -2480,7 +2486,7 @@ static void task_numa_find_cpu(struct task_numa_env *= env, =20 for_each_cpu(cpu, cpumask_of_node(env->dst_nid)) { /* Skip this CPU if the source task cannot migrate */ - if (!cpumask_test_cpu(cpu, env->p->cpus_ptr)) + if (!numa_migrate_test_cpu(env->p, cpu)) continue; =20 env->dst_cpu =3D cpu; --=20 2.20.1