From nobody Mon Apr 6 18:23:09 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 011963FD142 for ; Wed, 18 Mar 2026 16:27:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773851239; cv=none; b=OlJ0IZOuzGcHfUiawPEv+MD+H+RdKMrAMfBeFB4bP9QM0ijUgeJfVebiZEaFSBiir24w0yW3k+qyaGDavOwS3q5QLLsd9a9IxdEmI+SNaT7T9snjBbM1cyfkqtbL7I8t8C3CJ9Ix0tN+kuareezZP3Yv9ZvrEK7cylZ7ISrkho4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773851239; c=relaxed/simple; bh=YPl8dC+FWNYbig6FC8CWhTRlpJIuO11/DPHxoh5KsiM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RFokGlLUJODY1Gh0KmPKGtb2jgxGw6WcZHhyiZB4MjGmBGsuuyTTX269GAhujH3fxGdLjaE9aaWPO0rNqAaueFHfaPus62sKO5Bt+VWFIS/rSp6tMM49Nwz2yXBW7lE4DZdRzjw+xHHkNMgDyTvoLrwKhdUdxtYbxQVED2+RU4g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=MLZ9KP80; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MLZ9KP80" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4852ef20fe8so79065e9.1 for ; Wed, 18 Mar 2026 09:27:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773851230; x=1774456030; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Qmw4vC+CxZDBjEx/J8ylpMl/Lh1zLUYRQxMntaRS6nI=; b=MLZ9KP805KOpYcp7h5HJpjYCEBLvfZRbTSLByVzH+pTX9SgXYH2piBzgMI2u9k8Y+c RvN5ghcOrmh0gjtjsHWtzt7E/b5Myu+jxTBQ5GOctR6yDRdWEnWx/4UXLop0V2GZh+uU Qd+Fl7Zelo5t5W+nitWjtoTYW+PLc0q/zUWhjhMIMTv5YqbexLio0dZP55CPI2sS7tEY tOj/fZKFI6NX6uBE/QEgg2oqJaja/ljdw7An+nl4QURRoZcrQYUbs3h39kcJftjNOVCJ Aafggq5SrFTuxtgCXqnG17dWVV643mlBKTtcHxd/HLNsCWinH9AcxIYxiwpsGPHr5I3J N2oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773851230; x=1774456030; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Qmw4vC+CxZDBjEx/J8ylpMl/Lh1zLUYRQxMntaRS6nI=; b=VGh7pUUB+NH0guFvpUbtIY1SIHj0cK/4u0BhSxgWvETJgV9BdnS0uvoiFiTjeI3S6S L/mdGLPP7YAKgG2ftELYO2GEh4zKMHoZPRHguMzRce0mhI4xJd6oLYzyWPDW587RFIoJ I0qmjKaT6YCJ8wUPK8SiZyQsZ/OVwyiEAio+5/9/TtUE0Hd7Yuc263pNGBc1u2NgMusB II2+chUPYlg9pUK5mYR5InXNSHrTAHQndTlzv9l/0fa3N/3DT5X8KFepoJbJ8Uei7L/w 3fotUTqsTsQGN2pVhN9C9C8l1h7q3OYSMrYm0j/ZuUx1IipgyeWecOevDOQ9Xfu0YKQL LqyA== X-Forwarded-Encrypted: i=1; AJvYcCWckuLAQaD2PAqa3undP+ytLbQE8v69p4vQE94Mr8wg9hQqx/Vboq35JQLlL9v2CnwOoTG6qvveA4ZSpf8=@vger.kernel.org X-Gm-Message-State: AOJu0Yx32xTxHh8zk8d8KdkM8NpK8MROYEc1lQQEaWVAp5HgJi31yR9L Cb27TfzGKjPrpypk3g9MyriERcMri5YJtcbuiQf9yJJaDLf06lniZVdj8DMULYhgIg== X-Gm-Gg: ATEYQzzJZWdbV2pLascC7oR8ibg9i/fyUCP12333xvjNUQBhL0hBV8zN0qIcsH0UQAz P/fqSVRNI1udGT9RSJGmrqbmmKxlFuL7NJSeVqhVndPQk3ku1Y+kjTG+nQfhMH1bl+6eKgdVgB/ bugQlpnX8c7iglXqARmxo+nXuOGB2P6S1kgdUxZGJJYnpkBhwIdjaBXtWTdrc/uHVIygk4kyChs m1TOMlWAmTrTykjLVL0n8hhQlA+329QtqdciuyagKrBrDlOdlwD2589CdyZOv3d3rRIi7LqFy/Z 9U117jMFvqQjdZ0mSA8YjCnQsOdJvoZ1VYCfQ1hDVIVyr0rlvwWQx8GyLBVSs3aInK9q035me/w kGtbl+oD6iqEvBrvH1BYrE43QNBMF62U94ZboMuB5jrbqq1/wV4S/55rC8i6peeWXQEL7Pljkv5 UhETup+H3n6KbT+xfWVkWk0Jv3EYP+398CmxvOu/N1wqZ0CpI1Tf1xL+V4YAya X-Received: by 2002:a05:600c:8a4:b0:47b:e29f:c63f with SMTP id 5b1f17b1804b1-486f4ce8202mr780975e9.11.1773851229587; Wed, 18 Mar 2026 09:27:09 -0700 (PDT) Received: from localhost ([2a00:79e0:288a:8:c66d:1e51:595a:925]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-43b51852ab3sm9280149f8f.12.2026.03.18.09.27.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2026 09:27:09 -0700 (PDT) From: Jann Horn Date: Wed, 18 Mar 2026 17:26:58 +0100 Subject: [PATCH v2 1/4] sched: Ensure matching stack state for kcov disable/enable on switch 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260318-kcov-extrecord-v2-1-2522da6fcd3f@google.com> References: <20260318-kcov-extrecord-v2-0-2522da6fcd3f@google.com> In-Reply-To: <20260318-kcov-extrecord-v2-0-2522da6fcd3f@google.com> To: Dmitry Vyukov , Andrey Konovalov , Alexander Potapenko Cc: Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, llvm@lists.linux.dev, Jann Horn , Ingo Molnar , Peter Zijlstra X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1773851224; l=1827; i=jannh@google.com; s=20240730; h=from:subject:message-id; bh=YPl8dC+FWNYbig6FC8CWhTRlpJIuO11/DPHxoh5KsiM=; b=hiUxadU509ZAxL1hocvzwSwvDRdcyHk3+StHxZdd86Fp+GpZ8sfNB5SkrMjXjtjneFMJtxF9p H2PQmiAQWOaA5WPKypgYfFOvA7+Dj5DZOPpGlWaNRzQqx0U00Q8wSHu X-Developer-Key: i=jannh@google.com; a=ed25519; pk=AljNtGOzXeF6khBXDJVVvwSEkVDGnnZZYqfWhP1V+C8= Ensure that kcov is disabled and enabled with the same call stack. This will be relied on by subsequent patches for recording function entry/exit records via kcov. This patch should not affect compilation of normal kernels without KCOV (though it changes "inline" to "__always_inline"). To: Ingo Molnar To: Peter Zijlstra Signed-off-by: Jann Horn --- kernel/sched/core.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index b7f77c165a6e..c470f0a669ec 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5072,8 +5072,10 @@ static inline void kmap_local_sched_in(void) * * prepare_task_switch sets up locking and calls architecture specific * hooks. + * + * Must be inlined for kcov_prepare_switch(). */ -static inline void +static __always_inline void prepare_task_switch(struct rq *rq, struct task_struct *prev, struct task_struct *next) __must_hold(__rq_lockp(rq)) @@ -5149,7 +5151,6 @@ static struct rq *finish_task_switch(struct task_stru= ct *prev) tick_nohz_task_switch(); finish_lock_switch(rq); finish_arch_post_lock_switch(); - kcov_finish_switch(current); /* * kmap_local_sched_out() is invoked with rq::lock held and * interrupts disabled. There is no requirement for that, but the @@ -5295,7 +5296,13 @@ context_switch(struct rq *rq, struct task_struct *pr= ev, switch_to(prev, next, prev); barrier(); =20 - return finish_task_switch(prev); + rq =3D finish_task_switch(prev); + /* + * This has to happen outside finish_task_switch() to ensure that + * entry/exit records are balanced. + */ + kcov_finish_switch(current); + return rq; } =20 /* --=20 2.53.0.851.ga537e3e6e9-goog