<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/kernel/irq/proc.c, branch v6.19</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>genirq/proc: Fix race in show_irq_affinity()</title>
<updated>2025-10-31T21:30:05+00:00</updated>
<author>
<name>Muchun Song</name>
<email>songmuchun@bytedance.com</email>
</author>
<published>2025-10-28T09:04:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=9ea2b810d51ae662cc5b5578f9395cb620a34a26'/>
<id>9ea2b810d51ae662cc5b5578f9395cb620a34a26</id>
<content type='text'>
Reading /proc/irq/N/smp_affinity* races with irq_set_affinity() and
irq_move_masked_irq(), leading to old or torn output for users.

After a user writes a new CPU mask to /proc/irq/N/affinity*, the syscall
returns success, yet a subsequent read of the same file immediately returns
a value different from what was just written.

That's due to a race between show_irq_affinity() and irq_move_masked_irq()
which lets the read observe a transient, inconsistent affinity mask.

Cure it by guarding the read with irq_desc::lock.

[ tglx: Massaged change log ]

Signed-off-by: Muchun Song &lt;songmuchun@bytedance.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://patch.msgid.link/20251028090408.76331-1-songmuchun@bytedance.com
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reading /proc/irq/N/smp_affinity* races with irq_set_affinity() and
irq_move_masked_irq(), leading to old or torn output for users.

After a user writes a new CPU mask to /proc/irq/N/affinity*, the syscall
returns success, yet a subsequent read of the same file immediately returns
a value different from what was just written.

That's due to a race between show_irq_affinity() and irq_move_masked_irq()
which lets the read observe a transient, inconsistent affinity mask.

Cure it by guarding the read with irq_desc::lock.

[ tglx: Massaged change log ]

Signed-off-by: Muchun Song &lt;songmuchun@bytedance.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://patch.msgid.link/20251028090408.76331-1-songmuchun@bytedance.com
</pre>
</div>
</content>
</entry>
<entry>
<title>genirq: Consistently use '%u' format specifier for unsigned int variables</title>
<updated>2025-05-13T07:43:32+00:00</updated>
<author>
<name>Andy Shevchenko</name>
<email>andriy.shevchenko@linux.intel.com</email>
</author>
<published>2025-05-09T15:46:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=47af06c9d31fe558493de4e04f9a07847dc4992f'/>
<id>47af06c9d31fe558493de4e04f9a07847dc4992f</id>
<content type='text'>
There are three cases in the genirq code when the irq, as an unsigned
integer variable, is converted to text representation by sprintf().
In two cases it uses '%d' specifier which is for signed values. While
it's not a problem right now, potentially it might be in the future
in case too big (&gt; INT_MAX) number will appear there.

Consistently use '%u' format specifier for @irq which is declared as
unsigned int in all these cases.

Signed-off-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/all/20250509154643.1499171-1-andriy.shevchenko@linux.intel.com

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There are three cases in the genirq code when the irq, as an unsigned
integer variable, is converted to text representation by sprintf().
In two cases it uses '%d' specifier which is for signed values. While
it's not a problem right now, potentially it might be in the future
in case too big (&gt; INT_MAX) number will appear there.

Consistently use '%u' format specifier for @irq which is declared as
unsigned int in all these cases.

Signed-off-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/all/20250509154643.1499171-1-andriy.shevchenko@linux.intel.com

</pre>
</div>
</content>
</entry>
<entry>
<title>genirq/proc: Switch to lock guards</title>
<updated>2025-05-07T07:08:11+00:00</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2025-04-29T06:54:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=659ff9c9d77b8ad9d9c18e264abc9a56bd19230e'/>
<id>659ff9c9d77b8ad9d9c18e264abc9a56bd19230e</id>
<content type='text'>
Convert all lock/unlock pairs to guards and tidy up the code.

No functional change.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lore.kernel.org/all/20250429065420.373998838@linutronix.de


</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Convert all lock/unlock pairs to guards and tidy up the code.

No functional change.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lore.kernel.org/all/20250429065420.373998838@linutronix.de


</pre>
</div>
</content>
</entry>
<entry>
<title>genirq/proc: Add missing space separator back</title>
<updated>2024-12-03T13:59:34+00:00</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2024-12-03T10:40:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=9d9f204bdf7243bfc2c6a023d63c63f7cbf8ef0b'/>
<id>9d9f204bdf7243bfc2c6a023d63c63f7cbf8ef0b</id>
<content type='text'>
The recent conversion of show_interrupts() to seq_put_decimal_ull_width()
caused a formatting regression as it drops a previosuly existing space
separator.

Add it back by unconditionally inserting a space after the interrupt
counts and removing the extra leading space from the chip name prints.

