From patchwork Thu May 12 14:17:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiabing Wan X-Patchwork-Id: 12847759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15611C4332F for ; Thu, 12 May 2022 14:17:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355141AbiELORe (ORCPT ); Thu, 12 May 2022 10:17:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355137AbiELORc (ORCPT ); Thu, 12 May 2022 10:17:32 -0400 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2133.outbound.protection.outlook.com [40.107.117.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA6826D18B; Thu, 12 May 2022 07:17:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VA7qHG3mjHTpXMeCCVgbWGtcSj3cAkRu/Hg/1RDX+RxC/UUH4iF0W3mkO5i0HiqO1gldzpKyLadEYyD7zxWuwuedhKQg0OA6+vCnexjlokpDsmSydvLiTFEI2RS6Vz0yjYAy5k+jM5MsNxeqjKsYZ1+d7Xv3EZmGtNzeQK+RxLW32/xHqyg1jQJikkK10yfR6hk1hSw0EWDMQvl/hvO9Wom2+IJvOdzMlnum5txEVfsU0HrUA5nFu/leMIH+pJVzzA91I8AbUvLoZFDrk5Ov+dK3a94s+EmrG5f6TCpnOZ0ZDjKYuYi8MpSQOnfY3GqKNsvvukC3wLMgbEfDItGcfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3QtFBEqW/y4ETycRPZVO5c1a4DCagIa9eabyA/nIRN4=; b=NxAZucuuwNrxMqAqt3hl8V8gQbxtcZ8lSXytdrMaiVlAtm1OlIvh+KT+AM1pOP1hh5zzGyiO0mRapKAsUsCyn3IPhzydY7wyXF1qhqbzF2gHZrMFCD2baEJWQSi5OZlMj1OQScxOmjLZNKvjhsqUGPabSSIidei0bNJDY559ndSPi0KD5YS1F6HMGLS6IcI1/lCEqiTmVc/IIqU7GNpmfPDOGYX3MialCWV+oMNhDDEPYdHeh6MXEpB8jmC+poWfrJyTj5YNRoWEWlynat3pkEnkAnFalIwkWl032IXy15yGHailkkHjanSxmOwCGrM63eKynba6gHKPAmsD1catGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo0.onmicrosoft.com; s=selector2-vivo0-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3QtFBEqW/y4ETycRPZVO5c1a4DCagIa9eabyA/nIRN4=; b=ek5cRvqAnWxp/+GPuS32TVUS7wxaQX8gpVAQaJFyyRcf8D1Iz3EBuyS13OissxLHy4W53+PhFl+7LjYQgpmqsozcAbAnpbqgYQatYsjHOD/XkLLXv8pq3AkDL+1nKprJ/8GYb2A+nhj2vcQSkVQMRSwpSRh4er0YkkDqe/9GT3Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SG2PR06MB3367.apcprd06.prod.outlook.com (2603:1096:4:78::19) by HK0PR06MB2819.apcprd06.prod.outlook.com (2603:1096:203:30::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Thu, 12 May 2022 14:17:24 +0000 Received: from SG2PR06MB3367.apcprd06.prod.outlook.com ([fe80::4591:4f3e:f951:6c8c]) by SG2PR06MB3367.apcprd06.prod.outlook.com ([fe80::4591:4f3e:f951:6c8c%7]) with mapi id 15.20.5227.022; Thu, 12 May 2022 14:17:24 +0000 From: Wan Jiabing To: Steven Rostedt , Ingo Molnar , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Wan Jiabing Subject: [PATCH 0/3] bpf: optimize the bpf_kprobe_multi_link_attach function Date: Thu, 12 May 2022 22:17:07 +0800 Message-Id: <20220512141710.116135-1-wanjiabing@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: HK2PR02CA0133.apcprd02.prod.outlook.com (2603:1096:202:16::17) To SG2PR06MB3367.apcprd06.prod.outlook.com (2603:1096:4:78::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0967f460-abbe-4d73-69f0-08da34222286 X-MS-TrafficTypeDiagnostic: HK0PR06MB2819:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pEC8fk1YFnzPjgs99vjpNfwsvDuDkPrzCMoatHsjZjNfG5+6zNytl1b3IMjuhmIdy0X9fGse6UyVSjyiCBPymTz1QPkuSjI3aa2HPN9O2DBnv+we3JULmYcZLBaCvWxS4o45MotxBsWtEHJ5zs1eWH+ke9xeOR3Yoh1i/TIxpw7iXBIirOdEH/Sd6Dih4RWcKxMU+phjPlJBT5MprztQjSTxW3nGLFpECyipYxZDcpvsGfzPsoRn2nQtHiz5WN8F2DN7EuqS10nyz4uaq55P04O2BJPT0shYGTmk4DYN3lcpD+VctXuQslMYzZZX5eRoLLYKlQps0naCt9utuO6fHifYoHtN++fVWBxH1VL74OHRBvjIbYUZgyh3X+sKkUriQOzcgOlXejSQtPUNp+ABuCpNvq5nnUGhYAbfb9Pac7ONb0Nr8KtEm4RyU3kwqtInBDOSKBNgIamyFdt58NS1peLg7PGajxHIiEC8Lwnc/Lh3Mb4EO7+/IG8jl7SuZORW+qapmZ5WpFSfPWERmr744I6xL8o6MetRTtabxwWB2ScoPSDkl4vSudzPVQVeKGWVEZNMVW3vCbFMFKK01TvBYXAYlGJmWkAXszZIOAtFc/bKU6XsHUvQJIF5+BGWJk7zZjsJWZQkJAgZVIBS8kUskeFBjpSoezJNWAySGSyZi0ejN/DXVCsVA+RQXDoXxMq0QmQ2mt+9Ji3ZFvuOQQMJGBoBExgZmfZ/1AXhVMrm2+nll475muNeM/rHagnlY1jC X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SG2PR06MB3367.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(8936002)(921005)(36756003)(6512007)(38100700002)(38350700002)(2906002)(6486002)(26005)(6666004)(508600001)(7416002)(4744005)(52116002)(5660300002)(6506007)(110136005)(86362001)(83380400001)(316002)(66946007)(66556008)(66476007)(8676002)(4326008)(2616005)(107886003)(1076003)(186003)(21314003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BLJASHxLHegHUO1hzR/oUw+O88npuXAXKot2YkS5HG/P8CLHXk86ACJ7Up9hA5J0EoPbIUeOW1TT2NW1an2pzjmO9ecWCWi0OTZap6kfPvM2hgiKReA3oIUcuL3NdGO0nTbX6m1gybEoVaH6NXzKJG73AdL0oTl9wdXWSv2xPKIK5P1q/SqwiNjWe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QWm+zdV+wxfV9X1mAU8baLcz20xzB+ShCAxE5MJXeWPuJWp3WKRukJ1PL8luUVklZZu8HGQysAMBWZ5aLVqNgkmKr9igwftNpa9ZMA8OF154FKCgrTYe7XYhYraC7JwMo+gPhqE8ZqNZ3J49eAre9+I6g/LgRb88npZTvAhadNhZOrKFG4TdmQfhc45qwXNsFw2AFQwTb84ZQGj77K+dWbgWWC1xx7riAyHwiTWqtD/frSh3ACl8X4LBPhXTWXaISwaVI5FX0KRZGIKmNE4ylZ7eE8mURheDWMvMl5RHl6goqL4O2HuPw6Rg96yU7Dv4KsBb7FWGPctFPPvh+QSi7jyMvjFDFkqCSjJQt/Tv4RoGQCjviVlNh5K5sHWuKSrudRa/rVBF7K9IZR8GaQKQwte6OniG4FsIJRObUMCbd7gA1jf3QLedjjq5Uk9E2ECxtCB9XwSQJ/tkXyginlf3puRbm3VA== X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0967f460-abbe-4d73-69f0-08da34222286 X-MS-Exchange-CrossTenant-AuthSource: SG2PR06MB3367.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2022 14:17:24.2394 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: L/MqicdulRiUb9HvmeBWoTVOjJoT/Ir11E0LJTfIi5f/kFgIRwyMQGk/spLxXoKp3blc1vcw3nTW1Pf86iAhtg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK0PR06MB2819 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch series tries to optimize the bpf_kporbe_multi_link_attach in bpf_trace.c Firstly, there is only one 'error' tag to handle error code. But in one 'error' tag, there are three 'free' functions which is not efficient. So I split this one tag to three tags to make it clear. Secondly, I simplify double 'if' statements to one statement. Finally, coccicheck reports an opportunity for vmemdup_user. So I use vmemdup_user to make code cleaner. Wan Jiabing (3): bpf: use 'error_xxx' tags in bpf_kprobe_multi_link_attach bpf: simplify if-if to if in bpf_kprobe_multi_link_attach bpf: use vmemdup_user instead of kvmalloc and copy_from_user kernel/trace/bpf_trace.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-)