From patchwork Mon Dec 12 12:31:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "wuqiang.matt" X-Patchwork-Id: 2875 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2215355wrr; Mon, 12 Dec 2022 04:33:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf7svgIAKBfzZ7U/h7xG3XD0Oe6gtkzWSzJYD3kQukpDS1ATu3x8RZWdX5HEhiyHaRKvcMo9 X-Received: by 2002:a17:906:a3c1:b0:7ad:7d4a:ebfd with SMTP id ca1-20020a170906a3c100b007ad7d4aebfdmr13325301ejb.62.1670848439160; Mon, 12 Dec 2022 04:33:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670848439; cv=none; d=google.com; s=arc-20160816; b=SCKPehPDs8YwHYraG0ULkGrvbowEUXYYFXtTFxDZazoWMM8UThk1PdSGYwoGdQI3U4 KpGFYNWz54rJa3vjsYWsQzaMB6Y+lvyZ6wu0nXIU0bpToGaRJLS5lSFqB2XXBeQr8VvE gyeyqMoGd4vRqhMcSRLADp7VxnUFKzPi+Z1g/LMfI1cidMo3HV7XoDt4i3bRUzYgRqYH Lps/9NvGjBU2cT6zsztzWrZV39Bnr1Air2T6LFZI2mu5FfBQHPW9Db3x0eMMNEj+F7EZ F47PRHHKWIaOPyKGt7LHz/QArgJos4wywZyah1ksrOFqHlwZgyTUK6gO3k7nFMadQ9Dj gpNA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=hgZqsgFPlB2r29EuVp4P4X4aSqIJdTCkcI1OXU5kHKI=; b=WpaGOkF9n0NyNlADqpf3+sN7XcNpHDYOmhWzE6k/qcvosOBGfliZQdVj85XNd3hkri Wk886KWLd6w5oUJ73PiCrJohyKCWtS2kSX6G7C7IDpcJz0XvroX/111AnGr3oM71upED VyhdYIkzdXgCW1P48MXxMf7uiWYspitKG4AcJardZIVqSV3hKq2TqOCBNZzJJ6kmDduU R93pzlxBPldmtGWJc3lhpSj5QlDBOkIu7IUV7hE7JfQZvp7OowZ+6se/Q9Rwna/uWlgA kB6lXKqL0js2Rt0bYbho4lutjy3HhywzZeyBpIepCZurYoXDndQLxpgNKFkScr9ugx4y BsUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=xUD0yI4I; 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=NONE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg35-20020a170907a42300b0077b4248b138si5748395ejc.127.2022.12.12.04.33.34; Mon, 12 Dec 2022 04:33:59 -0800 (PST) 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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=xUD0yI4I; 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=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232085AbiLLMcg (ORCPT + 99 others); Mon, 12 Dec 2022 07:32:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231910AbiLLMcf (ORCPT ); Mon, 12 Dec 2022 07:32:35 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD35CF025 for ; Mon, 12 Dec 2022 04:32:32 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id o12so11864516pjo.4 for ; Mon, 12 Dec 2022 04:32:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hgZqsgFPlB2r29EuVp4P4X4aSqIJdTCkcI1OXU5kHKI=; b=xUD0yI4I0FjcHE50SeF+tpxonSL5ArNXKxRfZbPv3pU7F3jNRAIRRnHG2aWxHO5GN2 DP3p2LqWhtBDfCAtA6btcLs3HA1EIzKUwlBoSobuy5pI7Zf+9vFl6OnP/Gg+NlbVJzX0 fQ6LsfWMKSuuvu/Ks16CN7IrNTIzM8IoUXWzvMo6rACSk2Nq9z1lz+75hrv6Ol5smabp lmsw3i4UBv7JDSrQR7B7pqa1Xh9GK5BlynkAVuh+7s7E2W1PLqC7acaGAGqIC7n6OIJx 9BpY80BulF5JUAksEHIqSc/1CR6XEFwJGv/stumQxpUXaqRUAMungMOMn4dt4SzSOANU MUzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=hgZqsgFPlB2r29EuVp4P4X4aSqIJdTCkcI1OXU5kHKI=; b=jB9oD9RVR/5jHwtjBYVIQATPvLhdcc4GtFrdkbJT1I443OY+1ScmbLKm1mHzIc+BrJ Fa05fDJkp/KWv59NG6oP3+41RTbfaC+ibCpXiTx914NdG02/N9beIjf9F3RyQwfcN2E9 1HpfeZVinRTr9r1eWdbKxYxkeNcGZ9V2VhTnfZOWKWasRnHFjAXcUxXuAaIjvVlYTOIB rce04EM7kYrRjtHW2BNBzFK9Mi8DJdBbAd9T4ggG0MSTuxKVsruKCBX4Al7ZZn6VZgoT Qev4QZZH3T6rVFnR2E8hQguZ0jTRFP+FPEA0cHd4HytmAFDLxkhjdchqQ4aNXFoml6iN C6MA== X-Gm-Message-State: ANoB5pkEbUTc0K9FHC9FbysuMoMFtzODuU8oJ6GExJU8tlCXIXHh6nQQ qlHPxWwAAUw8lkjN2LRAP/KLEQ== X-Received: by 2002:a17:902:cf0a:b0:189:5bd:10aa with SMTP id i10-20020a170902cf0a00b0018905bd10aamr16238707plg.58.1670848352423; Mon, 12 Dec 2022 04:32:32 -0800 (PST) Received: from devtp.bytedance.net ([139.177.225.227]) by smtp.gmail.com with ESMTPSA id jw1-20020a170903278100b001869ba04c83sm6219987plb.245.2022.12.12.04.32.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 04:32:32 -0800 (PST) From: wuqiang To: mhiramat@kernel.org, davem@davemloft.net, anil.s.keshavamurthy@intel.com, naveen.n.rao@linux.ibm.com, rostedt@goodmis.org, peterz@infradead.org, akpm@linux-foundation.org, sander@svanheule.net, ebiggers@google.com, dan.j.williams@intel.com, jpoimboe@kernel.org Cc: linux-kernel@vger.kernel.org, lkp@intel.com, mattwu@163.com, wuqiang Subject: [PATCH v7 0/5] lib,kprobes: kretprobe scalability improvement Date: Mon, 12 Dec 2022 20:31:48 +0800 Message-Id: <20221212123153.190888-1-wuqiang.matt@bytedance.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752011573001851592?= X-GMAIL-MSGID: =?utf-8?q?1752011573001851592?= This patch series introduces a scalable and lockless ring-array based object pool and replaces the original freelist (a LIFO queue based on singly linked list) to improve scalability of kretprobed routines. Changes from v6 (https://lore.kernel.org/lkml/20221108071443.258794-1-wuqiang.matt@bytedance.com/): 1) objpool: implementation simplified as Masami advised 2) rethook_alloc: error codes returning supported (ERR_PTR) 3) MAINTAINERS: support added for objpool files 4) synced to latest 6.1 with x86_64/x86/aarch64 verified wuqiang (5): lib: objpool added: ring-array based lockless MPMC queue lib: objpool test module added kprobes: kretprobe scalability improvement with objpool kprobes: freelist.h removed MAINTAINERS: objpool added MAINTAINERS | 7 + include/linux/freelist.h | 129 -------- include/linux/kprobes.h | 9 +- include/linux/objpool.h | 109 ++++++ include/linux/rethook.h | 14 +- kernel/kprobes.c | 101 +++--- kernel/trace/fprobe.c | 37 +-- kernel/trace/rethook.c | 99 +++--- lib/Kconfig.debug | 11 + lib/Makefile | 4 +- lib/objpool.c | 320 ++++++++++++++++++ lib/test_objpool.c | 696 +++++++++++++++++++++++++++++++++++++++ 12 files changed, 1264 insertions(+), 272 deletions(-) delete mode 100644 include/linux/freelist.h create mode 100644 include/linux/objpool.h create mode 100644 lib/objpool.c create mode 100644 lib/test_objpool.c