Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1603329

Re: [PATCH v3] irqchip/gicv3-its: Avoid memory over allocation for ITEs

From Marc Zyngier <marc.zyngier@arm.com>
Newsgroups linux.kernel
Subject Re: [PATCH v3] irqchip/gicv3-its: Avoid memory over allocation for ITEs
Date 2017-03-17 15:00 +0100
Message-ID <tm0Aa-7ex-13@gated-at.bofh.it> (permalink)
References <tiohJ-h2-35@gated-at.bofh.it>
Organization ARM Ltd

Show all headers | View raw


On 07/03/17 14:25, Shanker Donthineni wrote:
> We are always allocating extra 255Bytes of memory to handle ITE
> physical address alignment requirement. The kmalloc() satisfies
> the ITE alignment since the ITS driver is requesting a minimum
> size of ITS_ITT_ALIGN bytes.
> 
> Let's try to allocate the exact amount of memory that is required
> for ITEs to avoid wastage.
> 
> Signed-off-by: Shanker Donthineni <shankerd@codeaurora.org>
> ---
> v2: removed 'Change-Id: Ia8084189833f2081ff13c392deb5070c46a64038' from commit.
> v3: changed from IITE to ITE.
> 
>  drivers/irqchip/irq-gic-v3-its.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
> index 86bd428..5aeca78 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -1329,8 +1329,13 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id,
>  	 */
>  	nr_ites = max(2UL, roundup_pow_of_two(nvecs));
>  	sz = nr_ites * its->ite_size;
> -	sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1;
> +	sz = max(sz, ITS_ITT_ALIGN);
>  	itt = kzalloc(sz, GFP_KERNEL);
> +	if (itt && !IS_ALIGNED(virt_to_phys(itt), ITS_ITT_ALIGN)) {
> +		kfree(itt);
> +		itt = kzalloc(sz + ITS_ITT_ALIGN - 1, GFP_KERNEL);
> +	}
> +

Is this really worth the complexity? Are you aware of a system where the
accumulation of overallocation actually shows up as being an issue?

If you want to be absolutely exact in your allocation, then I'd suggest
doing it all the time, and have a proper dedicated allocator that always
do the right thing, without a wasteful fallback like you still have here.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [PATCH v3] irqchip/gicv3-its: Avoid memory over allocation for  ITEs Marc Zyngier <marc.zyngier@arm.com> - 2017-03-17 15:00 +0100
  Re: [PATCH v3] irqchip/gicv3-its: Avoid memory over allocation for  ITEs Shanker Donthineni <shankerd@codeaurora.org> - 2017-03-17 15:20 +0100
    Re: [PATCH v3] irqchip/gicv3-its: Avoid memory over allocation for  ITEs Marc Zyngier <marc.zyngier@arm.com> - 2017-03-17 17:00 +0100
      Re: [PATCH v3] irqchip/gicv3-its: Avoid memory over allocation for  ITEs Shanker Donthineni <shankerd@codeaurora.org> - 2017-03-20 11:20 +0100
        Re: [PATCH v3] irqchip/gicv3-its: Avoid memory over allocation for  ITEs Shanker Donthineni <shankerd@codeaurora.org> - 2017-03-20 12:20 +0100

csiph-web