From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796135925; b=BIni1majOeydLhuLOwlcDkv8KMKI1TVuh6EaSDiC8Jnh8715JDZHhApHVtfCQq6AgTRM WqqBRjYpVccW6CgEoUm/47CiAsfNgOVGP8ridcCZOZaPoFPkyBJtoOAmTFk2L1VY4RGiI p9UQVtRUL0OyjWU8QCUOPqeU4DM4yhQDe8DJxqGqVlBYcZebgkX4O3DVBefdUP+eaKLFr 7OFsY+COD1xnjL1gbEJGTGDTs2nTq5d3pEI7oVN2mxjkEhNGqq6eFhm0dh+89vJdA+9cW v6dVXjtBsnjoN0pkDBUKVsWy7H0gVGO6wMsJGxMtWy15CTiBatx7czloa+pbJ00yvMw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796135925; h=Received:DKIM-Signature:X-Mailer:From:To:Cc:Subject:In-Reply-To: References:Date:Message-ID:MIME-Version:Content-Type; bh=N6FBsZPF8qG81vsCbEQnuIqgUxLgr4Urw/u58RJSqeI=; b=X6SOyW0RmIhPWGzkglRdXlUF1nRqoDPGvDiUlVEboAaHf4u2Tqfjnhow5wW7nuPPtCe5 TACtqSvRW2hbXDAS39mw0pgcfMCHJnbn2Jxi3gJ4QOOhOvtsBGdmRBsiKx/8FPVq4JNMJ 8nNSIwPTnjNodcZHGsGIMaKngA3DkqsoZ9ISMN69LH2MsnXKbmgw3mewPA+44aEAEYMQa MH6VfL3o+/t2H67+XG2KY4ZaEW831yTPlzRrp1O3J8pMXD2AUsPiZFUK7Y05v+f/5BOOM 8is1ZeF7MZRop6ouqYfOR02JebbFNFqWeijlC0a1Cr+6Crs9HvpKFkbYPelFj1plQQA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JNEJ0xFl; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37859606A31A; Tue, 1 Dec 2026 14:38:45 +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: 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-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain 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