Skip to contentSkip to conversation

of: Add OF_DMA_DEFAULT_COHERENT & select it on powerpc

PATCH Applied Michael Ellerman 9 participants 20 messages Jan 26, 2020 – Feb 8, 2020

Subsystems (6)
lore
Share & tools
lore

Michael Ellerman

author reviewer
#0 lore raw

PATCH 1/1 of: Add OF_DMA_DEFAULT_COHERENT & select it on powerpc

There's an OF helper called of_dma_is_coherent(), which checks if a device has a "dma-coherent" property to see if the device is coherent for DMA.

But on some platforms devices are coherent by default, and on some platforms it's not possible to update existing device trees to add the "dma-coherent" property.

So add a Kconfig symbol to allow arch code to tell of_dma_is_coherent() that devices are coherent by default, regardless of the presence of the property.

Select that symbol on powerpc when NOT_COHERENT_CACHE is not set, ie. when the system has a coherent cache.

Fixes 92ea637edea3 ("of: introduce of_dma_is_coherent() helper")
Cc [email protected] # v3.16+
---
 arch/powerpc/Kconfig | 1 +
 drivers/of/Kconfig   | 4 ++++
 drivers/of/address.c | 6 +++++-
 3 files changed, 10 insertions(+), 1 deletion(-)
arch/powerpc/Kconfig +1 -0
index 1ec34e16ed65..19f5aa8ac9a3 100644
@@ -238,6 +238,7 @@ config PPC
 	select NEED_DMA_MAP_STATE		if PPC64 || NOT_COHERENT_CACHE
 	select NEED_SG_DMA_LENGTH
 	select OF
+	select OF_DMA_DEFAULT_COHERENT		if !NOT_COHERENT_CACHE
 	select OF_EARLY_FLATTREE
 	select OLD_SIGACTION			if PPC32
 	select OLD_SIGSUSPEND
drivers/of/Kconfig +4 -0
index 37c2ccbefecd..d91618641be6 100644
@@ -103,4 +103,8 @@ config OF_OVERLAY
 config OF_NUMA
 	bool
 
+config OF_DMA_DEFAULT_COHERENT
+	# arches should select this if DMA is coherent by default for OF devices
+	bool
+
 endif # OF
drivers/of/address.c +5 -1
index 99c1b8058559..e8a39c3ec4d4 100644
@@ -995,12 +995,16 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz
  * @np:	device node
  *
  * It returns true if "dma-coherent" property was found
