From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 82D573101A6; Thu, 1 Jan 2026 22:18:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305908; cv=none; b=DnZWVQs+kaCkOxNjbSprWd38m0RoauqUam4hYEacRIRf4cSK741H+1nnaY1jd2twEMH8Lw3qdVdOR3mJzExxxKiT2Bzge8U588tdfMWRz0Bjj/NullL95ZYTc2C6Jlfa4XbbZDIpUGJKg5tZ6pF8BzWpfxVvi231DNOB0gtRSWU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305908; c=relaxed/simple; bh=cybpUb9IFSrtSEn6CVNh90w6y5FCshbAQhcAn4rc9bQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=onNKsVK7dJ9rogyfVcWEiIblEiEFQjYewGuzSSvxYz5eqBBmeyHdorn4eyQ3qwUiHpV3i3dbOf+Orl7b5yFa+Wg7iYik0vXIYhQgbQepUPkOfq0SxraiNiw4WmOGbfyKy1QxhAr2z5QA7XTekbN98vnp2nsOJAB0I2w82RlW53o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dKs4cuyy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dKs4cuyy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D778C116D0; Thu, 1 Jan 2026 22:18:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305908; bh=cybpUb9IFSrtSEn6CVNh90w6y5FCshbAQhcAn4rc9bQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dKs4cuyySogigb0CHjJKGicPzpmLF3keWilFbSY06Spy+118Ks90hsSQopL0I2Tta q1YIw8IVK6zIb/FMBQTyTlKkDfWyqj99/pfnp+rHWMmCIaHcamT5K8hKvVKo2tWaVm yuztN+96UASFPFnQGpTrLz3e9cskLBvUVKU2+txdPLfzlb8uQjnAxFbkcwFlhi4gqG LTn8i3HR2EvRis7KMpwBAV8hJH6PqsY1+Wgs7bzHTTjJj9ZLdM4p6Pna/QNZmQMZFA jF8uZmWY6brNA7sO54ERxDBPuY404ON4ub7VEwh7/HPb4ekacbIzK17ccHCt/eAV2a 1shCNQ4Ws5SvQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 31/33] kthread: Comment on the purpose and placement of kthread_affine_node() call Date: Thu, 1 Jan 2026 23:13:56 +0100 Message-ID: <20260101221359.22298-32-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit It may not appear obvious why kthread_affine_node() is not called before the kthread creation completion instead of after the first wake-up. The reason is that kthread_affine_node() applies a default affinity behaviour that only takes place if no affinity preference have already been passed by the kthread creation call site. Add a comment to clarify that. Reported-by: Peter Zijlstra Signed-off-by: Frederic Weisbecker --- kernel/kthread.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/kthread.c b/kernel/kthread.c index 03008154249c..51f419139dea 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -453,6 +453,10 @@ static int kthread(void *_create) self->started = 1; + /* + * Apply default node affinity if no call to kthread_bind[_mask]() nor + * kthread_affine_preferred() was issued before the first wake-up. + */ if (!(current->flags & PF_NO_SETAFFINITY) && !self->preferred_affinity) kthread_affine_node(); -- 2.51.1