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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55485C433EF for ; Sat, 7 May 2022 22:44:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 967B46B0071; Sat, 7 May 2022 18:44:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 916B06B0073; Sat, 7 May 2022 18:44:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DE5E6B0074; Sat, 7 May 2022 18:44:04 -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 6DDEF6B0071 for ; Sat, 7 May 2022 18:44:04 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2B72D20A69 for ; Sat, 7 May 2022 22:44:04 +0000 (UTC) X-FDA: 79440426408.31.271DE69 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 14328140050 for ; Sat, 7 May 2022 22:43:51 +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 B23226006F; Sat, 7 May 2022 22:44:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E74A6C385A6; Sat, 7 May 2022 22:44:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1651963442; bh=LFDF+v9rMvdsEoJacs7pK9AjGrthf5IqOgNjed0c3l8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=GZJ8qDAZNf8fk6i3sD/+8xeewAgs0KmmpqHosEeWVIH47cOmJQnxC2vA/3nOKl0D/ iXdGTA1qia9a0sHs4DwVUg8wuxv6PrOOeQBpc1nBR7JjM3txbRNtYN+j8OQ0BUrVoC EoWxQFdNYFc1J/uV/y4+FsW65zmrN+EC10BEw0a0= Date: Sat, 7 May 2022 15:44:01 -0700 From: Andrew Morton To: Wei Yang Cc: Linux-MM Subject: Re: [PATCH 1/2] mm/mlock: not handle NULL vma specially Message-Id: <20220507154401.fc4d239e850a60d2e4c139ab@linux-foundation.org> In-Reply-To: References: <20220504003958.18402-1-richard.weiyang@gmail.com> <20220507140346.e6e44657af1c98fea411239c@linux-foundation.org> 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-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 14328140050 X-Stat-Signature: xu6baijdh67hp1xmx3aick51rg6s6edt Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=GZJ8qDAZ; spf=pass (imf23.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-HE-Tag: 1651963431-890268 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 Sun, 8 May 2022 05:56:15 +0800 Wei Yang wrote: > > > - 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. > > > > I took a look at mm-unstabe branch with last commit > > 2b58b3f33ba2 mm/shmem: convert shmem_swapin_page() to shmem_swapin_folio() > It isn't early to mid next week yet ;) > Function count_mm_mlocked_page_nr() looks not changed. > > Do I need to rebase on top of it? static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm, unsigned long start, size_t len) { struct vm_area_struct *vma; unsigned long count = 0; unsigned long end; VMA_ITERATOR(vmi, mm, start); if (mm == NULL) mm = current->mm; /* Don't overflow past ULONG_MAX */ if (unlikely(ULONG_MAX - len < start)) end = ULONG_MAX; else end = start + len; for_each_vma_range(vmi, vma, end) { if (vma->vm_flags & VM_LOCKED) { if (start > vma->vm_start) count -= (start - vma->vm_start); if (end < vma->vm_end) { count += end - vma->vm_start; break; } count += vma->vm_end - vma->vm_start; } } return count >> PAGE_SHIFT; }