From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 294A71CBEB9 for ; Tue, 24 Feb 2026 18:03:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771956218; cv=none; b=gmusULg2lKYSLD19fngQtyG+vdtmKAHJIstXBfO6XHJ30uO+AqdnoyzIpF/+XZ0kgK25RdUulvkLPP73Xb0W3Yxz7rS1DcXYomrju0lOQT7/G8NivL9v/pvCqsvd2X9FtaVvSvOoD8KeBdWioqM4qP80jUsJPB9TkTSkT2ALdL4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771956218; c=relaxed/simple; bh=jf5IZQq3cAlA1i+ZX03AhkGPmE/XhSdStfkzshA61pY=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=L+UlzlyOdlNhxgXGqAykSvL7SyP8wAKJBqFY/r1JsG0E0EGvgbMLWIpkC+70gwCHjSB4wpiNo98vt4N4SKLqcII4F8f26mEG9djV/TflYT5xTx9PfaRdC8rD5G5elY+rnwwJsEOXUHsd2W5DjRrZsqBpUDsTNcdI4Fh3ySpbeA4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bDRze4GL; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bDRze4GL" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-5a0ff30b240so43364e87.0 for ; Tue, 24 Feb 2026 10:03:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771956215; x=1772561015; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=O4oIsYGmK/xdzzCq4Y4y/7a2RiK61m8snUa5jjavVTo=; b=bDRze4GLD4jgA4AOyNX5b9kR+HYueAf2E6e3dEwPU/NpOfZfAsm1YhUxtVT3BvYLXl 1GbuBt9W4fYXwlwF4TviF5NWERQMry1Xt75IsIHcXNvWv6XmOiDb1TFrn3sUWcISobTu 6ARpULk+TRxytgL04rLR052Ct3q42ufTnJjINgr1L2Vgs/YhaaRbxqSEYZta/pJaBlOp xFuoWzQJXf6U2W/9+5evpde4Ypz6M8djX5c6iJXS+n5JGoj+RWz8Bs07kPTDnBRMCy1D WHicFqpUXfUvfKBkGueWmuJB4/83D/iKAaZ7/HdEM2kVq16VbRFyWNHt7hFAFoIzyFMs V/jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771956215; x=1772561015; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O4oIsYGmK/xdzzCq4Y4y/7a2RiK61m8snUa5jjavVTo=; b=AIPqQ1BBdthZATQMPXx+vzETwRXXcUzEMJPAYjSkg/wSNLkX8/PWtmM/UGXU5NlzEq Dm00tHT5BeLA9FF5KndS15L1SIrZItScmzN7Fvfrufiosue5vh79NyRoMdit2m97uIhx ZJQl0pQO83iuNe5y/jt8GCv0O0f0eNIHZFwUEdyu7oWqV3SQJnkaRMLlALeHixyCHn+c YlpNRrNFp9xwDZ6LfWQRidRDErN0Mai2xToFSr5LpTPqR+FnGZ2eTBIEVwm0Nzj5f5mA mVWBJNTmxK3x4DnHx2eJcEzJkBQ/fdYv/3lbqHe00IrhJK6DIBwaNDVb0PxSMzUsVEX0 JW1w== X-Forwarded-Encrypted: i=1; AJvYcCVbr10MKe+i8pBfQkgxZi3mfjVOsPwSDRrmkc2/HqcsZYlatM2FIyE7TQuKTKS7YRE2+4yeEqE0ncZ8xtc=@vger.kernel.org X-Gm-Message-State: AOJu0Yzp45gM0xNF36VUSOGSTMl+/WKNYZuZSOZ/Ddh+E/v9HYMR8hAA LX0mjCyCfmjUCbeRUD2FVI+MsYV/86E202HruEk95sNojOZpu8QPemfl X-Gm-Gg: ATEYQzyH4Tw7p4aGh2rC+kIzoyTsspGECFB973/t7vyrtibKJYHxwKQLriVx6FqRAp9 bDcuL/MY1uavy/Q3ZEU0WK2NCcvuKBYR/xCmeVfUaysCg+RenSOG4BzY4VWbOpB22DY+Op8HdUy 3D+wZglyz9t4eSfo/BKZtes56lFzU6g2O1LwpamhGXGKfL4DbWMt8oy5MrNUVJNx7jmmHLvFZWG qojipvYNCYKrNxInqbJOsw0gwGxGlObyfYojYoO+MnbgrusT13vwShF2Mfw4Kuw6vMqFBAlWUM/ ZmnUfs1WLPjMFiMl2JzzIAuCOw0ocDdpyFdFxeyYg73pyziiSytfWzXEl+Ael3LPVQUiEbM3y9E uCB8yP8FdSrbeVjnY0w7DjcEZpah3jJoZwKxZtk76HHQdm9cd9y8L6SKGInMf6GRu5SEz4cyt6J 1V4eXPgXAnNDJ9/FrMmW8CbNRYkMEYEPAbUmQh0icQxPfXbSLuFXzj X-Received: by 2002:a05:6512:4016:b0:59d:f71b:3608 with SMTP id 2adb3069b0e04-5a0ed99bdc8mr3767938e87.31.1771956215059; Tue, 24 Feb 2026 10:03:35 -0800 (PST) Received: from pc636 (host-90-233-215-147.mobileonline.telia.com. [90.233.215.147]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a0eeb0b8b0sm2329602e87.15.2026.02.24.10.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Feb 2026 10:03:34 -0800 (PST) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Tue, 24 Feb 2026 19:03:32 +0100 To: Johannes Weiner Cc: Uladzislau Rezki , Andrew Morton , Joshua Hahn , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] mm: vmalloc: streamline vmalloc memory accounting Message-ID: References: <20260220191035.3703800-1-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 Mon, Feb 23, 2026 at 03:19:20PM -0500, Johannes Weiner wrote: > On Mon, Feb 23, 2026 at 04:30:32PM +0100, Uladzislau Rezki wrote: > > On Fri, Feb 20, 2026 at 02:10:34PM -0500, Johannes Weiner wrote: > > > @@ -3655,6 +3649,8 @@ vm_area_alloc_pages(gfp_t gfp, int nid, > > > continue; > > > } > > > > > > + mod_node_page_state(page, NR_VMALLOC, 1 << large_order); > > > + > > > split_page(page, large_order); > > > for (i = 0; i < (1U << large_order); i++) > > > pages[nr_allocated + i] = page + i; > > > @@ -3675,6 +3671,7 @@ vm_area_alloc_pages(gfp_t gfp, int nid, > > > if (!order) { > > > while (nr_allocated < nr_pages) { > > > unsigned int nr, nr_pages_request; > > > + int i; > > > > > > /* > > > * A maximum allowed request is hard-coded and is 100 > > > @@ -3698,6 +3695,9 @@ vm_area_alloc_pages(gfp_t gfp, int nid, > > > nr_pages_request, > > > pages + nr_allocated); > > > > > > + for (i = nr_allocated; i < nr_allocated + nr; i++) > > > + inc_node_page_state(pages[i], NR_VMALLOC); > > > + > > > nr_allocated += nr; > > > > > > /* > > > @@ -3722,6 +3722,8 @@ vm_area_alloc_pages(gfp_t gfp, int nid, > > > if (unlikely(!page)) > > > break; > > > > > > + mod_node_page_state(page, NR_VMALLOC, 1 << order); > > > + > > > /* > > Can we move *_node_page_stat() to the end of the vm_area_alloc_pages()? > > > > Or mod_node_page_state in first place should be invoked on high-order > > page before split(to avoid of looping over small pages afterword)? > > > > I mean it would be good to place to the one solid place. If it is possible > > of course. > > Note that the top one in the fast path IS called before the > split. We're accounting in the same step size as the page allocator > can give us. > > In the fallback paths (bulk allocator, and one-by-one loop), the issue > is that the individual pages could be coming from different nodes, so > they need to bump different counters. One possible solution would be > to remember the last node and accumulate until it differs, then flush: > > fallback_loop() { > page = alloc_pages(); > nid = page_to_nid(page); > if (nid != last_nid) { > if (node_count) { > mod_node_page_state(...); > node_count = 0; > } > last_nid = nid; > } > } > > if (node_count) > mod_node_page_state(...); > > But it IS the slow path, and these are fairly cheap per-cpu > counters. Especially compared to the cost of calling into the > allocator. So I'm not sure it's worth it... What do you think? > I see. I agree it is easier to keep original solution. I see that Andrew took it, but just in case: Reviewed-by: Uladzislau Rezki (Sony) -- Uladzislau Rezki