Fixes: f9ed1f7c2e26 ("genirq/proc: Use seq_put_decimal_ull_width() for decimal values")
Reported-by: Geert Uytterhoeven &lt;geert@linux-m68k.org&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Tested-by: Geert Uytterhoeven &lt;geert@linux-m68k.org&gt;
Reviewed-by: David Wang &lt;00107082@163.com&gt;
Link: https://lore.kernel.org/all/87zfldt5g4.ffs@tglx
Closes: https://lore.kernel.org/all/4ce18851-6e9f-bbe-8319-cc5e69fb45c@linux-m68k.org
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The recent conversion of show_interrupts() to seq_put_decimal_ull_width()
caused a formatting regression as it drops a previosuly existing space
separator.

Add it back by unconditionally inserting a space after the interrupt
counts and removing the extra leading space from the chip name prints.

Fixes: f9ed1f7c2e26 ("genirq/proc: Use seq_put_decimal_ull_width() for decimal values")
Reported-by: Geert Uytterhoeven &lt;geert@linux-m68k.org&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Tested-by: Geert Uytterhoeven &lt;geert@linux-m68k.org&gt;
Reviewed-by: David Wang &lt;00107082@163.com&gt;
Link: https://lore.kernel.org/all/87zfldt5g4.ffs@tglx
Closes: https://lore.kernel.org/all/4ce18851-6e9f-bbe-8319-cc5e69fb45c@linux-m68k.org
</pre>
</div>
</content>
</entry>
<entry>
<title>genirq/proc: Use seq_put_decimal_ull_width() for decimal values</title>
<updated>2024-11-13T16:36:35+00:00</updated>
<author>
<name>David Wang</name>
<email>00107082@163.com</email>
</author>
<published>2024-11-08T16:07:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f9ed1f7c2e26fcd19781774e310a6236d7525c11'/>
<id>f9ed1f7c2e26fcd19781774e310a6236d7525c11</id>
<content type='text'>
seq_printf() is more expensive than seq_put_decimal_ull_width() due to the
format string parsing costs.

Profiling on a x86 8-core system indicates seq_printf() takes ~47% samples
of show_interrupts(). Replacing it with seq_put_decimal_ull_width() yields
almost 30% performance gain.

[ tglx: Massaged changelog and fixed up coding style ]

Signed-off-by: David Wang &lt;00107082@163.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/all/20241108160717.9547-1-00107082@163.com

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
seq_printf() is more expensive than seq_put_decimal_ull_width() due to the
format string parsing costs.

Profiling on a x86 8-core system indicates seq_printf() takes ~47% samples
of show_interrupts(). Replacing it with seq_put_decimal_ull_width() yields
almost 30% performance gain.

[ tglx: Massaged changelog and fixed up coding style ]

Signed-off-by: David Wang &lt;00107082@163.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/all/20241108160717.9547-1-00107082@163.com

</pre>
</div>
</content>
</entry>
<entry>
<title>genirq: Switch to irq_get_nr_irqs()</title>
<updated>2024-10-16T19:56:59+00:00</updated>
<author>
<name>Bart Van Assche</name>
<email>bvanassche@acm.org</email>
</author>
<published>2024-10-15T19:09:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=1ad2048bf7146efb83bc033147ca1611a7fe8494'/>
<id>1ad2048bf7146efb83bc033147ca1611a7fe8494</id>
<content type='text'>
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Cache the result of this function in a local variable in
order not to rely on CSE (common subexpression elimination). Prepare
for changing 'nr_irqs' from an exported global variable into a variable
with file scope.

Signed-off-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/all/20241015190953.1266194-22-bvanassche@acm.org

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Cache the result of this function in a local variable in
order not to rely on CSE (common subexpression elimination). Prepare
for changing 'nr_irqs' from an exported global variable into a variable
with file scope.

Signed-off-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/all/20241015190953.1266194-22-bvanassche@acm.org

</pre>
</div>
</content>
</entry>
<entry>
<title>genirq/proc: Change the return value for set affinity permission error</title>
<updated>2024-08-29T14:42:06+00:00</updated>
<author>
<name>Jeff Xie</name>
<email>jeff.xie@linux.dev</email>
</author>
<published>2024-08-26T14:58:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=eb29369fa543e7d5557c19ebecf072244bb14815'/>
<id>eb29369fa543e7d5557c19ebecf072244bb14815</id>
<content type='text'>
Currently, when the affinity of an irq cannot be set due to lack of
permission, the write_irq_affinity() returns the error code -EIO.

Change the return value to -EPERM as that reflects the cause of error
correctly.

Signed-off-by: Jeff Xie &lt;jeff.xie@linux.dev&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/all/20240826145805.5938-1-jeff.xie@linux.dev
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently, when the affinity of an irq cannot be set due to lack of
permission, the write_irq_affinity() returns the error code -EIO.

Change the return value to -EPERM as that reflects the cause of error
correctly.

