Skip to contentSkip to conversation

Expose the irq_desc node in proc/irq

PATCH In review Dimitri Sivanich 2 participants 3 messages Dec 11, 2009 – Dec 12, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Expose the irq_desc node in proc/irq

Expose the irq_desc node as /proc/irq/*/node.

---

 kernel/irq/proc.c |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
kernel/irq/proc.c +23 -0
Index: linux/kernel/irq/proc.c
===================================================================
@@ -146,6 +146,26 @@ static const struct file_operations defa
 	.release	= single_release,
 	.write		= default_affinity_write,
 };
+
+static int irq_node_proc_show(struct seq_file *m, void *v)
+{
+	struct irq_desc *desc = irq_to_desc((long) m->private);
+
+	seq_printf(m, "%d\n", desc->node);
+	return 0;
+}
+
+static int irq_node_proc_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, irq_node_proc_show,  PDE(inode)->data);
+}
+
+static const struct file_operations irq_node_proc_fops = {
+	.open		= irq_node_proc_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
 #endif
 
 static int irq_spurious_proc_show(struct seq_file *m, void *v)
@@ -230,6 +250,9 @@ void register_irq_proc(unsigned int irq,
 	/* create /proc/irq/<irq>/smp_affinity */
 	proc_create_data("smp_affinity", 0600, desc->dir,
 			 &irq_affinity_proc_fops, (void *)(long)irq);
+
+	proc_create_data("node", 0444, desc->dir,
+			 &irq_node_proc_fops, (void *)(long)irq);
 #endif
 
 	proc_create_data("spurious", 0444, desc->dir,
#1 lore raw
Quoted 2 lines · On Fri, 11 Dec 2009 10:25:32 -0600 Dimitri Sivanich <[email protected]> wrote:

Expose the irq_desc node as /proc/irq/*/node.

:(

If the changelog provides no reason for the change, the recipient has no reason to apply the patch.

kernel/irq/proc.c static const struct file_operations defa · line 160

Quoted 3 lines

...

kernel/irq/proc.c +1 -0
+	return single_open(file, irq_node_proc_show,  PDE(inode)->data);

I'd have expected checkpatch to complain about the double-space, but it doesn't.

kernel/irq/proc.c void register_irq_proc(unsigned int irq, · line 258

Quoted 10 lines

...

kernel/irq/proc.c +3 -0
 	/* create /proc/irq/<irq>/smp_affinity */
 	proc_create_data("smp_affinity", 0600, desc->dir,
 			 &irq_affinity_proc_fops, (void *)(long)irq);
+
+	proc_create_data("node", 0444, desc->dir,
+			 &irq_node_proc_fops, (void *)(long)irq);
 #endif
 
 	proc_create_data("spurious", 0444, desc->dir,

This should be documented in Documentation/filesystems/proc.txt, alongside smp_affinity.

#2 lore raw

PATCH 1/1 Expose the irq_desc node in proc/irq

Expose the irq_desc node as /proc/irq/*/node.

This file provides device hardware locality information for apps desiring to include hardware locality in irq mapping decisions.

---

 Documentation/filesystems/proc.txt |    4 ++++
 kernel/irq/proc.c                  |   23 +++++++++++++++++++++++
 2 files changed, 27 insertions(+)
kernel/irq/proc.c +23 -0
Index: linux/kernel/irq/proc.c
===================================================================
@@ -146,6 +146,26 @@ static const struct file_operations defa
 	.release	= single_release,
 	.write		= default_affinity_write,
 };
+
+static int irq_node_proc_show(struct seq_file *m, void *v)
+{
+	struct irq_desc *desc = irq_to_desc((long) m->private);
+
+	seq_printf(m, "%d\n", desc->node);
+	return 0;
+}
+
+static int irq_node_proc_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, irq_node_proc_show, PDE(inode)->data);
+}
+
+static const struct file_operations irq_node_proc_fops = {
+	.open		= irq_node_proc_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
 #endif
 
 static int irq_spurious_proc_show(struct seq_file *m, void *v)
@@ -230,6 +250,9 @@ void register_irq_proc(unsigned int irq,
 	/* create /proc/irq/<irq>/smp_affinity */
 	proc_create_data("smp_affinity", 0600, desc->dir,
 			 &irq_affinity_proc_fops, (void *)(long)irq);
+
+	proc_create_data("node", 0444, desc->dir,
+			 &irq_node_proc_fops, (void *)(long)irq);
 #endif
 
 	proc_create_data("spurious", 0444, desc->dir,
Documentation/filesystems/proc.txt +4 -0
Index: linux/Documentation/filesystems/proc.txt
===================================================================
@@ -558,6 +558,10 @@ The default_smp_affinity mask applies to
 IRQs which have not yet been allocated/activated, and hence which lack a
 /proc/irq/[0-9]* directory.
 
+The node file on an SMP system shows the node to which the device using the IRQ
+reports itself as being attached.  This hardware locality information does not
+include information about any possible driver locality preference.
+
 prof_cpu_mask specifies which CPUs are to be profiled by the system wide
 profiler. Default value is ffffffff (all cpus).