Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1666041iog; Thu, 16 Jun 2022 11:03:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1utTrZvv9KclRtnX6KbO7D9z5gdy44mDVrvtOe1YBQJSXMHBQD4NaIgRdRULZ9ZOpLK7+Ho X-Received: by 2002:a17:907:7f1c:b0:711:f3b4:da5 with SMTP id qf28-20020a1709077f1c00b00711f3b40da5mr5359930ejc.508.1655402602434; Thu, 16 Jun 2022 11:03:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655402602; cv=none; d=google.com; s=arc-20160816; b=IA3ZqrPdv/lTBZwJC9koFKj3r1L2kyzt2S16n7PQoc5zD5Gj+AFuVguLvuWKySx9S7 bMSI/I0y3mOz9Yyrprax7HagQkLV0hjNeLMeVBqvsawvABeKRiOAvM+rINH3ZHBN1cqm 4thI5qivhw+ghWwPxqwnmrrIShFYG2hm+hBDtjehoY2x7FVI2JQepwxaEUS78BAZNZ81 uQhRQC0Iz3sbMhkZCzR3RB95giPUjOKrI3G4XtfOyUej9rd35KFCamEA+6Th+Y0yC6V7 tjuLXAoi4pkUaedvS78cglH3w1QLsnGqxm4GIZw6pZZ8fhHzg26T4I1sfgwi23iAgr4i AJwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QRTCWUz/v80cwRev6O447pCBMSdMFGV94XhB5oNBreQ=; b=0/aq00VEL1J8/6AiCKcmLG8YRL83wisSaZM20yMYEzRtjvGzXyYHA8SuCaGP5FWFH7 xaJe35WtTr3WMA/JyET6Fe4EQaEIbUKO0cmxwwlGoV17yYnqcgLgnoD6C/j7J3UZh+ZP gDzd+iw6YSKwgYvnnSFPhUsYA0B8v3ZzJjOJG0eilo31tUuqyfCtxHwMINKyQPdAeZzM WFQfEF+tTwZJ++azZbCokwjs2FZ/JYK4IioX0LFtO7xihR92ZW84TtJFva+7NQRXjWnS iTuNlMOdEytrKchk598p6CgVjaiRJuDm8FhVTCKYgbk/nSN0PPoSWa9wmWNz8Hr7QZt0 nE+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Fm5abIw4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e2-20020a170906748200b00718e483c586si2457956ejl.201.2022.06.16.11.02.52; Thu, 16 Jun 2022 11:03:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Fm5abIw4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358050AbiFPRtZ (ORCPT + 99 others); Thu, 16 Jun 2022 13:49:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237614AbiFPRtA (ORCPT ); Thu, 16 Jun 2022 13:49:00 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF2064CD69 for ; Thu, 16 Jun 2022 10:48:57 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id y196so2111057pfb.6 for ; Thu, 16 Jun 2022 10:48:57 -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=QRTCWUz/v80cwRev6O447pCBMSdMFGV94XhB5oNBreQ=; b=Fm5abIw414WczmkiARiuOIB9/0ASIunFH2zFKcRTz+KBNKvcBYcmyc+rwz37WtNCMN Q91YdwCifI/utdZj36nMuMzQ4+xEtVBzz4U+2d8nLuOBijN4D6KkGIrGsfWfJqgzx88i N4serWC67hGg9tGb1K1E+W3IM/ktOQLXj8AjMMv2xSPVvxkLY8yTbIBB23hujhfKIjuF qR8R2Fl5Vg/GOWk7BTeueqJwqM3OPvf3ZTwxKrBpWmtBKIO+6AXuItMuxGrDC5dm3FVJ yOYhpdT39E1dzHRcviaiO05a4p0BqyMWfcINITHFuS6WnG9CxsdiuWgtrO7U4uWx+vZy 185Q== 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=QRTCWUz/v80cwRev6O447pCBMSdMFGV94XhB5oNBreQ=; b=RcmLyNfMWN8i2OHDt9mbyCtdo/B5lUCdOZ2vFyY7vUXBoicyJjMCapRPsBugCQVa+/ d1Tlvqu94RtkYMolSD/xFKj9Ozk1ZRCpaZp5LaA5XMEuDkpMcMKdMS740VLG0Egu40GB U5sqJMt0VsuLZ4hZo/H6+ciojfxlcy72nEbjymcCehelEzM7hDHY9buWKE1S/087h7g7 RX2hMgmGbGrbd+L7+Q2BEQ9TfGtx61ACvAI8fETB+H3qjqaqjWXBpVmNu+qvxiF76+jg ngOV0AJ0mvdljzTu0q41hqTJyKpawAEDdMAlOheJsVB8UNFcNEPz71B67sBJgVBfm1X4 ugvQ== X-Gm-Message-State: AJIora+HfmWwW9bDFVXE3m1IrSUb+wU0nnPU+J3tUlm5LPZD6kls069A 5QfkKkfCNeCSo9UgGJgiztU= X-Received: by 2002:a05:6a00:1513:b0:51c:3ca8:47a4 with SMTP id q19-20020a056a00151300b0051c3ca847a4mr5967135pfu.48.1655401737201; Thu, 16 Jun 2022 10:48:57 -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 z21-20020a17090a8b9500b001e8520b211bsm1818289pjn.53.2022.06.16.10.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 10:48:56 -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: [v5 PATCH 6/7] mm: khugepaged: reorg some khugepaged helpers Date: Thu, 16 Jun 2022 10:48:39 -0700 Message-Id: <20220616174840.1202070-7-shy828301@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20220616174840.1202070-1-shy828301@gmail.com> References: <20220616174840.1202070-1-shy828301@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Reviewed-by: Zach O'Keefe Signed-off-by: Yang Shi --- include/linux/huge_mm.h | 8 ++++++++ include/linux/khugepaged.h | 14 -------------- mm/huge_memory.c | 4 ++-- mm/khugepaged.c | 18 +++++++++++------- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index cd8a6c5d9fe5..ae3d8e2fd9e2 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)) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index d0c37d99917b..0f2cce2d7041 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -117,11 +117,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 2a676f37c921..d8ebb60aae36 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<