Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp420367lqh; Tue, 7 May 2024 03:22:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXwBJBLH/GMoBY78w9KhbS2NvANHoDQaw+5KjDaNRYbKtw14M6QYPBJxZvKzayQJlxXMba8ddHUcmlNHR09JxJExjvnMlYcoe32YtABWg== X-Google-Smtp-Source: AGHT+IENVnFTEEKwtK4U7NUQk8YpOM5bRvbEOxr33HZ8AvOwDtk/sxOwXnQsdaWj2P0ZLD4i1Thp X-Received: by 2002:a17:907:6d20:b0:a59:b136:e40f with SMTP id sa32-20020a1709076d2000b00a59b136e40fmr6241662ejc.38.1715077320225; Tue, 07 May 2024 03:22:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715077320; cv=pass; d=google.com; s=arc-20160816; b=DNWh52bPxWk6E2YsmtIsuTj9tDvwkbtAOKOPYMZ7Cw6cfUjECaOiCiU9pa76kzgFAD hna+OzZrRbcuz5lAt7fh4GsQTMvvZ5XRC4dwGAtVRpLN6miPa+WlOj6U2J9QIdz6WfBU lRRIZv/+ZoRGxVy0NsPi3+t9FcaOMCzybq+eTTbR+vKF4vjGl3lj3CiF4UmA8mnZgbx7 VMu0dUw3coaA+FWCTUKghAp3SSNuBVF1rAeC2ym4Tvcv0dJriL9zZC3uoyjAd8DucHHt YS7YOmiYCKMOIvkjAQBMUrpzIJwJ4v+5Cbt8AN+YO9LYMYg+1/+8+QCmegGrm+HWVeLY 39Jw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=eWH/AeWo/1ZmjhV8xkyllxPYPfkaXQCRlFvi6eEYW5Y=; fh=HNK8sdzpIJPmAtVDUobkBqk0l8CCDzPJbXt8Ie4VX3A=; b=IPAvOeNWKC9n22VWqIq6VSS2wZH+7meRxHTZmqp3gRU8t4zRkKwKlrcQ0UaaXXuvT7 NhKcLtOm1UREMbVehAZwhkTsrflZ1BueVmAVtcfOEAjWCy8Rbubgnxeu3yGYnDXPfDHc GaMK5YJGI9raaEksDgJIx6QSKeucEVX274GClScY0LXuqHiWZVTy6ewJU0eysUJPsISY mHI9kCgAhmUOX9NwJYbt7/foDYmw57ianoi27IiGqlDjc0tUgB/sgQn8ka5F1+quhXxA XePW1WQ+Mjm2kfMF2tjm4guHoXBDQqNKFaROL0Ywom2MRvtAXA7YJuyQ+GUyb9l1JxgL pQAA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-171080-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171080-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c6-20020a170906340600b00a59e6cbaa90si816984ejb.957.2024.05.07.03.22.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 03:22:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171080-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-171080-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171080-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 am.mirrors.kernel.org (Postfix) with ESMTPS id F17111F23816 for ; Tue, 7 May 2024 10:21:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35A9314F10D; Tue, 7 May 2024 10:21:49 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 493C814E2E7 for ; Tue, 7 May 2024 10:21:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715077308; cv=none; b=Ft4xzDFthjzxA/lncxFCHMVaYuyWiVKgquVdxTMqnlCaMLp3sxW0lPGNJozI0JPbG513EeM3rykybJ0JSbjw6WF7SQFqE5gTgKydZDRID3n8nHK5lty76JyPiIMnEHCTBXSlPmqccv4o8FMGd4XldANUgH7BqLnxW+k3A1S8sv4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715077308; c=relaxed/simple; bh=ECyR1tgzfLMX85fMy9PUgl5KdwwbExytsPT9LvKv8Zs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=RfGocQB009Aba+WrVmmC5N+xZXYW5AYjAPOQQtCNDE9gUEwAEniug/36Nd3tmt+CZKZoUbdHoRoubA0vItzAnie4kP/KTzSj+N33pb0OPTxJRoMTSPsp4TEoCxSjDVuTHDlyy/H8SUrcs734Q15m074UCnLAFdGJLTd0tagMyjc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ABC7C1063; Tue, 7 May 2024 03:22:12 -0700 (PDT) Received: from [10.1.34.181] (unknown [10.1.34.181]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1FCCC3F587; Tue, 7 May 2024 03:21:45 -0700 (PDT) Message-ID: <9576c979-8a11-48e2-aec4-646acf0d8e26@arm.com> Date: Tue, 7 May 2024 11:21:43 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/8] mm: move highest_order() and next_order() out of the THP config Content-Language: en-GB To: Baolin Wang , 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, shy828301@gmail.com, ziy@nvidia.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 06/05/2024 09:46, Baolin Wang wrote: > Move highest_order() and next_order() out of the CONFIG_TRANSPARENT_HUGEPAGE > macro, which can be common functions to be used. Sorry if I haven't kept up with the discussion, but why is this needed? I wouldn't expect a need to iterate over orders if THP is compile-time disabled because we will never try to allocate THP? > > 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