From patchwork Wed May 4 00:39:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12836602 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 9A5ADC433EF for ; Wed, 4 May 2022 00:40:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1D8A26B0071; Tue, 3 May 2022 20:40:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 189906B0073; Tue, 3 May 2022 20:40:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 028336B0074; Tue, 3 May 2022 20:40:08 -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 E80226B0071 for ; Tue, 3 May 2022 20:40:08 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BE36920619 for ; Wed, 4 May 2022 00:40:08 +0000 (UTC) X-FDA: 79426203696.30.C8EDC43 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by imf12.hostedemail.com (Postfix) with ESMTP id EFE0E40074 for ; Wed, 4 May 2022 00:39:52 +0000 (UTC) Received: by mail-ej1-f48.google.com with SMTP id l18so92473ejc.7 for ; Tue, 03 May 2022 17:40:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=Nf38s1A5zTXOllKlkSmUba20xoUK9J5QKde/12UcW/U=; b=Cgde2c4nr4J+Racw0LYjSPbxRfDz5TxNPNP7YmqUshuEhY3xrh7NQ/u3xzeH0Un60T KgnSu0d3QqhFOYbCR46lUXM3ZV8NsU0pmeBAZIFo3DhBHrOJF7zQbFTqJVXkAMFjVSGB /RYqMYkFNKUefB5DODjqyZaWCkk+uqowipgEszhMmcQvsgqqwI/p8MMV8MYu+0WcuVjC b9ahWtCck5kJSEEwi8gMsP0jT/HuB5pZDchmJp5PRoto1Rm1kMxLHv/tQyq5MfdLpEPM ZnQsPZv1GVab6oCTtprZUASTwuflTovdwfuVr2MkZ11+BZPl2StWp30Uk4T41qxlWUSO LlZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Nf38s1A5zTXOllKlkSmUba20xoUK9J5QKde/12UcW/U=; b=boV/0/uwZ2mdKZYJ5abAyADyhA62FqoAcEgvvv1rjzE8ADtl+ph1CgWV1xmIYwgud2 +bHCghzhcCVxKslppfjogczTi0Rz9CprbpAy9QhtaTXJ7AEsvR9yIsmDphh5uzBBgSAw ApFolua8UszqzyTkicLMLhIPJs3p3bzlFFhwo0TcrMvwLWSYdoywL/cQ3Jr/dBg9Mf/K 8N+1A6yvvxD6NR1nMTQ7U0JWDsNc89YC8jmALkE8sRpnt+g7hFtEFNkLln/JXlN0BCup RT2D3ksmYtUUfIrT3D/3lS9jHvCwHzVqOkUVfGluBJLVCQzT2LwEv6TJVww0luOg5XA0 MgmQ== X-Gm-Message-State: AOAM533zuhIZapoxO+kX5kEhFqrM2zk2HR46+bbR1CXQV7iE1wvJBVKa g/pxWbzjvgTBB56ORcDc8YE= X-Google-Smtp-Source: ABdhPJwVY3GVRxpJdaGg7nOuN3HDyiAeGuDjJNqnjOa4sCzlHujonXWWvquVhkp/zeSetgxyM0oWOQ== X-Received: by 2002:a17:906:ad9:b0:6f3:da10:1389 with SMTP id z25-20020a1709060ad900b006f3da101389mr17895132ejf.32.1651624807072; Tue, 03 May 2022 17:40:07 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id jl6-20020a17090775c600b006f3ef214e64sm5049095ejc.202.2022.05.03.17.40.06 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 May 2022 17:40:06 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [PATCH 1/2] mm/mlock: not handle NULL vma specially Date: Wed, 4 May 2022 00:39:57 +0000 Message-Id: <20220504003958.18402-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: EFE0E40074 X-Stat-Signature: a7rahr1za1d5t8z4eyyc67zi8431wdqu Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Cgde2c4n; spf=pass (imf12.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.48 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1651624792-608367 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: If we can't find a proper vma, the loop would terminate as expected. It's not necessary to handle it specially. Signed-off-by: Wei Yang --- mm/mlock.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mm/mlock.c b/mm/mlock.c index efd2dd2943de..0b7cf7d60922 100644 --- 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)