Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1305034lqm; Thu, 2 May 2024 10:32:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXD9zq1VyrBHVJombb1GQ/UFMOR4hihIXLSZ6SJ3YL10voEPrKN45UHN2ptA6tvhAGE8tPrZ1EJKYriyPSDCXor74c8D8A4HBiWqqxKfg== X-Google-Smtp-Source: AGHT+IHf+mZHl9+kQwgDOD0UUX+MtwUlr8bJlW+2kglL6nzU8+eN4GopGjfmUNYa8M0O10lpgMLs X-Received: by 2002:a17:90a:a516:b0:2b2:2793:9394 with SMTP id a22-20020a17090aa51600b002b227939394mr479746pjq.2.1714671126952; Thu, 02 May 2024 10:32:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714671126; cv=pass; d=google.com; s=arc-20160816; b=bvpYNw1VG8XW+YnWHARX/B3mV7HdJs5gmYGEaH/idEVkjiWz5oH0NVnJekWvdKmHbo pLuYLET0SHG0/8oUdr0W3QSivg0he2ax0ghslOcAXMQ08H95vOHecLwpz+zXxNj8PD/7 qboBXvyAIxu2Lck9bJ/I/o1LmixU+9C76MvmObiJM5A4zy3Ansb8WfA+YSFH6Z/N93sL P4yCLOyEfGnVN2sVGbL/82nQyfxHcb4q/syfNEWKhr6qbbQVSAOymramB8kWrtQLgvPo dlJPD9WedTDVClVlaa0JHCDi18qd5BB1A1TKKAVq/bMvnDytVxXuiu2fbvafqMnU3BzZ BEkg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=KUNTNSxf5jFZNiSIENiFHEDs4SL26oCzRgNOWpdMUDI=; fh=H+gda+eRxM5tE7BKE4Q7/teZeG9IVyexslDxCkj4rMk=; b=NIl+Ucg5gUmP798euUMFJV3agcAJj614mHYaZdPaIUcbYGEZHWK8Fj0VQYHy6v/K8y xt+jlEHyMANr23x4ytbl7g4mqeHKWo/kF9QaEjuoKCHXotUIN8fhfUIUqy+7S/CkyylZ EbyoRAPrN6J2ugpmokPE0AtYtgdrY6l/RLkWVKz1s/LgbF10SxMe/D8KXsXrP/X863k1 fuK51nDHrWm6dqfecsNwVAcFsmBONCBcoMM8keKMIQFM62WOIHyhzcaHInPWgN6b/DAZ Lz0ipRC5fkT/14/Vgmr01n6KXVMisnWFxywwPlxlfDfAPxN0LdFGemhgSIjKv4h8j22x 1Ddg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=GF2pJc9p; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-166787-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166787-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id pc4-20020a17090b3b8400b0029bb32706b9si3951475pjb.47.2024.05.02.10.32.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 10:32:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166787-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=GF2pJc9p; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-166787-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166787-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A3BA6B21462 for ; Thu, 2 May 2024 17:28:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C8DAD16FF4F; Thu, 2 May 2024 17:27:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GF2pJc9p" Received: from mail-vs1-f44.google.com (mail-vs1-f44.google.com [209.85.217.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82D3A16FF43 for ; Thu, 2 May 2024 17:27:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714670860; cv=none; b=jAOWvFefzQUQ5o+EI1ktQAJeHlyCzQ3xFTT6sTX95b8TNsPVW3Usu8nk3GjAe0LQvWmoAzQj8BK/LaxmVG0xWTDSf4rFicmrPu52+R2ECWWn6FzwPrGxxsBt92sEItQmBza42yHBqG93ATzd5O/aI2pkyHKnJCscml7BkbZktVg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714670860; c=relaxed/simple; bh=IODz6rURhmbvGrZ5LohgKuLkW2J02pSbwFR6mCjv3xY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=oTdc4G+boMuB4nQ+gXFjqIFHUT74rv0jpVX0+NnNAkZ0ETpmJAE7vweYcrb4Dq+MzL5KJnmX8/eA++geoXAJxNQI09dH0S0W2RRXpdhQMdV+eXmfw0w3NRoun4D3bZnKvKJEhqXB18VLtlwy4k4MhNs4L3n0BjLXmsGwmkUYUys= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=GF2pJc9p; arc=none smtp.client-ip=209.85.217.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-vs1-f44.google.com with SMTP id ada2fe7eead31-47a404c6decso2422179137.3 for ; Thu, 02 May 2024 10:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1714670857; x=1715275657; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=KUNTNSxf5jFZNiSIENiFHEDs4SL26oCzRgNOWpdMUDI=; b=GF2pJc9pUvoAaNiTQi7bPplrbypCYDd3HfHa7EM/NzApHVbtIuBi9qYSRVF+ZrOKrm Kz6LBsULgcKOTeHRvq4y/F61DdZ9YTEiAtyhZpVHai+SjcKcQWdKsvCFDr/Z/uM43JD/ A0FdlY1/8y2UL8GhBpGuT7K2cq1EX2ZVis4T9uiRm9rWnt03neLf729qMiMLen5Nf6au r+TM7ZfDyPChGvtZW9iaGe2PMeoeNJ0fLldxDgTD0cNyrbjroKQEbsD/NfrQjV7paJ4m SHwhm76SOc5hKNTySErQxayBboz/X6tldXLC3XRULAc/uKKd5GXmIj5rPAfXX5Z9cFrd t2sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714670857; x=1715275657; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KUNTNSxf5jFZNiSIENiFHEDs4SL26oCzRgNOWpdMUDI=; b=f+vhKLbGPOiYUvrtZ9FV9o7R8T8P7WUA3g/m64GIpOLJIRPDNqidm461YcHNKKUNx1 N4pckIdMFH2jfELUENemPeG+5kNpxdL02VsUYOe1POCrNT8fTwSvFDnDkZutEZv7dgHp 9VOak4TFsMa8azgs2MmcfDbs9VywkbMLpXxaFJuNlVncmnnc8IDn5q3SzkJhREhv2Tjq kc9EpK5fXOtmW8ADP9rhKRSmbVseK7abA2rlNyBZpnFZBfZloGEiq/dduD2jfs7IzJsb WfGQ4ldJmipXM4XMnw2ld86UWqsM/rxgsyrbf8e3GIqe1kOSaAbV9Iw42dS7l85UrUZE FDjQ== X-Forwarded-Encrypted: i=1; AJvYcCU7ixipvCnxViuJBLTglsqKvgdJWT25r52mr806Sbn+Ru7RxrdtWNc5U4XMds53Cmm4TCVCyqAj0zaV1W2PSuRK9+2MTroEF2vNc5vv X-Gm-Message-State: AOJu0YxACg7io7TyfUK1+HwkDhpdAHjd7v1S5gFXyrBGgzoLaERdUKeR q6t1tq6HyH/J26AOMagovY+0Yancsu4iCWn77wVVlM3FfEKqJDIzN1NIUUUkOPmJT8mJxIh4kA+ ebezMeSg8n3yLC1c1wvXs27fUX26yXRf61QI9 X-Received: by 2002:a05:6122:4319:b0:4db:223b:1c0a with SMTP id cp25-20020a056122431900b004db223b1c0amr408732vkb.11.1714670857208; Thu, 02 May 2024 10:27:37 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240430161437.2100295-1-fvdl@google.com> In-Reply-To: From: Frank van der Linden Date: Thu, 2 May 2024 10:27:25 -0700 Message-ID: Subject: Re: [PATCH] mm/hugetlb: align cma on allocation order, not demotion order To: David Hildenbrand Cc: linux-mm@kvack.org, muchun.song@linux.dev, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Roman Gushchin Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 2, 2024 at 6:15=E2=80=AFAM David Hildenbrand = wrote: > > On 30.04.24 18:14, Frank van der Linden wrote: > > Align the CMA area for hugetlb gigantic pages to their size, not the > > size that they can be demoted to. Otherwise there might be misaligned > > sections at the start and end of the CMA area that will never be used > > for hugetlb page allocations. > > > > Signed-off-by: Frank van der Linden > > Cc: Roman Gushchin > > Fixes: a01f43901cfb ("hugetlb: be sure to free demoted CMA pages to CMA= ") > > --- > > mm/hugetlb.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > > index 5dc3f5ea3a2e..cfe7b025c576 100644 > > --- a/mm/hugetlb.c > > +++ b/mm/hugetlb.c > > @@ -7794,7 +7794,7 @@ void __init hugetlb_cma_reserve(int order) > > * huge page demotion. > > */ > > res =3D cma_declare_contiguous_nid(0, size, 0, > > - PAGE_SIZE << HUGETLB_PAGE_ORDER, > > + PAGE_SIZE << order, > > HUGETLB_PAGE_ORDER, false, name, > > &hugetlb_cma[nid], nid); > > if (res) { > > I was wondering how that worked when reviewing your other patch. > Wondering why we never got a BUG report, maybe we were always lucky > about the alignment we actually got? I think this issue was probably masked by the hugetlb allocator falling back to direct alloc_contig_pages allocation if cma_alloc fails. So if you're not under memory pressure, the failure to allocate from the misaligned areas might not have been noticed. I noticed it, because I was working with change I made: a flag that prevents the fallback to straight alloc_contig_pages, as that behavior may not be desired - you don't want to potentially eat in to non-movable space that the kernel needs, it might be better to fail if there's no CMA available. > > We round up size to PAGE_SIZE << order, so that's the alignment we need. > > Reviewed-by: David Hildenbrand Thanks!