From nobody Tue Apr 7 21:31:23 2026 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 532272F60CC for ; Wed, 11 Mar 2026 21:06:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773263211; cv=none; b=kDfukXSA1llrhNcsnGjpoW+bZ9K2Kyv3nr73cftxIhAf/mk2cQH4Lc63V5eact9KbBwIJpQe5o/nM8OfK3YSs0T4TmWQTFlzJXJrqyXFKjRpOclKnf0w2wf6ksiHJWyy4EKomeggje8GVQxu9aJuzDVW/Yt8aFO0LeUer45BHto= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773263211; c=relaxed/simple; bh=Rn/uhAEizGU7xZ5aEfF2VvvEfAV/mBrSUtHKuGh1e2Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OIay9aa/NBPPa0uVktShtdwID/wsRFXphu7cEjR1UC8g3NDg+f0aZedESNLK16IpVcl7/9CV/vzphyA9kF0YXQKodX2w86YOlZCF/FS4nVLntAXAWL0r/pCrR34Bn16l5s4VbDcHUffdmnp9Y1SnQP0iGJQwI46DEYXed5hGboU= 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=UpEXIHp0; arc=none smtp.client-ip=209.85.128.46 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="UpEXIHp0" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-485317b6bd0so9065e9.1 for ; Wed, 11 Mar 2026 14:06:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1773263209; x=1773868009; 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=Jq184yv6qhyq5he4JEdx2+D4Atx68RIlmhXc/nCq5F8=; b=UpEXIHp0UNk1DU1/bGozN7QSc/NYKqrSqvpaLbTVAVkEJFEVme/CZyENWr2b9DmW5c IW8CkNcBXXfJOOjqstxr60+qYtKMkLhzKtyxSI/up4TgWCiodeZ6f/+ytXpVwd6SFtN3 vJKOwwchTKD2Vf38BQ9HE9UU3ZRz/z43rnYHevdsPj0Zu35m7eBzbcza8ilqu5kRnwux rJiNG7BCittYPtEmKleg+AaN/3iZy4T+cyc8/WyCzdZnhQWmxEOgxswiCrDEd70xxO43 8fcto1V4jaRnlU7I2iU5Qy7vID5KR42esB7r4uKl5rG1oBmwSXVJrKY72vBq687m5aoA EklQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773263209; x=1773868009; 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=Jq184yv6qhyq5he4JEdx2+D4Atx68RIlmhXc/nCq5F8=; b=Xe7wpnnLEZ4YwGEKY6SQkdNXQFheUROK/NBVph0SmTPlWRYFOJZpitGKiXxor4cSrn K0sDtMsv1aevjKbn+tmTj7iq2lKIWkwfQhlBkPbQxmNADzZwOKt/sG9DQNrqwtujfL72 3azwHUvgc7UC4X8ddu1ygdTQu3S2lSHXJJn9mm5NanhTkZSWwmiiL9GU+RRzj0CDtEOM jjeBT+bid0o+qCrEGIvz31KRoud3iTDQHBJ5KGoTb30WdNxhleZ7NtPd9g4jguaFV8UH QNmq1QiFHkH4x36lFRpAeU65MHa+WCVZWSZDzauu4gqI5iMOgmSG9uO7ly8CvI0wKjHj YXGQ== X-Forwarded-Encrypted: i=1; AJvYcCWewlQa7ed+qTmAKKtoepJ3t3VybbPZVOQJLuOPYQtMdDiFA/YzS7UFhIinHMtb9GO0HYc4RReYlpqi9l0=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6x5OWWeMOVuGdm8b2C3f4glEfumziI91ck6UQT37iwY+EUn2P xGc22wQ/t/kOeeUXf1vPy03L7vCQBMxwwLs1mYcEcTBolEayUKychCvRKyRVRZ1DdQ== X-Gm-Gg: ATEYQzx8EV+WJ35LBlK9K5O7xhjsahcm2yLi9CVLjLg6OWorjxkbR4r9Q9xjxmDFpe6 N1OWY2k1rs5nU2gJggiKIPz1bkHtkbvkGr8TutQOjyK3HJz7FVZ1hH3G+8UEM0TAwiVJO8oBLV9 VW1ELnW887izv1XIxa8hT888Of0wiCUedGdGqXL2pKJ4QEym2sJG1cCj5sw+REg5Hv8N/m/Gh9D rCmhd8q5EdThacNpnSmLFwzfjFXL65lXq1/vUv7n//B8ZSa1jWYf2HRTC7vRf+DvIbXlt1m14x3 2tN4eQj5eI9fNpf3S74H2mER9Kv562VqWSbnK5ew34ara2Cryi9Vv23lMf8VUn9sxvzEeD7M99Y 9Dvj5EL9/ohbV87VrU6jCWtXHAJYo8RW/3zM1pklTLTnyNcaWzoyQoAJj8Cn4DrA9SRjyMOpb8i /SbJg/A1jKT5uEJQ7gZBQYEYibEegp2POT6p75qve8vAKf7DtayHLn2VrJwy709w== X-Received: by 2002:a05:600c:4688:b0:483:1093:f29b with SMTP id 5b1f17b1804b1-4854fa11e50mr229415e9.8.1773263208180; Wed, 11 Mar 2026 14:06:48 -0700 (PDT) Received: from localhost ([2a00:79e0:288a:8:c9d4:528c:7414:ba3a]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-439fe219c41sm1949038f8f.29.2026.03.11.14.06.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2026 14:06:47 -0700 (PDT) From: Jann Horn Date: Wed, 11 Mar 2026 22:06:14 +0100 Subject: [PATCH 1/3] 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: <20260311-kcov-extrecord-v1-1-68f03c4a05ad@google.com> References: <20260311-kcov-extrecord-v1-0-68f03c4a05ad@google.com> In-Reply-To: <20260311-kcov-extrecord-v1-0-68f03c4a05ad@google.com> To: Dmitry Vyukov , Andrey Konovalov 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=1773263202; l=1827; i=jannh@google.com; s=20240730; h=from:subject:message-id; bh=Rn/uhAEizGU7xZ5aEfF2VvvEfAV/mBrSUtHKuGh1e2Y=; b=nT5u7hSmk+peI4Z70WnnNJltIQzTqQK/FPRXLCAfr/CfAZI5TfWDbVdHNATBPrJE8rscRMwNT pAw0yBbVLkOAnpe1QwRXRzw27rZhNYJFgCMi0/mSGW/bPY0IR7FtcjT 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.473.g4a7958ca14-goog