From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (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 2CB7B36AB4B for ; Mon, 6 Apr 2026 16:12:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775491982; cv=none; b=iUtx1px3QIEA107Mbstmx8o4KDHJGl07OOr2ynakDHnV5E1hru27HgRkMrCY37qazFUWhOQpuQPf5wMydBfTU5GHT1/FIVLijoRhXRfJAN/9Ew1ee3x4RglFPe4sss8sZqPDnaWgmpjSvEdpYrNdVLXX8lmdAQP2LvIjIRclWKA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775491982; c=relaxed/simple; bh=qQWhDY74TPfqwIOBEJvdPylSxqO07ekml/qHHdXA3eQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CZyedgkTAMzuszj9bnBscBX4O24ielEzOko7P3bi3JFQpZLEHWT0kM0EYrUtRNjYNO91F0TfXkBOIReuPNEiP39zlc2HaSx4YpwyUzOkJSjxxtip+Uo/89U97VbYBml/8lacbubcDxUgoJ2ZmkIhIx/c5jQGmU14AKYINt03JPw= 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 header.i=@cmpxchg.org header.b=GkoiNMCn; arc=none smtp.client-ip=209.85.160.169 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="GkoiNMCn" Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-50b2b289925so37302641cf.2 for ; Mon, 06 Apr 2026 09:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1775491978; x=1776096778; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=8WGlrIJpvPnuQtTh0sCZ/YJHBX7OWAu7nDVvuxQbARI=; b=GkoiNMCnrq164CyOK3JgGMv79iL64oqr4EVs07Fw98hfZ3CZlL5sCv4bcLLw2JpkeB cys7Oh3T+xCEppxmIcx2lGsakevxBk3LCgNflp9gzGAVYC6uN3Us/hpD7vFVPenO2d4D Ny5KuB9OjdYR/+GDF+d6Ru7OgLtDDIgKP5X3b+acmy77IKFxgt+MtLxqq0JdJPqroIW/ A91QNnSEtHSRTcUyRa5vJqHAY1Ezx0EdLJcYcloRanvAd2tLrDhhp1J1hMSdIP4FbPYe 0Sggilgaot4Ka8QLEfDoSwJde7q3YrBWrAEAiCh8LWFumiO80tb+2Hi0nlSqW18+eLyf zUgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775491978; x=1776096778; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8WGlrIJpvPnuQtTh0sCZ/YJHBX7OWAu7nDVvuxQbARI=; b=g86FX5dIVyt3hUuBLUOxDn6uoS65ZnJGUnGtkTO4/z936GoBCiankj9CwZqKlBovaq I1MRjIzFH6F07ysnhauYcp57LoaBQzesqsOfObnil5MG/MiT0bSWgp3Z6EYBRFEWT/38 HaFaBI2SW+ukWTLJQyf/f7KP0oJhufMgpL0LMn2zx0e79GKSuz65ksokJIFn5LcOF0SR xWGYZLWtVxzZmXy5eYzsRBi52CejVkmEkRA5vt/8UM8YhMPWi99UyNZRJZrfCRNUx08h 99kAemuoaYeskojloDaxM/Ns2hhOkSNLpRRObltYAO1yD+PhrDvNi5qHye/j8XhkysNo HW6g== X-Forwarded-Encrypted: i=1; AJvYcCVxvNahcdx2KD2vEE7oaYcfv5XFqqsqvJRf85p4CNFOhQDKuhb9lN1rLRVubwpNabjAWsU9YFwrhDtbfWo=@vger.kernel.org X-Gm-Message-State: AOJu0Yzjgnk5lu5waRxUg/AnUtjfjgnFRjH7plBXttUU6cKX4XJdfhiL A1YWaXRtC2m3eHyoUH9mfhuhFMffkZeS4s0zndoYPHH36G7PdEVYjzsm0sNoYqTMwYM= X-Gm-Gg: AeBDieukLLO+222fG31aEl7NGj0KhfC6oZ5PFiX7TOgnhhcI+pH3AU90zQ1nL/atooM 5fW+NsvPouwk01YWBVpVl7VSI22PKhYInFHdMayhYDkjsuUdKKn6RSKoaN9JWW1DDKOkqwmRMEf jNnRLOUZlkY12Oxak5x3YtTFHcvap5Bt2lu+1b6KT6loVacb35vlglkxOpmFfsB2mZ700qC3JJa vY5FW1cDkmIH8T4RrG22/DKL3tIwsFRvVKzxSIblIlD69jWH0cV5HP5jYsRrvFViQoom2VzOw1B kIh2e1fdvoCqJ3JpkDmn0tNrTBQagBd5ozirNGPpEif3dN+/g7s5nCXHJX4f5o4Sxh6YFmahFe7 hT7OAJspEyDNzNbZvcFkppjlCy2tGJcfJkFjzN/WIlV+Zhu9K6RPWujs07zRLI9U4MXaAGZaLi0 fT2AUcQQLPl/4WiyfPj5gRlA== X-Received: by 2002:ac8:7f07:0:b0:50b:3c7e:a33c with SMTP id d75a77b69052e-50d62a95fbbmr218250341cf.38.1775491977759; Mon, 06 Apr 2026 09:12:57 -0700 (PDT) Received: from localhost ([2603:7000:c00:3a00:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50d4b93dd10sm115521861cf.7.2026.04.06.09.12.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2026 09:12:57 -0700 (PDT) Date: Mon, 6 Apr 2026 12:12:53 -0400 From: Johannes Weiner To: Rik van Riel Cc: linux-mm@kvack.org, Vlastimil Babka , Zi Yan , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , linux-kernel@vger.kernel.org Subject: Re: [RFC 2/2] mm: page_alloc: per-cpu pageblock buddy allocator Message-ID: References: <20260403194526.477775-1-hannes@cmpxchg.org> <20260403194526.477775-3-hannes@cmpxchg.org> <984aee1a7af2ea4b576a0114a367402537d3deca.camel@surriel.com> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <984aee1a7af2ea4b576a0114a367402537d3deca.camel@surriel.com> On Fri, Apr 03, 2026 at 09:42:08PM -0400, Rik van Riel wrote: > On Fri, 2026-04-03 at 15:40 -0400, Johannes Weiner wrote: > > > > @@ -755,6 +752,9 @@ struct per_cpu_pages { > >  #endif > >   short free_count; /* consecutive free count */ > >   > > + /* Pageblocks owned by this CPU, for fragment recovery */ > > + struct list_head owned_blocks; > > + > >   /* Lists of pages, one per migrate type stored on the pcp-lists */ > >   struct list_head lists[NR_PCP_LISTS]; > >  } ____cacheline_aligned_in_smp; > > > > > + /* > > + * Phase 0: Recover fragments from owned blocks. > > + * > > + * The owned_blocks list tracks blocks that have fragments > > + * sitting in zone buddy (put there by drains). Pull matching > > + * fragments back to PCP with PagePCPBuddy so they participate > > + * in merging, instead of claiming fresh blocks and spreading > > + * fragmentation further. > > + * > > + * Only recover blocks matching the requested migratetype. > > + * After recovery, remove the block from the list -- the drain > > + * path re-adds it if new fragments arrive. > > + */ > > + list_for_each_entry_safe(pbd, tmp, &pcp->owned_blocks, cpu_node) { > > + unsigned long base_pfn, pfn; > > + int block_mt; > > + > > + base_pfn = pbd->block_pfn; > > + block_mt = pbd_migratetype(pbd); > > + if (block_mt != migratetype) > > + continue; > > GIven that you just skip over blocks of the wrong migratetype, > I wonder if it makes sense to have a different list head for each > migratetype in the per_cpu_pages struct. The list is fairly small in practice (pcp->high / average_free_pages_per_block). I haven't run into any issues with it so far (although like I said, my tests have been limited). That said, I also don't think it would be an issue to do that split if necessary. Additional list heads are 16 bytes per cpu per zone. Let me keep an eye on this during larger scale tests.