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=-12.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 C3D00C433B4 for ; Sat, 1 May 2021 05:04:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 31F00613C8 for ; Sat, 1 May 2021 05:04:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31F00613C8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=lespinasse.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2F0C16B006C; Sat, 1 May 2021 01:04:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DABB6B006E; Sat, 1 May 2021 01:04:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 169106B0070; Sat, 1 May 2021 01:04:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id F0CA66B006C for ; Sat, 1 May 2021 01:04:43 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id ADFCF5923BFF for ; Sat, 1 May 2021 05:04:43 +0000 (UTC) X-FDA: 78091472046.07.24BE603 Received: from server.lespinasse.org (server.lespinasse.org [63.205.204.226]) by imf07.hostedemail.com (Postfix) with ESMTP id 0E7BBA000396 for ; Sat, 1 May 2021 05:04:41 +0000 (UTC) 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) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=lespinasse.org header.s=srv-14-ed header.b=hkLMsUB5; dkim=pass header.d=lespinasse.org header.s=srv-14-rsa header.b=dcKXKGQL; spf=pass (imf07.hostedemail.com: domain of michel@lespinasse.org designates 63.205.204.226 as permitted sender) smtp.mailfrom=michel@lespinasse.org; dmarc=pass (policy=none) header.from=lespinasse.org X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 0E7BBA000396 X-Stat-Signature: f4znkhrqpnfca6cyojccnxk9totbzzeh Received-SPF: none (lespinasse.org>: No applicable sender policy available) receiver=imf07; identity=mailfrom; envelope-from=""; helo=server.lespinasse.org; client-ip=63.205.204.226 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619845481-881422 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 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