From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1BC3606A329 for ; Tue, 1 Dec 2026 14:38:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JNEJ0xFl Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F3D510E4E5; Tue, 1 Dec 2026 14:38:52 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6533910E010 for ; Tue, 1 Dec 2026 14:38:45 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 268C2418BC; Tue, 1 Dec 2026 14:38:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6731E1F00926; Tue, 1 Dec 2026 14:38:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796135924; bh=N6FBsZPF8qG81vsCbEQnuIqgUxLgr4Urw/u58RJSqeI=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=JNEJ0xFl3uW+jiXvVSXhv7NQJWuWZiW2rckcU7WhW3ImICaVN+IvHS6TCJzSHq8yO h5ILqmUERdUYP7vhhN2itxROWYxsO1+QD4gq2QLaoy2gcFisQRqOuBN8uvjO+8yxBo GH59rBzqrAPi4KqkHmazajbIJ0sQLxCMQ7D3oODrQ31lHqzFqzsiJGa+bcuc7Xzhb9 g1+nLqQlGqV38itBIemPyO0DJzMto2He0CUwOahripq087Cg6KhiFd9nZr3kkH2dtZ P+HU8PnVCzQQRuVfldThacoTp8xFY6ZNtyAxfZKLfMtv9nj45TiNKXneDctfP/+lE0 rOpXpvKxlln8A== X-Mailer: emacs 31.1 (via feedmail 11-beta-1 I) From: Aneesh Kumar K.V To: Jason Gunthorpe Cc: Catalin Marinas , linux-coco@lists.linux.dev, Andrew Morton , Baoquan He , Mike Rapoport , Pasha Tatashin , Pratyush Yadav , Christian K?nig , Joerg Roedel , Marc Zyngier , Marek Szyprowski , Robin Murphy , Steven Price , Sumit Semwal , Suzuki K Poulose , Thomas Gleixner , Will Deacon , Russell King , Benjamin Gaignard , Brian Starkey , John Stultz , Mark Rutland , Radu Rendec , "T.J. Mercier" , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Ritesh Harjani , Shrikanth Hegde , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , Kiryl Shutsemau , Rick Edgecombe , "K . Y . Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Paolo Bonzini , Vitaly Kuznetsov , Andy Lutomirski , Peter Zijlstra , dri-devel@lists.freedesktop.org, iommu@lists.linux.dev, linaro-mm-sig@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-mm@kvack.org, kvmarm@lists.linux.dev, patches@lists.linux.dev Subject: Re: [PATCH v10 04/13] irqchip/gic-v3-its: Allocate shared tables using CoCo shared memory allocator In-Reply-To: <20261201132156.GC1856591@ziepe.ca> References: <20261116091137.94252-1-aneesh.kumar@kernel.org> <20261116091137.94252-5-aneesh.kumar@kernel.org> <20261124134621.GI9566@ziepe.ca> <20261201132156.GC1856591@ziepe.ca> Date: Tue, 01 Dec 2026 20:08:21 +0530 Message-ID: X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "dri-devel" X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Jason Gunthorpe writes: > On Sat, Nov 28, 2026 at 10:09:33PM +0530, Aneesh Kumar K.V wrote: >> Catalin Marinas writes: >> >> > On Tue, Nov 24, 2026 at 09:46:21AM -0400, Jason Gunthorpe wrote: >> >> On Tue, Nov 24, 2026 at 07:00:00PM +0530, Aneesh Kumar K.V wrote: >> >> >> >> > Taking Jason's feedback into account, we could have the allocator >> >> > request compound pages and recover the actual allocation order with >> >> > compound_order(). That would avoid passing an order to free: >> >> > >> >> > void *alloc_cc_shared_node(int nid, gfp_t gfp, unsigned int order); >> >> > void *alloc_cc_shared(gfp_t gfp, unsigned int order); >> >> > void free_cc_shared(void *addr); >> >> >> >> It probably shouldn't be order here, that is hard to use. Just size_t >> >> len >> >> >> >> And round up internally >> > >> > Minor point in favour of keeping the '_pages' naming and order is that >> > it makes it more obvious what alignment is returned for code that needs >> > it like the ITS. Otherwise we can just document it, I don't have a >> > strong opinion either way (only that it's simpler than what was proposed >> > earlier). >> > >> >> Thanks. I'll keep the byte-based interface for now and document the >> returned alignment: >> >> void *alloc_cc_shared_node(int nid, gfp_t gfp, size_t len); >> void *alloc_cc_shared(gfp_t gfp, size_t len); >> void free_cc_shared(void *addr); >> >> This leaves room for a kmalloc-style shared buffer cache in the future, >> where allocations could come from already-shared backing memory. Callers >> would request a byte count without needing to know the underlying >> allocation order. >> >> For now, the implementation will round up the size internally, allocate >> compound pages, and share the entire allocation. Will add this to the >> kernel doc? >> >> * Allocate a physically contiguous block of at least @len bytes, rounded >> * up to the sharing granule and then to a power-of-two number of pages. >> * The physical base address is aligned to the full allocation size. >> * The entire allocation is shared and zeroed. > > It is "power-of-two sharing granule" right? > > And when doing the ITS conversions you'll need to min() to the > required alignments that Mark explained. > Yes, the allocation size is a power-of-two multiple of the sharing granule, since the sharing granule is itself a power-of-two multiple of PAGE_SIZE. However, is that the clearest way to document it? The code does: cc_shared_round_size(len, &size); order = get_order(size); page = alloc_pages(gfp, order); Would it be clearer to describe the returned alignment in terms of PAGE_SIZE and the resulting order? The ITS code already sizes its requests assuming that the allocator returns memory aligned to the allocation size. Since the new allocator preserves that guarantee, I thought those requests would continue to meet the ITS alignment requirements. -aneesh