From nobody Fri Nov 29 23:44:06 2024 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 68C78194ACA; Fri, 13 Sep 2024 23:03: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=1726268608; cv=none; b=U6RiC34MPwm1qyVuuHAlz2cFlZCzPHmXBElt/OIZnqi62hkESzCxZzOGKcLNOlOO953poa8YAamcGgwsWGXC88ixvl0XTi8AKPpGCRXQkf+vEYJ1EZ8k6n8CgHoFQPMwoUN9KtfuLoX/HWolPocgymr92lgqOMKxkBRyV6YwE+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726268608; c=relaxed/simple; bh=0WuovsNM7TaO1oYzqlLrboI468hoPkzVYKsi9xko4u4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jgaTnPCxcUBDFeNwJFlSs2UnMR9873SQisBF/pIMRp+4WTmQdaZcyYFAuIFi7mzGsiq7R6PNWeH4ewZ1WrC+jhxHUmY2fUUB2e0ni+6QcTn2Zkadt+ClxMthscul1p0X85lar4b0Qrc4zISzIHjeBAFcxZzKuiOWtURNE4d+Nw4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BJJGuHnZ; 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="BJJGuHnZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F356C4CEC5; Fri, 13 Sep 2024 23:03:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726268608; bh=0WuovsNM7TaO1oYzqlLrboI468hoPkzVYKsi9xko4u4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BJJGuHnZDZGHlcrc0068NiNy4moT5d2cYpiizv067ynrq+IRchaaSh3SPSr0V8nTe Dzyxlb23a6MSocyIQkxvC+uUGrnqt2yV/LUK9hdYII1OIbtXz5EYtatAPjlxlDtS1B E0f1slcet58/b0XcmA5QtATfSHWalSCpiaudm6ZrSaNLEBH3SYBSwAJEAzv9RON7PS xNHzTFnX3groYtbQhBe7+tT+fOdGeLlYimIB1kDt5jAqpl3A+OWL6LcjZ2FZLQS62U YyMdL+BoyJbz1eCbruQ0dQXLf/lmHb0BsTWDDHrW6sD1+m0wv7ybrbKsECcIboVJyw FeO7PwuKZxwqg== From: Josh Poimboeuf To: x86@kernel.org Cc: Peter Zijlstra , Steven Rostedt , Ingo Molnar , Arnaldo Carvalho de Melo , linux-kernel@vger.kernel.org, Indu Bhagat , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Mark Brown , linux-toolchains@vger.kernel.org, Jordan Rome , Sam James Subject: [PATCH v2 08/11] perf: Simplify get_perf_callchain() user logic Date: Sat, 14 Sep 2024 01:02:10 +0200 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: 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" Simplify the get_perf_callchain() user logic a bit. task_pt_regs() should never be NULL. Acked-by: Namhyung Kim Signed-off-by: Josh Poimboeuf --- kernel/events/callchain.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c index 655fb25a725b..2278402b7ac9 100644 --- a/kernel/events/callchain.c +++ b/kernel/events/callchain.c @@ -241,22 +241,20 @@ get_perf_callchain(struct pt_regs *regs, bool kernel,= bool user, =20 if (user) { if (!user_mode(regs)) { - if (current->mm) - regs =3D task_pt_regs(current); - else - regs =3D NULL; + if (!current->mm) + goto exit_put; + regs =3D task_pt_regs(current); } =20 - if (regs) { - if (add_mark) - perf_callchain_store_context(&ctx, PERF_CONTEXT_USER); + if (add_mark) + perf_callchain_store_context(&ctx, PERF_CONTEXT_USER); =20 - start_entry_idx =3D entry->nr; - perf_callchain_user(&ctx, regs); - fixup_uretprobe_trampoline_entries(entry, start_entry_idx); - } + start_entry_idx =3D entry->nr; + perf_callchain_user(&ctx, regs); + fixup_uretprobe_trampoline_entries(entry, start_entry_idx); } =20 +exit_put: put_callchain_entry(rctx); =20 return entry; --=20 2.46.0