From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796210713; b=uhsLWULELZWOFIF4kMFtFQ8c8PUOOAlzjFdHsLwn8mSDR5pe5GuZJYOL6B1GxDidqnPO u+O6Mrqk7Z5ATMMDXg1bUzZr6IINKxD6zr45raHAuBYlz+UXMjzy7btTx5bzxwkQ26jAw kP6H61fFIH2ZCvfCa1r+TljoYB7AYXQMRVWVKvz5dWyxuC5yd7pEAXvqY/Sr2qHyBNc4V cNasrBacwWyGZBTnX6B9rFpaNRIlPwCLtjyml2TxPJa2Texkg/9fy4O8CXUnLYJZebsOE hgka2Dj6YlfPZzKCrSBKL4i9uQG+aFii4jmF90p9f8ajhHHeYMOrKDb7ZarlPrWGMiQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796210713; h=DMARC-Filter:Received:Received:DKIM-Signature:Message-ID:Date: MIME-Version:User-Agent:Subject:From:Cc:References:Content-Language: In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=LWfntKuTliV0e7uluudZ5lZChDu/yx97YspOgfCzabk=; b=zclPuaosB4g54SMubpwYD2wNoRTyHfbldqENOXvfd88Kfb4a7W4lzAxMkvYKM7d4ifgl 4DMCod1u1O9KhO9EPELcjn3SVH+6jalF+JBLCKx/Z+T9SLVuPp5iwvGmta+pCZyElzbMV GLBv43OcrOdAtuE5OvQBSZGze3DHdXx8AV0mQygal0+Mm9uadbEtTwhf9MnTrn61guWV7 dPgOv9yeIqA8xoAPkVI41xO+iDBYLVHB3a2j/Flz/s9iTn90di6A3sqR/Yo4XTB2Gp1CX TKrUud1LFBN0+Wh5g5pnrIVYbKecOODLFrkS7h04XYZz8dQ2DQxzIvhqWS1OdqRnMIw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=GP9vOk9B; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 26BA4606A32F for ; Wed, 2 Dec 2026 11:25:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 26BA4606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=GP9vOk9B Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7C72A1570; Wed, 2 Dec 2026 03:25:09 -0800 (PST) Received: from [10.211.55.3] (unknown [10.57.91.208]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B69473F7D8; Wed, 2 Dec 2026 03:25:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796210712; bh=570qsZM9STxunOazuEVh0QxT227hq1A6FcXKEmDf2Fg=; h=Date:Subject:From:Cc:References:In-Reply-To:From; b=GP9vOk9BBUMYlJMM97WLL22CbyCqA5aB5b3ANSepuIaRCcBZjaiwCVl8B+17xSP5N t+JgSxc96erwDrmSFIn5Awfs0FOoeDgOsDoJmcvc6wCB1pNb30DV6MuH7AdSAhE6s8 +JA1PJmWccCDn1GhQVaBCn5sz11r2N71T9Dj0gWI= Message-ID: <146269e3-c4ce-4fa1-bedc-79bfc5dddd8e@arm.com> Date: Wed, 2 Dec 2026 11:25:09 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Thunderbird Daily Subject: Re: [PATCH v3 3/3] fs/resctrl: Allocate rdt_l3_mon_domain::rmid_busy_llc using kvzalloc_objs() From: Ben Horgan Cc: tony.luck@intel.com, reinette.chatre@intel.com, x86@kernel.org, Dave.Martin@arm.com, james.morse@arm.com, babu.moger@amd.com, fenghuay@nvidia.com, bp@alien8.de, linux-kernel@vger.kernel.org References: <20261125164753.3759904-1-ben.horgan@arm.com> <20261125164753.3759904-4-ben.horgan@arm.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 02/12/2026 09:59, Ben Horgan wrote: > Replying to myself... > > On 25/11/2026 16:47, Ben Horgan wrote: >> The bitmap rdt_l3_mon_domain::rmid_busy_llc has >> resctrl_arch_system_num_rmid_idx() entries. On an MPAM system this is the >> number of PARTIDs multiplied by the number of PMGs. The maximum possible number >> of PARTIDs is 0x10000 and the maximum number of PMGs is 0x100. On a system >> approaching these limits the kmalloc() based allocation will consistently fail >> and hence fail to bring the monitor domain online. >> >> As there is no equivalent to bitmap_zalloc() that uses kvmalloc() or vmalloc(), >> open code the allocation of rmid_busy_llc using kvzalloc_objs() so that large > > I chatted to James offline about this and he suggested that even if resctrl is the only user of a kvmalloc() based > bitmap allocation that I should make some helpers that could be used verbatim in the bitmap core code even if they at > first start life in resctrl. I'll also do some better searching to see if they would be useful elsewhere. Looks there are some more places the helpers would be useful. linux$ git grep 'kv.*alloc.*BITS_TO_LONGS' drivers/md/dm-pcache/cache.c: cache->seg_map = kvcalloc(BITS_TO_LONGS(cache_dev->seg_num), sizeof(unsigned long), GFP_KERNEL); drivers/md/dm-pcache/cache_dev.c: cache_dev->seg_bitmap = kvcalloc(BITS_TO_LONGS(cache_dev->seg_num), sizeof(unsigned long), GFP_KERNEL); drivers/md/dm-verity-target.c: v->validated_blocks = kvcalloc(BITS_TO_LONGS(v->data_blocks), drivers/net/ethernet/mellanox/mlx5/core/fs_pool.c: fs_bulk->bitmask = kvcalloc(BITS_TO_LONGS(fs_bulk->bulk_len), fs/verity/open.c: vi->hash_block_verified = kvcalloc(BITS_TO_LONGS(num_bits), fs/xfs/xfs_zone_alloc.c: return kvmalloc_array(BITS_TO_LONGS(mp->m_sb.sb_rgcount), kernel/bpf/verifier.c: env->callx_edges = kvcalloc(BITS_TO_LONGS(cnt * cnt), sizeof(long), lib/region_alloc_benchmark.c: bitmap = kvmalloc_array(BITS_TO_LONGS(max_cap), sizeof(*bitmap), GFP_KERNEL); Thanks, Ben (The arm64 > asid has large bitmaps that don't need to physically contiguous but these allocated once at boot so we've already got > more problems if those allocations are failing.) > > I'll re-spin with some proper helpers which I'll call bitmap_kvzalloc() and bitmap_kvfree() unless anyone has any better > ideas. > > Thanks, > > BEn > >> allocations fall back to vmalloc(). >> >> Fixes: 264c285999fc ("arm_mpam: resctrl: Add monitor initialisation and domain boilerplate") >> Signed-off-by: Ben Horgan >> --- >> fs/resctrl/rdtgroup.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c >> index c55f125ce9a1..a8eebb5a5c4b 100644 >> --- a/fs/resctrl/rdtgroup.c >> +++ b/fs/resctrl/rdtgroup.c >> @@ -4503,7 +4503,7 @@ static void domain_destroy_l3_mon_state(struct rdt_l3_mon_domain *d) >> int idx; >> >> kvfree(d->cntr_cfg); >> - bitmap_free(d->rmid_busy_llc); >> + kvfree(d->rmid_busy_llc); >> for_each_mbm_idx(idx) { >> kvfree(d->mbm_states[idx]); >> d->mbm_states[idx] = NULL; >> @@ -4624,7 +4624,7 @@ static int domain_setup_l3_mon_state(struct rdt_resource *r, struct rdt_l3_mon_d >> int idx; >> >> if (resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID)) { >> - d->rmid_busy_llc = bitmap_zalloc(idx_limit, GFP_KERNEL); >> + d->rmid_busy_llc = kvzalloc_objs(unsigned long, BITS_TO_LONGS(idx_limit)); >> if (!d->rmid_busy_llc) >> return -ENOMEM; >> } >> @@ -4646,7 +4646,7 @@ static int domain_setup_l3_mon_state(struct rdt_resource *r, struct rdt_l3_mon_d >> >> return 0; >> cleanup: >> - bitmap_free(d->rmid_busy_llc); >> + kvfree(d->rmid_busy_llc); >> for_each_mbm_idx(idx) { >> kvfree(d->mbm_states[idx]); >> d->mbm_states[idx] = NULL; >