Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5455081imm; Tue, 16 Oct 2018 10:28:39 -0700 (PDT) X-Google-Smtp-Source: ACcGV63VuB1MXbX6IXCNXpGQEI/EyBZXcNqI9p1lQjo4zUszrRVme/F9LLkSp6cv9NZKbPrkTAhR X-Received: by 2002:a17:902:a9c5:: with SMTP id b5-v6mr18629561plr.340.1539710919000; Tue, 16 Oct 2018 10:28:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539710918; cv=none; d=google.com; s=arc-20160816; b=UrQNjKhjXBAE4IxZtc1SUiEmcrLI/1DzBeH1AgrjMvchhABquxRyOFY62/D4tFRCYy 9GNIV7HenrSQqafRsbuEY2qHreSupSt8A1BTLLYqyoTb1S2SSkbHp4Vtk0n1SP6LDpNA jdxe8JyLMMopgbljIenylHcmdmJ6v8sfmgwQZbGa11sBYdpw0gohlgSvR0nOOOrVloPt i3oY5QQ7QuzyBYlPnyq5uVWoe/g/F9ncvspaHFfsH92TBkJ29iQgEAr0RVVDYqpMHF63 zzZhCMMvGW/6N8F0FAhxBlCaxMkVt52afoIESbJvdzy+/fIJiBcC0l1ElTnYNxz2CQpQ nadQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=x7O73kMV3oqnT3WNZu7LCAU+PJNhP2JJregkjJP6laE=; b=dAUEOqw1rDnUTPTn7XVlm2/PoQXJCQ1njt8nQ3ziFm/TU2ysmtsdvrsRxEpIfaQb0O ueTlhUk5v3xKUzESd94ew7t6pWZZ7dFgzHN7wXdgBWe60nRa4MwokJdogVLBRXVxRoYH k3dtmuLL4Ps5vfqi8t93qto8Zc2QbkbCO+Rr/V4hd3i7avC1p2eHJL43pCxytzgDMWjH FpRsTRbCZIoow6q2qESeWyj2tE4xMOQfINVJZ7guwljFVp9KHlxOh20YcTqiwGaij34Y 6dCXz5g/hAvFYRtaTAzT7cYIoKgg3JnON1MY1Do5/D8q2G116E25Plq2VWGl89M8gLyv kL6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rILFYOZ5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x13-v6si9838564plr.439.2018.10.16.10.28.23; Tue, 16 Oct 2018 10:28:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rILFYOZ5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731900AbeJQBQi (ORCPT + 99 others); Tue, 16 Oct 2018 21:16:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:35322 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730396AbeJQBQh (ORCPT ); Tue, 16 Oct 2018 21:16:37 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AEE1320866; Tue, 16 Oct 2018 17:25:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539710711; bh=gsRULgFs11CRW6QCb0FGj4RGOS6VCJaPLJ6LKxSDlcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rILFYOZ5icb5qDOy4WmHJh0l0+UGO/f4JB0C1vDIzygYg7IveCcdZu3lIFsQ/hkQL +wQ++FoSmT7sSg5/IlSy9guirjv4oOCDoT/hrbky3tD9UClD0SzVxmi8P102/iW6Y4 KVf0F57MYFOuIRr11Gv1N+4bs6yM3965SSqdpXkc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "David S. Miller" Subject: [PATCH 4.9 62/71] net: speed up skb_rbtree_purge() Date: Tue, 16 Oct 2018 19:09:59 +0200 Message-Id: <20181016170542.493641718@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181016170539.315587743@linuxfoundation.org> References: <20181016170539.315587743@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet As measured in my prior patch ("sch_netem: faster rb tree removal"), rbtree_postorder_for_each_entry_safe() is nice looking but much slower than using rb_next() directly, except when tree is small enough to fit in CPU caches (then the cost is the same) Also note that there is not even an increase of text size : $ size net/core/skbuff.o.before net/core/skbuff.o text data bss dec hex filename 40711 1298 0 42009 a419 net/core/skbuff.o.before 40711 1298 0 42009 a419 net/core/skbuff.o From: Eric Dumazet Signed-off-by: David S. Miller (cherry picked from commit 7c90584c66cc4b033a3b684b0e0950f79e7b7166) Signed-off-by: Greg Kroah-Hartman --- net/core/skbuff.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -2433,12 +2433,15 @@ EXPORT_SYMBOL(skb_queue_purge); */ void skb_rbtree_purge(struct rb_root *root) { - struct sk_buff *skb, *next; + struct rb_node *p = rb_first(root); - rbtree_postorder_for_each_entry_safe(skb, next, root, rbnode) - kfree_skb(skb); + while (p) { + struct sk_buff *skb = rb_entry(p, struct sk_buff, rbnode); - *root = RB_ROOT; + p = rb_next(p); + rb_erase(&skb->rbnode, root); + kfree_skb(skb); + } } /**