From patchwork Tue May 10 20:32:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 12845497 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 99462C433EF for ; Tue, 10 May 2022 20:32:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DE3D8D0003; Tue, 10 May 2022 16:32:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28FC78D0002; Tue, 10 May 2022 16:32:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 108D68D0003; Tue, 10 May 2022 16:32:43 -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 F30718D0002 for ; Tue, 10 May 2022 16:32:42 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id CB95A818AA for ; Tue, 10 May 2022 20:32:42 +0000 (UTC) X-FDA: 79450981764.24.46ED0FA Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by imf05.hostedemail.com (Postfix) with ESMTP id C576F1000AC for ; Tue, 10 May 2022 20:32:24 +0000 (UTC) Received: by mail-pg1-f174.google.com with SMTP id r192so11384484pgr.6 for ; Tue, 10 May 2022 13:32:41 -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 :mime-version:content-transfer-encoding; bh=XG6VTF0MKKyBvJ7LiNjeRAoppMqMyK0KQDU/n3DucWk=; b=PMhjaTnCNiBqvYANKcfUWI+ZsxV1u8tVoKwehsvBgPR2RO8ckI8e3lCcRt+GGQFVxq K+aNHihlxCeMd7YlipMUDpbilZ7k/WknqF1VpYC0ElnBfhKfuSDV0NQhLrepmM6O7fBl 9uqv2lXcB3zE/Op1BjFkvflCXb5sMblUoAoACyX6Tgg9svJKMuCABXHPlntdP9V8MUwc OnNgmbK1aux9SskLR/NTo2Gp9nQNB7mkaBDgIg4cbPfpW3jFKiRUaVSDX0txy306jYi/ Q0F5OJoRAg+orbNa3CPxZlNyYcEmwY5T3aX6ist/XLS7R5yHo78lSMS5A5Udyv8Mtlm0 VA1Q== 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:mime-version:content-transfer-encoding; bh=XG6VTF0MKKyBvJ7LiNjeRAoppMqMyK0KQDU/n3DucWk=; b=rHQ/NVhW7yu7Y3pCdmJFTovNVJXOwjPpqdZMfecJX5BABCj3QU8HyBSmm4eZLTD3R0 HxgZQ8phm3opI+74JzQOyvmRF3mm9iWgpKaVppAzc5mTfC6SEZ+0GDtOXb9/Bjx1gBgS fK+2WD72NXYQlTX1atIeoBSSEqCsUACLIMqEmvANP6Iqn86pQSxy0j53VtygUVM1WqsH RM3tck3OQuZdK+NOAroqRYY7AvOxD5BjlusUD3qOHgwWDJu9JImIum3UbjA1d0k5v+/N 5wyt/s4vPFkA3J3wMzKKOMgOvfsO4pMtvt5mT3oD58mTo3oJes5BYNXXpHvFtsd6J+PD 5HlQ== X-Gm-Message-State: AOAM5304k2OdETdrOQ3GNZrgQaPeYhsWJHx0RXHw0IqoiktzlpNBaY3E D/h7naWfEphIW/5+hFWD+zk= X-Google-Smtp-Source: ABdhPJxDBFjRdbGsSAuMlA39SdbMIa9m6FJbsVEC4ShwNFejY3QJzjUGmyo3GyjuRcco2U598+vqwg== X-Received: by 2002:a63:2303:0:b0:3da:eae2:583a with SMTP id j3-20020a632303000000b003daeae2583amr4116533pgj.123.1652214761202; Tue, 10 May 2022 13:32:41 -0700 (PDT) Received: from localhost.localdomain (c-67-174-241-145.hsd1.ca.comcast.net. [67.174.241.145]) by smtp.gmail.com with ESMTPSA id v17-20020a1709028d9100b0015e8d4eb1d4sm58898plo.30.2022.05.10.13.32.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 13:32:40 -0700 (PDT) From: Yang Shi To: vbabka@suse.cz, kirill.shutemov@linux.intel.com, linmiaohe@huawei.com, songliubraving@fb.com, riel@surriel.com, willy@infradead.org, ziy@nvidia.com, tytso@mit.edu, akpm@linux-foundation.org Cc: shy828301@gmail.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [v4 PATCH 2/8] mm: khugepaged: remove redundant check for VM_NO_KHUGEPAGED Date: Tue, 10 May 2022 13:32:16 -0700 Message-Id: <20220510203222.24246-3-shy828301@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20220510203222.24246-1-shy828301@gmail.com> References: <20220510203222.24246-1-shy828301@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: C576F1000AC X-Stat-Signature: ozmc9e5mmh4s7kf7j7mqrc7yiapg8b7f Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=PMhjaTnC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf05.hostedemail.com: domain of shy828301@gmail.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-Rspam-User: X-HE-Tag: 1652214744-562533 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: The hugepage_vma_check() called by khugepaged_enter_vma_merge() does check VM_NO_KHUGEPAGED. Remove the check from caller and move the check in hugepage_vma_check() up. More checks may be run for VM_NO_KHUGEPAGED vmas, but MADV_HUGEPAGE is definitely not a hot path, so cleaner code does outweigh. Reviewed-by: Miaohe Lin Acked-by: Song Liu Acked-by: Vlastmil Babka Signed-off-by: Yang Shi --- mm/khugepaged.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 76c4ad60b9a9..dc8849d9dde4 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -365,8 +365,7 @@ int hugepage_madvise(struct vm_area_struct *vma, * register it here without waiting a page fault that * may not happen any time soon. */ - if (!(*vm_flags & VM_NO_KHUGEPAGED) && - khugepaged_enter_vma_merge(vma, *vm_flags)) + if (khugepaged_enter_vma_merge(vma, *vm_flags)) return -ENOMEM; break; case MADV_NOHUGEPAGE: @@ -445,6 +444,9 @@ static bool hugepage_vma_check(struct vm_area_struct *vma, if (!transhuge_vma_enabled(vma, vm_flags)) return false; + if (vm_flags & VM_NO_KHUGEPAGED) + return false; + if (vma->vm_file && !IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff, HPAGE_PMD_NR)) return false; @@ -470,7 +472,8 @@ static bool hugepage_vma_check(struct vm_area_struct *vma, return false; if (vma_is_temporary_stack(vma)) return false; - return !(vm_flags & VM_NO_KHUGEPAGED); + + return true; } int __khugepaged_enter(struct mm_struct *mm)