Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1255092lqh; Mon, 6 May 2024 01:47:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWNHBdHLxYqN4JP5VebGyFdHzUGaU6eXLOTfjIswt6lv54dS/LzJV2MyS4da21zaBUi2b5q29h+TqJ1OEl56OHKcQENjL4Ad5yCDELUvg== X-Google-Smtp-Source: AGHT+IG5AitR74lGklm3PnQVIvo6m5m5EYu2m6s946OzCbx4S6b+Nz6KL6YPpdZx+guGuLBt0mIS X-Received: by 2002:a05:6358:9883:b0:186:3ae:e138 with SMTP id q3-20020a056358988300b0018603aee138mr13253470rwa.25.1714985223988; Mon, 06 May 2024 01:47:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714985223; cv=pass; d=google.com; s=arc-20160816; b=dNAmk0z1kmYiKZRVXzMsAEBHoVyQn3dluLButix8GfiWSg4QKjx5oO608B+Q7Beo46 breNMLffRuMx77BSOkbp+YljO1TIJf4UqnAMT23JHt8dnybl/1XB39W+4Mm3kRwsoq5U qfTvnjLt+VnX5eehQEHOFeGSxnti3o/fJoiFjZah8sUtY306XBuemCRxqb3m9k1ciTRf +N/UDhcN66szUxPpcCA3LSzHKcCg+muD4NDJhlZEKi6TMZ0XVPqveH1KxeC8CSvkQeyh npTcqaUUsbXpxedHjo43Zn6BC6hXON437VX6DlEK2s9mca9h8JKoGqzWJ7z38PiGDUB8 sYrg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=p4+ojbN485lnDhEdHj7u8+ldhF5xWmY9Y6UtO0qnCFI=; fh=QbwS3auWn4deePzqcQEgPh0o+FZG4BOPGyVFHXP9ySY=; b=dI+ZttrLBi7B/AvRzmLwMKbypnchsKZHv1VhxQfH4SW+IMlc3mx30dCUkeR0Oamj5c 4++VYOTu6bA3Sl4Uf8wm36HYshsns3r7Hb3IZCEkbWb+UqUOfqvTj66CCtnw/dt1OQQs 7E2YkMrDlLDYHnGOeTtv4InMhhJqfTbpLLcQzTvhMF3TjtHTdaMUVQqk8NMbsuXAV7XB w3TfZ4Kr0FhQbqPepdpst1DZCGmuPG8IizBC6TcNgzouSlotgVeq0jxievZXmsrvxgTo SjpxKX86LAgA3Ibbj3BA9I03AURQcS5rTXifWSB69/0NFPTa/Isw/IhbagEsSq0uGM3b l84Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=niS9UOjU; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-169518-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169518-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y8-20020a655288000000b005e857e42aa7si8216089pgp.55.2024.05.06.01.47.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 01:47:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169518-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=niS9UOjU; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-169518-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169518-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9995B281FB2 for ; Mon, 6 May 2024 08:47:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF8D41422AC; Mon, 6 May 2024 08:46:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="niS9UOjU" Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 993C91411CE for ; Mon, 6 May 2024 08:46:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714985210; cv=none; b=F+MVNNH/wLXNrIR5Fuy/i+9/mZPI0M1XnhFGmgf9lnUlqfBFE9j5Z5MdOt8oog41rcr1lDaZ0V1bEuL+/J+HD4rViTGCraIKkFiwGteePNkfkcNf9WrxDq4dUM3kSwzTYM+Dj+FV+JKVAyHZ2J+ec6UJX0dEyB24IWPN3tlTFRA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714985210; c=relaxed/simple; bh=rApUqYVsVt9Lmm4m+jmthQspAsl2swdyFeKQOkOm8b0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kFdidOZugT8WRNKo0gC4KPnQVAcf0o24YLBf4ugguPWMpd3Af5ezzigrZsnbudLH+AhffdbNJhAWAXZwmF10PLPd0yCuUqVZymiQ4JHZY7gmdzjhUzLEfDEymNO2eQEWiaMSsocJQTTmnNYYNFI2sR2wdkGPcCMOMNrW1V1gF14= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=niS9UOjU; arc=none smtp.client-ip=115.124.30.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1714985206; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=p4+ojbN485lnDhEdHj7u8+ldhF5xWmY9Y6UtO0qnCFI=; b=niS9UOjU7LndqDhtzwDcEt+Nfw0URVg8yrCSFEALpmc3Vm5xcN/riz/NmlSyJqe7ND5+tiPqsKIzdFgV+vDpQ79KB5m6B03drAkW/amtl07eFjEmIzsvbwN3S0oWNkQzZDEC8NQG86j27UDgMD78jvNe1hRIBb1uP7LXmR7Wk3Q= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R571e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033032014031;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0W5weiJg_1714985203; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W5weiJg_1714985203) by smtp.aliyun-inc.com; Mon, 06 May 2024 16:46:44 +0800 From: Baolin Wang To: akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, david@redhat.com, ioworker0@gmail.com, wangkefeng.wang@huawei.com, ying.huang@intel.com, 21cnbao@gmail.com, ryan.roberts@arm.com, shy828301@gmail.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/8] mm: move highest_order() and next_order() out of the THP config Date: Mon, 6 May 2024 16:46:25 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Move highest_order() and next_order() out of the CONFIG_TRANSPARENT_HUGEPAGE macro, which can be common functions to be used. Signed-off-by: Baolin Wang --- include/linux/huge_mm.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 017cee864080..e49b56c40a11 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -106,6 +106,17 @@ extern struct kobj_attribute shmem_enabled_attr; #define HPAGE_PUD_MASK (~(HPAGE_PUD_SIZE - 1)) #define HPAGE_PUD_SIZE ((1UL) << HPAGE_PUD_SHIFT) +static inline int highest_order(unsigned long orders) +{ + return fls_long(orders) - 1; +} + +static inline int next_order(unsigned long *orders, int prev) +{ + *orders &= ~BIT(prev); + return highest_order(*orders); +} + #ifdef CONFIG_TRANSPARENT_HUGEPAGE extern unsigned long transparent_hugepage_flags; @@ -138,17 +149,6 @@ static inline bool hugepage_flags_enabled(void) huge_anon_orders_madvise; } -static inline int highest_order(unsigned long orders) -{ - return fls_long(orders) - 1; -} - -static inline int next_order(unsigned long *orders, int prev) -{ - *orders &= ~BIT(prev); - return highest_order(*orders); -} - /* * Do the below checks: * - For file vma, check if the linear page offset of vma is -- 2.39.3