From patchwork Mon Aug 19 06:01:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Chen X-Patchwork-Id: 13767942 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (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 64FFA14A4C6 for ; Mon, 19 Aug 2024 06:02:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724047335; cv=pass; b=MJW5yqHdk5TET08iECPyxoKgvf8YscjrMgp6nli6gnyWiqgQx6FX7ygKnXBd5vwDAFDRfGuin6WsxiAaJWIJZepEkWKHufKQ+KLe2H6vxXjcUyuL5+j1MrWTjupBkGOxhzZ83LNooUTAecvxQ1941JCRIf0ntb4FGFlBRBKeyfM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724047335; c=relaxed/simple; bh=TiIejifxjXNe2dIwc9B/6sG0Ue2sD5DWgj7qc4Z/Z1g=; h=Date:Message-ID:From:To:Subject:MIME-Version:Content-Type; b=ZZ4ma21pQP/QMAKiVZgZeB13gDixX5jkeCwyQ971Ykqta1Ni1HxjbTXKrGn7AXPAb/4u+xmWBtumDYzPTJuUvZfCkf3cLNcPHoZB7D8yikrwIXtrpXxYyg51CHMHOQFp9sDFyH8VSGoaJqbJOVjw5QY9cAEy4sLmLbQFXjYe+dg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty; spf=pass smtp.mailfrom=linux.beauty; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b=hI+deuSS; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.beauty Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b="hI+deuSS" ARC-Seal: i=1; a=rsa-sha256; t=1724047325; cv=none; d=zohomail.com; s=zohoarc; b=luyhpgoIQapup4/4axDhAckGysrFitJS/PDoJfE7oq1ipQbdhPQhvsoKr43U9meKMMnpWU34WUbA8rzyb9104D3TRXVToei6rVI4ajyz8WS9/VsPIcqjjYyE5QQLc/GTo9krJpJjBwGCXV8m/Tq/HHRfH17p1vehB6IwqvK8Rwg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724047325; h=Content-Type:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=NaLr5sdKjzEjkp303RQnNmcsIjbXJuKkaqMFa+MgYd4=; b=azPmOQDYOe3pmhp6qCnrqLAYmZIpnaA9bIQFkYl7ceAOMxfo+c9e1cn9KVZyaDizIGn0rA6T+6tEwcb/8NQA74SVZ3qGijyUOsnEKPbkdIXc2fJVudAqfFUmXTn/+2+kEjX5bMdjF4y+sa4vV53MguhlArb9CMJp4sHO0QE4JNg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=linux.beauty; spf=pass smtp.mailfrom=me@linux.beauty; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1724047325; s=zmail; d=linux.beauty; i=me@linux.beauty; h=Date:Date:Message-ID:From:From:To:To:Subject:Subject:MIME-Version:Content-Type:Message-Id:Reply-To:Cc; bh=NaLr5sdKjzEjkp303RQnNmcsIjbXJuKkaqMFa+MgYd4=; b=hI+deuSSZ81zFVBS2AF3MW9AuIdpO+3co5IqtU0zb8pYz6U6h2U4X2ZnCqbdYuNY GZV3EXMrzUL5gEPaCpx+kw+yXGQ+oqrLggUcb5G2nawHgzSCUAEGCLqtoROZuhO+Epk 1UHvVlS9qOKp2F/li3Fja6jtOCRaqW7vwW8rW030= Received: by mx.zohomail.com with SMTPS id 172404732437886.60265887675257; Sun, 18 Aug 2024 23:02:04 -0700 (PDT) Date: Mon, 19 Aug 2024 14:01:53 +0800 Message-ID: <87y14t6ofi.wl-me@linux.beauty> From: Li Chen To: linux-trace-kernel@vger.kernel.org, Mathieu Desnoyers , Steven Rostedt , Masami Hiramatsu Subject: [PATCH] ftrace: Use this_cpu_ptr() instead of per_cpu_ptr(smp_processor_id()) User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?iso-8859-4?q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.4 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-ZohoMailClient: External From: Li Chen Use this_cpu_ptr() instead of open coding the equivalent in various ftrace functions. Signed-off-by: Li Chen --- kernel/trace/trace_functions.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c index 3b0cea37e0297..65fed0bbc5c22 100644 --- a/kernel/trace/trace_functions.c +++ b/kernel/trace/trace_functions.c @@ -184,7 +184,6 @@ function_trace_call(unsigned long ip, unsigned long parent_ip, struct trace_array_cpu *data; unsigned int trace_ctx; int bit; - int cpu; if (unlikely(!tr->function_enabled)) return; @@ -195,8 +194,7 @@ function_trace_call(unsigned long ip, unsigned long parent_ip, trace_ctx = tracing_gen_ctx(); - cpu = smp_processor_id(); - data = per_cpu_ptr(tr->array_buffer.data, cpu); + data = this_cpu_ptr(tr->array_buffer.data); if (!atomic_read(&data->disabled)) trace_function(tr, ip, parent_ip, trace_ctx); @@ -300,7 +298,6 @@ function_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip, unsigned int trace_ctx; unsigned long flags; int bit; - int cpu; if (unlikely(!tr->function_enabled)) return; @@ -309,8 +306,7 @@ function_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip, if (bit < 0) return; - cpu = smp_processor_id(); - data = per_cpu_ptr(tr->array_buffer.data, cpu); + data = this_cpu_ptr(tr->array_buffer.data); if (atomic_read(&data->disabled)) goto out; @@ -321,7 +317,7 @@ function_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip, * TODO: think about a solution that is better than just hoping to be * lucky. */ - last_info = per_cpu_ptr(tr->last_func_repeats, cpu); + last_info = this_cpu_ptr(tr->last_func_repeats); if (is_repeat_check(tr, last_info, ip, parent_ip)) goto out;