Received: by 2002:a05:7412:1492:b0:e2:908c:2ebd with SMTP id s18csp616403rdh; Tue, 22 Aug 2023 06:06:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmLsDZaikIo6xc51rO4iwFDgjsTz/youmEAVxNZ1m61Lcs9geuYbaNZcMemHCmCntwy95k X-Received: by 2002:aa7:d616:0:b0:525:5ed2:abed with SMTP id c22-20020aa7d616000000b005255ed2abedmr6728196edr.30.1692709568494; Tue, 22 Aug 2023 06:06:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692709568; cv=none; d=google.com; s=arc-20160816; b=DDjYASX4HaSgvJZCvLiyrZeuLBG8FhXTEewHZmlhWX/BwQWsIkXypOgt0G94qLlKn6 nbQ96NUjgjvQqlqwI4UqoKnaUeVwhyk6SZzduh+bj8/JeR7bXst8/66yhWrBp9+rDnQd gQst4V7xg9fTRlPfwhY5oAhs+diBmXpohM6WjkSgu6JRGFCxVI3nNL7j/Zi+OOoE13p4 sOwzTMS6Jc8iVCdBoivfHcr7nuFUNAMRsEYuJGyuqwVMdIJQrdGCcvBM5zNhCTC5wTmK NNB0yg/EFiFcMfrYtLhxxPBXg5QV2JwGFPSHIyWfI0V+UpiV5ffvNAWikF2hJd+hr0dx e8lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=ZsrHorbMQxgUK0dmPO42nVIM+1qLmOBJ0Y5OWRAoPy8=; fh=m1ceP8X+apq/PQGmNASsAU7e6WWrdGf1T5v0WvmT+8Q=; b=cQVjCsREFkdabPD7AOi16N7WlE2W4gpIDbU4n0+eKnBkzzxVnfuUXQUS3bOHhJ51Zg PWln3WGFi6pp2o6XEyZFtg7Lgh+yicKDJl2s27BK1gSfSDKJyN1KkRr+Y3SIbj2NScV9 G/UkeDU7QIh0PWYK+4rEXIuB9Kz+HLbn/Rw1r8zbn53r/VK5eNE640Yk0N1JzrspSX9e M7YuPgOv8KQ2HX68J2qjoD89LN86HXMAmRhd7yUaeKTwCr13Rh1RGBeDnm4SxkAOsiHJ JdGhae/MrOaK93i5P9BkQB2CTxMGC/ZKTZz80puEi8qD08dX7ADuvCbNGjH3MaQlMKmZ RQxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c08ixnTw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020aa7d44f000000b0052553cc3360si7610285edr.118.2023.08.22.06.05.40; Tue, 22 Aug 2023 06:06:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c08ixnTw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235146AbjHVLph (ORCPT + 99 others); Tue, 22 Aug 2023 07:45:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235149AbjHVLph (ORCPT ); Tue, 22 Aug 2023 07:45:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D424ACD5; Tue, 22 Aug 2023 04:45:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 91607652E7; Tue, 22 Aug 2023 11:43:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47B58C433C8; Tue, 22 Aug 2023 11:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692704631; bh=wudzfjkA+EHXZH5qzkghyq8ajyMjlMf7/CcJJ8H1loo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=c08ixnTweOTEtnk7FrRu6NFWA4FtFG7ygUbW0O4N83Vkn/aJruTvsCyHJZBy9MZI5 N1drMLM/Uif/ij51EJg9IPd5ZNuXgnHjk81HLEQTIMgnj/9wDnztbm/5/4uC6WhDWR SRkVaKvDYZ/RHGhYUb6nI52f4cag5U9HYaMrx3uHoMXx/3Tcxvd8m1pz5tEK/iZHMx RmCuugBgVyh0JRzFUpNXlL8wUPubolaYWiEc+WwLHWTTAKpFNcm/aINZRlymvHDLVK tR2CGsvnHyviV+z4Mrgwfj24m+NV1LU97uUDYH+lTntgRJ0nlytm7ba2iHfGqhxPUK iWzBDS0DWsyeA== Date: Tue, 22 Aug 2023 20:43:47 +0900 From: Masami Hiramatsu (Google) To: Chuang Wang Cc: Steven Rostedt , Masami Hiramatsu , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: Re: [PATCH v3] tracing/eprobe: Iterate trace_eprobe directly Message-Id: <20230822204347.8b90a8507bde3343bb1ca264@kernel.org> In-Reply-To: <20230822022433.262478-1-nashuiliang@gmail.com> References: <20230822022433.262478-1-nashuiliang@gmail.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 22 Aug 2023 10:24:33 +0800 Chuang Wang wrote: > Refer to the description in [1], we can skip "container_of()" following > "list_for_each_entry()" by using "list_for_each_entry()" with > "struct trace_eprobe" and "tp.list". > > Also, this patch defines "for_each_trace_eprobe_tp" to simplify the code > of the same logic. > > [1] https://lore.kernel.org/all/CAHk-=wjakjw6-rDzDDBsuMoDCqd+9ogifR_EE1F0K-jYek1CdA@mail.gmail.com/ > > Signed-off-by: Chuang Wang Thanks, this looks good to me. Acked-by: Masami Hiramatsu (Google) > --- > v2 -> v3: > - use "for_each_trace_eprobe_tp" instead of "for_each_trace_eprobe_on_trace_probe" > > v1 -> v2: > - add "for_each_trace_eprobe_on_trace_probe" as suggested by Masami > > v0 -> v1: > - remove "Fixes" in the commit information. > > kernel/trace/trace_eprobe.c | 18 +++++++++--------- > 1 file changed, 9 insertions(+), 9 deletions(-) > > diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c > index a0a704ba27db..6a024b5912e2 100644 > --- a/kernel/trace/trace_eprobe.c > +++ b/kernel/trace/trace_eprobe.c > @@ -41,6 +41,10 @@ struct eprobe_data { > struct trace_eprobe *ep; > }; > > + > +#define for_each_trace_eprobe_tp(ep, _tp) \ > + list_for_each_entry(ep, trace_probe_probe_list(_tp), tp.list) > + > static int __trace_eprobe_create(int argc, const char *argv[]); > > static void trace_event_probe_cleanup(struct trace_eprobe *ep) > @@ -640,7 +644,7 @@ static int disable_eprobe(struct trace_eprobe *ep, > static int enable_trace_eprobe(struct trace_event_call *call, > struct trace_event_file *file) > { > - struct trace_probe *pos, *tp; > + struct trace_probe *tp; > struct trace_eprobe *ep; > bool enabled; > int ret = 0; > @@ -662,8 +666,7 @@ static int enable_trace_eprobe(struct trace_event_call *call, > if (enabled) > return 0; > > - list_for_each_entry(pos, trace_probe_probe_list(tp), list) { > - ep = container_of(pos, struct trace_eprobe, tp); > + for_each_trace_eprobe_tp(ep, tp) { > ret = enable_eprobe(ep, file); > if (ret) > break; > @@ -680,8 +683,7 @@ static int enable_trace_eprobe(struct trace_event_call *call, > */ > WARN_ON_ONCE(ret != -ENOMEM); > > - list_for_each_entry(pos, trace_probe_probe_list(tp), list) { > - ep = container_of(pos, struct trace_eprobe, tp); > + for_each_trace_eprobe_tp(ep, tp) { > disable_eprobe(ep, file->tr); > if (!--cnt) > break; > @@ -699,7 +701,7 @@ static int enable_trace_eprobe(struct trace_event_call *call, > static int disable_trace_eprobe(struct trace_event_call *call, > struct trace_event_file *file) > { > - struct trace_probe *pos, *tp; > + struct trace_probe *tp; > struct trace_eprobe *ep; > > tp = trace_probe_primary_from_call(call); > @@ -716,10 +718,8 @@ static int disable_trace_eprobe(struct trace_event_call *call, > trace_probe_clear_flag(tp, TP_FLAG_PROFILE); > > if (!trace_probe_is_enabled(tp)) { > - list_for_each_entry(pos, trace_probe_probe_list(tp), list) { > - ep = container_of(pos, struct trace_eprobe, tp); > + for_each_trace_eprobe_tp(ep, tp) > disable_eprobe(ep, file->tr); > - } > } > > out: > -- > 2.39.2 > -- Masami Hiramatsu (Google)