um: vector: use GFP_ATOMIC under spin lock
Subsystems (5)
PATCH 1/1 um: vector: use GFP_ATOMIC under spin lock
A spin lock is taken here so we should use GFP_ATOMIC.
--- arch/um/drivers/vector_kern.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/um/drivers/vector_kern.c +2 -2
@@ -1402,7 +1402,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,kfree (vp->bpf->filter); vp->bpf->filter =NULL ; }else { - vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_KERNEL ); + vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_ATOMIC );if (vp->bpf =NULL ) {netdev_err (dev,"failed to allocate memory for firmware\n" ); goto flash_fail;
@@ -1414,7 +1414,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,if (request_firmware (&fw, efl->data, &vdevice->pdev.dev)) goto flash_fail; - vp->bpf->filter =kmemdup (fw->data, fw->size,GFP_KERNEL ); + vp->bpf->filter =kmemdup (fw->data, fw->size,GFP_ATOMIC );if (!vp->bpf->filter) goto free_buffer;
Quoted 25 lines · Wei Yongjun
A spin lock is taken here so we should use
GFP_ATOMIC.Fixes 9807019a62dc ("um: Loadable BPF "Firmware" for vector drivers")Signed-off-by Wei Yongjun <[email protected]>--- arch/um/drivers/vector_kern.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/um/drivers/vector_kern.c +1
-1@@ -1402,7 +1402,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,kfree (vp->bpf->filter); vp->bpf->filter =NULL ; }else { - vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_KERNEL ); + vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_ATOMIC );if (vp->bpf =NULL ) {netdev_err (dev,"failed to allocate memory for firmware\n" ); goto flash_fail;
arch/um/drivers/vector_kern.c static int vector_net_load_bpf_flash(struct net_device *dev, · line 1420
Quoted 8 lines
arch/um/drivers/vector_kern.c +1
-1@@ -1414,7 +1414,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,if (request_firmware (&fw, efl->data, &vdevice->pdev.dev)) goto flash_fail; - vp->bpf->filter =kmemdup (fw->data, fw->size,GFP_KERNEL ); + vp->bpf->filter =kmemdup (fw->data, fw->size,GFP_ATOMIC );if (!vp->bpf->filter) goto free_buffer;
Quoted 5 lines
_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Signature · 3 lines
Anton R. Ivanov Cambridgegreys Limited. Registered in England. Company Number 10273661 https://www.cambridgegreys.com/
Quoted 22 lines · Wei Yongjun
A spin lock is taken here so we should use
GFP_ATOMIC.Fixes 9807019a62dc ("um: Loadable BPF "Firmware" for vector drivers")Signed-off-by Wei Yongjun <[email protected]>--- arch/um/drivers/vector_kern.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/um/drivers/vector_kern.c +1
-1@@ -1402,7 +1402,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,kfree (vp->bpf->filter); vp->bpf->filter =NULL ; }else { - vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_KERNEL ); + vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_ATOMIC );if (vp->bpf =NULL ) {netdev_err (dev,"failed to allocate memory for firmware\n" ); goto flash_fail;
arch/um/drivers/vector_kern.c static int vector_net_load_bpf_flash(struct net_device *dev, · line 1414
Quoted 1 line
arch/um/drivers/vector_kern.c +0
-0@@ -1414,7 +1414,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,if (request_firmware (&fw, efl->data, &vdevice->pdev.dev))
^^^^^^^^^^^^^^^^
Is it really possible to call request_firmware() while holding a spin_lock? I was so sure that read from the disk.
regards,
dan carpenter
Quoted 8 lines
arch/um/drivers/vector_kern.c +1
-1goto flash_fail; - vp->bpf->filter =kmemdup (fw->data, fw->size,GFP_KERNEL ); + vp->bpf->filter =kmemdup (fw->data, fw->size,GFP_ATOMIC );if (!vp->bpf->filter) goto free_buffer;
Anton Ivanov
maintainerQuoted 26 lines · Dan Carpenter
Quoted 22 lines · Wei Yongjun
A spin lock is taken here so we should use
GFP_ATOMIC.Fixes 9807019a62dc ("um: Loadable BPF "Firmware" for vector drivers")Signed-off-by Wei Yongjun <[email protected]>--- arch/um/drivers/vector_kern.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/um/drivers/vector_kern.c +1
-1@@ -1402,7 +1402,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,kfree (vp->bpf->filter); vp->bpf->filter =NULL ; }else { - vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_KERNEL ); + vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_ATOMIC );if (vp->bpf =NULL ) {netdev_err (dev,"failed to allocate memory for firmware\n" ); goto flash_fail;arch/um/drivers/vector_kern.c static int vector_net_load_bpf_flash(struct net_device *dev, · line 1414
Quoted 1 line
arch/um/drivers/vector_kern.c +0
-0@@ -1414,7 +1414,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,if (request_firmware (&fw, efl->data, &vdevice->pdev.dev))^^^^^^^^^^^^^^^^
Quoted 2 lines
Is it really possible to call
request_firmware()while holding aspin_lock? I was so sure that read from the disk.
Works, I tested the patch quite a few times.
Quoted 18 lines
regards,
dan carpenterarch/um/drivers/vector_kern.c static int vector_net_load_bpf_flash(struct net_device *dev,
Quoted 8 lines
arch/um/drivers/vector_kern.c +1
-1goto flash_fail; - vp->bpf->filter =kmemdup (fw->data, fw->size,GFP_KERNEL ); + vp->bpf->filter =kmemdup (fw->data, fw->size,GFP_ATOMIC );if (!vp->bpf->filter) goto free_buffer;_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Signature · 3 lines
Anton R. Ivanov Cambridgegreys Limited. Registered in England. Company Number 10273661 https://www.cambridgegreys.com/
Quoted 29 lines · Anton Ivanov
Quoted 26 lines · Dan Carpenter
Quoted 22 lines · Wei Yongjun
A spin lock is taken here so we should use
GFP_ATOMIC.Fixes 9807019a62dc ("um: Loadable BPF "Firmware" for vector drivers")Signed-off-by Wei Yongjun <[email protected]>--- arch/um/drivers/vector_kern.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/um/drivers/vector_kern.c +1
-1@@ -1402,7 +1402,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,kfree (vp->bpf->filter); vp->bpf->filter =NULL ; }else { - vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_KERNEL ); + vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_ATOMIC );if (vp->bpf =NULL ) {netdev_err (dev,"failed to allocate memory for firmware\n" ); goto flash_fail;arch/um/drivers/vector_kern.c static int vector_net_load_bpf_flash(struct net_device *dev, · line 1414
Quoted 1 line
arch/um/drivers/vector_kern.c +0
-0@@ -1414,7 +1414,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,if (request_firmware (&fw, efl->data, &vdevice->pdev.dev))^^^^^^^^^^^^^^^^
Quoted 5 lines
Quoted 2 lines
Is it really possible to call
request_firmware()while holding aspin_lock? I was so sure that read from the disk.Works, I tested the patch quite a few times.
Do you have CONFIG_DEBUG_ATOMIC_SLEEP enabled? The GFP_KERNEL calls should have triggered a warning if so.
regards,
dan carpenter
Anton Ivanov
maintainerQuoted 30 lines · Dan Carpenter
Quoted 29 lines · Anton Ivanov
Quoted 26 lines · Dan Carpenter
Quoted 22 lines · Wei Yongjun
A spin lock is taken here so we should use
GFP_ATOMIC.Fixes 9807019a62dc ("um: Loadable BPF "Firmware" for vector drivers")Signed-off-by Wei Yongjun <[email protected]>--- arch/um/drivers/vector_kern.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/um/drivers/vector_kern.c +1
-1@@ -1402,7 +1402,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,kfree (vp->bpf->filter); vp->bpf->filter =NULL ; }else { - vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_KERNEL ); + vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_ATOMIC );if (vp->bpf =NULL ) {netdev_err (dev,"failed to allocate memory for firmware\n" ); goto flash_fail;arch/um/drivers/vector_kern.c static int vector_net_load_bpf_flash(struct net_device *dev, · line 1414
Quoted 1 line
arch/um/drivers/vector_kern.c +0
-0@@ -1414,7 +1414,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,if (request_firmware (&fw, efl->data, &vdevice->pdev.dev))^^^^^^^^^^^^^^^^
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Is it really possible to call
request_firmware()while holding aspin_lock? I was so sure that read from the disk.Works, I tested the patch quite a few times.
Do you have
CONFIG_DEBUG_ATOMIC_SLEEPenabled? TheGFP_KERNELcalls should have triggered a warning if so.
I do not think we can use that in um.
config DEBUG_ATOMIC_SLEEP
bool "Sleep inside atomic section checking" select PREEMPT_COUNT
depends on DEBUG_KERNEL
depends on !ARCH_NO_PREEMPT
In arch/um/Kconfig
select ARCH_NO_PREEMPT
Brgds,
Quoted 10 lines
regards,
dan carpenter_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Signature · 3 lines
Anton R. Ivanov Cambridgegreys Limited. Registered in England. Company Number 10273661 https://www.cambridgegreys.com/
Richard Weinberger
maintainer----- Ursprüngliche Mail -----
Quoted 38 lines
Von: "anton ivanov" <[email protected]>
An: "Dan Carpenter" <[email protected]>, "Wei Yongjun" <[email protected]>
CC: "Song Liu" <[email protected]>, "Daniel Borkmann" <[email protected]>, "kernel-janitors" <[email protected]>, "richard" <[email protected]>, "Jeff Dike" <[email protected]>, "linux-um" <[email protected]>, "Alexei Starovoitov" <[email protected]>, "netdev" <[email protected]>, [email protected], "Martin KaFai Lau" <[email protected]>
Gesendet: Donnerstag, 28. November 2019 09:18:30
Betreff: Re: [PATCH -next] um: vector: useGFP_ATOMICunder spin lockQuoted 28 lines · Dan Carpenter
Quoted 23 lines · Wei Yongjun
A spin lock is taken here so we should use
GFP_ATOMIC.Fixes 9807019a62dc ("um: Loadable BPF "Firmware" for vector drivers")Signed-off-by Wei Yongjun <[email protected]>--- arch/um/drivers/vector_kern.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/um/drivers/vector_kern.c +1
-1@@ -1402,7 +1402,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,kfree (vp->bpf->filter); vp->bpf->filter =NULL ; }else { - vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_KERNEL ); + vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_ATOMIC );if (vp->bpf =NULL ) {netdev_err (dev,"failed to allocate memory for firmware\n" );goto
flash_fail;arch/um/drivers/vector_kern.c static int vector_net_load_bpf_flash(struct net_device · line 1415
Quoted 2 lines
arch/um/drivers/vector_kern.c +0
-0@@ -1414,7 +1414,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev, if (request_firmware(&fw, efl->data, &vdevice->pdev.dev))^^^^^^^^^^^^^^^^
Quoted 4 lines
Quoted 2 lines
Is it really possible to call
request_firmware()while holding aspin_lock? I was so sure that read from the disk.Works, I tested the patch quite a few times.
It works because of the nature of UML ->no SMP or PREEMPT. But better request the firmware before taking the spinlock. request_firmware() can block.
Same for the kmalloc(), just allocate the buffer before and then assign the pointer under the lock. That way you don't need GFP_ATOMIC.
Thanks,
//richard
Anton Ivanov
maintainerQuoted 42 lines · Richard Weinberger
----- Ursprüngliche Mail -----
Quoted 41 lines
Von: "anton ivanov" <[email protected]>
An: "Dan Carpenter" <[email protected]>, "Wei Yongjun" <[email protected]>
CC: "Song Liu" <[email protected]>, "Daniel Borkmann" <[email protected]>, "kernel-janitors" <[email protected]>, "richard" <[email protected]>, "Jeff Dike" <[email protected]>, "linux-um" <[email protected]>, "Alexei Starovoitov" <[email protected]>, "netdev" <[email protected]>, [email protected], "Martin KaFai Lau" <[email protected]>
Gesendet: Donnerstag, 28. November 2019 09:18:30
Betreff: Re: [PATCH -next] um: vector: useGFP_ATOMICunder spin lockQuoted 30 lines · Dan Carpenter
Quoted 23 lines · Wei Yongjun
A spin lock is taken here so we should use
GFP_ATOMIC.Fixes 9807019a62dc ("um: Loadable BPF "Firmware" for vector drivers")Signed-off-by Wei Yongjun <[email protected]>--- arch/um/drivers/vector_kern.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/um/drivers/vector_kern.c +1
-1@@ -1402,7 +1402,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,kfree (vp->bpf->filter); vp->bpf->filter =NULL ; }else { - vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_KERNEL ); + vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_ATOMIC );if (vp->bpf =NULL ) {netdev_err (dev,"failed to allocate memory for firmware\n" );goto flash_fail;arch/um/drivers/vector_kern.c static int vector_net_load_bpf_flash(struct net_device · line 1415
Quoted 2 lines
arch/um/drivers/vector_kern.c +0
-0@@ -1414,7 +1414,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev, if (request_firmware(&fw, efl->data, &vdevice->pdev.dev))^^^^^^^^^^^^^^^^Is it really possible to call
request_firmware()while holding aspin_lock? I was so sure that read from the disk.
Quoted 7 lines
Quoted 1 line
Works, I tested the patch quite a few times.
It works because of the nature of UML ->no SMP or PREEMPT. But better request the firmware before taking the spinlock.
request_firmware()can block.
Same for thekmalloc(), just allocate the buffer before and then assign the pointer under the lock. That way you don't needGFP_ATOMIC.
Ack.
I will make an incremental on top of the existing patch (as that is already in -next
Brgds,
Quoted 9 lines
Thanks,
//richard_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Signature · 3 lines
Anton R. Ivanov Cambridgegreys Limited. Registered in England. Company Number 10273661 https://www.cambridgegreys.com/