From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28ED4C54EBE for ; Tue, 10 Jan 2023 08:22:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230119AbjAJIVz (ORCPT ); Tue, 10 Jan 2023 03:21:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbjAJIVx (ORCPT ); Tue, 10 Jan 2023 03:21:53 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EA6B11A22 for ; Tue, 10 Jan 2023 00:21:51 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 034D461511 for ; Tue, 10 Jan 2023 08:21:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 420C0C433D2; Tue, 10 Jan 2023 08:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673338910; bh=vbqWNUveq6DaJ6LQ1YU6cnSkGkBsp8r/3HKPlPuYGuM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=pmlOIOZ702LLEg51BS9tYjXySdTjKPOi90FXlkCS9lxwkOeT0gvutDcscfLkSeagI 7DFcuFKcD4+NvdLu7A76ktIKyabfdV5L/SEQhwHOX0ujTH/yfKvrGaOMfloJnlC4Pa D70oqqFM6Pto3+OecsWAB2735s8FqU1dAP2PZWKtoURReUhxE+JgqE5GV+CW2Ai+4r t472xdHh635onVrIjtZ4YNUm2AFiTV1mizxptbEr1EO/wDT8eFb8rvF3K9qi3xKbIP jM+JlImNoCmiZInuthr/Q/S78hVg4kHOfc8lnCS6KjW38P+VyMDhaeqHYbFG51Proz UJQF/GFRixtxg== Received: from ip-185-104-136-29.ptr.icomera.net ([185.104.136.29] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pF9tD-000W4f-Q4; Tue, 10 Jan 2023 08:21:47 +0000 Date: Tue, 10 Jan 2023 08:20:38 +0000 Message-ID: <87pmbmer6x.wl-maz@kernel.org> From: Marc Zyngier To: Shanker Donthineni Cc: Catalin Marinas , Will Deacon , James Morse , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] arm64: gic: increase the number of IRQ descriptors In-Reply-To: References: <20230104023738.1258925-1-sdonthineni@nvidia.com> <86sfgq7jb3.wl-maz@kernel.org> <2a0116a8-fbd0-d866-ada0-ed50f0523f1d@nvidia.com> <86k0216ydh.wl-maz@kernel.org> <4cc4114d-7fa5-1c23-3504-0ca4dbdd0f62@nvidia.com> <86fscjoe3i.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.104.136.29 X-SA-Exim-Rcpt-To: sdonthineni@nvidia.com, catalin.marinas@arm.com, will@kernel.org, james.morse@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 09 Jan 2023 17:13:25 +0000, Shanker Donthineni wrote: > > >>> I'm happy to help with it, but I'm certainly not willing to accept any > >>> sort of new compile-time limit. > >> > >> Thanks for helping with a scalable solution instead of static > >> allocation. Please include me whenever patches posted to LKML. I'm > >> happy to verify on NVIDIA server platforms and provide test > >> feedback. > >> > > > > I offered to help you. I didn't offer to do the work for you! ;-) > > > > I've looked at the IDR/IDA API. There is no suitable function for > allocating contiguous IDs to replace bitmap API. > > __irq_alloc_descs(): > > mutex_lock(&sparse_irq_lock); > > start = bitmap_find_next_zero_area(allocated_irqs, IRQ_BITMAP_BITS, > from, cnt, 0); > ret = -EEXIST; > > Is there any existing API that I can use for allocating contiguous IDs? I think you should address the problem the other way around, as there are lower hanging fruits: - turn the irq_desc_tree radix tree into a XArray - use the XArray mark feature to reimplement the irqs_resend bitmap Once you have done that, you have already halved the memory usage. To implement the allocated_irqs bitmap functionality, you have a bunch of options: - make the XArray an allocating XArray, and iterate over XA_FREE_MARK to find the free range (see how the infiniband subsystem is doing exactly that) - use another Xarray mark to annotate the allocated IRQs, find the distance between two allocations, and use this range if the request fits (a poor man's variation of the above) - use a sideband data structure such as the GICv3 LPI allocator, which is already dealing with range allocation (I'd rather avoid that) - something else? It should be fairly straightforward to perform the conversion in place. Thanks, M. -- Without deviation from the norm, progress is not possible.