Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp937737pxy; Fri, 30 Apr 2021 22:05:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2BAV/N4iq978c07RbRbyfQuOaCb0iP5xDi8+5WWDREQNpTQuM41NVBWsDltPwmtwlR+lu X-Received: by 2002:a17:90a:e64e:: with SMTP id ep14mr8852906pjb.103.1619845529281; Fri, 30 Apr 2021 22:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619845529; cv=none; d=google.com; s=arc-20160816; b=nkqxipjliQbct78o1Ifw7Myf0MV6a0FjGTVuNpkal563zu51pqb97OPjgUbr1zgfMN 8esbMlJgSUV4u2pI/L+xVM2/WAP4E78lSlsdKT9S+SXqhwhEho5EOG+C38fo+TzhRBoU Co3tv5S7NBZvD3LE20DFelwUmVLAJ8xqM065dt5L59WJKTTz0+sus/xtBeq5e5Qwp2Dp iRl/VprzvUdv+/t/G0TVrMUikCukruxz3DxoEDcZQ7LJ9bWK0OwTUafRO84i1YCLi8By vjKHP1AD2VNst97k1pOzQ2RPCrcCMReZn+S8RFR/hiD6L4PbdMBzmh2eddDHBN4bx0GX H+5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=nRZfoo813GNy5ZLZUGZ2bJgXOBhdjd9VR0ztKnAnN+c=; b=ihU+gmvgIfFcXI3lZ/t7UxmRuXBWLBeuLw/9alPI9bJZKwE8H0j+8+a2/GdKQqFrHp 8Ah5EkP1UH0VdTIC++puTIHEeNFnNwo9VwM+3DFHl9i1QARSXjZYoCTxsd9M8MY4Eyvk ZX3GHoPY3gp7uxM8emZPBr04t8Xx+msJYrSFiBqxp7vVahcA9w/6pPYCZ8jKZZK8cQ17 j1fifhwMcZuQ0WeAiIDXWRIC5MMPx5CNu+R6b4j0ON0koT8dw2wKXToI9oSnuAUjQ+bE eYh6HYhUgv2EpWYYhgIAFVQS/cS0/tnTNHDCf4NK7Gc5+6dp2kCMk0WXkLbq82GTWQ+V QVaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-14-rsa header.b=dcKXKGQL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lespinasse.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j9si16990860pjs.171.2021.04.30.22.05.16; Fri, 30 Apr 2021 22:05:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-14-rsa header.b=dcKXKGQL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lespinasse.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229908AbhEAFFe (ORCPT + 99 others); Sat, 1 May 2021 01:05:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229540AbhEAFFb (ORCPT ); Sat, 1 May 2021 01:05:31 -0400 Received: from server.lespinasse.org (server.lespinasse.org [IPv6:2001:470:82ab::100:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A10EFC06174A for ; Fri, 30 Apr 2021 22:04:42 -0700 (PDT) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-14-ed; t=1619845481; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to : from; bh=nRZfoo813GNy5ZLZUGZ2bJgXOBhdjd9VR0ztKnAnN+c=; b=hkLMsUB5PsrVKLDLi3uVJ93mD/Wa7e7oVM4dEbcK/nnoLSKUCMhp6Mt2RL/WixV8jzUYG 9LRpNRlHN6SMIqwCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-14-rsa; t=1619845481; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to : from; bh=nRZfoo813GNy5ZLZUGZ2bJgXOBhdjd9VR0ztKnAnN+c=; b=dcKXKGQLiPseYjbnvxU0U7plyfHV9OaDEgVBLXFqtrXd6IvfheCxOYm0tvBnS0fU9w0iG BuOkqeKPu1L1Wq3AffxI8PyE0TH6wi6HdQS2cwag0wEuiZjzMZbTwqBeS9NUIi0arJVSnRn bxIH5ZFSA7PyepoRUzdUzHUsM6esOfb4+Wrt3CBuGQLL/l5XOB8fZdEexjQK1u2SXfHydVB h9uNSAUpC6W6J7om5UHypL7I+7H4nFO7DqyQbKS2kX7LR0CQEgZQ3mOewLHU5H465pkMthp 606ZaIIdMX2TdfSUgWQNdJbgLk/PFjlgphbJTUfn6kkiom/7gQ9+x+LgIAxQ== Received: by server.lespinasse.org (Postfix, from userid 1000) id 0F583160324; Fri, 30 Apr 2021 22:04:41 -0700 (PDT) Date: Fri, 30 Apr 2021 22:04:41 -0700 From: Michel Lespinasse To: Liam Howlett Cc: "maple-tree@lists.infradead.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton , Song Liu , Davidlohr Bueso , "Paul E . McKenney" , Matthew Wilcox , Laurent Dufour , David Rientjes , Axel Rasmussen , Suren Baghdasaryan , Vlastimil Babka , Rik van Riel , Peter Zijlstra , Michel Lespinasse Subject: Re: [PATCH 01/94] mm: Add vma_lookup() Message-ID: <20210501050441.GB5188@lespinasse.org> References: <20210428153542.2814175-1-Liam.Howlett@Oracle.com> <20210428153542.2814175-2-Liam.Howlett@Oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210428153542.2814175-2-Liam.Howlett@Oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 28, 2021 at 03:35:43PM +0000, Liam Howlett wrote: > Many places in the kernel use find_vma() to get a vma and then check the > start address of the vma to ensure the next vma was not returned. > > Other places use the find_vma_intersection() call with add, addr + 1 as > the range; looking for just the vma at a specific address. > > The third use of find_vma() is by developers who do not know that the > function starts searching at the provided address upwards for the next > vma. This results in a bug that is often overlooked for a long time. > > Adding the new vma_lookup() function will allow for cleaner code by > removing the find_vma() calls which check limits, making > find_vma_intersection() calls of a single address to be shorter, and > potentially reduce the incorrect uses of find_vma(). > > Signed-off-by: Liam R. Howlett This seems like a good API to have, and I agree it's less error prone than having every caller check the vma->vm_start address. Minor nitpick, I would prefer if the implementation used find_vma() and then checked the vma->vm_start address - I don't like using [i, i+1) intervals to implement stabbing queries. But other than that, I think this (and the other patches adding corresponding call sites) is safe for merging. -- Michel "walken" Lespinasse