Signed-off-by: Jeff Xie &lt;jeff.xie@linux.dev&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/all/20240826145805.5938-1-jeff.xie@linux.dev
</pre>
</div>
</content>
</entry>
<entry>
<title>genirq/proc: Use irq_move_pending() in show_irq_affinity()</title>
<updated>2024-08-29T14:42:06+00:00</updated>
<author>
<name>Jinjie Ruan</name>
<email>ruanjinjie@huawei.com</email>
</author>
<published>2024-08-29T11:15:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=9012f84e1c5b653c282b7a6cca81454ecf7c5a0a'/>
<id>9012f84e1c5b653c282b7a6cca81454ecf7c5a0a</id>
<content type='text'>
irq_move_pending() encapsulates irqd_is_setaffinity_pending() depending on
CONFIG_GENERIC_PENDING_IRQ.

Replace the open coded #ifdeffery with it.

Signed-off-by: Jinjie Ruan &lt;ruanjinjie@huawei.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/all/20240829111522.230595-1-ruanjinjie@huawei.com

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
irq_move_pending() encapsulates irqd_is_setaffinity_pending() depending on
CONFIG_GENERIC_PENDING_IRQ.

Replace the open coded #ifdeffery with it.

Signed-off-by: Jinjie Ruan &lt;ruanjinjie@huawei.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/all/20240829111522.230595-1-ruanjinjie@huawei.com

</pre>
</div>
</content>
</entry>
<entry>
<title>genirq/proc: Correctly set file permissions for affinity control files</title>
<updated>2024-08-29T14:41:42+00:00</updated>
<author>
<name>Jeff Xie</name>
<email>jeff.xie@linux.dev</email>
</author>
<published>2024-08-25T13:19:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c7718e5c76d49b5bb394265383ae51f766d5dd3a'/>
<id>c7718e5c76d49b5bb394265383ae51f766d5dd3a</id>
<content type='text'>
The kernel already knows at the time of interrupt allocation whether
affinity of an interrupt can be controlled by userspace or not.

It still creates all related procfs control files with read/write
permissions. That's inconsistent and non-intuitive for system
administrators and tools.

Therefore set the file permissions to read-only for such interrupts.

[ tglx: Massage change log, fixed UP build ]

Signed-off-by: Jeff Xie &lt;jeff.xie@linux.dev&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/all/20240825131911.107119-1-jeff.xie@linux.dev
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The kernel already knows at the time of interrupt allocation whether
affinity of an interrupt can be controlled by userspace or not.

It still creates all related procfs control files with read/write
permissions. That's inconsistent and non-intuitive for system
administrators and tools.

Therefore set the file permissions to read-only for such interrupts.

[ tglx: Massage change log, fixed UP build ]

Signed-off-by: Jeff Xie &lt;jeff.xie@linux.dev&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/all/20240825131911.107119-1-jeff.xie@linux.dev
</pre>
</div>
</content>
</entry>
<entry>
<title>genirq/proc: Simplify irqdesc::kstat_irqs handling further</title>
<updated>2024-06-03T09:48:29+00:00</updated>
<author>
<name>Adrian Huang</name>
<email>ahuang12@lenovo.com</email>
</author>
<published>2024-05-15T10:06:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=540588772ed0b191969c7902bf90d561ab0035be'/>
<id>540588772ed0b191969c7902bf90d561ab0035be</id>
<content type='text'>
Interrupts which have no action and chained interrupts can be
ignored due to the following reasons (as per tglx's comment):

  1) Interrupts which have no action are completely uninteresting as
     there is no real information attached.

  2) Chained interrupts do not have a count at all.

So there is no point to evaluate the number of accounted interrupts before
checking for non-requested or chained interrupts.

Remove the any_count logic and simply check whether the interrupt
descriptor has the kstat_irqs member populated.

[ tglx: Adapted to upstream changes ]

Suggested-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Adrian Huang &lt;ahuang12@lenovo.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Tested-by: Jiwei Sun &lt;sunjw10@lenovo.com&gt;
Link: https://lore.kernel.org/r/20240515100632.1419-1-ahuang12@lenovo.com
Link: https://lore.kernel.org/lkml/87h6f0knau.ffs@tglx/
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Interrupts which have no action and chained interrupts can be
ignored due to the following reasons (as per tglx's comment):

  1) Interrupts which have no action are completely uninteresting as
     there is no real information attached.

  2) Chained interrupts do not have a count at all.

So there is no point to evaluate the number of accounted interrupts before
checking for non-requested or chained interrupts.

Remove the any_count logic and simply check whether the interrupt
descriptor has the kstat_irqs member populated.

[ tglx: Adapted to upstream changes ]

Suggested-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Adrian Huang &lt;ahuang12@lenovo.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Tested-by: Jiwei Sun &lt;sunjw10@lenovo.com&gt;
Link: https://lore.kernel.org/r/20240515100632.1419-1-ahuang12@lenovo.com
Link: https://lore.kernel.org/lkml/87h6f0knau.ffs@tglx/
</pre>
</div>
</content>
</entry>
</feed>
