Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp313638ybi; Tue, 2 Jul 2019 21:05:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvrZNx1ev9FWLjjfxQFtX186oYq5kqUlSfVZNQ6p0rvzrhD4+bsu3Rhi5daHdUa5ENSYTH X-Received: by 2002:a17:90a:e397:: with SMTP id b23mr9867612pjz.117.1562126701358; Tue, 02 Jul 2019 21:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562126701; cv=none; d=google.com; s=arc-20160816; b=C/M+YMgYLUvKnU/S8/sq87u7WLTmKilx/cxbHlu/GfrhIwkoR5ag8Hf1P1Jsg0afOr 3Gb39c4lzGxpFuDjWEw4th2HIYGtmw3gOfw6TVxrN0cYRwDKT69ezEZmo9qM20o29b04 nrIcUlzC7HR6O1yblEqqx9zhYef/cRPAxNfCSiOJvWyZTMlF11+A9dBYHcbXWbr+n/Bb 6acfmu/RFaHnIxPuYtRyoZnJkL9eLbQneKVLZdlIDCFSYyXQfCM8RJ3ScNMdGZ1sGJpq RmH5+E3cnFc439eJrnEiUZjlHgF5BH6xBp+8zx5X8yI+1HOmiEjY+7RltVDBJHfij5Zj E9Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=+Bz9EK5nXnCLx3MyMoxYoR0icGFjWu9nXmNokal9mQM=; b=v7TCIOyCi431zWPaprpfeAG5Hnli1CWVpVIS6s234mk8TsoWhBpkj86j5cwiJT3yZ7 defo8RaU3/g2W2bt2oCsSaUCM2cf4q8abj6usfExcOjPDvk/md99gas8eXK0hFqfCBkq 5LlxSwkDOsTliratRgKi5FQTU1UOZ0+O3SlhmQxTWXsKeV/orF2qMe0tLYD0TAONv21K N6oLhiT8KzlfBwB/8+z8kpQ8fyF84jyT6JUB54Rl0SkdNlQsyvVWRzzeqdJc+c/vGOfC LFPQxUK8K1oXuU5EOUj9PbWqULGY/eIyG1bhqqp9sAqsXb9vWYgPIsKM7myJnUnchLAv 8f2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ADj3VWtl; 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 19si851212pfc.239.2019.07.02.21.04.45; Tue, 02 Jul 2019 21:05:01 -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=ADj3VWtl; 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 S1727065AbfGCECQ (ORCPT + 99 others); Wed, 3 Jul 2019 00:02:16 -0400 Received: from mail-pg1-f201.google.com ([209.85.215.201]:53866 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725847AbfGCECC (ORCPT ); Wed, 3 Jul 2019 00:02:02 -0400 Received: by mail-pg1-f201.google.com with SMTP id u4so748101pgb.20 for ; Tue, 02 Jul 2019 21:02:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=+Bz9EK5nXnCLx3MyMoxYoR0icGFjWu9nXmNokal9mQM=; b=ADj3VWtlBGJk4u5ja3UlOVOUmIjGfBzRceZgHd/JjkItmsL9/IvBWO8SH+vctlhEk4 y0Czn5yxio8Pej1EY2pnnCDEOM4qIdwiwa42NoBg7rUITtuhKvv59CkMeZhq+Cu9lqke 7/We+NoLCObmzpy4kLqiXY37wH8bB9z9apxSfHrhEOUi3wSDZ6O7G7/h8/YGDkqffy0E vTKU/mLGyqoKN5r07okLNUFNFig2aorpTHLrLtIfPR841tdvuEBcQvetc4tH44yDXPe+ LGS1yLh0tGEJe+HLLgEtNniKY2TOjxEkmIRcl+NMI2AaOtMdDGAEtbNOefurcKfku4SL 7Syw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+Bz9EK5nXnCLx3MyMoxYoR0icGFjWu9nXmNokal9mQM=; b=NuZrs+bvPjmxm+8IneZS7ekRVVApgWvAKcxlUh0+MVP3gCrjtzVMAB0qqZr5ytrY/V BLWP3+JVFqRvHbmvU44PZWI59OaRGSIMjv7iNYPcqMXEhlo3D2oX1LGymcCFUP8a4wCY TsFiWiL65iyyUHNF63alIZ6HFh8fRZl17KRMPAtBPlLv647AUD75aZS2UgJNIOmj5WXW uhQSX6eOKUf2SZk/ic9mX0s1EvFOo2mIsXk0X3v1WhqUFzOeMRGI8Ic/ZxbMvwusbqfw JqwScqgBu2zNn3XzezCQVaFEf3dzunsfn7ReShM5xzpPMO4BTu+0sCu+Qd/DnCJ1qi3G P07A== X-Gm-Message-State: APjAAAVjtXAbdB03w+LPt6iAxMlvM7cVJGF+7E+NuRiDnkl1Y5iY3DCk 7vsfDrFe6P8Xe4bK7FNL2uWjyA2kV9c= X-Received: by 2002:a63:1b5c:: with SMTP id b28mr3590819pgm.101.1562126521287; Tue, 02 Jul 2019 21:02:01 -0700 (PDT) Date: Tue, 2 Jul 2019 21:01:54 -0700 In-Reply-To: <20190703040156.56953-1-walken@google.com> Message-Id: <20190703040156.56953-2-walken@google.com> Mime-Version: 1.0 References: <20190703040156.56953-1-walken@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH v3 1/3] augmented rbtree: add comments for RB_DECLARE_CALLBACKS macro From: Michel Lespinasse To: Davidlohr Bueso , Peter Zijlstra , David Howells Cc: Andrew Morton , linux-kernel@vger.kernel.org, Michel Lespinasse , Davidlohr Bueso 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 Add a short comment summarizing the arguments to RB_DECLARE_CALLBACKS. The arguments are also now capitalized. This copies the style of the INTERVAL_TREE_DEFINE macro. No functional changes in this commit, only comments and capitalization. Signed-off-by: Michel Lespinasse Acked-by: Davidlohr Bueso --- include/linux/rbtree_augmented.h | 54 ++++++++++++++++---------- tools/include/linux/rbtree_augmented.h | 54 ++++++++++++++++---------- 2 files changed, 66 insertions(+), 42 deletions(-) diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h index f1ed3fc80bbb..5923495276e0 100644 --- a/include/linux/rbtree_augmented.h +++ b/include/linux/rbtree_augmented.h @@ -72,39 +72,51 @@ rb_insert_augmented_cached(struct rb_node *node, rb_insert_augmented(node, &root->rb_root, augment); } -#define RB_DECLARE_CALLBACKS(rbstatic, rbname, rbstruct, rbfield, \ - rbtype, rbaugmented, rbcompute) \ +/* + * Template for declaring augmented rbtree callbacks + * + * RBSTATIC: 'static' or empty + * RBNAME: name of the rb_augment_callbacks structure + * RBSTRUCT: struct type of the tree nodes + * RBFIELD: name of struct rb_node field within RBSTRUCT + * RBTYPE: type of the RBAUGMENTED field + * RBAUGMENTED: name of RBTYPE field within RBSTRUCT holding data for subtree + * RBCOMPUTE: name of function that recomputes the RBAUGMENTED data + */ + +#define RB_DECLARE_CALLBACKS(RBSTATIC, RBNAME, RBSTRUCT, RBFIELD, \ + RBTYPE, RBAUGMENTED, RBCOMPUTE) \ static inline void \ -rbname ## _propagate(struct rb_node *rb, struct rb_node *stop) \ +RBNAME ## _propagate(struct rb_node *rb, struct rb_node *stop) \ { \ while (rb != stop) { \ - rbstruct *node = rb_entry(rb, rbstruct, rbfield); \ - rbtype augmented = rbcompute(node); \ - if (node->rbaugmented == augmented) \ + RBSTRUCT *node = rb_entry(rb, RBSTRUCT, RBFIELD); \ + RBTYPE augmented = RBCOMPUTE(node); \ + if (node->RBAUGMENTED == augmented) \ break; \ - node->rbaugmented = augmented; \ - rb = rb_parent(&node->rbfield); \ + node->RBAUGMENTED = augmented; \ + rb = rb_parent(&node->RBFIELD); \ } \ } \ static inline void \ -rbname ## _copy(struct rb_node *rb_old, struct rb_node *rb_new) \ +RBNAME ## _copy(struct rb_node *rb_old, struct rb_node *rb_new) \ { \ - rbstruct *old = rb_entry(rb_old, rbstruct, rbfield); \ - rbstruct *new = rb_entry(rb_new, rbstruct, rbfield); \ - new->rbaugmented = old->rbaugmented; \ + RBSTRUCT *old = rb_entry(rb_old, RBSTRUCT, RBFIELD); \ + RBSTRUCT *new = rb_entry(rb_new, RBSTRUCT, RBFIELD); \ + new->RBAUGMENTED = old->RBAUGMENTED; \ } \ static void \ -rbname ## _rotate(struct rb_node *rb_old, struct rb_node *rb_new) \ +RBNAME ## _rotate(struct rb_node *rb_old, struct rb_node *rb_new) \ { \ - rbstruct *old = rb_entry(rb_old, rbstruct, rbfield); \ - rbstruct *new = rb_entry(rb_new, rbstruct, rbfield); \ - new->rbaugmented = old->rbaugmented; \ - old->rbaugmented = rbcompute(old); \ + RBSTRUCT *old = rb_entry(rb_old, RBSTRUCT, RBFIELD); \ + RBSTRUCT *new = rb_entry(rb_new, RBSTRUCT, RBFIELD); \ + new->RBAUGMENTED = old->RBAUGMENTED; \ + old->RBAUGMENTED = RBCOMPUTE(old); \ } \ -rbstatic const struct rb_augment_callbacks rbname = { \ - .propagate = rbname ## _propagate, \ - .copy = rbname ## _copy, \ - .rotate = rbname ## _rotate \ +RBSTATIC const struct rb_augment_callbacks RBNAME = { \ + .propagate = RBNAME ## _propagate, \ + .copy = RBNAME ## _copy, \ + .rotate = RBNAME ## _rotate \ }; diff --git a/tools/include/linux/rbtree_augmented.h b/tools/include/linux/rbtree_augmented.h index 372a539314af..f46c1bf91f64 100644 --- a/tools/include/linux/rbtree_augmented.h +++ b/tools/include/linux/rbtree_augmented.h @@ -74,39 +74,51 @@ rb_insert_augmented_cached(struct rb_node *node, rb_insert_augmented(node, &root->rb_root, augment); } -#define RB_DECLARE_CALLBACKS(rbstatic, rbname, rbstruct, rbfield, \ - rbtype, rbaugmented, rbcompute) \ +/* + * Template for declaring augmented rbtree callbacks + * + * RBSTATIC: 'static' or empty + * RBNAME: name of the rb_augment_callbacks structure + * RBSTRUCT: struct type of the tree nodes + * RBFIELD: name of struct rb_node field within RBSTRUCT + * RBTYPE: type of the RBAUGMENTED field + * RBAUGMENTED: name of RBTYPE field within RBSTRUCT holding data for subtree + * RBCOMPUTE: name of function that recomputes the RBAUGMENTED data + */ + +#define RB_DECLARE_CALLBACKS(RBSTATIC, RBNAME, RBSTRUCT, RBFIELD, \ + RBTYPE, RBAUGMENTED, RBCOMPUTE) \ static inline void \ -rbname ## _propagate(struct rb_node *rb, struct rb_node *stop) \ +RBNAME ## _propagate(struct rb_node *rb, struct rb_node *stop) \ { \ while (rb != stop) { \ - rbstruct *node = rb_entry(rb, rbstruct, rbfield); \ - rbtype augmented = rbcompute(node); \ - if (node->rbaugmented == augmented) \ + RBSTRUCT *node = rb_entry(rb, RBSTRUCT, RBFIELD); \ + RBTYPE augmented = RBCOMPUTE(node); \ + if (node->RBAUGMENTED == augmented) \ break; \ - node->rbaugmented = augmented; \ - rb = rb_parent(&node->rbfield); \ + node->RBAUGMENTED = augmented; \ + rb = rb_parent(&node->RBFIELD); \ } \ } \ static inline void \ -rbname ## _copy(struct rb_node *rb_old, struct rb_node *rb_new) \ +RBNAME ## _copy(struct rb_node *rb_old, struct rb_node *rb_new) \ { \ - rbstruct *old = rb_entry(rb_old, rbstruct, rbfield); \ - rbstruct *new = rb_entry(rb_new, rbstruct, rbfield); \ - new->rbaugmented = old->rbaugmented; \ + RBSTRUCT *old = rb_entry(rb_old, RBSTRUCT, RBFIELD); \ + RBSTRUCT *new = rb_entry(rb_new, RBSTRUCT, RBFIELD); \ + new->RBAUGMENTED = old->RBAUGMENTED; \ } \ static void \ -rbname ## _rotate(struct rb_node *rb_old, struct rb_node *rb_new) \ +RBNAME ## _rotate(struct rb_node *rb_old, struct rb_node *rb_new) \ { \ - rbstruct *old = rb_entry(rb_old, rbstruct, rbfield); \ - rbstruct *new = rb_entry(rb_new, rbstruct, rbfield); \ - new->rbaugmented = old->rbaugmented; \ - old->rbaugmented = rbcompute(old); \ + RBSTRUCT *old = rb_entry(rb_old, RBSTRUCT, RBFIELD); \ + RBSTRUCT *new = rb_entry(rb_new, RBSTRUCT, RBFIELD); \ + new->RBAUGMENTED = old->RBAUGMENTED; \ + old->RBAUGMENTED = RBCOMPUTE(old); \ } \ -rbstatic const struct rb_augment_callbacks rbname = { \ - .propagate = rbname ## _propagate, \ - .copy = rbname ## _copy, \ - .rotate = rbname ## _rotate \ +RBSTATIC const struct rb_augment_callbacks RBNAME = { \ + .propagate = RBNAME ## _propagate, \ + .copy = RBNAME ## _copy, \ + .rotate = RBNAME ## _rotate \ }; -- 2.22.0.410.gd8fdbe21b5-goog