- * for this device in DT.
+ * for this device in the DT, or if DMA is coherent by
+ * default for OF devices on the current platform.
  */
 bool of_dma_is_coherent(struct device_node *np)
 {
 	struct device_node *node = of_node_get(np);
 
+	if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT))
+		return true;
+
 	while (node) {
 		if (of_property_read_bool(node, "dma-coherent")) {
 			of_node_put(node);
Signature · 1 line
2.21.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Michael Ellerman

There's an OF helper called of_dma_is_coherent(), which checks if a device has a "dma-coherent" property to see if the device is coherent for DMA.

But on some platforms devices are coherent by default, and on some platforms it's not possible to update existing device trees to add the "dma-coherent" property.

So add a Kconfig symbol to allow arch code to tell of_dma_is_coherent() that devices are coherent by default, regardless of the presence of the property.

Quoted 8 lines

Select that symbol on powerpc when NOT_COHERENT_CACHE is not set, ie. when the system has a coherent cache.

Fixes 92ea637edea3 ("of: introduce of_dma_is_coherent() helper")
Cc [email protected] # v3.16+

Thanks Michael for helping out fixing and this! The patch looks good to me.

Kind regards
Uffe

Quoted 56 lines
---
 arch/powerpc/Kconfig | 1 +
 drivers/of/Kconfig   | 4 ++++
 drivers/of/address.c | 6 +++++-
 3 files changed, 10 insertions(+), 1 deletion(-)
arch/powerpc/Kconfig +1 -0
index 1ec34e16ed65..19f5aa8ac9a3 100644
@@ -238,6 +238,7 @@ config PPC
        select NEED_DMA_MAP_STATE               if PPC64 || NOT_COHERENT_CACHE
        select NEED_SG_DMA_LENGTH
        select OF
+       select OF_DMA_DEFAULT_COHERENT          if !NOT_COHERENT_CACHE
        select OF_EARLY_FLATTREE
        select OLD_SIGACTION                    if PPC32
        select OLD_SIGSUSPEND
drivers/of/Kconfig +4 -0
index 37c2ccbefecd..d91618641be6 100644
@@ -103,4 +103,8 @@ config OF_OVERLAY
 config OF_NUMA
        bool
 
+config OF_DMA_DEFAULT_COHERENT
+       # arches should select this if DMA is coherent by default for OF devices
+       bool
+
 endif # OF
drivers/of/address.c +5 -2
index 99c1b8058559..e8a39c3ec4d4 100644
@@ -995,12 +995,16 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz
  * @np:        device node
  *
  * It returns true if "dma-coherent" property was found
- * for this device in DT.
+ * for this device in the DT, or if DMA is coherent by
+ * default for OF devices on the current platform.
  */
 bool of_dma_is_coherent(struct device_node *np)
 {
        struct device_node *node = of_node_get(np);
 
+       if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT))
+               return true;
+
        while (node) {
                if (of_property_read_bool(node, "dma-coherent")) {
                        of_node_put(node);
--

2.21.1

author reviewer
#2 lore raw
Quoted 22 lines · Ulf Hansson
Quoted 12 lines · Michael Ellerman

There's an OF helper called of_dma_is_coherent(), which checks if a device has a "dma-coherent" property to see if the device is coherent for DMA.

But on some platforms devices are coherent by default, and on some platforms it's not possible to update existing device trees to add the "dma-coherent" property.

So add a Kconfig symbol to allow arch code to tell of_dma_is_coherent() that devices are coherent by default, regardless of the presence of the property.

Quoted 8 lines

Select that symbol on powerpc when NOT_COHERENT_CACHE is not set, ie. when the system has a coherent cache.

Fixes 92ea637edea3 ("of: introduce of_dma_is_coherent() helper")
Cc [email protected] # v3.16+
Quoted 3 lines

Thanks Michael for helping out fixing and this! The patch looks good to me.

Thanks for the review.

cheers

#3 lore raw

Latest Git kernel: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

In reply to Ulf Hansson

Hello,

We regularly compile and test Linux kernels every day during the merge window. Since Thuesday we have very high CPU loads because of the avahi daemon on our desktop Linux systems (Ubuntu, Debian etc).

Error message: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Could you please test the latest Git kernel?

It is possible to deactivate the avahi daemon with the following lines in the file "/etc/avahi/avahi-daemon.conf":

use-ipv4=no
use-ipv6=no

But this is only a temporary solution.

Thanks,
Christian

#4 lore raw

Re: Latest Git kernel: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

[might be network related, so adding netdev mailing list]

Quoted 17 lines · Christian Zigotzky

Hello,

We regularly compile and test Linux kernels every day during the merge window. Since Thuesday we have very high CPU loads because of the avahi daemon on our desktop Linux systems (Ubuntu, Debian etc).

Error message: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Could you please test the latest Git kernel?

It is possible to deactivate the avahi daemon with the following lines in the file "/etc/avahi/avahi-daemon.conf":

use-ipv4=no
use-ipv6=no

But this is only a temporary solution.

Thanks,
Christian

Signature · 1 line
~Randy
#5 lore raw

Re: Latest Git kernel: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

In reply to Christian Zigotzky

Hello,

Le 02/02/2020 à 01:08, Christian Zigotzky a écrit :

Quoted 5 lines

Hello,

We regularly compile and test Linux kernels every day during the merge window. Since Thuesday we have very high CPU loads because of the avahi daemon on our desktop Linux systems (Ubuntu, Debian etc).

Error message: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Do you know which ioctl, on which device ?
Can you take a trace of running avahi-daemon with 'strace' ?

Can you bisect ?

Christophe

#6 lore raw

Re: Latest Git kernel: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Quoted 7 lines · Christophe Leroy

Hello,

Le 02/02/2020 à 01:08, Christian Zigotzky a écrit :

Quoted 4 lines

Hello,

We regularly compile and test Linux kernels every day during the merge window. Since Thuesday we have very high CPU loads because of the avahi daemon on our desktop Linux systems (Ubuntu, Debian etc).

Quoted 8 lines
Quoted 1 line

Error message: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Do you know which ioctl, on which device ?
Can you take a trace of running avahi-daemon with 'strace' ?

Can you bisect ?

Christophe

Hi Christophe,
Hi All,

I figured out that the avahi-daemon has a problem with the IPv6 address of a network interface since the Git kernel from Thursday. (Log attached) This generates high CPU usage because the avahi-daemon tries to access the IPv6 address again and again and thereby it produces a lot of log messages.

We figured out that the networking updates aren't responsible for this issue because we created a test kernel on Wednesday. The issue is somewhere in the commits from Wednesday night to Thursday (CET).

Please compile the latest Git kernel and test it with a desktop linux distribution for example Ubuntu. In my point of view there are many desktop machines affected. Many server systems don't use the avahi daemon so they aren't affected.

It's possible to deactivate the access to the IPv6 address with the following line in the file "/etc/avahi/avahi-daemon.conf":

use-ipv6=no

After a reboot the CPU usage is normal again. This is only a temporary solution.

Unfortunately I don't have the time for bisecting next week. I have a lot of other work to do. In my point of view it is very important that you also compile the latest Git kernels. Then you will see the issue and then you have a better possibility to fix the issue.

Thanks,
Christian

Kernel 5.5.0: journalctl | grep -i avahi

Feb 02 13:57:05 DC1 systemd[1]: Listening on Avahi mDNS/DNS-SD Stack Activation Socket.
Feb 02 13:57:05 DC1 systemd[1]: Starting Avahi mDNS/DNS-SD Stack...
Feb 02 13:57:05 DC1 avahi-daemon[4314]: Found user 'avahi' (UID 112) and group 'avahi' (GID 122).
Feb 02 13:57:05 DC1 avahi-daemon[4314]: Successfully dropped root privileges.
Feb 02 13:57:05 DC1 avahi-daemon[4314]: avahi-daemon 0.6.32-rc starting up.
Feb 02 13:57:06 DC1 systemd[1]: Started Avahi DNS Configuration Daemon.
Feb 02 13:57:06 DC1 avahi-daemon[4314]: Successfully called chroot().
Feb 02 13:57:06 DC1 avahi-daemon[4314]: Successfully dropped remaining capabilities.
Feb 02 13:57:06 DC1 avahi-daemon[4314]: No service file found in /etc/avahi/services.
Feb 02 13:57:06 DC1 avahi-daemon[4314]: Network interface enumeration completed.
Feb 02 13:57:06 DC1 avahi-daemon[4314]: Server startup complete. Host name is DC1.local. Local service cookie is 3202921551.
Feb 02 13:57:06 DC1 avahi-daemon[4314]: Failed to parse address 'localhost', ignoring.
Feb 02 13:57:06 DC1 avahi-dnsconfd[4487]: Successfully connected to Avahi daemon.
Feb 02 13:57:06 DC1 systemd[1]: Started Avahi mDNS/DNS-SD Stack.
Feb 02 13:57:07 DC1 root[4749]: /etc/dhcp/dhclient-enter-hooks.d/avahi-autoipd returned non-zero exit status 1
Feb 02 13:57:07 DC1 avahi-daemon[4314]: Joining mDNS multicast group on interface enP4096p4s4.IPv4 with address 192.168.178.47.
Feb 02 13:57:07 DC1 avahi-daemon[4314]: New relevant interface enP4096p4s4.IPv4 for mDNS.
Feb 02 13:57:07 DC1 avahi-daemon[4314]: Registering new address record for 192.168.178.47 on enP4096p4s4.IPv4.
Feb 02 13:57:09 DC1 avahi-daemon[4314]: Joining mDNS multicast group on interface enP4096p4s4.IPv6 with address fe80::250:fcff:fecb:5181.
Feb 02 13:57:09 DC1 avahi-daemon[4314]: New relevant interface enP4096p4s4.IPv6 for mDNS.
Feb 02 13:57:09 DC1 avahi-daemon[4314]: Registering new address record for fe80::250:fcff:fecb:5181 on enP4096p4s4.*.
Feb 02 13:57:10 DC1 avahi-daemon[4314]: Leaving mDNS multicast group on interface enP4096p4s4.IPv6 with address fe80::250:fcff:fecb:5181.
Feb 02 13:57:10 DC1 avahi-daemon[4314]: Joining mDNS multicast group on interface enP4096p4s4.IPv6 with address 2a02:8109:89c0:ebfc:250:fcff:fecb:5181.
Feb 02 13:57:10 DC1 avahi-daemon[4314]: Registering new address record for 2a02:8109:89c0:ebfc:250:fcff:fecb:5181 on enP4096p4s4.*.
Feb 02 13:57:10 DC1 avahi-daemon[4314]: Withdrawing address record for fe80::250:fcff:fecb:5181 on enP4096p4s4.

------

Latest Git kernel (5.6): journalctl | grep -i avahi

Feb 02 14:04:04 DC1 systemd[1]: Listening on Avahi mDNS/DNS-SD Stack Activation Socket.
Feb 02 14:04:05 DC1 systemd[1]: Started Avahi DNS Configuration Daemon.
Feb 02 14:04:05 DC1 systemd[1]: Starting Avahi mDNS/DNS-SD Stack...
Feb 02 14:04:05 DC1 avahi-daemon[4573]: Found user 'avahi' (UID 112) and group 'avahi' (GID 122).
Feb 02 14:04:05 DC1 avahi-daemon[4573]: Successfully dropped root privileges.
Feb 02 14:04:05 DC1 avahi-daemon[4573]: avahi-daemon 0.6.32-rc starting up.
Feb 02 14:04:05 DC1 avahi-daemon[4573]: Successfully called chroot().
Feb 02 14:04:05 DC1 avahi-daemon[4573]: Successfully dropped remaining capabilities.
Feb 02 14:04:05 DC1 avahi-daemon[4573]: No service file found in /etc/avahi/services.
Feb 02 14:04:05 DC1 avahi-daemon[4573]: Network interface enumeration completed.
Feb 02 14:04:05 DC1 avahi-daemon[4573]: Server startup complete. Host name is DC1.local. Local service cookie is 285370789.
Feb 02 14:04:05 DC1 avahi-daemon[4573]: Failed to parse address 'localhost', ignoring.
Feb 02 14:04:05 DC1 avahi-dnsconfd[4425]: Successfully connected to Avahi daemon.
Feb 02 14:04:05 DC1 root[4642]: /etc/dhcp/dhclient-enter-hooks.d/avahi-autoipd returned non-zero exit status 1
Feb 02 14:04:06 DC1 systemd[1]: Started Avahi mDNS/DNS-SD Stack.
Feb 02 14:04:06 DC1 avahi-daemon[4573]: Joining mDNS multicast group on interface enP4096p4s4.IPv4 with address 192.168.178.47.
Feb 02 14:04:06 DC1 avahi-daemon[4573]: New relevant interface enP4096p4s4.IPv4 for mDNS.
Feb 02 14:04:06 DC1 avahi-daemon[4573]: Registering new address record for 192.168.178.47 on enP4096p4s4.IPv4.
Feb 02 14:04:08 DC1 avahi-daemon[4573]: Joining mDNS multicast group on interface enP4096p4s4.IPv6 with address fe80::250:fcff:fecb:5181.
Feb 02 14:04:08 DC1 avahi-daemon[4573]: New relevant interface enP4096p4s4.IPv6 for mDNS.
Feb 02 14:04:08 DC1 avahi-daemon[4573]: Registering new address record for fe80::250:fcff:fecb:5181 on enP4096p4s4.*.
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
...
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:09 DC1 avahi-daemon[4573]: Leaving mDNS multicast group on interface enP4096p4s4.IPv6 with address fe80::250:fcff:fecb:5181.
Feb 02 14:04:09 DC1 avahi-daemon[4573]: Joining mDNS multicast group on interface enP4096p4s4.IPv6 with address 2a02:8109:89c0:ebfc:250:fcff:fecb:5181.
Feb 02 14:04:09 DC1 avahi-daemon[4573]: Registering new address record for 2a02:8109:89c0:ebfc:250:fcff:fecb:5181 on enP4096p4s4.*.
Feb 02 14:04:09 DC1 avahi-daemon[4573]: Withdrawing address record for fe80::250:fcff:fecb:5181 on enP4096p4s4.
Feb 02 14:04:28 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:28 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:28 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:28 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:28 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:28 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
...
Feb 02 14:04:29 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:29 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:29 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:35 DC1 systemd-journald[2489]: Suppressed 513915 messages from /system.slice/avahi-daemon.service
Feb 02 14:04:35 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:35 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:35 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device

------

Latest Git kernel (5.6): systemctl status avahi-daemon
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2020-02-02 14:04:06 CET; 11min ago
Main PID: 4573 (avahi-daemon)
Status: "avahi-daemon 0.6.32-rc starting up."
CGroup: /system.slice/avahi-daemon.service

           ├─4573 avahi-daemon: running [DC1.local]
           └─4581 avahi-daemon: chroot helper
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device

------

maintainer
#7 lore raw

Re: Latest Git kernel: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Quoted 28 lines · Christian Zigotzky
Quoted 12 lines · Christophe Leroy

Hello,

Le 02/02/2020 à 01:08, Christian Zigotzky a écrit :

Quoted 8 lines

Hello,

We regularly compile and test Linux kernels every day during the merge window. Since Thuesday we have very high CPU loads because of the avahi daemon on our desktop Linux systems (Ubuntu, Debian etc).

Error message: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Quoted 6 lines

Do you know which ioctl, on which device ?
Can you take a trace of running avahi-daemon with 'strace' ?

Can you bisect ?

Christophe

Hi Christophe,
Hi All,

I figured out that the avahi-daemon has a problem with the IPv6 address of a network interface since the Git kernel from Thursday. (Log attached) This generates high CPU usage because the avahi-daemon tries to access the IPv6 address again and again and thereby it produces a lot of log messages.

Quoted 3 lines

We figured out that the networking updates aren't responsible for this issue because we created a test kernel on Wednesday. The issue is somewhere in the commits from Wednesday night to Thursday (CET).

FWIW Thursday is when the latest networking pull came in, so could well be networking related..

Quoted 17 lines

Please compile the latest Git kernel and test it with a desktop linux distribution for example Ubuntu. In my point of view there are many desktop machines affected. Many server systems don't use the avahi daemon so they aren't affected.

It's possible to deactivate the access to the IPv6 address with the following line in the file "/etc/avahi/avahi-daemon.conf":

use-ipv6=no

After a reboot the CPU usage is normal again. This is only a temporary solution.

Unfortunately I don't have the time for bisecting next week. I have a lot of other work to do. In my point of view it is very important that you also compile the latest Git kernels. Then you will see the issue and then you have a better possibility to fix the issue.

#8 lore raw

Re: Latest Git kernel: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Quoted 28 lines · Jakub Kicinski
Quoted 27 lines · Christian Zigotzky
Quoted 9 lines · Christophe Leroy

Hello,

Le 02/02/2020 à 01:08, Christian Zigotzky a écrit :

Quoted 6 lines

Hello,

We regularly compile and test Linux kernels every day during the merge window. Since Thursday we have very high CPU loads because of the avahi daemon on our desktop Linux systems (Ubuntu, Debian etc).

Quoted 8 lines
Quoted 2 lines

Error message: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Do you know which ioctl, on which device ?
Can you take a trace of running avahi-daemon with 'strace' ?

Can you bisect ?

Christophe

Hi Christophe,
Hi All,

I figured out that the avahi-daemon has a problem with the IPv6 address of a network interface since the Git kernel from Thursday. (Log attached) This generates high CPU usage because the avahi-daemon tries to access the IPv6 address again and again and thereby it produces a lot of log messages.

Quoted 23 lines
Quoted 3 lines

We figured out that the networking updates aren't responsible for this issue because we created a test kernel on Wednesday. The issue is somewhere in the commits from Wednesday night to Thursday (CET).

FWIW Thursday is when the latest networking pull came in, so could well be networking related..

Quoted 17 lines

Please compile the latest Git kernel and test it with a desktop linux distribution for example Ubuntu. In my point of view there are many desktop machines affected. Many server systems don't use the avahi daemon so they aren't affected.

It's possible to deactivate the access to the IPv6 address with the following line in the file "/etc/avahi/avahi-daemon.conf":

use-ipv6=no

After a reboot the CPU usage is normal again. This is only a temporary solution.

Unfortunately I don't have the time for bisecting next week. I have a lot of other work to do. In my point of view it is very important that you also compile the latest Git kernels. Then you will see the issue and then you have a better possibility to fix the issue.

Hi All,

The issue still exist in the latest Git kernel. It's a PowerPC issue. I compiled the latest Git kernel on a PC today and there aren't any issues with the avahi daemon. Another Power Mac user reported the same issue on his G5. I tested with the AmigaOne X1000 and X5000 in the last days.

I bisected today but I think the result isn't correct because it founds the other problem with ordering of PCSCSI definition in esp_rev enum. I don't know how to bisect if there is another issue at the same time. Maybe "git bisect skip"?

2086faae3c55a652cfbd369e18ecdb703aacc493 is the first bad commit commit 2086faae3c55a652cfbd369e18ecdb703aacc493
Author: Kars de Jong <[email protected]>
Date:   Tue Nov 19 21:20:20 2019 +0100

    scsi: esp_scsi: Correct ordering of PCSCSI definition in esp_rev enum

    The order of the definitions in the esp_rev enum is important. The values are used in comparisons for chip features.

    Add a comment to the enum explaining this.

    Also, the actual values for the enum fields are irrelevant, so remove the explicit values (suggested by Geert Uytterhoeven). This makes adding a new field in the middle of the enum easier.

    Finally, move the PCSCSI definition to the right place in the enum. In its previous location, at the end of the enum, the wrong values are written to the CONFIG3 register when used with FAST-SCSI targets.

:040000 040000 cdc128596e33fb60406b5de9b17b79623c187c1a 48ceab06439f95285e8b30181e75f9a68c25fcb5 M    drivers

Cheers,
Christian

#9 lore raw

Re: Latest Git kernel: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

In reply to Jakub Kicinski

Kernel 5.5 PowerPC is also affected.

— Christian

Christian Zigotzky wrote:

Hi All,

The issue with the avahi-daemon still exist in the latest Git kernel. It's a PowerPC issue. I compiled the latest Git kernel on a PC today and there aren't any issues with the avahi daemon. Another Power Mac user reported the same issue on his G5. I tested with the AmigaOne X1000 and X5000 in the last days.

I bisected today but I think the result isn't correct because it found the other problem with ordering of PCSCSI definition in esp_rev enum. I don't know how to bisect if there is another issue at the same time. Maybe "git bisect skip"?

2086faae3c55a652cfbd369e18ecdb703aacc493 is the first bad commit commit 2086faae3c55a652cfbd369e18ecdb703aacc493

Author: Kars de Jong <[email protected]>
Date:   Tue Nov 19 21:20:20 2019 +0100

scsi: esp_scsi: Correct ordering of PCSCSI definition in esp_rev enum

The order of the definitions in the esp_rev enum is important. The values are used in comparisons for chip features.

Add a comment to the enum explaining this.

Also, the actual values for the enum fields are irrelevant, so remove the explicit values (suggested by Geert Uytterhoeven). This makes adding a new field in the middle of the enum easier.

Finally, move the PCSCSI definition to the right place in the enum. In its previous location, at the end of the enum, the wrong values are written to the CONFIG3 register when used with FAST-SCSI targets.

:040000 040000 cdc128596e33fb60406b5de9b17b79623c187c1a 48ceab06439f95285e8b30181e75f9a68c25fcb5 M drivers

author reviewer
#10 lore raw

Re: Latest Git kernel: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Quoted 1 line · Christian Zigotzky

Kernel 5.5 PowerPC is also affected.

I don't know what you mean by that. What sha are you talking about?

I have a system with avahi running and everything's fine.

  # grep use- /etc/avahi/avahi-daemon.conf 
  use-ipv4=yes
  use-ipv6=yes
  # systemctl status -l --no-pager avahi-daemon
  ● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
     Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2020-02-06 14:55:34 AEDT; 38min ago
   Main PID: 1884 (avahi-daemon)
     Status: "avahi-daemon 0.7 starting up."
     CGroup: /system.slice/avahi-daemon.service
             ├─1884 avahi-daemon: running [mpe-ubuntu-le.local]
             └─1888 avahi-daemon: chroot helper
  Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for fe80::5054:ff:fe66:2a19 on eth0.*.
  Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for 10.61.141.81 on eth0.IPv4.
  Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for ::1 on lo.*.
  Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for 127.0.0.1 on lo.IPv4.
  Feb 06 14:55:34 mpe-ubuntu-le systemd[1]: Started Avahi mDNS/DNS-SD Stack.
  Feb 06 14:55:35 mpe-ubuntu-le avahi-daemon[1884]: Server startup complete. Host name is mpe-ubuntu-le.local. Local service cookie is 3972418141.
  Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Leaving mDNS multicast group on interface eth0.IPv6 with address fe80::5054:ff:fe66:2a19.
  Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Joining mDNS multicast group on interface eth0.IPv6 with address fd69:d75f:b8b5:61:5054:ff:fe66:2a19.
  Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for fd69:d75f:b8b5:61:5054:ff:fe66:2a19 on eth0.*.
  Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Withdrawing address record for fe80::5054:ff:fe66:2a19 on eth0.
  # uname -r
  5.5.0-gcc-8.2.0

The key question is what ioctl is it complaining about. You should be able to find that via strace.

cheers

Quoted 33 lines

Christian Zigotzky wrote:

Hi All,

The issue with the avahi-daemon still exist in the latest Git kernel. It's a PowerPC issue. I compiled the latest Git kernel on a PC today and there aren't any issues with the avahi daemon. Another Power Mac user reported the same issue on his G5. I tested with the AmigaOne X1000 and X5000 in the last days.

I bisected today but I think the result isn't correct because it found the other problem with ordering of PCSCSI definition in esp_rev enum. I don't know how to bisect if there is another issue at the same time. Maybe "git bisect skip"?

2086faae3c55a652cfbd369e18ecdb703aacc493 is the first bad commit commit 2086faae3c55a652cfbd369e18ecdb703aacc493

Author: Kars de Jong <[email protected]>
Date:   Tue Nov 19 21:20:20 2019 +0100

scsi: esp_scsi: Correct ordering of PCSCSI definition in esp_rev enum

The order of the definitions in the esp_rev enum is important. The values are used in comparisons for chip features.

Add a comment to the enum explaining this.

Also, the actual values for the enum fields are irrelevant, so remove the explicit values (suggested by Geert Uytterhoeven). This makes adding a new field in the middle of the enum easier.

Finally, move the PCSCSI definition to the right place in the enum. In its previous location, at the end of the enum, the wrong values are written to the CONFIG3 register when used with FAST-SCSI targets.

:040000 040000 cdc128596e33fb60406b5de9b17b79623c187c1a 48ceab06439f95285e8b30181e75f9a68c25fcb5 M drivers

#11 lore raw

Re: Latest Git kernel: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Quoted 31 lines · Michael Ellerman
Quoted 1 line · Christian Zigotzky

Kernel 5.5 PowerPC is also affected.

I don't know what you mean by that. What sha are you talking about?

I have a system with avahi running and everything's fine.

   # grep use- /etc/avahi/avahi-daemon.conf
   use-ipv4=yes
   use-ipv6=yes
   # systemctl status -l --no-pager avahi-daemon
   ● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
      Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
      Active: active (running) since Thu 2020-02-06 14:55:34 AEDT; 38min ago
    Main PID: 1884 (avahi-daemon)
      Status: "avahi-daemon 0.7 starting up."
      CGroup: /system.slice/avahi-daemon.service
              ├─1884 avahi-daemon: running [mpe-ubuntu-le.local]
              └─1888 avahi-daemon: chroot helper
   Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for fe80::5054:ff:fe66:2a19 on eth0.*.
   Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for 10.61.141.81 on eth0.IPv4.
   Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for ::1 on lo.*.
   Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for 127.0.0.1 on lo.IPv4.
   Feb 06 14:55:34 mpe-ubuntu-le systemd[1]: Started Avahi mDNS/DNS-SD Stack.
   Feb 06 14:55:35 mpe-ubuntu-le avahi-daemon[1884]: Server startup complete. Host name is mpe-ubuntu-le.local. Local service cookie is 3972418141.
   Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Leaving mDNS multicast group on interface eth0.IPv6 with address fe80::5054:ff:fe66:2a19.
   Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Joining mDNS multicast group on interface eth0.IPv6 with address fd69:d75f:b8b5:61:5054:ff:fe66:2a19.
   Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for fd69:d75f:b8b5:61:5054:ff:fe66:2a19 on eth0.*.
   Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Withdrawing address record for fe80::5054:ff:fe66:2a19 on eth0.
Quoted 9 lines
   # uname -r
   5.5.0-gcc-8.2.0

The key question is what ioctl is it complaining about. You should be able to find that via strace.

cheers

Hello Michael,

Sorry it isn't true that the kernel 5.5 is also affected. A Power Mac G5 user told me that but this isn't correct. I compiled and tested the stable kernel 5.5.1 and 5.5.2 today and both kernels don't have the issue with the avahi daemon. Could you please also test the latest Git kernel?

strace /usr/sbin/avahi-daemon

...
poll([{fd=4, events=POLLIN}, {fd=16, events=POLLIN}, {fd=15, events=POLLIN}, {fd=14, events=POLLIN}, {fd=13, events=POLLIN}, {fd=12, events=POLLIN}, {fd=11, events=POLLIN}, {fd=10, events=POLLIN}, {fd=9, events=POLLIN}, {fd=8, events=POLLIN}, {fd=6, events=POLLIN}], 11, 65) = 2 ([{fd=12, revents=POLLIN}, {fd=9, revents=POLLIN}]) ioctl(12, FIONREAD, 0xffba6f24)         = -1 ENOTTY (Inappropriate ioctl for device)
write(2, "ioctl(): Inappropriate ioctl for"..., 39ioctl(): Inappropriate ioctl for device) = 39
write(2, "\n", 1
)                       = 1
...

Thanks,
Christian

author reviewer
#12 lore raw

Re: Latest Git kernel: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Quoted 39 lines · Christian Zigotzky
Quoted 38 lines · Michael Ellerman
Quoted 1 line · Christian Zigotzky

Kernel 5.5 PowerPC is also affected.

I don't know what you mean by that. What sha are you talking about?

I have a system with avahi running and everything's fine.

   # grep use- /etc/avahi/avahi-daemon.conf
   use-ipv4=yes
   use-ipv6=yes
   # systemctl status -l --no-pager avahi-daemon
   ● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
      Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
      Active: active (running) since Thu 2020-02-06 14:55:34 AEDT; 38min ago
    Main PID: 1884 (avahi-daemon)
      Status: "avahi-daemon 0.7 starting up."
      CGroup: /system.slice/avahi-daemon.service
              ├─1884 avahi-daemon: running [mpe-ubuntu-le.local]
              └─1888 avahi-daemon: chroot helper
   Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for fe80::5054:ff:fe66:2a19 on eth0.*.
   Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for 10.61.141.81 on eth0.IPv4.
   Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for ::1 on lo.*.
   Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for 127.0.0.1 on lo.IPv4.
   Feb 06 14:55:34 mpe-ubuntu-le systemd[1]: Started Avahi mDNS/DNS-SD Stack.
   Feb 06 14:55:35 mpe-ubuntu-le avahi-daemon[1884]: Server startup complete. Host name is mpe-ubuntu-le.local. Local service cookie is 3972418141.
   Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Leaving mDNS multicast group on interface eth0.IPv6 with address fe80::5054:ff:fe66:2a19.
   Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Joining mDNS multicast group on interface eth0.IPv6 with address fd69:d75f:b8b5:61:5054:ff:fe66:2a19.
   Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for fd69:d75f:b8b5:61:5054:ff:fe66:2a19 on eth0.*.
   Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Withdrawing address record for fe80::5054:ff:fe66:2a19 on eth0.
   # uname -r
   5.5.0-gcc-8.2.0

The key question is what ioctl is it complaining about. You should be able to find that via strace.

Quoted 8 lines
Quoted 2 lines

cheers

Hello Michael,

Sorry it isn't true that the kernel 5.5 is also affected. A Power Mac G5 user told me that but this isn't correct. I compiled and tested the stable kernel 5.5.1 and 5.5.2 today and both kernels don't have the issue with the avahi daemon.

OK good to know.

Quoted 1 line

Could you please also test the latest Git kernel?

That's literally all I ever do.

The problem here is you didn't tell me you were running a big endian distro, which uses compat mode.

In hindsight I should have thought of that.

Now that I know that, I can reproduce the bug:

  Feb 08 23:31:12 mpe-ubuntu-be avahi-daemon[24819]: ioctl(): Inappropriate ioctl for device
  Feb 08 23:31:12 mpe-ubuntu-be avahi-daemon[24819]: ioctl(): Inappropriate ioctl for device
  Feb 08 23:31:12 mpe-ubuntu-be avahi-daemon[24819]: ioctl(): Inappropriate ioctl for device
  Feb 08 23:31:12 mpe-ubuntu-be avahi-daemon[24819]: ioctl(): Inappropriate ioctl for device

But it seems you've already identified the problem commit, thanks for bisecting.

I'm sure Arnd will be able to fix it now that you've identified the problematic commit.

cheers

Quoted 18 lines

strace /usr/sbin/avahi-daemon

...
poll([{fd=4, events=POLLIN}, {fd=16, events=POLLIN}, {fd=15, events=POLLIN}, {fd=14, events=POLLIN}, {fd=13, events=POLLIN}, {fd=12, events=POLLIN}, {fd=11, events=POLLIN}, {fd=10, events=POLLIN}, {fd=9, events=POLLIN}, {fd=8, events=POLLIN}, {fd=6, events=POLLIN}], 11, 65) = 2 ([{fd=12, revents=POLLIN}, {fd=9, revents=POLLIN}]) ioctl(12, FIONREAD, 0xffba6f24)         = -1 ENOTTY (Inappropriate ioctl for device)
write(2, "ioctl(): Inappropriate ioctl for"..., 39ioctl(): Inappropriate ioctl for device) = 39
write(2, "\n", 1
)                       = 1
...

Thanks,
Christian

#13 lore raw

Latest Git kernel: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

In reply to Michael Ellerman

Hello Arnd,

We regularly compile and test Linux kernels every day during the merge window. Since Thursday last week we have very high CPU usage because of the avahi daemon on our desktop Linux systems (Ubuntu, Debian etc). The avahi daemon produces a lot of the following log message. This generates high CPU usage.

Error message: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

strace /usr/sbin/avahi-daemon:

poll([{fd=4, events=POLLIN}, {fd=16, events=POLLIN}, {fd=15, events=POLLIN}, {fd=14, events=POLLIN}, {fd=13, events=POLLIN}, {fd=12, events=POLLIN}, {fd=11, events=POLLIN}, {fd=10, events=POLLIN}, {fd=9, events=POLLIN}, {fd=8, events=POLLIN}, {fd=6, events=POLLIN}], 11, 65) = 2 ([{fd=12, revents=POLLIN}, {fd=9, revents=POLLIN}]) ioctl(12, FIONREAD, 0xffba6f24)         = -1 ENOTTY (Inappropriate ioctl for device)
write(2, "ioctl(): Inappropriate ioctl for"..., 39ioctl(): Inappropriate ioctl for device) = 39
write(2, "\n", 1
)                       = 1

----------------------

I bisected the latest kernel source code today.

Result:

77b9040195dea3fcddf19e136c9e99a501351778 is the first bad commit commit 77b9040195dea3fcddf19e136c9e99a501351778
Author: Arnd Bergmann <[email protected]>
Date:   Wed Nov 27 21:25:36 2019 +0100

    compat_ioctl: simplify the implementation

    Now that both native and compat ioctl syscalls are in the same file, a couple of simplifications can be made, bringing the implementation closer together:

    - do_vfs_ioctl(), ioctl_preallocate(), and compat_ioctl_preallocate() can become static, allowing the compiler to optimize better

    - slightly update the coding style for consistency between the functions.

    - rather than listing each command in two switch statements for the compat case, just call a single function that has all the common commands.

    As a side-effect, FS_IOC_RESVSP/FS_IOC_RESVSP64 are now available to x86 compat tasks, along with FS_IOC_RESVSP_32/FS_IOC_RESVSP64_32. This is harmless for i386 emulation, and can be considered a bugfix for x32 emulation, which never supported these in the past.

:040000 040000 5c4b62f4d1bfe643d3bbf9d9a3b50ee50ae0f159 5ca610e3197df96adfcae4f94fceeb496756609b M    fs :040000 040000 086f2e2ac49384988733cbb706243943748c4ce7 b906926e53dfa2e8927629e77a0708dda6f49d31 M    include

----------------------

Link to the first bad commit: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=77b9040195dea3fcddf19e136c9e99a501351778

I was able to revert the first bad commit.

git revert 77b9040195dea3fcddf19e136c9e99a501351778

[master a91dcf9dc14c] Revert "compat_ioctl: simplify the implementation"

 4 files changed, 105 insertions(+), 64 deletions(-)

After that the avahi daemon works without any problems again.

I created a patch today. (attached)

It is also possible to deactivate the avahi daemon with the following lines in the file "/etc/avahi/avahi-daemon.conf":

use-ipv4=no
use-ipv6=no

Could you please check your commit?

Thanks,
Christian

fs/internal.h +6 -0
diff -rupN a/fs/internal.h b/fs/internal.h
@@ -182,6 +182,12 @@ extern void mnt_pin_kill(struct mount *m
  */
 extern const struct dentry_operations ns_dentry_operations;
 
+/*
+ * fs/ioctl.c
+ */
+extern int do_vfs_ioctl(struct file *file, unsigned int fd, unsigned int cmd,
+		    unsigned long arg);
+
 /* direct-io.c: */
 int sb_init_dio_done_wq(struct super_block *sb);
 
fs/ioctl.c +93 -64

272 lines not on this page · raw message

include/linux/falloc.h +2 -0
diff -rupN a/include/linux/falloc.h b/include/linux/falloc.h
@@ -51,6 +51,8 @@ struct space_resv_32 {
 #define FS_IOC_UNRESVSP64_32	_IOW ('X', 43, struct space_resv_32)
 #define FS_IOC_ZERO_RANGE_32	_IOW ('X', 57, struct space_resv_32)
 
+int compat_ioctl_preallocate(struct file *, int, struct space_resv_32 __user *);
+
 #endif
 
 #endif /* _FALLOC_H_ */
include/linux/fs.h +4 -0
diff -rupN a/include/linux/fs.h b/include/linux/fs.h
@@ -2563,6 +2563,10 @@ extern int finish_open(struct file *file
 			int (*open)(struct inode *, struct file *));
 extern int finish_no_open(struct file *file, struct dentry *dentry);
 
+/* fs/ioctl.c */
+
+extern int ioctl_preallocate(struct file *filp, int mode, void __user *argp);
+
 /* fs/dcache.c */
 extern void __init vfs_caches_init_early(void);
 extern void __init vfs_caches_init(void);
#14 lore raw

Re: Latest Git kernel: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Quoted 9 lines · Christian Zigotzky

Hello Arnd,

We regularly compile and test Linux kernels every day during the merge window. Since Thursday last week we have very high CPU usage because of the avahi daemon on our desktop Linux systems (Ubuntu, Debian etc). The avahi daemon produces a lot of the following log message. This generates high CPU usage.

Quoted 4 lines

Error message: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

strace /usr/sbin/avahi-daemon:

Thanks a lot for the detailed analysis, with this I immediately saw what went wrong in my
original commit and I sent you a fix. Please test to ensure that this correctly addresses
the problem.

Arnd

#15 lore raw

Re: Latest Git kernel: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Quoted 20 lines · Arnd Bergmann

On Fri, Feb 7, 2020 at 3:34 PM Christian Zigotzky

Quoted 9 lines · <[email protected]> wrote:

Hello Arnd,

We regularly compile and test Linux kernels every day during the merge window. Since Thursday last week we have very high CPU usage because of the avahi daemon on our desktop Linux systems (Ubuntu, Debian etc). The avahi daemon produces a lot of the following log message. This generates high CPU usage.

Quoted 4 lines

Error message: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

strace /usr/sbin/avahi-daemon:

Quoted 7 lines

Thanks a lot for the detailed analysis, with this I immediately saw what went wrong in my
original commit and I sent you a fix. Please test to ensure that this correctly addresses
the problem.

Arnd

Hi Arnd,

Thanks a lot for your patch! I will test it as soon as possible.

Cheers,
Christian

#16 lore raw

Re: Latest Git kernel: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Quoted 23 lines · Christian Zigotzky
Quoted 23 lines · Arnd Bergmann

On Fri, Feb 7, 2020 at 3:34 PM Christian Zigotzky

Quoted 8 lines · <[email protected]> wrote:

Hello Arnd,

We regularly compile and test Linux kernels every day during the merge window. Since Thursday last week we have very high CPU usage because of the avahi daemon on our desktop Linux systems (Ubuntu, Debian etc). The avahi daemon produces a lot of the following log message. This generates high CPU usage.

Quoted 4 lines

Error message: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

strace /usr/sbin/avahi-daemon:

Thanks a lot for the detailed analysis, with this I immediately saw what went wrong in my
original commit and I sent you a fix. Please test to ensure that this correctly addresses
the problem.

Quoted 7 lines
Quoted 1 line

Arnd

Hi Arnd,

Thanks a lot for your patch! I will test it as soon as possible.

Cheers,
Christian

Hi Arnd,

I successfully compiled the latest Git kernel with your patch today. The avahi daemon works fine now. That means your patch has solved the avahi issue.

Thanks for your patch and have a nice weekend!

Cheers,
Christian

#17 lore raw
In reply to Michael Ellerman

+ Frank (me)

Quoted 74 lines · Michael Ellerman

There's an OF helper called of_dma_is_coherent(), which checks if a device has a "dma-coherent" property to see if the device is coherent for DMA.

But on some platforms devices are coherent by default, and on some platforms it's not possible to update existing device trees to add the "dma-coherent" property.

So add a Kconfig symbol to allow arch code to tell of_dma_is_coherent() that devices are coherent by default, regardless of the presence of the property.

Select that symbol on powerpc when NOT_COHERENT_CACHE is not set, ie. when the system has a coherent cache.

Fixes 92ea637edea3 ("of: introduce of_dma_is_coherent() helper")
Cc [email protected] # v3.16+
---
 arch/powerpc/Kconfig | 1 +
 drivers/of/Kconfig   | 4 ++++
 drivers/of/address.c | 6 +++++-
 3 files changed, 10 insertions(+), 1 deletion(-)
arch/powerpc/Kconfig +1 -0
index 1ec34e16ed65..19f5aa8ac9a3 100644
@@ -238,6 +238,7 @@ config PPC
 	select NEED_DMA_MAP_STATE		if PPC64 || NOT_COHERENT_CACHE
 	select NEED_SG_DMA_LENGTH
 	select OF
+	select OF_DMA_DEFAULT_COHERENT		if !NOT_COHERENT_CACHE
 	select OF_EARLY_FLATTREE
 	select OLD_SIGACTION			if PPC32
 	select OLD_SIGSUSPEND
drivers/of/Kconfig +4 -0
index 37c2ccbefecd..d91618641be6 100644
@@ -103,4 +103,8 @@ config OF_OVERLAY
 config OF_NUMA
 	bool
 
+config OF_DMA_DEFAULT_COHERENT
+	# arches should select this if DMA is coherent by default for OF devices
+	bool
+
 endif # OF
drivers/of/address.c +5 -1
index 99c1b8058559..e8a39c3ec4d4 100644
@@ -995,12 +995,16 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz
  * @np:	device node
  *
  * It returns true if "dma-coherent" property was found
- * for this device in DT.
+ * for this device in the DT, or if DMA is coherent by
+ * default for OF devices on the current platform.
  */
 bool of_dma_is_coherent(struct device_node *np)
 {
 	struct device_node *node = of_node_get(np);
 
+	if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT))
+		return true;
+
 	while (node) {
 		if (of_property_read_bool(node, "dma-coherent")) {
 			of_node_put(node);
maintainer Applied
#18 lore raw
In reply to Michael Ellerman
Quoted 20 lines · Michael Ellerman

There's an OF helper called of_dma_is_coherent(), which checks if a device has a "dma-coherent" property to see if the device is coherent for DMA.

But on some platforms devices are coherent by default, and on some platforms it's not possible to update existing device trees to add the "dma-coherent" property.

So add a Kconfig symbol to allow arch code to tell of_dma_is_coherent() that devices are coherent by default, regardless of the presence of the property.

Select that symbol on powerpc when NOT_COHERENT_CACHE is not set, ie. when the system has a coherent cache.

Fixes 92ea637edea3 ("of: introduce of_dma_is_coherent() helper")
Cc [email protected] # v3.16+
Quoted 6 lines
---
 arch/powerpc/Kconfig | 1 +
 drivers/of/Kconfig   | 4 ++++
 drivers/of/address.c | 6 +++++-
 3 files changed, 10 insertions(+), 1 deletion(-)

Applied, thanks.

Rob

author reviewer
#19 lore raw
Quoted 28 lines · Rob Herring
Quoted 20 lines · Michael Ellerman

There's an OF helper called of_dma_is_coherent(), which checks if a device has a "dma-coherent" property to see if the device is coherent for DMA.

But on some platforms devices are coherent by default, and on some platforms it's not possible to update existing device trees to add the "dma-coherent" property.

So add a Kconfig symbol to allow arch code to tell of_dma_is_coherent() that devices are coherent by default, regardless of the presence of the property.

Select that symbol on powerpc when NOT_COHERENT_CACHE is not set, ie. when the system has a coherent cache.

Fixes 92ea637edea3 ("of: introduce of_dma_is_coherent() helper")
Cc [email protected] # v3.16+
Quoted 6 lines
---
 arch/powerpc/Kconfig | 1 +
 drivers/of/Kconfig   | 4 ++++
 drivers/of/address.c | 6 +++++-
 3 files changed, 10 insertions(+), 1 deletion(-)
Quoted 1 line

Applied, thanks.

Thanks.

cheers