[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <A5ED84D3BB3A384992CBB9C77DEDA4D413805E24@USINDEM103.corp.hds.com>
Date: Mon, 20 Aug 2012 20:56:21 +0000
From: Seiji Aguchi <seiji.aguchi@....com>
To: Mike Waychison <mikew@...gle.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Luck, Tony (tony.luck@...el.com)" <tony.luck@...el.com>,
"Matthew Garrett (mjg@...hat.com)" <mjg@...hat.com>,
"dzickus@...hat.com" <dzickus@...hat.com>,
"dle-develop@...ts.sourceforge.net"
<dle-develop@...ts.sourceforge.net>,
Satoru Moriya <satoru.moriya@....com>
Subject: RE: [RFC][PATCH v2 2/3] efi_pstore: Introducing workqueue updating
sysfs entries
> > +static void delete_sysfs_entry(void)
> > +{
> > + struct efivars *efivars = &__efivars;
> > + struct efivar_entry *entry, *n;
> > + efi_status_t status;
> > + unsigned long flags;
> > +
> > + list_for_each_entry_safe(entry, n, &efivars->list, list) {
>
> This ->lock here is protecting this list, so it isn't correct to grab the lock within iteration. The lock should instead be grabbed before
> iterating through the list, dropped if we need to unregister and iteration should restart completely if the lock was dropped.
>
Thank you for your comment.
If my understanding is correct, the code should be changed as follows.
+ while (1) {
+ found = NULL;
+ spin_lock_irqsave(&efivars->lock, flags);
+ list_for_each_entry(entry, &efivars->list, list) {
+ status = get_var_data_locked(efivars, &entry->var);
+ if (status != EFI_SUCCESS) {
+ found = entry;
+ list_del(&entry->list);
+ break;
+ }
+ }
+ spin_unlock_irqrestore(&efivars->lock, flags);
+ if (found)
+ efivar_unregister(entry);
+ else
+ break;
+ }
> > + spin_lock_irqsave(&efivars->lock, flags);
> > + status = get_var_data_locked(efivars, &entry->var);
> > + if (status != EFI_SUCCESS) {
> > + list_del(&entry->list);
> > + spin_unlock_irqrestore(&efivars->lock, flags);
> > + efivar_unregister(entry);
> > + } else
> > + spin_unlock_irqrestore(&efivars->lock, flags);
> > + }
> > +}
> > + /* Delete unavailable sysfs entries */
> > + delete_sysfs_entry();
>
> This method needs a better name that reflects what it is doing.
> delete_all_stale_sysfs_entries ?
OK. I will change the name to it.
Seiji
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists