From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EAC93606A327 for ; Tue, 1 Dec 2026 14:38:49 +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 kanga.kvack.org (Postfix) id 11E936B05B3; Tue, 1 Dec 2026 09:38:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0CF336B05B4; Tue, 1 Dec 2026 09:38:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED9A36B05E0; Tue, 1 Dec 2026 09:38:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CA4636B05B3 for ; Tue, 1 Dec 2026 09:38:48 -0500 (EST) Received: from smtpin03.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C2F33140ECE for ; Tue, 1 Dec 2026 14:38:47 +0000 (UTC) X-FDA: 85495670694.03.A3AD4F2 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf19.hostedemail.com (Postfix) with ESMTP id 10B0F1A000B for ; Tue, 1 Dec 2026 14:38:45 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=JNEJ0xFl; spf=pass (imf19.hostedemail.com: domain of aneesh.kumar@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=aneesh.kumar@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796135926; b=FviaEIeD+OV4vszrPqI4IEXOIebhNSlrqG++erwzv4F1W/51LJ08ULs3mXT8wDA9JBpH75 W7bncj9XayPuf0TSEPnyFmLheyvgQd9KjJGj3YvNi66QORvNyLm/UhyH2HC4UZmJ75NmOS EYIGSPyalpgvsiQ2Sw2zS/bGh9EwDt8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796135926; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=N6FBsZPF8qG81vsCbEQnuIqgUxLgr4Urw/u58RJSqeI=; b=sabCx8mClb+fc4y8GqEA/lSxDZt8+B+ljj6oYT//PoyLZzUyWvSmaApGHI85jIQ56BmX9c 9bqUZOoZNfuMkkDqL/GWJIhL8MZqZqHU5UVmrJQdea/r0dd5o3uzvcxLsyvKdkL7A2mjAH zPbbs0fyL/VSQ9xofFF20UlNNeaUfNE= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=JNEJ0xFl; spf=pass (imf19.hostedemail.com: domain of aneesh.kumar@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=aneesh.kumar@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org 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-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 10B0F1A000B 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_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Stat-Signature: jxr17g8tk8cd33fsc6zbzezfmiba7cjs X-HE-Tag: 1796135925-326310 X-HE-Meta: U2FsdGVkX1+D+GnCRpBWyrdYMYmq0GHczX1xR/dQsFLYyxjdOg4YKyPQNjeVVYmC9RN75ktlQGI2t7LEd74t9N+ZOgvyrwFiU1zX1aRUv4dtLA0NU9Di7tkMxLw6AIO7Mgs2kzDIHbM5iET3ASnTWLCPVsl0JUnHt4NmlHma/1ZwT+s35D4hUIIvQmFuKzAHCyxFQ4MZNGORzb5FoxFKaYdh9cgyqAuj+62r9xZ8B89uEuBsHUf48A64ETcYTA9fv6QHYOrElNuEdqEslIlss0U+mPLl9Qjj0EgSYyrpBNepGxX/bZT//pnmRVB2oyKiO6yH4NRHcV00jPF3KgjyIcUnf8qQRpehv6xBw4Osv6dm2DVjy5Nc4vx3KwQHWknTHr72IwpGmQH87+zcoKjwWjkYyC4wBwtVH73Tyko9cuSvL/wcj1ZeRmfRhu00N3lagU1vGNyA0PW51+sb5MOlMTizdSQYV29TZXmb12HbqA6xZZ2lqcTOXrLPKFFTz8GGMYPeWdHPelxl1v1A9ee3L05bStbfNzSpHaZwt6S4FU0vNMhNQfjSmRdeWkRHEX0/5kW8cEz5CeQ4R0ygk2XyH+eaiX3Y7Bv4bsqDILax4mx4HEr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Subscribe: 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