Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3175055rdg; Tue, 17 Oct 2023 06:58:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJpgRYj6tAj1OjrNqme7v2Y5AwsedKPzwx9Vysvi7awsMIH3fxWx9W2fovOcwfB30hgnVz X-Received: by 2002:a17:902:c945:b0:1c5:9c73:c91c with SMTP id i5-20020a170902c94500b001c59c73c91cmr2710424pla.48.1697551112713; Tue, 17 Oct 2023 06:58:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697551112; cv=none; d=google.com; s=arc-20160816; b=jaz2Yqye4QEu5i615ZXjgnhV+gQqznZyDE6C8jjw7SHhR65P3IKzvxLHABxbDfARmo jVUHqSVjOdPrc3SWhHqWMRbXCrTjf+IWX18hnB6POVGoS6mfzA5Wi7tsSLS2tVbpHZEI CKID7C4OWRnyf5lTMWgcTnfBlZVyhnwNbErf4v8M1V48KkFiSMXhKur0f6pBIaSFNJW+ A/aCyL1AKhq8iD8mgTf7hEHvI4qWL5dkrwqZf0coyfbKBy3d3dHRgBpgMsMKYqgUBC8f Oew4A+l6AfwmtizoicpR49n2ueuLD0lykXwXyF2w+Q9hu44HHYCp7f11OcQR7phXRTHo FF5w== 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:date:subject:cc:to:from :dkim-signature; bh=DeCI1NwP8+gNkfLZ//g6QG7eHPqu4x99wp4QGWvVdhI=; fh=IpZUYbsqKid0r4pbePo9OTESEiKTs4Y7HhR29dJG614=; b=BLBj58eyhzImSh1/GWkAhbIhZLTFuhwck7VbsiCKJ7Zdfx7PGtq3JMH8uopSk3l/uy X0F6VSR80ZCIw68D+e/uxg8QivC+CwoPpM49GnZttvGCm+HN75TvJSz8SAuX/i4gFUbx 7ribVs8ckC2AzfufFMDjOASMOOYN2jLiKZ6uexEQ4Abux6C7aXmYQPZbzwCYxOzUMlJs qoDAHjqsipAmb0r3T1/E1P+l2UCHbcKSOV2d3pE1VlR1V1EVCVgv4ItCUatsMs2rVT2d c1MesYdJGkUNiP5+MN9bbh4T4r6ZuilG6efnW9UQAA0CeTEEYZNRs3NRBLRKzQ9krV7E Oxqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=jI8kYVnQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id li11-20020a170903294b00b001c61af1e683si1669942plb.641.2023.10.17.06.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 06:58:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=jI8kYVnQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id B21A08033DC2; Tue, 17 Oct 2023 06:58:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343998AbjJQN6A (ORCPT + 99 others); Tue, 17 Oct 2023 09:58:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235065AbjJQN5y (ORCPT ); Tue, 17 Oct 2023 09:57:54 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B04AF0 for ; Tue, 17 Oct 2023 06:57:33 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6bb4abb8100so2319561b3a.2 for ; Tue, 17 Oct 2023 06:57:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1697551053; x=1698155853; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DeCI1NwP8+gNkfLZ//g6QG7eHPqu4x99wp4QGWvVdhI=; b=jI8kYVnQzrWJ/FoIBcQYkC/UZRT2VH6IwA1fRfZ9f2W7AXo2gTDwjExJObrH4iF8um /UkoDoRYx97P/in7R5SA922l+ddKczqF+/F+B03NqEDt3t2y9sTJ8sHxEN1fi65hJX9R 0C8kvbpMOlXymHCEIPLVLGbhnuYfTUXa1IJpZDaTHOVgoUcX0hAw7NAL2A0Ksf33GLTM RaSzhoZsa4Nykmx3BoxSw1V00XqWsJqcsv4XhMc/Y2Q/+sQf95IDBQClQLpXHa29a9rH od4uhShohguPO6lGvX+zMyMZ5Q8NQwq5qUvZLIGJHBlAGyCmd0qWQQUsDrgCwaw84rSH 6yZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697551053; x=1698155853; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DeCI1NwP8+gNkfLZ//g6QG7eHPqu4x99wp4QGWvVdhI=; b=sDd3OTj0Af230R6nM3BStdNDO5Tu3Nnq9hl9/VV4LCXN55LkM42BlQVbLD7JnwMnt9 82BYZlQ3uqupbgPS/dXnm4WXA5YBSDtRpYR/LdOMBNNVruNDFackPyUFxzOz1rZ+0G6b dhaIEA1rHMIyfi/9p2pimQTM5OieetRqnLOJAtHCrHgmn3NwCvHSgXuB+R/FFk7FA5gR knBMwzUQQRS1YgpFGBB/zLqM/777l6ekEYqbzB67fuyA6lu5VNSfv89PrjhDlynLppOi +YGI/Xv7iAdij1PFno5m5aMfZTIjRo1CMZiGkGg7r2VdvXbr+o2OIPeOk6oM/W7cqXbS BaHw== X-Gm-Message-State: AOJu0YxxFArSw9CHtRyZ0bNEHRDsK6ly0yCPOA6CWIqaNwExBdPnSPOG CNH7cwohVMgqR+tAlvMOKNzLDg== X-Received: by 2002:a05:6a21:33a4:b0:161:3120:e872 with SMTP id yy36-20020a056a2133a400b001613120e872mr2356665pzb.20.1697551052698; Tue, 17 Oct 2023 06:57:32 -0700 (PDT) Received: from devz1.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id b9-20020a170903228900b001b9e9edbf43sm1566634plh.171.2023.10.17.06.57.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 06:57:32 -0700 (PDT) From: "wuqiang.matt" To: linux-trace-kernel@vger.kernel.org, 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.matt" Subject: [PATCH v11 4/5] kprobes: freelist.h removed Date: Tue, 17 Oct 2023 21:56:53 +0800 Message-Id: <20231017135654.82270-5-wuqiang.matt@bytedance.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231017135654.82270-1-wuqiang.matt@bytedance.com> References: <20231017135654.82270-1-wuqiang.matt@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 17 Oct 2023 06:58:29 -0700 (PDT) This patch will remove freelist.h from kernel source tree, since the only use cases (kretprobe and rethook) are converted to objpool. Signed-off-by: wuqiang.matt --- include/linux/freelist.h | 129 --------------------------------------- 1 file changed, 129 deletions(-) delete mode 100644 include/linux/freelist.h diff --git a/include/linux/freelist.h b/include/linux/freelist.h deleted file mode 100644 index fc1842b96469..000000000000 --- a/include/linux/freelist.h +++ /dev/null @@ -1,129 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause */ -#ifndef FREELIST_H -#define FREELIST_H - -#include - -/* - * Copyright: cameron@moodycamel.com - * - * A simple CAS-based lock-free free list. Not the fastest thing in the world - * under heavy contention, but simple and correct (assuming nodes are never - * freed until after the free list is destroyed), and fairly speedy under low - * contention. - * - * Adapted from: https://moodycamel.com/blog/2014/solving-the-aba-problem-for-lock-free-free-lists - */ - -struct freelist_node { - atomic_t refs; - struct freelist_node *next; -}; - -struct freelist_head { - struct freelist_node *head; -}; - -#define REFS_ON_FREELIST 0x80000000 -#define REFS_MASK 0x7FFFFFFF - -static inline void __freelist_add(struct freelist_node *node, struct freelist_head *list) -{ - /* - * Since the refcount is zero, and nobody can increase it once it's - * zero (except us, and we run only one copy of this method per node at - * a time, i.e. the single thread case), then we know we can safely - * change the next pointer of the node; however, once the refcount is - * back above zero, then other threads could increase it (happens under - * heavy contention, when the refcount goes to zero in between a load - * and a refcount increment of a node in try_get, then back up to - * something non-zero, then the refcount increment is done by the other - * thread) -- so if the CAS to add the node to the actual list fails, - * decrese the refcount and leave the add operation to the next thread - * who puts the refcount back to zero (which could be us, hence the - * loop). - */ - struct freelist_node *head = READ_ONCE(list->head); - - for (;;) { - WRITE_ONCE(node->next, head); - atomic_set_release(&node->refs, 1); - - if (!try_cmpxchg_release(&list->head, &head, node)) { - /* - * Hmm, the add failed, but we can only try again when - * the refcount goes back to zero. - */ - if (atomic_fetch_add_release(REFS_ON_FREELIST - 1, &node->refs) == 1) - continue; - } - return; - } -} - -static inline void freelist_add(struct freelist_node *node, struct freelist_head *list) -{ - /* - * We know that the should-be-on-freelist bit is 0 at this point, so - * it's safe to set it using a fetch_add. - */ - if (!atomic_fetch_add_release(REFS_ON_FREELIST, &node->refs)) { - /* - * Oh look! We were the last ones referencing this node, and we - * know we want to add it to the free list, so let's do it! - */ - __freelist_add(node, list); - } -} - -static inline struct freelist_node *freelist_try_get(struct freelist_head *list) -{ - struct freelist_node *prev, *next, *head = smp_load_acquire(&list->head); - unsigned int refs; - - while (head) { - prev = head; - refs = atomic_read(&head->refs); - if ((refs & REFS_MASK) == 0 || - !atomic_try_cmpxchg_acquire(&head->refs, &refs, refs+1)) { - head = smp_load_acquire(&list->head); - continue; - } - - /* - * Good, reference count has been incremented (it wasn't at - * zero), which means we can read the next and not worry about - * it changing between now and the time we do the CAS. - */ - next = READ_ONCE(head->next); - if (try_cmpxchg_acquire(&list->head, &head, next)) { - /* - * Yay, got the node. This means it was on the list, - * which means should-be-on-freelist must be false no - * matter the refcount (because nobody else knows it's - * been taken off yet, it can't have been put back on). - */ - WARN_ON_ONCE(atomic_read(&head->refs) & REFS_ON_FREELIST); - - /* - * Decrease refcount twice, once for our ref, and once - * for the list's ref. - */ - atomic_fetch_add(-2, &head->refs); - - return head; - } - - /* - * OK, the head must have changed on us, but we still need to decrement - * the refcount we increased. - */ - refs = atomic_fetch_add(-1, &prev->refs); - if (refs == REFS_ON_FREELIST + 1) - __freelist_add(prev, list); - } - - return NULL; -} - -#endif /* FREELIST_H */ -- 2.40.1