From patchwork Fri May 20 21:15:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 12857449 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 C1B06C433EF for ; Fri, 20 May 2022 21:16:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A6DE6B0072; Fri, 20 May 2022 17:16:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 554D66B0073; Fri, 20 May 2022 17:16:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41FD26B0074; Fri, 20 May 2022 17:16:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 236BE6B0072 for ; Fri, 20 May 2022 17:16:15 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E944E20AEE for ; Fri, 20 May 2022 21:16:14 +0000 (UTC) X-FDA: 79487379468.06.AC16FE2 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf23.hostedemail.com (Postfix) with ESMTP id C6228140019 for ; Fri, 20 May 2022 21:15:55 +0000 (UTC) Received: by mail-pf1-f180.google.com with SMTP id 202so1730443pfu.0 for ; Fri, 20 May 2022 14:16:14 -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=1QLKDkRDVEEGrLLKtQdSS38U6TUL0EcDbwYp3Or4BIw=; b=NYhrj7RyelVXOqRq9pojKSUdPKLFF1GIynVR/ldLf8JQqCX/3ntxNjQlV8L/A0DZMc vZ3c2YpPQjeoSfj1bIIeoFSY9OrsZKsihZwdZVL9hNitrGjSLb+nkpG3pDB8zJalWliK z7pCIOXi+JA7utglSAMGkRg9wmUgLkKmGLZ45dCi0HvrjH9NyUYg12kTdp+RiMT92spe 5kAh9NdQ+7XItGxLIKc7LOvbW3UGvk3GT6Y2UnsuvKQVidxG9rsjG8OvEtzQi7RQ64/R vKvAj2RGL5JUkp3/a7pW0lPJ3ubI9yqBORm5hJxGErWGBNVxb5CSgIczrHxiy0pRnpBs 0HHw== 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=1QLKDkRDVEEGrLLKtQdSS38U6TUL0EcDbwYp3Or4BIw=; b=4+TMIXZ9BGDFpSDxbfXfm3a/XnFMTvNTsyF6DE+Kw/31ebJExNpV+40Mfnr8buFDp2 fWMV7h7s6Sa//Rf+o7dW+EOQSyFfaXcQul0BPluyqAMt7GvmBC1ES0tbeek+jUvVoFa3 3R99oQ+sti0DB9u3adD6UhLan+u9EUVQGdeHM9uBoQfcyLiJ4jxa5x86xb4CrcwKoBUh iVRz+1IDepBV/cvCGVrBINGYlCh005zFZBzyiaTzpEyasVqhL4WpRG7PTzUDL00Ir9sP OKEShwrOWuUfOAyoY45eAPZkcUQzrbHus59SEv1oPehmBmdokZyv260op1XDeVsOhDxU wJ1w== X-Gm-Message-State: AOAM5311YKk8XgIuXO+m/JzzXnAYw958rFbXAmGDlggPiqbeKQflMbf2 kURBmr6ES06tUv4+3OrA9w8= X-Google-Smtp-Source: ABdhPJzjqV91/dbDxBd+KTR/6WHbquHR0Y+DY4HXucFpGAZnlfdhBfKsWiMXYk3Dbuqk5G7NZrTGMQ== X-Received: by 2002:a05:6a00:1251:b0:50d:f2c2:7f4e with SMTP id u17-20020a056a00125100b0050df2c27f4emr11912367pfi.72.1653081373606; Fri, 20 May 2022 14:16:13 -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 h1-20020a170902748100b0015e8d4eb2c2sm167620pll.268.2022.05.20.14.16.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 14:16:12 -0700 (PDT) From: Yang Shi To: vbabka@suse.cz, kirill.shutemov@linux.intel.com, akpm@linux-foundation.org Cc: shy828301@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] mm: khugepaged: check THP flag in hugepage_vma_check() Date: Fri, 20 May 2022 14:15:59 -0700 Message-Id: <20220520211605.51473-2-shy828301@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20220520211605.51473-1-shy828301@gmail.com> References: <20220520211605.51473-1-shy828301@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: C6228140019 X-Stat-Signature: xu49ore87kxazn9xrf9r8ujri7oqrnzx Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=NYhrj7Ry; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of shy828301@gmail.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1653081355-219826 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: Currently the THP flag check in hugepage_vma_check() will fallthrough if the flag is NEVER and VM_HUGEPAGE is set. This is not a problem for now since all the callers have the flag checked before or can't be invoked if the flag is NEVER. However, the following patch will call hugepage_vma_check() in more places, for example, page fault, so this flag must be checked in hugepge_vma_check(). Signed-off-by: Yang Shi --- mm/khugepaged.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 637bfecd6bf5..92e91c08d96a 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -458,6 +458,9 @@ bool hugepage_vma_check(struct vm_area_struct *vma, if (shmem_file(vma->vm_file)) return shmem_huge_enabled(vma); + if (!khugepaged_enabled()) + return false; + /* THP settings require madvise. */ if (!(vm_flags & VM_HUGEPAGE) && !khugepaged_always()) return false;