From patchwork Thu Jun 2 18:21: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: 12868048 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 CF2E1CCA47E for ; Thu, 2 Jun 2022 18:22:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82B6D6B007E; Thu, 2 Jun 2022 14:22:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7DF946B0080; Thu, 2 Jun 2022 14:22:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 67E276B0081; Thu, 2 Jun 2022 14:22:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 584546B007E for ; Thu, 2 Jun 2022 14:22:15 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 35FFD61549 for ; Thu, 2 Jun 2022 18:22:15 +0000 (UTC) X-FDA: 79534115430.09.ACE8AF8 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf03.hostedemail.com (Postfix) with ESMTP id 7798D20055 for ; Thu, 2 Jun 2022 18:21:59 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id w2-20020a17090ac98200b001e0519fe5a8so5492898pjt.4 for ; Thu, 02 Jun 2022 11:22: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=hSlU6Lbj1xiMbj9OJuSwVIYBVljgpyUnPXL4SbncscE=; b=lGZfQS2dawbRWYfKai5mohgnC6yt8NU/fBuHreLbnhxS97F65F2IH6yIfmwsgNBetc uFdybSvcBfa+1M9DRHLj17ljNMUCHlZ6Xk7AG7WWycs4dAoYD5s/K4rdpgBIL3UCUB9G HH4CoA17dtS6p+Vd8cfKk30Eu9iclYqbz1S0R41UohcGIvBsQi5lMbCZQmpA8hdUW5IG aVQoazoRZZpG8c1P2qx8COdlJb8mN/ADUEM21hHpay14hLGhve2iRFQO0hr5NggEsvut /PF6h+6XgH8ZsPuvCKZvUvacDbVy4LqiyBF5x7hoX0X4zq2qaCroPWD88S79nZKNrc9O ujWg== 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=hSlU6Lbj1xiMbj9OJuSwVIYBVljgpyUnPXL4SbncscE=; b=QQCky5xwLVrt72aYTOtQVIm5+5tkrPpUvs3Sg3d/expP/KvnC+XYMLU6BTSwgWZAdi ZF01Semp8NhXq4w7FWhrY+wNA09GyhG1AOSaZqEhBks/Q1EwBRn0/njvK1LPiRCB5ZvU 4CB7wr9l4F3iuw/DuUGrLDf0SbB/P2YrRLK4t7MGk6D26zbwJr6etkIsaznxQgKRKqe9 gdLwNtprF4+sHiNFCuWCkMns6dmkrPeoNE29SfcV+k/FfAxwE6MrGz9lRE/WwSnr6l/y Sc058pH6YaBKlRrm9DIMcymjcW51PYJqc+/vhUWqYom0pHBoIk7M3xB0OwomU8pRMfBZ QzNA== X-Gm-Message-State: AOAM532ASVqYaFRPzL2+IKUMvUT5PIfsZuxhnegtlipzbBRuSsvVyDN6 jLcCbEIEvwLHdNOxj0265tk= X-Google-Smtp-Source: ABdhPJxLT/aEEZENsrdalshxpkuYcAThzVkBKsWYUCQpfppCvGax4dxmv0zOoGgMtYqcV1ArZ2nVxA== X-Received: by 2002:a17:90b:4d0a:b0:1e2:c0b4:8bb8 with SMTP id mw10-20020a17090b4d0a00b001e2c0b48bb8mr6724889pjb.94.1654194134287; Thu, 02 Jun 2022 11:22:14 -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 t10-20020a1709027fca00b0015f2d549b46sm3866779plb.237.2022.06.02.11.22.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 11:22:13 -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: [v2 PATCH 7/7] mm: khugepaged: reorg some khugepaged helpers Date: Thu, 2 Jun 2022 11:21:59 -0700 Message-Id: <20220602182159.248387-8-shy828301@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20220602182159.248387-1-shy828301@gmail.com> References: <20220602182159.248387-1-shy828301@gmail.com> MIME-Version: 1.0 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lGZfQS2d; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.43 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 7798D20055 X-Rspam-User: X-Stat-Signature: o5fyujhz4qayx9cmfjmz1qzodin8ji4b X-HE-Tag: 1654194119-254652 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 khugepaged_{enabled|always|req_madv} are not khugepaged only anymore, move them to huge_mm.h and rename to hugepage_flags_xxx, and remove khugepaged_req_madv due to no users. Also move khugepaged_defrag to khugepaged.c since its only caller is in that file, it doesn't have to be in a header file. Signed-off-by: Yang Shi --- include/linux/huge_mm.h | 8 ++++++++ include/linux/khugepaged.h | 17 +---------------- mm/huge_memory.c | 4 ++-- mm/khugepaged.c | 18 +++++++++++------- 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index bbbaf3eba30a..452eaef24948 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -116,6 +116,14 @@ extern struct kobj_attribute shmem_enabled_attr; extern unsigned long transparent_hugepage_flags; +#define hugepage_flags_enabled() \ + (transparent_hugepage_flags & \ + ((1<flags)) @@ -53,8 +39,7 @@ static inline void khugepaged_exit(struct mm_struct *mm) static inline void khugepaged_enter(struct vm_area_struct *vma, unsigned long vm_flags) { - if (!test_bit(MMF_VM_HUGEPAGE, &vma->vm_mm->flags) && - khugepaged_enabled()) { + if (!test_bit(MMF_VM_HUGEPAGE, &vma->vm_mm->flags)) { if (hugepage_vma_check(vma, vm_flags, false, false)) __khugepaged_enter(vma->vm_mm); } diff --git a/mm/huge_memory.c b/mm/huge_memory.c index b95786ada466..866b98a39496 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -102,11 +102,11 @@ bool hugepage_vma_check(struct vm_area_struct *vma, if (!in_pf && shmem_file(vma->vm_file)) return shmem_huge_enabled(vma); - if (!khugepaged_enabled()) + if (!hugepage_flags_enabled()) return false; /* THP settings require madvise. */ - if (!(vm_flags & VM_HUGEPAGE) && !khugepaged_always()) + if (!(vm_flags & VM_HUGEPAGE) && !hugepage_flags_always()) return false; /* Only regular file is valid */ diff --git a/mm/khugepaged.c b/mm/khugepaged.c index ab6183c5489f..2523c085625a 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -472,7 +472,7 @@ void khugepaged_enter_vma(struct vm_area_struct *vma, unsigned long vm_flags) { if (!test_bit(MMF_VM_HUGEPAGE, &vma->vm_mm->flags) && - khugepaged_enabled()) { + hugepage_flags_enabled()) { if (hugepage_vma_check(vma, vm_flags, false, false)) __khugepaged_enter(vma->vm_mm); } @@ -763,6 +763,10 @@ static bool khugepaged_scan_abort(int nid) return false; } +#define khugepaged_defrag() \ + (transparent_hugepage_flags & \ + (1<