Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp749886rdg; Thu, 10 Aug 2023 20:10:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9nAm9xkhZFFdzdhKTdx+wGZniox9K1lJ6JEygcp0lMm/DUrOX1eI4nMubVWJoAcjTafgm X-Received: by 2002:a17:906:1cf:b0:99c:57ed:baf1 with SMTP id 15-20020a17090601cf00b0099c57edbaf1mr537511ejj.51.1691723403183; Thu, 10 Aug 2023 20:10:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691723403; cv=none; d=google.com; s=arc-20160816; b=rClIT/dVs1DUr7dKBz9oXc665XaDiz+RLSx2tHTZkdlJUI3PXduxI9MyBDbNVU7xMN S2qnRPEK+aBspi7dFMTDbFpEAtY2esgHdQoSQddvnsEKRapLVd+8v+kYhvVsFeHepoQ6 PGqes2IZfmiNaCAdeMQcqYiVbv7en9I+g3xUQfxWy4FTGl9UM3wMbkfjTExCRwE8u88d TzYZnBVoY6IqLjHvEINrEfvMEt3m20aqwnavnyAYftvOVtYAdvU2sJM5sOUQevKKIuN1 2QWsySpyQ28JQ4Eyta8XNUoy/OG7Q1VWg4VhYq/tWeNwyO7I7YzMeDXZJ+1EA5mktmhT JqBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=qhP8QpiCMA2S8cH3ID9XcIgvYsWAB2QE5PGdgRieaYQ=; fh=qjhh+Q8lY5AZS5kDkvTqle2A5Pfr+jb6ugOMh5jf/U0=; b=xMHq/LQYaJXxpBLWZeXGUCoi3Az3wD76DOBLDjNIDEFvp065yVV3a7iDybDHfRpC8h QWhGW+6ukGvCjK8nkA7aoxFTqngSd5HSwxbP/aUoZ765C0NcQSQatxmGQaSkhtcwMKvp stJBcY531HnfDOdUzH0LkA5wyU6T4600HTChiW1wXP93L/OxXYwZoKL3sptr+l28xg5M zY73sZpeHEYVmlJfcHb5nINwB8B7U6KwdOJ4rCxErA7OwU0fl5oHJRmh6T0EZMLxKblf WjlC6YVZsX7Xu44oKJrfhesouVaq1RjWETVB0f4QRNaOLGIvqdedju3h5MOGBK2wT8Zi ctMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20221208 header.b=gLMl1f3p; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fx11-20020a170906b74b00b0099367350a83si2702832ejb.898.2023.08.10.20.09.31; Thu, 10 Aug 2023 20:10:03 -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=fail header.i=@gmail.com header.s=20221208 header.b=gLMl1f3p; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232549AbjHKCrY (ORCPT + 99 others); Thu, 10 Aug 2023 22:47:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjHKCrX (ORCPT ); Thu, 10 Aug 2023 22:47:23 -0400 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FDAA2D60; Thu, 10 Aug 2023 19:47:22 -0700 (PDT) Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-768054797f7so115712185a.2; Thu, 10 Aug 2023 19:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691722041; x=1692326841; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qhP8QpiCMA2S8cH3ID9XcIgvYsWAB2QE5PGdgRieaYQ=; b=gLMl1f3pC55DMTipYsAr92CK6zvaQfdCtmqXF2JTJlOfY2E1VY5tLK1+Q5JWVgfo7n lVFNu8bQVUuULLZyMlMb8aqUDzg+8KfxdjuW0vp8SbNco+5mQKWOukisSj3clCPPgMHw jpJ9cYzuB2QXSvhtmbOCNMCVHBGyHflx0F39f+g78WfAh1qgN6wl5ThnypPptWVzRgB7 Bh/i8aIuEGjfUlFC1f5E7KnWCQIbsC2Aw7u8mrHtDIpLfcY8/QRg/BubeRlfuVgOJuQG MCLNo2AMxRglrp5MORZzL/CVHC6gBpNSbgBdNpH1AAp+QY+VudedevhqOAPkfVVXLaKd 9FjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691722041; x=1692326841; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qhP8QpiCMA2S8cH3ID9XcIgvYsWAB2QE5PGdgRieaYQ=; b=ibusgeVkfEL5Ki/F5mqT7tcSUcoAuvbk9MO6f4PLnEqKPrSp5Rm9bgHgANvemLzZqY d2BotSMNo0djlhODA53CnXLQI7qT00Xjo/1YkiXT2fP5bGcCNxEOxP36BoD6uVvlIvgE MhabNhOf/WxxBAJEoIFGmbvm2FTahTLCwDNWzYBGntR2rRtOlF66163J69sAPbogVFTW nx3ufp5cb9HuB7YCiTkwZQI7LQ/c1KLpmMJLD+kfgvknGVdaqHLzMX5bS1GVUMzHJrrV WfKL/DkQ++wYgjI8EYEkzqjNbAaXyhOKjkZODhu3ADQeK5K5CGgYXwkCAkghe4oh6lTN CU7Q== X-Gm-Message-State: AOJu0YzcoDXRDy7Q7r82qdGgd/v/7viOnGOmmen4N1+9Ww9+1OtRxf4v SmEHZ25LZnIkZeTxi6XUlA+4Ilih3vM= X-Received: by 2002:a05:620a:1a19:b0:768:1572:e9af with SMTP id bk25-20020a05620a1a1900b007681572e9afmr730090qkb.8.1691722040685; Thu, 10 Aug 2023 19:47:20 -0700 (PDT) Received: from localhost.localdomain ([8.210.156.175]) by smtp.gmail.com with ESMTPSA id a3-20020aa78643000000b0064d32771fa8sm2206332pfo.134.2023.08.10.19.47.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 19:47:19 -0700 (PDT) From: Chuang Wang Cc: Chuang Wang , Steven Rostedt , Masami Hiramatsu , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH v1] tracing/eprobe: Iterate trace_eprobe directly Date: Fri, 11 Aug 2023 10:47:02 +0800 Message-Id: <20230811024702.245746-1-nashuiliang@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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". [1] https://lore.kernel.org/all/CAHk-=wjakjw6-rDzDDBsuMoDCqd+9ogifR_EE1F0K-jYek1CdA@mail.gmail.com/ Signed-off-by: Chuang Wang --- v0->v1: - remove "Fixes" in the commit information. kernel/trace/trace_eprobe.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c index a0a704ba27db..d68d660dff7c 100644 --- a/kernel/trace/trace_eprobe.c +++ b/kernel/trace/trace_eprobe.c @@ -640,7 +640,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 +662,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); + list_for_each_entry(ep, trace_probe_probe_list(tp), tp.list) { ret = enable_eprobe(ep, file); if (ret) break; @@ -680,8 +679,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); + list_for_each_entry(ep, trace_probe_probe_list(tp), tp.list) { disable_eprobe(ep, file->tr); if (!--cnt) break; @@ -699,7 +697,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,8 +714,7 @@ 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); + list_for_each_entry(ep, trace_probe_probe_list(tp), tp.list) { disable_eprobe(ep, file->tr); } } -- 2.39.2