mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] Trivial sparse acquire/release annotations
@ 2013-07-06 12:11 Ramkumar Ramachandra
  2013-07-06 12:11 ` [PATCH 1/3] nfs: add lock annotations to squelch sparse warnings Ramkumar Ramachandra
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-06 12:11 UTC (permalink / raw)
  To: LKML

Hi,

So, I was looking at sparse this lazy Saturday afternoon.  Thought I
might as well clean up a few obvious warnings while I'm there.

Thanks.

Ramkumar Ramachandra (3):
  nfs: add lock annotations to squelch sparse warnings
  apic: add lock annotations to squelch sparse warnings
  irq: add lock annotation to squelch a sparse warning

 arch/x86/kernel/apic/io_apic.c | 2 ++
 fs/nfs/client.c                | 4 ++++
 kernel/irq/irqdesc.c           | 1 +
 3 files changed, 7 insertions(+)

-- 
1.8.3.2.733.gf8abaeb


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

* [PATCH 1/3] nfs: add lock annotations to squelch sparse warnings
  2013-07-06 12:11 [PATCH 0/3] Trivial sparse acquire/release annotations Ramkumar Ramachandra
@ 2013-07-06 12:11 ` Ramkumar Ramachandra
  2013-07-06 12:11 ` [PATCH 2/3] apic: " Ramkumar Ramachandra
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-06 12:11 UTC (permalink / raw)
  To: LKML; +Cc: David Howells, Trond Myklebust

sparse, being a static analyzer, emits the following warnings:

  context imbalance in 'nfs_server_list_start' - wrong count at exit
  context imbalance in 'nfs_server_list_start' - unexpected unlock
  context imbalance in 'nfs_volume_list_start' - wrong count at exit
  context imbalance in 'nfs_volume_list_start' - unexpected unlock

Help it by annotating the pairs of functions with __acquires and
__releases.

Cc: David Howells <dhowells@redhat.com>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 fs/nfs/client.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index c513b0c..2a32ac8 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1253,6 +1253,7 @@ static int nfs_server_list_open(struct inode *inode, struct file *file)
  * set up the iterator to start reading from the server list and return the first item
  */
 static void *nfs_server_list_start(struct seq_file *m, loff_t *_pos)
+	__acquires(&nn->nfs_client_lock)
 {
 	struct nfs_net *nn = net_generic(m->private, nfs_net_id);
 
@@ -1275,6 +1276,7 @@ static void *nfs_server_list_next(struct seq_file *p, void *v, loff_t *pos)
  * clean up after reading from the transports list
  */
 static void nfs_server_list_stop(struct seq_file *p, void *v)
+	__releases(&nn->nfs_client_lock)
 {
 	struct nfs_net *nn = net_generic(p->private, nfs_net_id);
 
@@ -1338,6 +1340,7 @@ static int nfs_volume_list_open(struct inode *inode, struct file *file)
  * set up the iterator to start reading from the volume list and return the first item
  */
 static void *nfs_volume_list_start(struct seq_file *m, loff_t *_pos)
+	__acquires(&nn->nfs_client_lock)
 {
 	struct nfs_net *nn = net_generic(m->private, nfs_net_id);
 
@@ -1360,6 +1363,7 @@ static void *nfs_volume_list_next(struct seq_file *p, void *v, loff_t *pos)
  * clean up after reading from the transports list
  */
 static void nfs_volume_list_stop(struct seq_file *p, void *v)
+	__releases(&nn->nfs_client_lock)
 {
 	struct nfs_net *nn = net_generic(p->private, nfs_net_id);
 
-- 
1.8.3.2.733.gf8abaeb


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

* [PATCH 2/3] apic: add lock annotations to squelch sparse warnings
  2013-07-06 12:11 [PATCH 0/3] Trivial sparse acquire/release annotations Ramkumar Ramachandra
  2013-07-06 12:11 ` [PATCH 1/3] nfs: add lock annotations to squelch sparse warnings Ramkumar Ramachandra
