From patchwork Wed Jun 15 17:29:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 12882799 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 B3E5CC433EF for ; Wed, 15 Jun 2022 17:29:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4BA1A6B0072; Wed, 15 Jun 2022 13:29:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 43EC06B0074; Wed, 15 Jun 2022 13:29:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 307216B0075; Wed, 15 Jun 2022 13:29:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 223116B0072 for ; Wed, 15 Jun 2022 13:29:36 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EC5403D9 for ; Wed, 15 Jun 2022 17:29:35 +0000 (UTC) X-FDA: 79581157110.15.472030C Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf04.hostedemail.com (Postfix) with ESMTP id 7ED224008D for ; Wed, 15 Jun 2022 17:29:35 +0000 (UTC) Received: by mail-pf1-f170.google.com with SMTP id c196so12058019pfb.1 for ; Wed, 15 Jun 2022 10:29:35 -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=gQUColGb/PRKYuEV4lE8XSFjbzf2io5XZTvMnHxGXf0=; b=P5PSssOdjWY/xPZ7jddHeQPn8UutJ5m9TF+K4vzKHaQtM6cE/Mf+NE4GoAnGSxi3Io Y2LlfpoNzzarjkEPUOBBbK2VNLV6QvrkCU0YgZMxegJsia53STwh6Di/GzL3gsyqzoFP rUAxM+SHTD3Ks6z6Onsi/In0Mrk2HzetpwpKANFN1OqsGo2AHjr6/haWrWg2TS12egTu 1PKdIZyzPNk09Cs6fGAidY2XEJ/VqNbV78o1QLo7kcwS7nDaVKeKv77VuBXpQHOqqTvl KFl4JRX1TJx3TG4Jb+1vv779H0J6hBCcUH2+m3wdmfheRWs69YXkaQK77FyCnII6PT7d qqTQ== 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=gQUColGb/PRKYuEV4lE8XSFjbzf2io5XZTvMnHxGXf0=; b=K8cIfTmRiBzdpW3hxtcvzVAqo1YLkNjp5viudO/zeksNMSqP2cax2+mQtJ6OAsr2QS eyZUFz+gPhxsu7Yp11f9pShivl+wT8Mw0YsCCnStqpH6WjgKXgcpgxfSVIImAH3KoEPl XvovPaJiSMYTwF83BCuimKaGyV109h8tGb1iL2H5Vk+nua3JRvUFHa46xZdmoPXUW5xj 9E5cK76U0E/kn9O4mAQg8LAL0dZUQIoeigrnMbmihy+p2DUPBP6aF/BZXKkEQ4b6aJcu hsTBojQ1ER215wz5XAItEpp9OXdRmEYjhlI78KMHI/xpWw11c6WnQnkube7M7ZX0vW/9 9TgA== X-Gm-Message-State: AJIora9YqtwjdqXqMX0xxm8Jg2N+bM3KtGU2cLBeumzBaDq1zFDlZaOt QYtCrcWuK6JEZYAFf0GMAFw= X-Google-Smtp-Source: AGRyM1s1Cazz5Rcz0v51mDmvba3KC32sP5s7r0OCDu88q+Oc50uuWQFdSzmqKeUrPH3UKttvAQA9+w== X-Received: by 2002:a63:ec0f:0:b0:3fd:e23d:b9f9 with SMTP id j15-20020a63ec0f000000b003fde23db9f9mr747614pgh.612.1655314174419; Wed, 15 Jun 2022 10:29:34 -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 w14-20020a1709029a8e00b001676f87473fsm9552244plp.302.2022.06.15.10.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 10:29:33 -0700 (PDT) From: Yang Shi To: vbabka@suse.cz, kirill.shutemov@linux.intel.com, willy@infradead.org, zokeefe@google.com, linmiaohe@huawei.com, akpm@linux-foundation.org Cc: shy828301@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [v4 PATCH 1/7] mm: khugepaged: check THP flag in hugepage_vma_check() Date: Wed, 15 Jun 2022 10:29:20 -0700 Message-Id: <20220615172926.546974-2-shy828301@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20220615172926.546974-1-shy828301@gmail.com> References: <20220615172926.546974-1-shy828301@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655314175; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gQUColGb/PRKYuEV4lE8XSFjbzf2io5XZTvMnHxGXf0=; b=J5dS5nSxHVLS5OUcER7bBBV11mFENq6xAoKrcfB68nWvEmbrlekas3FZr7E5I9yqcDfIhz AYwoH2vs0KMzmmqTTZt3JsUAPvHEJhdTTBiMr35378DuwmS0WYuWBG7tAK8HdtUsyCF/WB TwOjE0m496ZaSJupOEmq3ttx2QePAHI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655314175; a=rsa-sha256; cv=none; b=MxctkHi73+FeIFGUiGG+e2RPfJHT5pr325Ud+DAhEqptiuPmOTR+9sSmCNPqIfw0XsWK4U CcPCqGZzgCAV7jJFpUfRlpW+Lzpkv6BnTwSRUG9+LN21P/8y0YJIWqKeMmsd/Z7XzHv8m0 +9YQ93xDChMBM37lGiSgCm48DENSqT8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=P5PSssOd; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of shy828301@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=shy828301@gmail.com Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=P5PSssOd; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of shy828301@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-Rspamd-Server: rspam12 X-Rspam-User: X-Stat-Signature: ycwtygjp3tag7tqh695hx43qs9upbib5 X-Rspamd-Queue-Id: 7ED224008D X-HE-Tag: 1655314175-782205 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(). Reviewed-by: Zach O'Keefe Reviewed-by: Miaohe Lin 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 476d79360101..b1dab94c0f1e 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;