Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp114641lqo; Wed, 27 Mar 2024 08:18:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX2DkD0hYEF4QMfzBYwdnGb5YkHvbIjxfoRzR2wfY7JTfOhHGt9jpD1wYdaC6yhI5xNdB+/s2jQ4useaEUZHXwEoW7cQ0rdXiaFQH60fQ== X-Google-Smtp-Source: AGHT+IFb3ZEWSJO4OY3VfLrTRC13YC/OPU79+Iki2yXNnNk3T7K/YKlGpDG2wYd+MIKyxzNZ6FNP X-Received: by 2002:a17:902:f684:b0:1e0:b28c:ab with SMTP id l4-20020a170902f68400b001e0b28c00abmr4323plg.13.1711552705270; Wed, 27 Mar 2024 08:18:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711552705; cv=pass; d=google.com; s=arc-20160816; b=HqOaslCdyLh4hqfTzTsD/xOSaS+pmyW+zYsgyQQE7Vr5gYPP8DSbUFkppqIklsVRwC 15zB+/h0hEOfyQhN5VzKXcuThH1u/7Z+xnzdNa+uvHAYKa1hrIOGhvBLy0zPFGMUmqpu N7Un0KuoCfmAvzeobb8krWL+0qfGfi+2db946HOkO8K3x9cSjU9NhvvGFD1ChE5G6JcU uSQ/SeZtojsM0EamqkfRvOaHQ8lmvSVEPs9AG12GpgL5EICky12RdsUtrF+P/nw8Mcom B13/PbecgjaAR0z6j9ttuqtHw9ZlrN5I/gaDl6b22sZqJK+QbPeziJOAlxdhV/A2Hqoc wHeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Vjl4T139soDHCaOLCmona2jIshqQpQnAUTRCdsvrmJ4=; fh=MOW7QT52B/E18+0eX8gfwYAkz9naZBc9tTCmJuPpHNM=; b=ahWO2VemWCno6zJS6N6xINPa/+EhQud6I2BC5Tpk8Wbl39B0B9AHNW9AqqasSeI/tY uBk0NitoWBu8blknLqxWz2oE4XkZwkJo4IjMDsi5212hyM42svKSj7B4/OOV4fn0ssYN QdvZccUVdvuHcap/zqNbMViOH0115a3isHhTSK+rHZEKr3oVeiyvZjg+IOW76m1xVBYY B1mLyNCm8HAetb58unm/hpPFZktqj0oQIoM2kKcTRxq2FjBBNaDeRqtmh2OU5iyB0bEO o9+gGcyXF5C2Rzwx43/KyOGceM26gKIpfmq8AJhF7YnT5s+aROQ85LddRj5Xi8PoURfE 3/6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=GGvrvLay; arc=pass (i=1 spf=pass spfdomain=cmpxchg.org dkim=pass dkdomain=cmpxchg-org.20230601.gappssmtp.com dmarc=pass fromdomain=cmpxchg.org); spf=pass (google.com: domain of linux-kernel+bounces-121442-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121442-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id mb4-20020a170903098400b001dcfaf5bfefsi9956908plb.573.2024.03.27.08.18.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:18:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121442-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=GGvrvLay; arc=pass (i=1 spf=pass spfdomain=cmpxchg.org dkim=pass dkdomain=cmpxchg-org.20230601.gappssmtp.com dmarc=pass fromdomain=cmpxchg.org); spf=pass (google.com: domain of linux-kernel+bounces-121442-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121442-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org 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 7B7552C3D12 for ; Wed, 27 Mar 2024 15:09:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F2D9127B7F; Wed, 27 Mar 2024 14:32:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b="GGvrvLay" Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (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 058342E62C for ; Wed, 27 Mar 2024 14:32:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711549961; cv=none; b=IIRfUJAQBfxGaTFPYkHKgZj6mdRd7l4N3RGDbxENUruPodkCb0YuZAuG4aolZXp8DInTZolNl9EVh9WNW55tmxxInSCxbGd8o0MtZz/xdtB2fByAUvFmJl7+/yaNcB4jnHt8ejCLiHNjJS9S53Ys97pK+xds9Cr+GLgttPTEZGo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711549961; c=relaxed/simple; bh=nCtunvuCgrqfxtH1JP7NEPXwfpvzt45vRCZIfaGuBLU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=S+WzOlxOvhfX5Khcg1TQK4BQM5Q3h9dFLbUN3MbICRvMaoghZo1KxrSiaEnbKBIz5vc/CpmqgNH5/LiBT5j6BnUWmPpCLvFdMfDcDeYVzmfQvTrcubFgi5Szqf5rkROskrSGIQzClCKIX47mjMfdLdGtKV4LylVHJRbGEGpTHaI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b=GGvrvLay; arc=none smtp.client-ip=209.85.167.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3bbbc6e51d0so4000013b6e.3 for ; Wed, 27 Mar 2024 07:32:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1711549958; x=1712154758; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Vjl4T139soDHCaOLCmona2jIshqQpQnAUTRCdsvrmJ4=; b=GGvrvLayBSbnMl8bmSoA9Gl8fDWAq2W7kd40kekGkjB7QWM5ejE6XFr8xuLUMiHYqO sNcIFHQqbN8msuMxju4NjLR6ZzNRcSg/2MuBNKzyUKVgF5CMuPS6K6op3Pz6HPvnlN3x XkG2K0PQgeY83ffItTyRxgqE4BJiOjq+Hrr+DJFCoND6Vih/x5Qn80U/8yT+60QHwwX+ npf1MtviMFqbqQtNfP5L64/qd+hpQPdak31M9Pv+toUgzmJAltVVamXMsm8qg53DEfjC nld6edin8/UnV++yQ/TeE12/qY0kSnRPuyMN35GTdlg0+FMcjW98of2bAL6AlEtSqbzJ uXhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711549958; x=1712154758; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Vjl4T139soDHCaOLCmona2jIshqQpQnAUTRCdsvrmJ4=; b=YG19K73ylKth4O9u2xOpU8uOsVF2ESZG9SH84gQRtyvqWAHtdFC9miy+sBbCptJtMq aeCTuYb2p4ZCQgifCLHqbUoLyHoNikuwjDhLDsqAlTiSvimdmfTHr85e+k1BqCPSVVT2 6ZUbvHQ0C4jix0QJyfr0/4461q+a3YS3fdOl+wBlCuTFVdgh38AJdYeCfpNZS+XuZ3d8 7IasGiYnzZovuNh2uIklC25R0+p8ZoWdGgy9IZp/s3JkO6LrdCAVbr1U2aVsBl/Uu3IR yDKsptkKk2mFc9Zjvg3Baw7FvB4FV+zc241Ej+osA5pcfF89fOgTEfnS4I0SRlZFZMgj avew== X-Forwarded-Encrypted: i=1; AJvYcCXV6eJxuDd/khwpv+adl87xmp+cEfmblgfF2NNpaBKO+Qjdp5ZNx/wLSjMZbA62ZAhI+QR4VY/X5QFQl0SJ02h2S6TLhvl60PWZLD+m X-Gm-Message-State: AOJu0YwaSLtcdHGYONU4WtdqEg2B70D7I/zLfpn0vH1HjGbpBHmkTiYW 4IsWKRxWxObw3k4DcBes2Ki6XdkcMxGXYSNmfeqOmxVNNspRDBQWI96191toCX8= X-Received: by 2002:a05:6808:17a5:b0:3c3:d6d6:d40 with SMTP id bg37-20020a05680817a500b003c3d6d60d40mr56729oib.43.1711549958045; Wed, 27 Mar 2024 07:32:38 -0700 (PDT) Received: from localhost (2603-7000-0c01-2716-da5e-d3ff-fee7-26e7.res6.spectrum.com. [2603:7000:c01:2716:da5e:d3ff:fee7:26e7]) by smtp.gmail.com with ESMTPSA id gf15-20020a056214250f00b006912014b98dsm6338275qvb.129.2024.03.27.07.32.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 07:32:37 -0700 (PDT) Date: Wed, 27 Mar 2024 10:32:36 -0400 From: Johannes Weiner To: Vlastimil Babka Cc: Andrew Morton , Mel Gorman , Zi Yan , "Huang, Ying" , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 10/10] mm: page_alloc: consolidate free page accounting Message-ID: <20240327143236.GE229434@cmpxchg.org> References: <20240320180429.678181-1-hannes@cmpxchg.org> <20240320180429.678181-11-hannes@cmpxchg.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Mar 27, 2024 at 09:54:01AM +0100, Vlastimil Babka wrote: > On 3/20/24 7:02 PM, Johannes Weiner wrote: > > Free page accounting currently happens a bit too high up the call > > stack, where it has to deal with guard pages, compaction capturing, > > block stealing and even page isolation. This is subtle and fragile, > > and makes it difficult to hack on the code. > > > > Now that type violations on the freelists have been fixed, push the > > accounting down to where pages enter and leave the freelist. > > Awesome! > > > Signed-off-by: Johannes Weiner > > Reviewed-by: Vlastimil Babka > > Just some nits: > > > @@ -1314,10 +1349,10 @@ static inline void expand(struct zone *zone, struct page *page, > > * Corresponding page table entries will not be touched, > > * pages will stay not present in virtual address space > > */ > > - if (set_page_guard(zone, &page[size], high, migratetype)) > > + if (set_page_guard(zone, &page[size], high)) > > continue; > > > > - add_to_free_list(&page[size], zone, high, migratetype); > > + add_to_free_list(&page[size], zone, high, migratetype, false); > > This is account_freepages() in the hot loop, what if we instead used > __add_to_free_list(), sum up nr_pages and called account_freepages() once > outside of the loop? Good idea. I'll send a fixlet for that. > > set_buddy_order(&page[size], high); > > } > > } > > > > > diff --git a/mm/page_isolation.c b/mm/page_isolation.c > > index 042937d5abe4..914a71c580d8 100644 > > --- a/mm/page_isolation.c > > +++ b/mm/page_isolation.c > > @@ -252,7 +252,8 @@ static void unset_migratetype_isolate(struct page *page, int migratetype) > > * Isolating this block already succeeded, so this > > * should not fail on zone boundaries. > > */ > > - WARN_ON_ONCE(!move_freepages_block_isolate(zone, page, migratetype)); > > + WARN_ON_ONCE(!move_freepages_block_isolate(zone, page, > > + migratetype)); > > } else { > > set_pageblock_migratetype(page, migratetype); > > __putback_isolated_page(page, order, migratetype); > > Looks like a drive-by edit of an extra file just to adjust identation. Argh, yeah, I think an earlier version mucked with the signature and I didn't undo that cleanly. I'll send a fixlet for that too. Thanks for the review!