From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 63DF5302149 for ; Mon, 1 Dec 2025 11:08:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764587310; cv=none; b=hoP79ACTj4wmRrV+5eAKEWZXD3Nx/cyBKiw4jLgbbiKUdHWVMwS+cJCp7jaoS/t20sI/8oMSiXxpyCcsnqj8UNzHRjRFGbwcRlTQXGihn5lCM/+cW1ZOIc/GKFGMGijXO7b6DFYuNvXgcqePrKNVIo/LZ4i5cofBkyvJfA0mAMI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764587310; c=relaxed/simple; bh=hdIAAEJwogwmZ9Pz1q+1QustFFAcLoa+OS+FSTnlAZ4=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=knIbSapcfw/i6+5dVeSG/VrvkR215KllWtB7TSlGy4WxNXvjFvreu1YnSh6+xRarFmrGpKD79YPyZsHMaWXzg1foNgdabToNdhfxSrn/a9e+NxNHQeD55vwom59crMcSuccn7zlL6VtffuVwJ3LjeWbNX+F/HiM6LCnTGXJwO9g= 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=LZLOia1r; arc=none smtp.client-ip=209.85.208.172 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="LZLOia1r" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-37a415a22ecso37739921fa.0 for ; Mon, 01 Dec 2025 03:08:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764587306; x=1765192106; 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=apPnjqLgYv5KFdQVAUozAIQDApH/iP9GbYj6xjZKpNk=; b=LZLOia1r0TdUPFB4dHVVkOlDMIBtzU0AknzbBoNKZFIDs+dgidrg5QdHMzpwZeYCKr K3JFI5fBRy6qkdKdjVrPDqSs2A8cpMMSXR88DBQJNvye3urmDh+/YG5KCu+J1NhsZMcF hnOQUrLJK4v7azoe2Jsv30yTkae9iaM7CEWChJj1G3jsOh8ZWeIO2aw50OqLO4PvxaoR ZUdwWNyrNkkks9Xm/kYThZAid0l2DRc7pnfipHKKJIgRfRuKjUtJnQnDyCCZ9m7quPVP 33XLQx8Ly5L5B+kl8tmAxNtogr+mb1eC4TQLU9kFFnmtYdWp3mzoSNy9JNCilrz1HpW/ laoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764587306; x=1765192106; 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=apPnjqLgYv5KFdQVAUozAIQDApH/iP9GbYj6xjZKpNk=; b=fb8dGUI14dOpp0zWj194QyOqBvrHSOWzW69TnGOK/FJ4d7EDwJmwuLtdAZC1FOCyKx omyS3s/XU6AI6x/f6Hj8Lg/hcag8ChaO2zpAUlMluZc/r/xHr2ZRupyCEhOen9I6vlic 45UWfVFTsofqj/Zd5cl1ZN+7b4lbbYAqBRydyvLvIkNa0lb71ZauI9kgrzm1l74aS2DN X/3zEd9LHwEfv8TFjC8VDkEhcpYOMiQlLZzzhm/dofojmtJLP8lZw/c2T/A869OF3n7e Sur4Nx1w5yfIbCzbzIy05T5G8xna98Gi+KE1b1HBKHsFbyP7ZvYDej2ZTvh7LgL77vRx k+3A== X-Forwarded-Encrypted: i=1; AJvYcCUrgcQaBs1QtLLUWkU899gPqqZJxo3hhJ5S7a2/+QYd+H7Dh6PA/bRstSoWoEfwWduVFweEE3peyWca4PM=@vger.kernel.org X-Gm-Message-State: AOJu0YwNtS2Hujh76CKOjM4DiIrAEhftuaPO9J+yo5BagBiOETm5cTyM kf35Wop8zGu4/PQuD91TmzNpl1lOyeGuA3RDgHdXtDqgoVmKBZV02Yxh X-Gm-Gg: ASbGncvrJDsBT/iax99kAVVnF4AHCvuafKYLuBTigV2mU1e1w5KxX8InZDe7qpb4brD BslZ9P5MHWF78dkQCX+VVO52KcHKZKl0Hth3Z7Wgnb3Db5IBK9IcecIu5YApfbZDStuUhc4j1OM 2HLg7XlHgxB/cRawgc9PY0RPpw1Xm5EFf30CuSkXRPa/2XA8QoAJocbLsBP1O9/QfYvfa60cweD q9WezRJbwR8PmYesy5MvqrqxFRSSv35ioFVJySwKbS641grcFz0dn095VZjnUEZp1hAjvdPYyxV q6CaCpG+DlwoiMmHZWDxRICumcq/7FqGZHOopWzaC3FjGOGskbzk0XcT5ll26SD8lzdNUmsz8t1 4ygt4+8Y1ndIVgWy5SiwxmHsqNqulSsIvFa8EFFUfg3reaK10b6N9JQ== X-Google-Smtp-Source: AGHT+IFYuTqVq/XXzpVDPZNlji0QpaJTMsgY/VJiO3ObVzX6tMfBu+vPiuyhJLxl2QXQDIY11tZWpg== X-Received: by 2002:a2e:bc26:0:b0:376:41f5:a6ca with SMTP id 38308e7fff4ca-37cc8213bf3mr101258641fa.0.1764587306127; Mon, 01 Dec 2025 03:08:26 -0800 (PST) Received: from milan ([2001:9b1:d5a0:a500::24b]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-37d240981cbsm27895361fa.24.2025.12.01.03.08.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Dec 2025 03:08:25 -0800 (PST) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Mon, 1 Dec 2025 12:08:23 +0100 To: Barry Song <21cnbao@gmail.com> Cc: Uladzislau Rezki , akpm@linux-foundation.org, linux-mm@kvack.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, Barry Song , Sumit Semwal , John Stultz , Maxime Ripard Subject: Re: [PATCH RFC] mm/vmap: map contiguous pages in batches whenever possible Message-ID: References: <20251122090343.81243-1-21cnbao@gmail.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: On Fri, Nov 28, 2025 at 04:43:54AM +0800, Barry Song wrote: > > > > > > + /* > > > + * Some users may allocate pages from high-order down to order 0. > > > + * We roughly check if the first page is a compound page. If so, > > > + * there is a chance to batch multiple pages together. > > > + */ > > > if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMALLOC) || > > > - page_shift == PAGE_SHIFT) > > > + (page_shift == PAGE_SHIFT && !PageCompound(pages[0]))) > > > > > Do we support __GFP_COMP as vmalloc/vmap flag? As i see from latest: > > This is not the case for vmalloc, but applies to dma-bufs that are allocated > using alloc_pages() with GFP_COMP. > > #define LOW_ORDER_GFP (GFP_HIGHUSER | __GFP_ZERO) > #define HIGH_ORDER_GFP (((GFP_HIGHUSER | __GFP_ZERO | __GFP_NOWARN \ > | __GFP_NORETRY) & ~__GFP_RECLAIM) \ > | __GFP_COMP) > > > > > /* > > * See __vmalloc_node_range() for a clear list of supported vmalloc flags. > > * This gfp lists all flags currently passed through vmalloc. Currently, > > * __GFP_ZERO is used by BPF and __GFP_NORETRY is used by percpu. Both drm > > * and BPF also use GFP_USER. Additionally, various users pass > > * GFP_KERNEL_ACCOUNT. Xfs uses __GFP_NOLOCKDEP. > > */ > > #define GFP_VMALLOC_SUPPORTED (GFP_KERNEL | GFP_ATOMIC | GFP_NOWAIT |\ > > __GFP_NOFAIL | __GFP_ZERO | __GFP_NORETRY |\ > > GFP_NOFS | GFP_NOIO | GFP_KERNEL_ACCOUNT |\ > > GFP_USER | __GFP_NOLOCKDEP) > > > > Could you please clarify when PageCompound(pages[0]) returns true? > > > > In this case, dma-buf attempts to allocate as many compound high-order pages > as possible, falling back to 0-order allocations if necessary. > OK, it is folio who uses it. > Then, dma_buf_vmap() is called by the GPU drivers: > > 1 404 drivers/accel/amdxdna/amdxdna_gem.c <> > dma_buf_vmap(abo->dma_buf, map); > 2 1568 drivers/dma-buf/dma-buf.c <> > ret = dma_buf_vmap(dmabuf, map); > 3 354 drivers/gpu/drm/drm_gem_shmem_helper.c > <> > ret = dma_buf_vmap(obj->import_attach->dmabuf, map); > 4 85 drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c > <> > ret = dma_buf_vmap(etnaviv_obj->base.import_attach->dmabuf, &map); > 5 433 drivers/gpu/drm/vmwgfx/vmwgfx_blit.c <> > ret = dma_buf_vmap(bo->tbo.base.dma_buf, map); > 6 88 drivers/gpu/drm/vmwgfx/vmwgfx_gem.c <> > ret = dma_buf_vmap(obj->import_attach->dmabuf, map); > Thank you for clarification. That would be good to reflect it in the commit message. Also, please note that: > if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMALLOC) || > - page_shift == PAGE_SHIFT) > + (page_shift == PAGE_SHIFT && !PageCompound(pages[0]))) > we rely on page_shift == PAGE_SHIFT condition for the non-sleep vmalloc() allocations(GFP_ATOMIC, GFP_NOWAIT), so we go via vmap_small_pages_range_noflush() path. Your patch adds !PageCompound(pages[0]) also. It is not a problem since it is vmap() path but we need to comment that. -- Uladzislau Rezki