Linux Kernel Mentees Archive on lore.kernel.org
 help / color / Atom feed
* [Linux-kernel-mentees] [PATCH] x86: Fix RCU list usage to avoid false positive warnings
@ 2020-04-30 19:29 madhuparnabhowmik10
  2020-05-04 16:47 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: madhuparnabhowmik10 @ 2020-04-30 19:29 UTC (permalink / raw)
  To: mingo, pbonzini, bp
  Cc: kvm, paulmck, linux-pci, x86, linux-kernel,
	sean.j.christopherson, joel, cai, Madhuparna Bhowmik, bhelgaas,
	linux-kernel-mentees

From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>

Use list_for_each_entry() instead of list_for_each_entry_rcu() whenever
spinlock or mutex is always held.
Otherwise, pass cond to list_for_each_entry_rcu().

Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
---
 arch/x86/kernel/nmi.c          | 2 +-
 arch/x86/kvm/irq_comm.c        | 3 ++-
 arch/x86/pci/mmconfig-shared.c | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index 6407ea21fa1b..999dc6c134d2 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -195,7 +195,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
 
 	raw_spin_lock_irqsave(&desc->lock, flags);
 
-	list_for_each_entry_rcu(n, &desc->head, list) {
+	list_for_each_entry(n, &desc->head, list) {
 		/*
 		 * the name passed in to describe the nmi handler
 		 * is used as the lookup key
diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
index c47d2acec529..5b88a648e079 100644
--- a/arch/x86/kvm/irq_comm.c
+++ b/arch/x86/kvm/irq_comm.c
@@ -258,7 +258,8 @@ void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin,
 	idx = srcu_read_lock(&kvm->irq_srcu);
 	gsi = kvm_irq_map_chip_pin(kvm, irqchip, pin);
 	if (gsi != -1)
-		hlist_for_each_entry_rcu(kimn, &kvm->arch.mask_notifier_list, link)
+		hlist_for_each_entry_rcu(kimn, &kvm->arch.mask_notifier_list, link,
+					srcu_read_lock_held(&kvm->irq_srcu))
 			if (kimn->irq == gsi)
 				kimn->func(kimn, mask);
 	srcu_read_unlock(&kvm->irq_srcu, idx);
diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c
index 6fa42e9c4e6f..a096942690bd 100644
--- a/arch/x86/pci/mmconfig-shared.c
+++ b/arch/x86/pci/mmconfig-shared.c
@@ -797,7 +797,7 @@ int pci_mmconfig_delete(u16 seg, u8 start, u8 end)
 	struct pci_mmcfg_region *cfg;
 
 	mutex_lock(&pci_mmcfg_lock);
-	list_for_each_entry_rcu(cfg, &pci_mmcfg_list, list)
+	list_for_each_entry(cfg, &pci_mmcfg_list, list)
 		if (cfg->segment == seg && cfg->start_bus == start &&
 		    cfg->end_bus == end) {
 			list_del_rcu(&cfg->list);
-- 
2.17.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH] x86: Fix RCU list usage to avoid false positive warnings
  2020-04-30 19:29 [Linux-kernel-mentees] [PATCH] x86: Fix RCU list usage to avoid false positive warnings madhuparnabhowmik10
@ 2020-05-04 16:47 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2020-05-04 16:47 UTC (permalink / raw)
  To: madhuparnabhowmik10, mingo, bp
  Cc: kvm, paulmck, linux-pci, x86, linux-kernel,
	sean.j.christopherson, joel, cai, bhelgaas, linux-kernel-mentees

On 30/04/20 21:29, madhuparnabhowmik10@gmail.com wrote:
> From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> 
> Use list_for_each_entry() instead of list_for_each_entry_rcu() whenever
> spinlock or mutex is always held.
> Otherwise, pass cond to list_for_each_entry_rcu().
> 
> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> ---
>  arch/x86/kernel/nmi.c          | 2 +-
>  arch/x86/kvm/irq_comm.c        | 3 ++-
>  arch/x86/pci/mmconfig-shared.c | 2 +-
>  3 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
> index 6407ea21fa1b..999dc6c134d2 100644
> --- a/arch/x86/kernel/nmi.c
> +++ b/arch/x86/kernel/nmi.c
> @@ -195,7 +195,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
>  
>  	raw_spin_lock_irqsave(&desc->lock, flags);
>  
> -	list_for_each_entry_rcu(n, &desc->head, list) {
> +	list_for_each_entry(n, &desc->head, list) {
>  		/*
>  		 * the name passed in to describe the nmi handler
>  		 * is used as the lookup key
> diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
> index c47d2acec529..5b88a648e079 100644
> --- a/arch/x86/kvm/irq_comm.c
> +++ b/arch/x86/kvm/irq_comm.c
> @@ -258,7 +258,8 @@ void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin,
>  	idx = srcu_read_lock(&kvm->irq_srcu);
>  	gsi = kvm_irq_map_chip_pin(kvm, irqchip, pin);
>  	if (gsi != -1)
> -		hlist_for_each_entry_rcu(kimn, &kvm->arch.mask_notifier_list, link)
> +		hlist_for_each_entry_rcu(kimn, &kvm->arch.mask_notifier_list, link,
> +					srcu_read_lock_held(&kvm->irq_srcu))
>  			if (kimn->irq == gsi)
>  				kimn->func(kimn, mask);
>  	srcu_read_unlock(&kvm->irq_srcu, idx);
> diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c
> index 6fa42e9c4e6f..a096942690bd 100644
> --- a/arch/x86/pci/mmconfig-shared.c
> +++ b/arch/x86/pci/mmconfig-shared.c
> @@ -797,7 +797,7 @@ int pci_mmconfig_delete(u16 seg, u8 start, u8 end)
>  	struct pci_mmcfg_region *cfg;
>  
>  	mutex_lock(&pci_mmcfg_lock);
> -	list_for_each_entry_rcu(cfg, &pci_mmcfg_list, list)
> +	list_for_each_entry(cfg, &pci_mmcfg_list, list)
>  		if (cfg->segment == seg && cfg->start_bus == start &&
>  		    cfg->end_bus == end) {
>  			list_del_rcu(&cfg->list);
> 

For KVM parts, if the x86 maintainers want to apply the whole patch,

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-30 19:29 [Linux-kernel-mentees] [PATCH] x86: Fix RCU list usage to avoid false positive warnings madhuparnabhowmik10
2020-05-04 16:47 ` Paolo Bonzini

Linux Kernel Mentees Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-kernel-mentees/0 linux-kernel-mentees/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-kernel-mentees linux-kernel-mentees/ https://lore.kernel.org/linux-kernel-mentees \
		linux-kernel-mentees@lists.linuxfoundation.org
	public-inbox-index linux-kernel-mentees

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linuxfoundation.lists.linux-kernel-mentees


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git