lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221201092008.2nainxhjpxnsptin@vireshk-i7>
Date:   Thu, 1 Dec 2022 14:50:08 +0530
From:   Viresh Kumar <viresh.kumar@...aro.org>
To:     Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc:     "Rafael J. Wysocki" <rafael@...nel.org>,
        Thierry Reding <thierry.reding@...il.com>,
        Jonathan Hunter <jonathanh@...dia.com>,
        linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        linux-pm@...r.kernel.org, linux-tegra@...r.kernel.org
Subject: Re: [PATCH] cpufreq: tegra186: Use flexible array to simplify memory
 allocation

On 20-11-22, 18:19, Christophe JAILLET wrote:
> Use flexible array to simplify memory allocation.
> It saves some memory, avoids an indirection when reading the 'clusters'
> array and removes some LoC.
> 
> 
> Detailed explanation:
> ====================
> Knowing that:
>   - each devm_ allocation over-allocates 40 bytes for internal needs
>   - Some rounding is done by the memory allocator on 8, 16, 32, 64, 96,
>     128, 192, 256, 512, 1024, 2048, 4096, 8192 boundaries
> 
> and that:
>   - sizeof(struct tegra186_cpufreq_data) = 24
>   - sizeof(struct tegra186_cpufreq_cluster) = 16
> 
> Memory allocations in tegra186_cpufreq_probe() are:
>   data:           (24 + 40) = 64 		      => 64 bytes
>   data->clusters: (2 * 16 + 40) = 72     => 96 bytes
> So a total of 160 bytes are allocated.
> 56 for the real need, 80 for internal uses and 24 are wasted.
> 
> 
> If 'struct tegra186_cpufreq_data' is reordered so that 'clusters' is a
> flexible array:
>   - it saves one pointer in the structure
>   - only one allocation is needed
> 
> So, only 96 bytes are allocated:
>   16 + 2 * 16 + 40 = 88  => 96 bytes
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
> ---

Applied. Thanks.

-- 
viresh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