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) From patchwork Wed May 4 00:39:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12836603 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 858F9C433F5 for ; Wed, 4 May 2022 00:40:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EFD976B0073; Tue, 3 May 2022 20:40:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DBCF06B0074; 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 C5D486B0075; Tue, 3 May 2022 20:40:09 -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 B72456B0073 for ; Tue, 3 May 2022 20:40:09 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 98978292A1 for ; Wed, 4 May 2022 00:40:09 +0000 (UTC) X-FDA: 79426203738.23.94F9D94 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by imf21.hostedemail.com (Postfix) with ESMTP id E6EED1C0094 for ; Wed, 4 May 2022 00:40:03 +0000 (UTC) Received: by mail-ed1-f51.google.com with SMTP id y21so71375edo.2 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:in-reply-to:references; bh=oFox5Dj1JzhvNG8FV4woU3BY71fSczkL8n3MJysaQuw=; b=BadZhIYHAbsoPz6gR+TUu0F3MP+sm9CgIOvdAoQewAq1eNX/cYyqdZSB5KaAuhmBA9 SzTXB9Px7bnL0zwPNidJhG+QwSXtadoOJsLH8VqYVGcoYBF5uf/eappU8nq8I2Sf5oCv uWocjJyGwbnicyD8aGSlIWWXGwtYxzR7t6Zy6/2K2TqWPf54iXvNoBui8uTwgL6BfZ/0 w/Bsci7fELS04fgWoduTShzgHgTZ685fVKoKbsZ6ALlF/nmS9/R/rsWxYauwOPkBJ4eT TJPpKEaABSX5vawgNDbHCQmE15BC+vtNlSBp3YFD24RWuziylgc6GS0UJC+otmj1lAwf Q5oQ== 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:in-reply-to :references; bh=oFox5Dj1JzhvNG8FV4woU3BY71fSczkL8n3MJysaQuw=; b=dwHjd8dTKCfy4UPtyXTuZnZa39bxsifC5x219hkE+GA8KcqdtmPO/UfgQskrkX8QJJ xP0gUuaclKAAZ9mNJbTyYgY8dMK+MhhcowZhzVcVKVWuVZ4wmuB0gccZJR7FYyeS8SVN sMI7sfN4VezAYY1yMNAa/8FPGmleb9/H3xiFyTlKGLY7CXnwXmc/eqwSm+gEFljttlic HmT7OHTFdR6xAK9vHYzx2ryAXMIgwAcms/ovKo/SBciNSm7HRHlIHfhdBuExT9SjOkzp lrdKzlfpxLlqh9AhPjgNFYFihRdZ1Savho5jEIRF0vWCKhScs/rhnZStJoPRGD1J/c5B kzJg== X-Gm-Message-State: AOAM5300PgExQvzo7azWBdVkf2kHiWriCp0Fp2gr5zAkLlGvYz6NPaIF Dg58ShYWLmbYtoRSXNmSC/g= X-Google-Smtp-Source: ABdhPJzLYtaqlkm+Rfz3GZYMtJBCEiRaMh3Q5JLUM8gKlGNRWqU79rrWv9dxUbftEk4P83HPtVn/xA== X-Received: by 2002:a05:6402:4301:b0:427:c8e4:4acd with SMTP id m1-20020a056402430100b00427c8e44acdmr12620121edc.230.1651624807881; Tue, 03 May 2022 17:40:07 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id hg1-20020a1709072cc100b006f3ef214e72sm5082504ejc.216.2022.05.03.17.40.07 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 May 2022 17:40:07 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [PATCH 2/2] mm/mlock: start is always smaller then vm_end Date: Wed, 4 May 2022 00:39:58 +0000 Message-Id: <20220504003958.18402-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220504003958.18402-1-richard.weiyang@gmail.com> References: <20220504003958.18402-1-richard.weiyang@gmail.com> Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=BadZhIYH; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.51 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E6EED1C0094 X-Rspam-User: X-Stat-Signature: d1gcnzkc3izy66zb3wgqs7anqerqm45s X-HE-Tag: 1651624803-728954 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000074, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: We would meet this situation in the loop since: * find_vma() would return a vma meets vm_end > start. * the following vma->vm_end is growing So this situation never happens. Signed-off-by: Wei Yang --- mm/mlock.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/mlock.c b/mm/mlock.c index 0b7cf7d60922..eab3b0a5b569 100644 --- a/mm/mlock.c +++ b/mm/mlock.c @@ -505,8 +505,6 @@ static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm, mm = current->mm; for (vma = find_vma(mm, start); vma ; vma = vma->vm_next) { - if (start >= vma->vm_end) - continue; if (start + len <= vma->vm_start) break; if (vma->vm_flags & VM_LOCKED) {