Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp347546lqp; Tue, 11 Jun 2024 06:31:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWNxmPQZW+2AjoyWUAemyIU9+p04guR/zIZWyOJCIW/fOqC0sxEvoLp4kRE+rM1SHkFcMUJezog395BQZv7Z54PJG4CE2lrnrUBvxcInw== X-Google-Smtp-Source: AGHT+IH5TOTqziYeX/Kh38TGh9R+vVj66iWlvo4HZ+XtMcT0jv4NE4pVcoOgXYU3rQWgQzIdEITB X-Received: by 2002:ac8:5a0b:0:b0:440:5256:9a7f with SMTP id d75a77b69052e-44052569deemr123211751cf.56.1718112662841; Tue, 11 Jun 2024 06:31:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718112662; cv=pass; d=google.com; s=arc-20160816; b=k46LuG4Cydx9OFvxPS2C3ho6h6twsGAzHyYNehZUl7eDenX08y9zB52Lm/TNK+wEHH +xG1QDmmrmYawreen0SHnysM3Pp8BOdDb06c+QAG8b9KxW4A3Uy5Kg0d9ZPxq8Qgo07l NuckaVjVfatSES2/h5WDy7EZTlKCf9Woe3Tv1U8fhUv7wDkmKgGntvx8tvqBu6LUSj6z maR4VQIFsUWV+dcDuZNSfIrnye7fk1R6zeAxJB40vHMbi4bqXc5rSV2MkHfeK7oYWjIj qecMTl3ijqVguyo55CZs0YuWFonV0N5ZtkDlhiKBi2JvISSv7ZrxjPfAQleteRk/XWc+ nRnA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=/iCQYg3BygvOsRoFYNTVuxBpJMssgT0LAWQu28XFp1o=; fh=OXmnF2IabCVhttS9M0uF5EzWe+EI+vV+JgHilYyZTJA=; b=cuL3ysY5DsV13lKfsGQjg4bt2sSe2tBFZ4NW1eNbuIHBq9UN/JGMzmwhuZ3DGKUv+0 zdVLqdAsOt6h1rMuIYmZKeD4Sc+I/boVtWMTtDIOXTN8iEpRmV/PFVyw1nRqXAEUbKBS tYd9S4APVy5+OKN5V1MCA049Mu97Tw6BeHp/bQGZ7cIvfdCouM/91HsutNvETLDKMNnr HFBgChqFcF4puPXfr4IDrR+sqE/zPhS2POGtFWF6qDn/TkTh+TnnytLiCfv8+Jm5aO8n iTAcKSBrfWL+qajXNhlOIPvOBegqPGKlFh6DsjaTkCPOJi6m557gwLRhZKNi56hN29rO LaWg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bYq9LzV0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-209959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209959-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-44038b6167csi117286511cf.583.2024.06.11.06.31.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 06:31:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bYq9LzV0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-209959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209959-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 784471C21CFF for ; Tue, 11 Jun 2024 13:31:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C68817D341; Tue, 11 Jun 2024 13:30:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bYq9LzV0" 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 523D31EA71; Tue, 11 Jun 2024 13:30:51 +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=1718112651; cv=none; b=PgRQ8fGMyfEMbq40GFBY4EfW8icvfQllIx4w/JStg1uQYhnMFC12lWwxd7Ag1wEMh7V6VYNde/pPe02l+VTaYquNpp2lkqDdj/ywR55wNwzir/DQgO5zrojX73IPIskCZB20zI5vQCLcfXsGP8ssBTqLh0715B+5hImnGuBMLF8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718112651; c=relaxed/simple; bh=UGXI1foWNkX1CtbMA7xI1y2o5zHE8fPmybVoBCkZGpU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=UowL7xanRtl9dO/xMFZ5HLHJKsMLFBzWjjUaoznUSKxumk/LGKvXKt/yy1N9Q7huwhxoC/XCQ3/S4whOCG024T45+palSfhBnANqWq3E8B7q0DMgtU+fsFRozLD0f+okAnpECxCLgoawMmalvvKFlyjQDmN5WM7bKH4nTI/AQKw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bYq9LzV0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81114C2BD10; Tue, 11 Jun 2024 13:30:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718112650; bh=UGXI1foWNkX1CtbMA7xI1y2o5zHE8fPmybVoBCkZGpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bYq9LzV0UrQ6rFgge/s5761haf2UJ89dzXxLFB6ypXbxMM+DoEllbt7ieVww/xfJw JN5064FF+yjyl9hTb8B9I8+dFUfvmxd9eAfTQGGZbW0VuQKWEP2RtqrTN4qG4hspg8 Z67MVG2KutNA843Iht+QRQZhyz/gEF7edVEtxvEnouu1zL+6HqYlDazLnyIpA9pNUh fos0kryqw+v2njnuyAwPE5GT5b0ibfwBRRlPq/beodQc1G7pNdFaNvcpO0MeVoE3T9 QV/4jQ+WaTyeJp8DxBajHEzT1/iwWpAoP1HArzsSeZt55dK+i67Qm3jmuFF1+xGtCp gaZZxwU4ni2/w== From: "Masami Hiramatsu (Google)" To: Steven Rostedt Cc: LKML , Linux Trace Kernel , Masami Hiramatsu , Tom Zanussi Subject: [PATCH v3 2/3] tracing/kprobe: Integrate test warnings into WARN_ONCE Date: Tue, 11 Jun 2024 22:30:46 +0900 Message-Id: <171811264685.85078.8068819097047430463.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <171811262833.85078.12421348187962271050.stgit@devnote2> References: <171811262833.85078.12421348187962271050.stgit@devnote2> User-Agent: StGit/0.19 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: 8bit From: Masami Hiramatsu (Google) Cleanup the redundant WARN_ON_ONCE(cond) + pr_warn(msg) into WARN_ONCE(cond, msg). Also add some WARN_ONCE() for hitcount check. These WARN_ONCE() errors makes it easy to handle errors from ktest. Suggested-by: Steven Rostedt Signed-off-by: Masami Hiramatsu (Google) --- Changes in v3: - integrate WARN_ON_ONCE() and pr_warn() instead of remove WARN_ONCE(). --- kernel/trace/trace_kprobe.c | 54 +++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 16383247bdbf..8c5816c04bd2 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -2023,19 +2023,16 @@ static __init int kprobe_trace_self_tests_init(void) pr_info("Testing kprobe tracing: "); ret = create_or_delete_trace_kprobe("p:testprobe kprobe_trace_selftest_target $stack $stack0 +0($stack)"); - if (WARN_ON_ONCE(ret)) { - pr_warn("error on probing function entry.\n"); + if (WARN_ONCE(ret, "error on probing function entry.")) { warn++; } else { /* Enable trace point */ tk = find_trace_kprobe("testprobe", KPROBE_EVENT_SYSTEM); - if (WARN_ON_ONCE(tk == NULL)) { - pr_warn("error on getting new probe.\n"); + if (WARN_ONCE(tk == NULL, "error on probing function entry.")) { warn++; } else { file = find_trace_probe_file(tk, top_trace_array()); - if (WARN_ON_ONCE(file == NULL)) { - pr_warn("error on getting probe file.\n"); + if (WARN_ONCE(file == NULL, "error on getting probe file.")) { warn++; } else enable_trace_kprobe( @@ -2044,19 +2041,16 @@ static __init int kprobe_trace_self_tests_init(void) } ret = create_or_delete_trace_kprobe("r:testprobe2 kprobe_trace_selftest_target $retval"); - if (WARN_ON_ONCE(ret)) { - pr_warn("error on probing function return.\n"); + if (WARN_ONCE(ret, "error on probing function return.")) { warn++; } else { /* Enable trace point */ tk = find_trace_kprobe("testprobe2", KPROBE_EVENT_SYSTEM); - if (WARN_ON_ONCE(tk == NULL)) { - pr_warn("error on getting 2nd new probe.\n"); + if (WARN_ONCE(tk == NULL, "error on getting 2nd new probe.")) { warn++; } else { file = find_trace_probe_file(tk, top_trace_array()); - if (WARN_ON_ONCE(file == NULL)) { - pr_warn("error on getting probe file.\n"); + if (WARN_ONCE(file == NULL, "error on getting probe file.")) { warn++; } else enable_trace_kprobe( @@ -2079,18 +2073,15 @@ static __init int kprobe_trace_self_tests_init(void) /* Disable trace points before removing it */ tk = find_trace_kprobe("testprobe", KPROBE_EVENT_SYSTEM); - if (WARN_ON_ONCE(tk == NULL)) { - pr_warn("error on getting test probe.\n"); + if (WARN_ONCE(tk == NULL, "error on getting test probe.")) { warn++; } else { - if (trace_kprobe_nhit(tk) != 1) { - pr_warn("incorrect number of testprobe hits\n"); + if (WARN_ONCE(trace_kprobe_nhit(tk) != 1, + "incorrect number of testprobe hits.")) warn++; - } file = find_trace_probe_file(tk, top_trace_array()); - if (WARN_ON_ONCE(file == NULL)) { - pr_warn("error on getting probe file.\n"); + if (WARN_ONCE(file == NULL, "error on getting probe file.")) { warn++; } else disable_trace_kprobe( @@ -2098,18 +2089,15 @@ static __init int kprobe_trace_self_tests_init(void) } tk = find_trace_kprobe("testprobe2", KPROBE_EVENT_SYSTEM); - if (WARN_ON_ONCE(tk == NULL)) { - pr_warn("error on getting 2nd test probe.\n"); + if (WARN_ONCE(tk == NULL, "error on getting 2nd test probe.")) { warn++; } else { - if (trace_kprobe_nhit(tk) != 1) { - pr_warn("incorrect number of testprobe2 hits\n"); + if (WARN_ONCE(trace_kprobe_nhit(tk) != 1, + "incorrect number of testprobe2 hits.")) warn++; - } file = find_trace_probe_file(tk, top_trace_array()); - if (WARN_ON_ONCE(file == NULL)) { - pr_warn("error on getting probe file.\n"); + if (WARN_ONCE(file == NULL, "error on getting probe file.")) { warn++; } else disable_trace_kprobe( @@ -2117,23 +2105,19 @@ static __init int kprobe_trace_self_tests_init(void) } ret = create_or_delete_trace_kprobe("-:testprobe"); - if (WARN_ON_ONCE(ret)) { - pr_warn("error on deleting a probe.\n"); + if (WARN_ONCE(ret, "error on deleting a probe.")) warn++; - } ret = create_or_delete_trace_kprobe("-:testprobe2"); - if (WARN_ON_ONCE(ret)) { - pr_warn("error on deleting a probe.\n"); + if (WARN_ONCE(ret, "error on deleting a probe.")) warn++; - } + end: ret = dyn_events_release_all(&trace_kprobe_ops); - if (WARN_ON_ONCE(ret)) { - pr_warn("error on cleaning up probes.\n"); + if (WARN_ONCE(ret, "error on cleaning up probes.")) warn++; - } + /* * Wait for the optimizer work to finish. Otherwise it might fiddle * with probes in already freed __init text.