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=-8.1 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FSL_HELO_FAKE,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL 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 3715CC4CED1 for ; Fri, 4 Oct 2019 11:02:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F07E420867 for ; Fri, 4 Oct 2019 11:02:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KPrEoUte" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F07E420867 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8BAD26B0003; Fri, 4 Oct 2019 07:02:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 86C346B0005; Fri, 4 Oct 2019 07:02:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 759FA6B0007; Fri, 4 Oct 2019 07:02:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0161.hostedemail.com [216.40.44.161]) by kanga.kvack.org (Postfix) with ESMTP id 5022F6B0003 for ; Fri, 4 Oct 2019 07:02:31 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id B059187C7 for ; Fri, 4 Oct 2019 11:02:30 +0000 (UTC) X-FDA: 76005813660.05.brick92_8a455be88e052 X-HE-Tag: brick92_8a455be88e052 X-Filterd-Recvd-Size: 5632 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Fri, 4 Oct 2019 11:02:30 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id a2so3665259pfo.10 for ; Fri, 04 Oct 2019 04:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Ku4z59GegrGG+Xfk9fGT7bfSHa3f5Py2+RMuhy3okDg=; b=KPrEoUteCeYCa10uT2hn7fB1zM8Hfdoe38fSBpEFWdSxAeLJh80LvNzJLajpVpIDoX /iX2Pc4h0WUlJw74gUqIYTXsd3aS3JpzDEJN4AKPyJDVadMhQMAhQX65rEm880pH42Hj RDUPDWYlR7XhQrV5eNna2MGYLWZNX2T+y7fgeQXzM+Dxz/CZMJ4zE6dLWnRlkuz6PIRJ 3FMGaXriotJwSR+ciw2d7MTCGmzZXmNvIox5y5m5J6eI2pmx/Wl3u/ZnGWFP2CReGuxW Si5R7xoklkhvvPqrnyQPM5XFBJBvVrldWYSS1IGnZHK7+jErRzs6Bi8Pzy9UgL1Nwh7H RCsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Ku4z59GegrGG+Xfk9fGT7bfSHa3f5Py2+RMuhy3okDg=; b=DyFFqm4pLVb1PSNyOIehlNpfNFOTTj/EvZr5K9zBEQw2OiPIDSgrPsSqDzLZsZ4+NT FoOzQzpINxWKm+Hn8fy7fhNhu8otaDETaRvRyXUtFA92FP9zsa6+vTvvg+O6OZ67QTvs xH9xoWXDBquM2mCOTHN0AjXv/ULBzTk1tiFyQJ9TrrteqRd2thQTJ8Y3fALwOvYYPdYB S7naedhQI9ikgNBCHa/Phr6hQgZeosW63F2dLsMMaivt7CYrNhm8zcFIOtK3hUhxZNy3 mblcNGRPdWEJw2Foko8ZONCo0TTV5rgTH9zJ7JutG/Gl3rgNRLRYjJnIwPe/DgkkU7sS 4cTA== X-Gm-Message-State: APjAAAW80jP4Bts4vQegs1GBHfMD6G9J/PxSglikvkBjXd5tE1KtjEKc gfVP1rezEZCtrT3OkhGogr16tg== X-Google-Smtp-Source: APXvYqx4/60BB+JFHczOGrzL1Al0rm+OY0a+A9pZLRnWECaGlOjJLRWXCmf7DRnwimAuKwz5dG/Qgw== X-Received: by 2002:a65:5804:: with SMTP id g4mr14680236pgr.362.1570186948359; Fri, 04 Oct 2019 04:02:28 -0700 (PDT) Received: from google.com ([2620:15c:2cd:202:668d:6035:b425:3a3a]) by smtp.gmail.com with ESMTPSA id v8sm8911794pje.6.2019.10.04.04.02.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2019 04:02:26 -0700 (PDT) Date: Fri, 4 Oct 2019 04:02:24 -0700 From: Michel Lespinasse To: Davidlohr Bueso Cc: akpm@linux-foundation.org, peterz@infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, Davidlohr Bueso Subject: Re: [PATCH 02/11] lib/interval-tree: add an equivalent tree with [a,b) intervals Message-ID: <20191004110224.GA253758@google.com> References: <20191003201858.11666-1-dave@stgolabs.net> <20191003201858.11666-3-dave@stgolabs.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191003201858.11666-3-dave@stgolabs.net> User-Agent: Mutt/1.10.1 (2018-07-13) 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: On Thu, Oct 03, 2019 at 01:18:49PM -0700, Davidlohr Bueso wrote: > +/* \ > + * Iterate over intervals intersecting [start;end) \ > + * \ > + * Note that a node's interval intersects [start;end) iff: \ > + * Cond1: ITSTART(node) < end \ > + * and \ > + * Cond2: start < ITEND(node) \ > + */ \ > + \ > +static ITSTRUCT * \ > +ITPREFIX ## _subtree_search(ITSTRUCT *node, ITTYPE start, ITTYPE end) \ > +{ \ > + while (true) { \ > + /* \ > + * Loop invariant: start <= node->ITSUBTREE \ Should be start < node->ITSUBTREE > + * (Cond2 is satisfied by one of the subtree nodes) \ > + */ \ > + if (node->ITRB.rb_left) { \ > + ITSTRUCT *left = rb_entry(node->ITRB.rb_left, \ > + ITSTRUCT, ITRB); \ > + if (start < left->ITSUBTREE) { \ > + /* \ > + * Some nodes in left subtree satisfy Cond2. \ > + * Iterate to find the leftmost such node N. \ > + * If it also satisfies Cond1, that's the \ > + * match we are looking for. Otherwise, there \ > + * is no matching interval as nodes to the \ > + * right of N can't satisfy Cond1 either. \ > + */ \ > + node = left; \ > + continue; \ > + } \ > + } \ > + if (ITSTART(node) < end) { /* Cond1 */ \ > + if (start < ITEND(node)) /* Cond2 */ \ > + return node; /* node is leftmost match */ \ > + if (node->ITRB.rb_right) { \ > + node = rb_entry(node->ITRB.rb_right, \ > + ITSTRUCT, ITRB); \ > + if (start <= node->ITSUBTREE) \ Should be start < node->ITSUBTREE > + continue; \ > + } \ > + } \ > + return NULL; /* No match */ \ > + } \ > +} \ Other than that, the change looks good to me. This is something I might use, regardless of the status of converting other current users. The name "interval_tree_gen.h" makes it ambiguous wether gen stands for "generic" or "generator". This may sounds like a criticism, but it's not - I think it really stands for both :) Reviewed-by: Michel Lespinasse -- Michel "Walken" Lespinasse A program is never fully debugged until the last user dies.