[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2426186.1744387151@warthog.procyon.org.uk>
Date: Fri, 11 Apr 2025 16:59:11 +0100
From: David Howells <dhowells@...hat.com>
To: Jarkko Sakkinen <jarkko@...nel.org>
Cc: dhowells@...hat.com, keyrings@...r.kernel.org,
Jarkko Sakkinen <jarkko.sakkinen@...nsys.com>,
stable@...r.kernel.org, Lukas Wunner <lukas@...ner.de>,
Ignat Korchagin <ignat@...udflare.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
"David S. Miller" <davem@...emloft.net>,
Peter Huewe <peterhuewe@....de>, Jason Gunthorpe <jgg@...pe.ca>,
Paul Moore <paul@...l-moore.com>, James Morris <jmorris@...ei.org>,
"Serge E.
Hallyn" <serge@...lyn.com>,
James Bottomley <James.Bottomley@...senPartnership.com>,
Mimi Zohar <zohar@...ux.ibm.com>, linux-crypto@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-integrity@...r.kernel.org,
linux-security-module@...r.kernel.org
Subject: Re: [PATCH v8] KEYS: Add a list for unreferenced keys
Jarkko Sakkinen <jarkko@...nel.org> wrote:
> + spin_lock_irqsave(&key_graveyard_lock, flags);
> + list_splice_init(&key_graveyard, &graveyard);
> + spin_unlock_irqrestore(&key_graveyard_lock, flags);
I would wrap this bit in a check to see if key_graveyard is empty so that we
can avoid disabling irqs and taking the lock if the graveyard is empty.
> + if (!refcount_inc_not_zero(&key->usage)) {
Sorry, but eww. You're going to wangle the refcount twice on every key on the
system every time the gc does a pass. Further, in some cases inc_not_zero is
not the fastest op in the world.
> + spin_lock_irqsave(&key_graveyard_lock, flags);
> + list_add_tail(&key->graveyard_link, &key_graveyard);
> + spin_unlock_irqrestore(&key_graveyard_lock, flags);
> schedule_work(&key_gc_work);
This is going to enable and disable interrupts twice and that can be
expensive, depending on the arch. I wonder if it would be better to do:
local_irq_save(flags);
spin_lock(&key_graveyard_lock);
list_add_tail(&key->graveyard_link, &key_graveyard);
spin_unlock(&key_graveyard_lock);
schedule_work(&key_gc_work);
local_irq_restore(flags);
David
Powered by blists - more mailing lists