Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2722C433F5 for ; Sat, 7 May 2022 21:03:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C99956B0071; Sat, 7 May 2022 17:03:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C49686B0073; Sat, 7 May 2022 17:03:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B10856B0074; Sat, 7 May 2022 17:03:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9DA3A6B0071 for ; Sat, 7 May 2022 17:03:49 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6D8D28DA for ; Sat, 7 May 2022 21:03:49 +0000 (UTC) X-FDA: 79440173778.16.733F79E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf31.hostedemail.com (Postfix) with ESMTP id 8A0A620008 for ; Sat, 7 May 2022 21:03:30 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D80C660F01; Sat, 7 May 2022 21:03:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15496C385AE; Sat, 7 May 2022 21:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1651957427; bh=u4Ys8A5R4aT5FGbU3DoZ0AqnvNATU6/LwHVNJT9QiDU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=yCVGVgV5Ezdb6BMN/jQBAB9a4wHxEie5ZG7mnoNuq1wtKy1WXepdUDkiJvB2NmSQ/ oQSmQCGmusPrd9Jk63SNgIT4K0FrkEI600hfWXzd1IkHH4K679JqcEWOf/tMeWq3zZ hsGJtZVO5CpNH0ynnGAdBYi0rml6WvGidece/tck= Date: Sat, 7 May 2022 14:03:46 -0700 From: Andrew Morton To: Wei Yang Cc: linux-mm@kvack.org Subject: Re: [PATCH 1/2] mm/mlock: not handle NULL vma specially Message-Id: <20220507140346.e6e44657af1c98fea411239c@linux-foundation.org> In-Reply-To: <20220504003958.18402-1-richard.weiyang@gmail.com> References: <20220504003958.18402-1-richard.weiyang@gmail.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Stat-Signature: rr44w8eat7taraa98muycqbehndjquzw X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8A0A620008 X-Rspam-User: Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=yCVGVgV5; dmarc=none; spf=pass (imf31.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-HE-Tag: 1651957410-378222 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, 4 May 2022 00:39:57 +0000 Wei Yang wrote: > If we can't find a proper vma, the loop would terminate as expected. > > It's not necessary to handle it specially. > > ... > > --- a/mm/mlock.c > +++ b/mm/mlock.c > @@ -504,11 +504,7 @@ static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm, > if (mm == NULL) > mm = current->mm; > > - vma = find_vma(mm, start); > - if (vma == NULL) > - return 0; > - > - for (; vma ; vma = vma->vm_next) { > + for (vma = find_vma(mm, start); vma ; vma = vma->vm_next) { > if (start >= vma->vm_end) > continue; > if (start + len <= vma->vm_start) The mapletree patches mangle this code a lot. Please take a look at linux-next or the mm-unstabe branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm early to mid next week, see if you see anything which should be addressed.