[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKgze5ZVHax5AWP3Q764dSmjAJWncyZbn4ENQCkYs0ahbG9Haw@mail.gmail.com>
Date: Thu, 3 Feb 2022 15:24:29 -0300
From: Martin Fernandez <martin.fernandez@...ypsium.com>
To: Mike Rapoport <rppt@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-efi@...r.kernel.org,
platform-driver-x86@...r.kernel.org, linux-mm@...ck.org,
tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
ardb@...nel.org, dvhart@...radead.org, andy@...radead.org,
gregkh@...uxfoundation.org, rafael@...nel.org,
akpm@...ux-foundation.org, daniel.gutson@...ypsium.com,
hughsient@...il.com, alex.bazhaniuk@...ypsium.com,
alison.schofield@...el.com, keescook@...omium.org
Subject: Re: [PATCH v6 1/6] mm/memblock: Tag memblocks with crypto capabilities
On 2/3/22, Mike Rapoport <rppt@...nel.org> wrote:
> On Thu, Feb 03, 2022 at 01:43:23PM -0300, Martin Fernandez wrote:
>> +/**
>> + * memblock_node_is_crypto_capable - get if whole node is capable
>> + * of encryption
>> + * @nid: number of node
>> + *
>> + * Iterate over all memory memblock_type and find if all regions under
>> + * node @nid are capable of hardware encryption.
>> + *
>> + * Return:
>> + * true if every region in memory memblock_type is capable of
>> + * encryption, false otherwise.
>> + */
>> +bool __init_memblock memblock_node_is_crypto_capable(int nid)
>> +{
>> + struct memblock_region *region;
>> + bool crypto_capable = false;
>> + bool not_crypto_capable = false;
>> +
>> + for_each_mem_region(region) {
>> + if (memblock_get_region_node(region) == nid) {
>> + crypto_capable =
>> + crypto_capable ||
>> + (region->flags & MEMBLOCK_CRYPTO_CAPABLE);
>> + not_crypto_capable =
>> + not_crypto_capable ||
>> + !(region->flags & MEMBLOCK_CRYPTO_CAPABLE);
>
> Isn't
>
> if (region->flags & MEMBLOCK_CRYPTO_CAPABLE)
> crypto_capable++;
> else
> not_crypto_capable++;
>
> simpler and clearer?
>
> (of course s/bool/int in the declaration)
>
Yes! It is. I like that.
>> + }
>> + }
>> +
>> + if (crypto_capable && not_crypto_capable)
>> + pr_warn_once("Node %d has regions that are encryptable and regions that
>> aren't",
>> + nid);
>
> This will print only the first node with mixed regions. With a single
> caller of memblock_node_is_crypto_capable() I think pr_warn() is ok.
>
Yes, you are correct, don't really want _once here.
Powered by blists - more mailing lists