From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 581AF347DD for ; Wed, 29 Apr 2026 10:33:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777458816; cv=none; b=nJZLvXZ2kLWNbbs3mzfBLRatOGgQPqwVKlNti6LtkpGYlUQz4ezKG65u6xseLiK8ToJzYUgz1UPi0MhAoBarA8cwxlRALPyFRBwY5/n6X6jjX8akWvKoTZB2MRKCXqPmbpVOEVI2VUMffKjDYI516zt1fLG8smD0IYRa95yqU88= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777458816; c=relaxed/simple; bh=UmShxRC6zXdEi19yg5n4FmGwxPh4rT9g/WgZDs5vHuQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=td8fN5b2plTEd8+3W3x+dixLsXG0dcVGsMtIRKgTHw5Nb5KEMr/ExbAppNAZxTavj5j9FHLH1ORVaNQKl63B67nyleIGlpq0JPd5TiQ2HPlqs3TUeMHmWasya+xWXSiK69hDuwHjmEzD/LIe4EDgrqIz5eNI5yDApBlN3peZKx4= 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=EpwayYP1; arc=none smtp.client-ip=209.85.221.41 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="EpwayYP1" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-43d77f6092eso8624727f8f.2 for ; Wed, 29 Apr 2026 03:33:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1777458812; x=1778063612; 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=Rc1bdtiiLVnrHG/ySdu4hkFQib6QmOtBtlzbNliUfdc=; b=EpwayYP1a25T9uZmWPDwtK9u2GFuQxMsQ57cOyHVNzBiwDTCHkZ6XErPck5T3OSWBt FqpMrq9N36wf/JWaaMTultN8ZyO8iVW2h1neAqZJjT3aEkbY+lj7OChaMTcv2wrkXeyy rtyVipUFsC7SxB1S3G3DPwm9wD7f0g+1wCp4NPJQ0f1IBjxj3jC2s8Uh/dHVNnJ7NxMO qKE5YUddBINhKi0gQOuPmbj2IwGvqZnWl1U6osduPiFeytJ7Xsy7XGIQYxv0YrWFJSUc nmAH5h7GHKZyFPftPmfd3CkyBEJJl9zEs/woj8j0yVR/CUiYVofMY9C7sDSFFNVdGwvp bK9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777458812; x=1778063612; h=in-reply-to: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=Rc1bdtiiLVnrHG/ySdu4hkFQib6QmOtBtlzbNliUfdc=; b=c3ROsAufdLeZv13GZskr1KDaRLrtP99lrXhGE2e8NZ+7W50Xci01th/UCJjX76DqGj df38o8fSleqkQ/OIyGKEVIiUFDiQFqpTUi2lNSN3eOKnxuZwfHEIYxe7DxwDUm5DjZrM nuEym1XHWX7Dl7nOQka3RzTqBKq9OV4dDxBZz6Nr1DRilnUAC3IAbpecac5t2z9bWTa9 2rRLC4C6n1ntN62ejRwlfZ2NrHKso19/AyvEqsNDQ1bWyML+792eckg6QSIg/1tGdJtm yRNAehAcN3QoMRdKd02daXn4RGmLcKSTR3YUvQzFIya2PMx8ZOXT4abOcyedwqHz312+ yu3w== X-Forwarded-Encrypted: i=1; AFNElJ8lfKscnhGdC6rx+8+BJ3tosmz2KViRqwyjvNSwTZyYqKAlKpKg0bv5rRapFmiCVIa4nA2ARLnMBjiZoF4=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0vZYM+toBiHVe7sUPwijz+jjNZxfgpXnkmZC9pJBd1RibQ1wE rkK9V+ExL6pxVmeTFX9n9sAiTirbu2uGBs35lwg8HTLnF0evJ6Gzk8RUwxUTTwz5fA0= X-Gm-Gg: AeBDieuuBuq++tkru9NhFlqnkleFkZQS3RF5gU4R7uwctDBJ4jqQT8SmQSdv6ZRsWk6 IlEuT+EGMOUt3udchiFQ5AHOI1w4FJqy+ZdsqoPpWPbXWYJ7q/mPmUcqL/Ucz9eieZuFbZS/GZE QMf7XQPRviiFmxFEFpGdVPSAcSkjDKfI8NyEwX1vWDHBQciYDCcbxR8Ia/y7vH5r/jOd0sB738z V64G551O3k8Vh8JuO5Yj1kaMo7I5leEjndAzfl/87ubGBmrTSYP8ZaUg8P8aRleTjYv3ljJtjIT C1cX0SJZULiFLz+ngzZsSrVBS0K/LXo7LccpKYNAuIxmlgROgWK28Kcq5ONNLmevxcZVDqnDyLx 5di88kgs8I3XUh9PKlInFUSieYz3qsPHP/iC3FtSAmq1lsEpmG0tccE4s8HJYJ+gu84Xf4R3GIh NU8QvMnC5rlUtgBgc= X-Received: by 2002:a05:6000:438a:b0:43d:c95c:5e75 with SMTP id ffacd0b85a97d-44648f28e79mr12311770f8f.4.1777458812324; Wed, 29 Apr 2026 03:33:32 -0700 (PDT) Received: from localhost ([2620:10d:c092:600::1:ef7e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-447b3d481b2sm5124018f8f.4.2026.04.29.03.33.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2026 03:33:31 -0700 (PDT) Date: Wed, 29 Apr 2026 06:33:26 -0400 From: Johannes Weiner To: Muhammad Usama Anjum Cc: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Zi Yan , Uladzislau Rezki , Nick Terrell , David Sterba , Vishal Moola , linux-mm@kvack.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Ryan.Roberts@arm.com, david.hildenbrand@arm.com Subject: Re: [PATCH v6 0/3] mm: Free contiguous order-0 pages efficiently Message-ID: <20260429103326.GA1743@cmpxchg.org> References: <20260401101634.2868165-1-usama.anjum@arm.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=us-ascii Content-Disposition: inline In-Reply-To: <20260401101634.2868165-1-usama.anjum@arm.com> On Wed, Apr 01, 2026 at 11:16:18AM +0100, Muhammad Usama Anjum wrote: > Hi All, > > A recent change to vmalloc caused some performance benchmark regressions (see > [1]). I'm attempting to fix that (and at the same time significantly improve > beyond the baseline) by freeing a contiguous set of order-0 pages as a batch. I think we should revert the original patch. The premise is that we can save some allocator calls by requesting higher orders and splitting them up into singles. This is a frivolous and short-sighted use of a very coveted and expensive resource. The buddy allocator tries hard to retain contiguity *if it isn't needed by the caller*. This patch actively works around that. The cost of recreating those higher orders elsewhere is shouldered by whoever actually needs the contiguity down the line. And that process is orders of magnitudes more expensive than we save here: We're saving cycles per page in the vmalloc path, and later spend tens of thousands of cycles per page to recreate the contiguity. Scanning PFN ranges, folio locks, rmap walks, TLB flushes, page copies. That's a terrible trade-off.