Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3054461ybg; Mon, 28 Oct 2019 06:45:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHHGj4f5BpGwsOCgo7P+Bz6AhWyaIXaozK7Ryqkm2yFraNi0Cbo8xjgKBLGqvaPlkEXgGf X-Received: by 2002:a05:6402:4c7:: with SMTP id n7mr17552143edw.263.1572270354829; Mon, 28 Oct 2019 06:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572270354; cv=none; d=google.com; s=arc-20160816; b=pS/gPFb8ILN1jaEPOLGLfWEI99uZ0ierfXwlDe0AlzjNAlnnJ4RYBLsRySx4qlagkJ O08qINnfCEKOT4PPvS0rUsLbMnR+FkzGU8qM/YNN478Z0sW8Fxc0ptYgI6bJAwv4YkBf HYdcMKz+916sUrLY/P3XVJ/KPs/28zxOu1+pck1iQ2zJWAAra+XCTleeG8moybxmDd4W yPYAePgdQCaHSkIIu0rxfEJJy/A1lIkbAQ+wGKtaAXPvAIsAiWzJfPWeKbyVGQddgyQb m22Em1TESEK5z5VKPqAwUogfikAsdKY+0fXiF0S46bZ4TzfRYCmMmqaujEoDK4jA8yvb Cxkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Kay/B6Pbmp52GXhHLdI41CSSdennX3J2TNNpq3dL5KE=; b=Mf1xQvEa79j1wCOaBFEiY5R++I83Rzlcr9tmdakPrSG6wg2wkAzPS0znHDu+KNSGHy x8JoilrYlAG8/ZvLPRG4+9wRs2Ay+oQwy30PfuQX8ztNhIyI1EXz5a/Vm40hF+LO9HhG 7CihPayfbClvn2+sHmWRwxV++lYPEVDZCrMasKRZdV+kwIJf9H9lPSETZK0GP+UjXmqW tHdLH1pz8gKeWP0HkN2WlvTgIfGss4uV1asz9VQdgski/WRPgxN+BPjeR5LGGK1+eOxz fWbCJQ0a1Yvl388iyhPGeGDbIBXhx2XqSQ7q8cZL+EY9I3BzaUEBFeuT1f4HmnwT2Iy+ +wKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pHl3lffz; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s20si7736822edd.294.2019.10.28.06.45.30; Mon, 28 Oct 2019 06:45:54 -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=@google.com header.s=20161025 header.b=pHl3lffz; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726096AbfJ1E35 (ORCPT + 99 others); Mon, 28 Oct 2019 00:29:57 -0400 Received: from mail-yb1-f196.google.com ([209.85.219.196]:37330 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725920AbfJ1E35 (ORCPT ); Mon, 28 Oct 2019 00:29:57 -0400 Received: by mail-yb1-f196.google.com with SMTP id z125so3622440ybc.4 for ; Sun, 27 Oct 2019 21:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Kay/B6Pbmp52GXhHLdI41CSSdennX3J2TNNpq3dL5KE=; b=pHl3lffzuwfzmHI3pzQCCUD+EgCKcge0eQF50bDurCUXGU05HAlRKes7teALt2xETM B88kFIKmourv44FDT/Y5HnD7uhWT8HsCCgnXxNiZzpf7wbpgD++IclOzcO6zDB3N0GIB zMc34/Ya4/sb0EDCAGMLteY6Tl/H/CTEiVdsdDgGNMFL6nKgkRRhelAbP+gIsuoJdIlw HARizMQS6Ga7f02I9a54VIcpGQNyN4bS1wShB5b3A8WPjl0TRhjMXc7iu1ZYwtT5Bkgz Bmh2bQ6D7dim34qCoVv3gCLtwikssyw0nmQUO7CVowYjsjYkqsed+Fr8pRIqllq4wU37 giow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Kay/B6Pbmp52GXhHLdI41CSSdennX3J2TNNpq3dL5KE=; b=hQS6vTrsskygDGJ5EXe7wzyzfMPiS+LdbdNMqGLtAWwvYpOzwy7a7PqYz8iXWBcSNu q6WK6DUz/fKJzCdf+r+SrhIW+h3KvDDTtrozhOM5L/07k+yKz3CAHo5fdrLTs+TEMoW3 ZHquDLU8wm1T/rWXtEiZHkPbHWeWLFXZTMcMirs4QrZWWmaz3jnnpHlJBtGR5xKxMaHY O7XgAyfmi4Eg6oItYbqJS7dfxLJErZueD7yhoCoK/xbbE1IFoktUg460M0a7LqfG4Dm7 w6CtOtsIpANe6ZDNCwl9tqGa9gA4GfFXAb5pc7xc7M40MviDKfkItIfaO6DbV/u+M51I t3sg== X-Gm-Message-State: APjAAAWu6fMfjsP6swJ86m6MGjZscsRSCmKfCw0gM7ZGO4THUOrQAE9h CiUkQ8IHyPEHGy3dJ0hSHBNIh8SySjC/ouNFosmvkA== X-Received: by 2002:a25:19c5:: with SMTP id 188mr11659594ybz.253.1572236995910; Sun, 27 Oct 2019 21:29:55 -0700 (PDT) MIME-Version: 1.0 References: <20191028021442.5450-1-richardw.yang@linux.intel.com> In-Reply-To: <20191028021442.5450-1-richardw.yang@linux.intel.com> From: Michel Lespinasse Date: Sun, 27 Oct 2019 21:29:43 -0700 Message-ID: Subject: Re: [Patch v2 1/2] lib/rbtree: set successor's parent unconditionally To: Wei Yang Cc: Andrew Morton , Peter Zijlstra , Davidlohr Bueso , Thomas Gleixner , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Code looks fine, for both commits in this series. Please make sure to double check that lib/rbtree_test does not show any performance regressions, but assuming they don't, looks great ! Reviewed-By: Michel Lespinasse On Sun, Oct 27, 2019 at 7:15 PM Wei Yang wrote: > > 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 > > Signed-off-by: Wei Yang > --- > include/linux/rbtree_augmented.h | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h > index fdd421b8d9ae..99c42e1a74b8 100644 > --- a/include/linux/rbtree_augmented.h > +++ b/include/linux/rbtree_augmented.h > @@ -283,14 +283,13 @@ __rb_erase_augmented(struct rb_node *node, struct rb_root *root, > __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; > } > > -- > 2.17.1 > -- Michel "Walken" Lespinasse A program is never fully debugged until the last user dies.