@ 2013-07-06 12:11 ` Ramkumar Ramachandra
  2013-07-06 12:11 ` [PATCH 3/3] irq: add lock annotation to squelch a sparse warning Ramkumar Ramachandra
  2013-09-23 14:41 ` [PATCH 0/3] Trivial sparse acquire/release annotations Ramkumar Ramachandra
  3 siblings, 0 replies; 5+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-06 12:11 UTC (permalink / raw)
  To: LKML; +Cc: Yinghai Lu, Thomas Gleixner

sparse, being a static analyzer, emits the following warnings:

  context imbalance in 'lock_vector_lock' - wrong count at exit
  context imbalance in 'unlock_vector_lock' - unexpected unlock

Help it by annotating the pair of functions with __acquires and
__releases.

Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 arch/x86/kernel/apic/io_apic.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 9ed796c..b756417 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -1061,6 +1061,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
 
 void lock_vector_lock(void)
+	__acquires(&vector_lock)
 {
 	/* Used to the online set of cpus does not change
 	 * during assign_irq_vector.
@@ -1069,6 +1070,7 @@ void lock_vector_lock(void)
 }
 
 void unlock_vector_lock(void)
+	__releases(&vector_lock)
 {
 	raw_spin_unlock(&vector_lock);
 }
-- 
1.8.3.2.733.gf8abaeb


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

* [PATCH 3/3] irq: add lock annotation to squelch a sparse warning
  2013-07-06 12:11 [PATCH 0/3] Trivial sparse acquire/release annotations Ramkumar Ramachandra
  2013-07-06 12:11 ` [PATCH 1/3] nfs: add lock annotations to squelch sparse warnings Ramkumar Ramachandra
  2013-07-06 12:11 ` [PATCH 2/3] apic: " Ramkumar Ramachandra
@ 2013-07-06 12:11 ` Ramkumar Ramachandra
  2013-09-23 14:41 ` [PATCH 0/3] Trivial sparse acquire/release annotations Ramkumar Ramachandra
  3 siblings, 0 replies; 5+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-06 12:11 UTC (permalink / raw)
  To: LKML; +Cc: Thomas Gleixner

__irq_put_desc_unlock() releases &desc->lock, but being a static
analyzer, sparse emits a warning:

  context imbalance in '__irq_put_desc_unlock' - unexpected unlock

Help it by annotating the function with a __release.  Do not annotate
its counterpart which acquires the lock, __irq_get_desc_lock(), because
it does so conditionally.

Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 kernel/irq/irqdesc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 192a302..d6bc26a 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -449,6 +449,7 @@ __irq_get_desc_lock(unsigned int irq, unsigned long *flags, bool bus,
 }
 
 void __irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags, bool bus)
+	__releases(&desc->lock)
 {
 	raw_spin_unlock_irqrestore(&desc->lock, flags);
 	if (bus)
-- 
1.8.3.2.733.gf8abaeb


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

* Re: [PATCH 0/3] Trivial sparse acquire/release annotations
  2013-07-06 12:11 [PATCH 0/3] Trivial sparse acquire/release annotations Ramkumar Ramachandra
                   ` (2 preceding siblings ...)
  2013-07-06 12:11 ` [PATCH 3/3] irq: add lock annotation to squelch a sparse warning Ramkumar Ramachandra
@ 2013-09-23 14:41 ` Ramkumar Ramachandra
  3 siblings, 0 replies; 5+ messages in thread
From: Ramkumar Ramachandra @ 2013-09-23 14:41 UTC (permalink / raw)
  To: LKML; +Cc: Jiri Kosina

Ramkumar Ramachandra wrote:
> Ramkumar Ramachandra (3):
>   nfs: add lock annotations to squelch sparse warnings
>   apic: add lock annotations to squelch sparse warnings
>   irq: add lock annotation to squelch a sparse warning

Ping. Can someone pick these up?

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

end of thread, other threads:[~2013-09-23 14:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-06 12:11 [PATCH 0/3] Trivial sparse acquire/release annotations Ramkumar Ramachandra
2013-07-06 12:11 ` [PATCH 1/3] nfs: add lock annotations to squelch sparse warnings Ramkumar Ramachandra
2013-07-06 12:11 ` [PATCH 2/3] apic: " Ramkumar Ramachandra
2013-07-06 12:11 ` [PATCH 3/3] irq: add lock annotation to squelch a sparse warning Ramkumar Ramachandra
2013-09-23 14:41 ` [PATCH 0/3] Trivial sparse acquire/release annotations Ramkumar Ramachandra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®