From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.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 A0E3B18BC3D for ; Tue, 16 Dec 2025 21:19:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765919968; cv=none; b=lHY5IwX6j0sE6fCjOwI0XGBUW2+4NejP9NIUBbBerseejLOQuKjdQxkkDAD8t7DfMDJ3n3ocK2zNkzzPkmS4HhdJZPj92zUErDNTbyE9wvAjxJ2HzfHH9LDAyHmQfgpFjFOMuEZ/uasftkPdZBtZ8hqB84BKSCb8T1WqIonR02E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765919968; c=relaxed/simple; bh=lVP75U66InnkWup/C1250JKh/PJMNx8oFaZLJTc4ps0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=H96AfurdtIUqP2CFqDxZ17qVUcq70ltQ+GYrtx2LspAM8Htbv6KDHFKHH9x2EEwXap5tSl2T+hx4o2+HmJEWMo94Z2JE/+zf+WAeysH7A87+5gwGgq8qogriClRgxCq+wwKjoNKqElwDg1mhDbamPeYuUGkVCud0XAk7Wn9Ntaw= 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=TXTGDuFN; arc=none smtp.client-ip=209.85.208.169 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="TXTGDuFN" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-37a2dced861so44508421fa.1 for ; Tue, 16 Dec 2025 13:19:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765919964; x=1766524764; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=u+8dVyQBwp3ZyKp4kKSktDbrZYNV7A3Vfkv90WVBbxo=; b=TXTGDuFNZtqRWn5GvlhZtIXWSu7/T7WWiHiSyra/wPcgmfBC9itPR19CkewoYIi2ff 8F7dR7WjRYu/1vOJvHpaAV+Lk6XjsaTB9iOhf3LeSj9T3hcxteStYCFEUtB3kFHmaiYY +POKmjeoXSlN7KjYq+HvACu5lhoD/NtuUsZxzu1Urk4hv2qPFUFsgW90yhVKcQHLtBRP 3IFYs4G3UmKT3CtW6VAuSrbcNZ+nP7xrgVpbFoQPiK6hgNoreCMhexV6aug9xOlFU6ER HdH2P/Zx6nzWpNo0vsnRQW6w+lndCj7moQ6JMpeNFN4FbMdZaH7Xp08iFu7UDezuy6ey T8kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765919964; x=1766524764; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=u+8dVyQBwp3ZyKp4kKSktDbrZYNV7A3Vfkv90WVBbxo=; b=SF3zaB8DsBdv6pHdJx8MO58EVxXUXqfavRlCmFLxiq/cjdq9UGKbTxBCbNzwi0rvh1 Vu2nvovvLwzRSdddMBFANfUG+dMXxCDXKwUYyvpDig3gofR8d7EVaRUUAPPgxgTSHScz rlmcKQtyGG+kRW6fkFDAz/2lRwaV3gOfhAl798lNGCe2IqEGp4mu5OnN+7Xwt1xS1QsI lE2elShSIWrU+vpfW0OPX4i8V80C3X6YxCRC3n+6II+pWQMqdSaT2uLY8NrhgpbGbWF7 km9a+4KTTK1FmxLRIw20YU9eCuIuRS1Kt9tlgiMqRj3+ljUUTdIf1N1ahITWLGmWqVyi Dfzw== X-Forwarded-Encrypted: i=1; AJvYcCVootwhAGE9WqfBOldv7p5CA9u13d0+DYsY7qemi75aGO14czuhyZwgffbfhaIm6JDLIgMsn2KIAh4BbeE=@vger.kernel.org X-Gm-Message-State: AOJu0YweUunhT+jpK0AIskVhcIqSSfnIEiIvOm9FxOck8p1QLwPVMMoh 1tbK/BwdJ6+jVE2EVGVo2l72blyGbQ+BGEnNhMEeK6VkRipD127xlNmj X-Gm-Gg: AY/fxX40CCEE4bLco2yv/QarHlSkxTJcOnYotc3TMxQ7w10OmBSjNZ39wJYYPsRXSmY Cd1MvMkrQqYKZFy7qMDK7JoYxFONabYeZqA7xz5taA4v6kYHi44+fNL6fZfnmnATM/DalY2R2yh EZBwO0pcVJ5VJb3+ELR0Eda/0/Syc1PglZbg+45Pi15fWjaBq/csBKqhuCeioZpvT3w8uVTlrcr uUXrMMYfPf+KhrC4OLktcxHgBpV3mExkRWPEpjTjMmNEdfVJLYQrdgvpZy9qSeIf2QHI2nhmDpr uo8pmY2hhZiw6d+2VHH/Pt/ISlCY/APyieUNdGTfoJM26G0A87gFgAoubkvLcrkXQIBGUyLN9YG xomhl7jHhTJQz6YXuNHuQWlyddloe2XLvPKaowHUr8lf/U3UWQkRPbZGjEuvEns02cOikGjRHHH QlF34= X-Google-Smtp-Source: AGHT+IEZ/CxeH4/uXyMJT/As4DsgFewxgY9ubVlm3jlaijdvRnSqayer72IxzctOT0FoALGEDcXwEg== X-Received: by 2002:a05:651c:1502:b0:336:b891:18db with SMTP id 38308e7fff4ca-37fd087a8bamr53294561fa.2.1765919964040; Tue, 16 Dec 2025 13:19:24 -0800 (PST) Received: from localhost.localdomain ([2001:9b1:d5a0:a500::24b]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-37fdee05901sm40926971fa.43.2025.12.16.13.19.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Dec 2025 13:19:23 -0800 (PST) From: "Uladzislau Rezki (Sony)" To: linux-mm@kvack.org, Andrew Morton Cc: Vishal Moola , Ryan Roberts , Dev Jain , Baoquan He , LKML , Uladzislau Rezki Subject: [PATCH 1/2] mm/vmalloc: Add large-order allocation helper Date: Tue, 16 Dec 2025 22:19:20 +0100 Message-ID: <20251216211921.1401147-1-urezki@gmail.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Refactor vm_area_alloc_pages() by moving the high-order allocation code into a separate function, vm_area_alloc_pages_large_order(). No functional changes. Signed-off-by: Uladzislau Rezki (Sony) --- mm/vmalloc.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ecbac900c35f..d3a4725e15ca 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3624,18 +3624,20 @@ static inline gfp_t vmalloc_gfp_adjust(gfp_t flags, const bool large) return flags; } -static inline unsigned int -vm_area_alloc_pages(gfp_t gfp, int nid, - unsigned int order, unsigned int nr_pages, struct page **pages) +static unsigned int +vm_area_alloc_pages_large_order(gfp_t gfp, int nid, unsigned int order, + unsigned int nr_pages, struct page **pages) { unsigned int nr_allocated = 0; unsigned int nr_remaining = nr_pages; unsigned int max_attempt_order = MAX_PAGE_ORDER; struct page *page; + unsigned int large_order; + gfp_t large_gfp; int i; - unsigned int large_order = ilog2(nr_remaining); - gfp_t large_gfp = vmalloc_gfp_adjust(gfp, large_order) & ~__GFP_DIRECT_RECLAIM; + large_order = ilog2(nr_remaining); + large_gfp = vmalloc_gfp_adjust(gfp, large_order) & ~__GFP_DIRECT_RECLAIM; large_order = min(max_attempt_order, large_order); /* @@ -3666,6 +3668,20 @@ vm_area_alloc_pages(gfp_t gfp, int nid, large_order = min(max_attempt_order, large_order); } + return nr_allocated; +} + +static inline unsigned int +vm_area_alloc_pages(gfp_t gfp, int nid, + unsigned int order, unsigned int nr_pages, struct page **pages) +{ + unsigned int nr_allocated = 0; + struct page *page; + int i; + + nr_allocated = vm_area_alloc_pages_large_order(gfp, nid, + order, nr_pages, pages); + /* * For order-0 pages we make use of bulk allocator, if * the page array is partly or not at all populated due -- 2.47.3