From patchwork Mon Feb 28 23:57:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 12763901 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 A2290C433F5 for ; Mon, 28 Feb 2022 23:58:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C7F38D0005; Mon, 28 Feb 2022 18:58:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3770B8D0001; Mon, 28 Feb 2022 18:58:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 265D88D0005; Mon, 28 Feb 2022 18:58:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0066.hostedemail.com [216.40.44.66]) by kanga.kvack.org (Postfix) with ESMTP id 18A328D0001 for ; Mon, 28 Feb 2022 18:58:10 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C658E181C34FB for ; Mon, 28 Feb 2022 23:58:09 +0000 (UTC) X-FDA: 79193854698.25.27A56B7 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by imf07.hostedemail.com (Postfix) with ESMTP id 49F1540006 for ; Mon, 28 Feb 2022 23:58:09 +0000 (UTC) Received: by mail-pg1-f180.google.com with SMTP id 27so12921331pgk.10 for ; Mon, 28 Feb 2022 15:58:09 -0800 (PST) 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=+7utIe6zwoBoauJ2NDcsB651FtDL3xoIf2xpV9Lf8S0=; b=qXcrsfxt+hvAbzaB5ZB/MyAxUI9xoo6HoxydYwNc3CkF77+DBqZC8T5imRGPWrcRAA esh99RrRkr7bWkbYvpNi9XG4kEFjKk26aEuhEQ/J2Iu8zksxCUbIAmUrNU7+waOfM9lM yfphxzALZU1B1wD/dqWHXYoL+DYtJ8io1U1jAf70r+taKnzydII+k6v084eL8SSkYMue c/qRxVY6MuheK7tBR1u/mxmKUtMTqzKqdCy1Qp/R2wVHpWQUGVniSyRZBa5c6c6fO0A3 5mVx8u6UxkZ+0YSiav8lTwmXy40ZD5wmo7tyzS5539mlw0GPSZRBGbghOu2hFqm0mI1y vrbw== 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=+7utIe6zwoBoauJ2NDcsB651FtDL3xoIf2xpV9Lf8S0=; b=xd28NUm6DMPzUhIkXqgKDvPUEf8K4gA3B8M7yZGDnEV3J3nsieWoJbO4ZOgAEWd9VC zPtyAh+bRMQDQJfjovsvdB1REIdacaK1OwXmjOATeD8ij48FlBF6UyUxm1z+Xmds436R u3is0mp5pq7NhJwVnvgvNwqSf3a8JZ/3BTeaqb2ktQ6AF0MweYw+RDDv8BcySoxT+C4+ 2QpOEG8fqIVWS9t28Y+J4m4k4hNT6wtsZ4VpOzISmUxfLlm5+p6KgrXIMez+FQtjytLf Eg4omz1NggZfuChxuY25xnz060NbYzyPkJdxyj5m7paD0R+FJMMHpv5AH7WOgYYrUK0s yNTQ== X-Gm-Message-State: AOAM533MI1s4Gp0/eNxhVDb0PS4zGRL980cTBa8yVZiLkOp4fU4N1krL 8U0XGi+R1l3qqoUdUMj7+J0= X-Google-Smtp-Source: ABdhPJyUkJBFxZjHIgqTERZs6mkUNDMkgNt9kOSA3xlCm6y1IkyOi4wDqhot8eXP8IdFiudmtbtypw== X-Received: by 2002:a65:63d6:0:b0:375:7cc6:2b63 with SMTP id n22-20020a6563d6000000b003757cc62b63mr19289215pgv.598.1646092688435; Mon, 28 Feb 2022 15:58:08 -0800 (PST) Received: from localhost.localdomain (c-67-174-241-145.hsd1.ca.comcast.net. [67.174.241.145]) by smtp.gmail.com with ESMTPSA id on15-20020a17090b1d0f00b001b9d1b5f901sm396963pjb.47.2022.02.28.15.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 15:58:07 -0800 (PST) From: Yang Shi To: vbabka@suse.cz, kirill.shutemov@linux.intel.com, songliubraving@fb.com, linmiaohe@huawei.com, riel@surriel.com, willy@infradead.org, ziy@nvidia.com, akpm@linux-foundation.org, tytso@mit.edu, adilger.kernel@dilger.ca, darrick.wong@oracle.com Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/8] mm: khugepaged: remove redundant check for VM_NO_KHUGEPAGED Date: Mon, 28 Feb 2022 15:57:35 -0800 Message-Id: <20220228235741.102941-3-shy828301@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20220228235741.102941-1-shy828301@gmail.com> References: <20220228235741.102941-1-shy828301@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 49F1540006 X-Rspam-User: Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=qXcrsfxt; spf=pass (imf07.hostedemail.com: domain of shy828301@gmail.com designates 209.85.215.180 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: pcm5a1cha6jidpejhbpak3s8r8kz6aqc X-HE-Tag: 1646092689-21700 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000065, 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. Signed-off-by: Yang Shi Reviewed-by: Miaohe Lin --- mm/khugepaged.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 131492fd1148..82c71c6da9ce 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -366,8 +366,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: @@ -446,6 +445,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; @@ -471,7 +473,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)