From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F257C43603 for ; Thu, 5 Dec 2019 00:51:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D08AB24658 for ; Thu, 5 Dec 2019 00:51:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="aN9PgcSJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D08AB24658 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7EA026B0DAF; Wed, 4 Dec 2019 19:51:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C2D66B0DB1; Wed, 4 Dec 2019 19:51:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B0B16B0DB2; Wed, 4 Dec 2019 19:51:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0123.hostedemail.com [216.40.44.123]) by kanga.kvack.org (Postfix) with ESMTP id 539AF6B0DAF for ; Wed, 4 Dec 2019 19:51:49 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 2C3154DC7 for ; Thu, 5 Dec 2019 00:51:49 +0000 (UTC) X-FDA: 76229260338.26.use14_fda0942aef23 X-HE-Tag: use14_fda0942aef23 X-Filterd-Recvd-Size: 3070 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Dec 2019 00:51:48 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (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 CBC6C2465D; Thu, 5 Dec 2019 00:51:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575507108; bh=CNumfEPWSwi51AirPQnDcnTIvvyaDcywvX3vxdPk1ho=; h=Date:From:To:Subject:In-Reply-To:From; b=aN9PgcSJyC3waJtyiOxQJcE2H6tDn517KfqG7i2phMK/ft1lgev2h4Rkfm8N60skL 4NipxRBxZbWiWbZlZ/Sr535OB99fsNp0HNh+oYgFwuu5njmXKe7Cwh4SgvY34bF+Tg zkuOHDQ2+pEzxwqpUOI0kAqgZ40LzYfD70uvDKbc= Date: Wed, 04 Dec 2019 16:51:47 -0800 From: Andrew Morton To: akpm@linux-foundation.org, dbueso@suse.de, linux-mm@kvack.org, mm-commits@vger.kernel.org, peterz@infradead.org, richardw.yang@linux.intel.com, tglx@linutronix.de, torvalds@linux-foundation.org, walken@google.com Subject: [patch 38/86] lib/rbtree: set successor's parent unconditionally Message-ID: <20191205005147.IjXbLGgEv%akpm@linux-foundation.org> In-Reply-To: <20191204164858.fe4ed8886e34ad9f3b34ea00@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Wei Yang Subject: lib/rbtree: set successor's parent unconditionally Both in Case 2 and 3, we exchange n and s. This mean no matter whether child2 is NULL or not, successor's parent should be assigned to node's. This patch takes this step out to make it explicit and reduce the ambiguity. Besides, this step reduces some symbol size like rb_erase(). KERN_CONFIG upstream patched OPT_FOR_PERF 877 870 OPT_FOR_SIZE 635 621 Link: http://lkml.kernel.org/r/20191028021442.5450-1-richardw.yang@linux.intel.com Signed-off-by: Wei Yang Acked-by: Peter Zijlstra (Intel) Reviewed-by: Michel Lespinasse Reviewed-by: Davidlohr Bueso Cc: Thomas Gleixner Signed-off-by: Andrew Morton --- include/linux/rbtree_augmented.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/include/linux/rbtree_augmented.h~lib-rbtree-set-successors-parent-unconditionally +++ a/include/linux/rbtree_augmented.h @@ -283,14 +283,13 @@ __rb_erase_augmented(struct rb_node *nod __rb_change_child(node, successor, tmp, root); if (child2) { - successor->__rb_parent_color = pc; rb_set_parent_color(child2, parent, RB_BLACK); rebalance = NULL; } else { unsigned long pc2 = successor->__rb_parent_color; - successor->__rb_parent_color = pc; rebalance = __rb_is_black(pc2) ? parent : NULL; } + successor->__rb_parent_color = pc; tmp = successor; } _