From patchwork Fri Aug 11 02:47:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuang Wang X-Patchwork-Id: 134293 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp825967vqi; Thu, 10 Aug 2023 20:12:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYMok8rM0HDplvWoa24yE4T4py+1x+3waLa+15XQpxUhn5pXcAHIo+e7zgGaOp5t0gtw8A X-Received: by 2002:a17:90a:8990:b0:26b:f67:9d1b with SMTP id v16-20020a17090a899000b0026b0f679d1bmr305986pjn.30.1691723571972; Thu, 10 Aug 2023 20:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691723571; cv=none; d=google.com; s=arc-20160816; b=tyQ/z5O71yRPgOTblelGvgXw64ySGGeqbfELRHudTDo8fWdx9SMdVekQSUM9dN2Uii YRNCYuiPCChNghuIVZaV1/gZPggTxTpZGiWhwo36TaYT7ls7kqY3X16yKfPFR9goMMoS Zbk85JkKnHNCmQ1DVlleDra8XnHkhoZOX1wpN7XSMVbldM5NpqG1R8w0ji69UkHS17Tl /+XGix0RFQtowAiZ6GVuX3qq9FTzEQsiOz3A20umEXvzVn8Trz+pkj2xT57m+ncmScdc EV0ZVoaeXNHcbOXN+4tHZPcsHHNubxczLqRtTVegqaxKeeF00ACe7l1XThQ/hlgoEtYr y/QA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o11-20020a17090ac70b00b00267a487f014si4629346pjt.167.2023.08.10.20.12.39; Thu, 10 Aug 2023 20:12:51 -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 S232609AbjHKCrY (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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773900736133525385 X-GMAIL-MSGID: 1773900736133525385 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); } }