linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq()
       [not found] ` <20230627110025.vgtplc6nluiiuvoh@pengutronix.de>
@ 2023-06-30 11:11   ` Thomas Gleixner
  2023-07-03  9:13     ` Yangtao Li
                       ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Thomas Gleixner @ 2023-06-30 11:11 UTC (permalink / raw)
  To: Uwe Kleine-König, Yangtao Li
  Cc: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, shawnguo, s.hauer,
	kernel, festevam, linux-imx, agross, andersson, konrad.dybcio,
	thara.gopinath, heiko, mcoquelin.stm32, alexandre.torgue,
	thierry.reding, jonathanh, matthias.bgg,
	angelogioacchino.delregno, srinivas.pandruvada,
	DLG-Adam.Ward.opensource, shangxiaojing, bchihi, wenst,
	hayashi.kunihiko, niklas.soderlund+renesas, chi.minghao,
	johan+linaro, jernej.skrabec, linux-pm, linux-arm-msm,
	linux-kernel, linux-rockchip, linux-mediatek, linux-tegra,
	linux-stm32, linux-arm-kernel

On Tue, Jun 27 2023 at 13:00, Uwe Kleine-König wrote:
> On Tue, Jun 27, 2023 at 06:12:01PM +0800, Yangtao Li wrote:
>
> While I assume changing to dev_err_probe is a result of my concern that
> no error should be printed when rc=-EPROBEDEFER, my other concern that
> adding an error message to a generic allocation function is a bad idea
> still stands.

I agree in general, but if you actually look at the call sites of
devm_request_threaded_irq() then the vast majority of them print more or
less lousy error messages. A quick grep/sed/awk/sort/uniq revealed

     519 messages total (there are probably more)

     352 unique messages

     323 unique messages after lower casing

         Those 323 are mostly just variants of the same patterns with slight
         modifications in formatting and information provided.

     186 of these messages do not deliver any useful information,
         e.g. "no irq", "

     The most useful one of all is: "could request wakeup irq: %d"

So there is certainly an argument to be made that this particular
function should print a well formatted and informative error message.

It's not a general allocator like kmalloc(). It's specialized and in the
vast majority of cases failing to request the interrupt causes the
device probe to fail. So having proper and consistent information why
the device cannot be used _is_ useful.

Yangtao: The way how this is attempted is not useful at all.

    1) The changelog is word salad and provides 0 rationale

       Also such series require a cover letter...

    2) The dev_err() which is added is not informative at all and cannot
       replace actually useful error messages. It's not that hard to
       make it useful.

    2) Adding the printks unconditionally first will emit two messages
       with different content.

       This is not how such changes are done.

       The proper approach is to create a wrapper function which emits
       the error message:

       wrapper(....., const char *info)
       {
            ret = devm_request_threaded_irq(....);
            if (ret < 0) {
               dev_err(dev, "Failed to request %sinterrupt %u %s %s: %d\n,
                       thread_fn ? "threaded " : "",
                       irq, devname, info ? : "", ret);
            }
            return ret;
       }

       Then convert the callsites over one by one with proper
       changelogs and justification.

       See?

Thanks,

        tglx


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

* Re: [PATCH v2 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq()
  2023-06-30 11:11   ` [PATCH v2 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq() Thomas Gleixner
@ 2023-07-03  9:13     ` Yangtao Li
  2023-07-03  9:53       ` Uwe Kleine-König
  2023-07-03 12:15     ` Yangtao Li
                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Yangtao Li @ 2023-07-03  9:13 UTC (permalink / raw)
  To: Thomas Gleixner, Uwe Kleine-König
  Cc: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, shawnguo, s.hauer,
	kernel, festevam, linux-imx, agross, andersson, konrad.dybcio,
	thara.gopinath, heiko, mcoquelin.stm32, alexandre.torgue,
	thierry.reding, jonathanh, matthias.bgg,
	angelogioacchino.delregno, srinivas.pandruvada,
	DLG-Adam.Ward.opensource, shangxiaojing, bchihi, wenst,
	hayashi.kunihiko, niklas.soderlund+renesas, chi.minghao,
	johan+linaro, jernej.skrabec, linux-pm, linux-arm-msm,
	linux-kernel, linux-rockchip, linux-mediatek, linux-tegra,
	linux-stm32, linux-arm-kernel

Hi,

On 2023/6/30 19:11, Thomas Gleixner wrote:
> On Tue, Jun 27 2023 at 13:00, Uwe Kleine-König wrote:
>> On Tue, Jun 27, 2023 at 06:12:01PM +0800, Yangtao Li wrote:
>>
>> While I assume changing to dev_err_probe is a result of my concern that
>> no error should be printed when rc=-EPROBEDEFER, my other concern that
>> adding an error message to a generic allocation function is a bad idea
>> still stands.
> I agree in general, but if you actually look at the call sites of
> devm_request_threaded_irq() then the vast majority of them print more or
> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>
>       519 messages total (there are probably more)
>
>       352 unique messages
>
>       323 unique messages after lower casing
>
>           Those 323 are mostly just variants of the same patterns with slight
>           modifications in formatting and information provided.
>
>       186 of these messages do not deliver any useful information,
>           e.g. "no irq", "
>
>       The most useful one of all is: "could request wakeup irq: %d"
>
> So there is certainly an argument to be made that this particular
> function should print a well formatted and informative error message.
>
> It's not a general allocator like kmalloc(). It's specialized and in the
> vast majority of cases failing to request the interrupt causes the
> device probe to fail. So having proper and consistent information why
> the device cannot be used _is_ useful.
>
> Yangtao: The way how this is attempted is not useful at all.
>
>      1) The changelog is word salad and provides 0 rationale
>
>         Also such series require a cover letter...
>
>      2) The dev_err() which is added is not informative at all and cannot
>         replace actually useful error messages. It's not that hard to
>         make it useful.
>
>      2) Adding the printks unconditionally first will emit two messages
>         with different content.
>
>         This is not how such changes are done.
>
>         The proper approach is to create a wrapper function which emits
>         the error message:
>
>         wrapper(....., const char *info)
>         {
>              ret = devm_request_threaded_irq(....);
>              if (ret < 0) {
>                 dev_err(dev, "Failed to request %sinterrupt %u %s %s: %d\n,
>                         thread_fn ? "threaded " : "",
>                         irq, devname, info ? : "", ret);
>              }
>              return ret;
>         }
>
>         Then convert the callsites over one by one with proper
>         changelogs and justification.
>
>         See?


Yes, thanks a lot for the suggestion, and v3 has been sent.


MBR,

Yangtao


>
> Thanks,
>
>          tglx


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

* Re: [PATCH v2 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq()
  2023-07-03  9:13     ` Yangtao Li
@ 2023-07-03  9:53       ` Uwe Kleine-König
  2023-07-03 11:37         ` Yangtao Li
  0 siblings, 1 reply; 8+ messages in thread
From: Uwe Kleine-König @ 2023-07-03  9:53 UTC (permalink / raw)
  To: Yangtao Li
  Cc: Thomas Gleixner, heiko, hayashi.kunihiko, rafael, amitk,
	alexandre.torgue, linux-tegra, thierry.reding, jernej.skrabec,
	miquel.raynal, srinivas.pandruvada, festevam, linux-stm32, bchihi,
	florian.fainelli, daniel.lezcano, chi.minghao, jonathanh,
	linux-rockchip, agross, bcm-kernel-feedback-list, linux-imx,
	wenst, rui.zhang, thara.gopinath, kernel, linux-pm, linux-arm-msm,
	s.hauer, linux-mediatek, mmayer, matthias.bgg,
	DLG-Adam.Ward.opensource, johan+linaro, angelogioacchino.delregno,
	linux-arm-kernel, niklas.soderlund+renesas, andersson,
	linux-kernel, shangxiaojing, konrad.dybcio, mcoquelin.stm32,
	shawnguo

[-- Attachment #1: Type: text/plain, Size: 603 bytes --]

Hello,

On Mon, Jul 03, 2023 at 05:13:29PM +0800, Yangtao Li wrote:
> [...] v3 has been sent.

Please make sure that you send a v3 patch series (at least) to the
people who gave you feedback for v2. If you skip people who had general
concerns about the whole series, this might help you in the short run
because they might miss to also criticise v3, but in the long run it
might result in a loss of trust in you.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH v2 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq()
  2023-07-03  9:53       ` Uwe Kleine-König
@ 2023-07-03 11:37         ` Yangtao Li
  0 siblings, 0 replies; 8+ messages in thread
From: Yangtao Li @ 2023-07-03 11:37 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Thomas Gleixner, heiko, hayashi.kunihiko, rafael, amitk,
	alexandre.torgue, linux-tegra, thierry.reding, jernej.skrabec,
	miquel.raynal, srinivas.pandruvada, festevam, linux-stm32, bchihi,
	florian.fainelli, daniel.lezcano, chi.minghao, jonathanh,
	linux-rockchip, agross, bcm-kernel-feedback-list, linux-imx,
	wenst, rui.zhang, thara.gopinath, kernel, linux-pm, linux-arm-msm,
	s.hauer, linux-mediatek, mmayer, matthias.bgg,
	DLG-Adam.Ward.opensource, johan+linaro, angelogioacchino.delregno,
	linux-arm-kernel, niklas.soderlund+renesas, andersson,
	linux-kernel, shangxiaojing, konrad.dybcio, mcoquelin.stm32,
	shawnguo

Hi Uwe,

On 2023/7/3 17:53, Uwe Kleine-König wrote:
> Hello,
>
> On Mon, Jul 03, 2023 at 05:13:29PM +0800, Yangtao Li wrote:
>> [...] v3 has been sent.
> Please make sure that you send a v3 patch series (at least) to the
> people who gave you feedback for v2. If you skip people who had general
> concerns about the whole series, this might help you in the short run
> because they might miss to also criticise v3, but in the long run it
> might result in a loss of trust in you.


Sorry, I'm a little busy. I just added you and Krzysztof Kozlowski in v3.

If others are interested in the follow-up series, please refer to the 
following link:


https://lore.kernel.org/lkml/20230703090455.62101-1-frank.li@vivo.com/


Thx,

Yangtao


>
> Best regards
> Uwe
>


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

* Re: [PATCH v2 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq()
  2023-06-30 11:11   ` [PATCH v2 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq() Thomas Gleixner
  2023-07-03  9:13     ` Yangtao Li
@ 2023-07-03 12:15     ` Yangtao Li
  2023-07-03 12:19     ` Yangtao Li
       [not found]     ` <247a8166-f131-2d07-ec2b-479a4c19297f@vivo.com>
  3 siblings, 0 replies; 8+ messages in thread
From: Yangtao Li @ 2023-07-03 12:15 UTC (permalink / raw)
  To: tglx
  Cc: DLG-Adam.Ward.opensource, agross, alexandre.torgue, amitk,
	andersson, angelogioacchino.delregno, bchihi,
	bcm-kernel-feedback-list, chi.minghao, daniel.lezcano, festevam,
	florian.fainelli, frank.li, hayashi.kunihiko, heiko,
	jernej.skrabec, johan+linaro, jonathanh, kernel, konrad.dybcio,
	linux-arm-kernel, linux-arm-msm, linux-imx, linux-kernel,
	linux-mediatek, linux-pm, linux-rockchip, linux-stm32,
	linux-tegra, matthias.bgg, mcoquelin.stm32, miquel.raynal, mmayer,
	niklas.soderlund+renesas, rafael, rui.zhang, s.hauer,
	shangxiaojing, shawnguo, srinivas.pandruvada, thara.gopinath,
	thierry.reding, u.kleine-koenig, wenst

Hi Krzysztof,

Here. V3 was modified according to tglx's suggestion, if there is any problem, please point out.

Thx,
Yangtao


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

* Re: [PATCH v2 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq()
  2023-06-30 11:11   ` [PATCH v2 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq() Thomas Gleixner
  2023-07-03  9:13     ` Yangtao Li
  2023-07-03 12:15     ` Yangtao Li
@ 2023-07-03 12:19     ` Yangtao Li
       [not found]     ` <247a8166-f131-2d07-ec2b-479a4c19297f@vivo.com>
  3 siblings, 0 replies; 8+ messages in thread
From: Yangtao Li @ 2023-07-03 12:19 UTC (permalink / raw)
  To: krzysztof.kozlowski
  Cc: tglx, DLG-Adam.Ward.opensource, agross, alexandre.torgue, amitk,
	andersson, angelogioacchino.delregno, bchihi,
	bcm-kernel-feedback-list, chi.minghao, daniel.lezcano, festevam,
	florian.fainelli, frank.li, hayashi.kunihiko, heiko,
	jernej.skrabec, johan+linaro, jonathanh, kernel, konrad.dybcio,
	linux-arm-kernel, linux-arm-msm, linux-imx, linux-kernel,
	linux-mediatek, linux-pm, linux-rockchip, linux-stm32,
	linux-tegra, matthias.bgg, mcoquelin.stm32, miquel.raynal, mmayer,
	niklas.soderlund+renesas, rafael, rui.zhang, s.hauer,
	shangxiaojing, shawnguo, srinivas.pandruvada, thara.gopinath,
	thierry.reding, u.kleine-koenig, wenst

+cc krzysztof.kozlowski@linaro.org


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

* Re: [PATCH v2 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq()
       [not found]     ` <247a8166-f131-2d07-ec2b-479a4c19297f@vivo.com>
@ 2023-07-03 12:28       ` Krzysztof Kozlowski
  0 siblings, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-03 12:28 UTC (permalink / raw)
  To: Yangtao Li, Thomas Gleixner, Uwe Kleine-König
  Cc: miquel.raynal, rafael, daniel.lezcano, amitk, rui.zhang, mmayer,
	bcm-kernel-feedback-list, florian.fainelli, shawnguo, s.hauer,
	kernel, festevam, linux-imx, agross, andersson, konrad.dybcio,
	thara.gopinath, heiko, mcoquelin.stm32, alexandre.torgue,
	thierry.reding, jonathanh, matthias.bgg,
	angelogioacchino.delregno, srinivas.pandruvada,
	DLG-Adam.Ward.opensource, shangxiaojing, bchihi, wenst,
	hayashi.kunihiko, niklas.soderlund+renesas, chi.minghao,
	johan+linaro, jernej.skrabec, linux-pm, linux-arm-msm,
	linux-kernel, linux-rockchip, linux-mediatek, linux-tegra,
	linux-stm32, linux-arm-kernel

On 03/07/2023 13:54, Yangtao Li wrote:
> Hi Krzysztof,
> 
> On 2023/6/30 19:11, Thomas Gleixner wrote:
>> On Tue, Jun 27 2023 at 13:00, Uwe Kleine-König wrote:
>>> On Tue, Jun 27, 2023 at 06:12:01PM +0800, Yangtao Li wrote:
>>>
>>> While I assume changing to dev_err_probe is a result of my concern that
>>> no error should be printed when rc=-EPROBEDEFER, my other concern that
>>> adding an error message to a generic allocation function is a bad idea
>>> still stands.
>> I agree in general, but if you actually look at the call sites of
>> devm_request_threaded_irq() then the vast majority of them print more or
>> less lousy error messages. A quick grep/sed/awk/sort/uniq revealed
>>
>>       519 messages total (there are probably more)
>>
>>       352 unique messages
>>
>>       323 unique messages after lower casing
>>
>>           Those 323 are mostly just variants of the same patterns with slight
>>           modifications in formatting and information provided.
>>
>>       186 of these messages do not deliver any useful information,
>>           e.g. "no irq", "
>>
>>       The most useful one of all is: "could request wakeup irq: %d"
>>
>> So there is certainly an argument to be made that this particular
>> function should print a well formatted and informative error message.
>>
>> It's not a general allocator like kmalloc(). It's specialized and in the
>> vast majority of cases failing to request the interrupt causes the
>> device probe to fail. So having proper and consistent information why
>> the device cannot be used _is_ useful.
>>
>> Yangtao: The way how this is attempted is not useful at all.
>>
>>      1) The changelog is word salad and provides 0 rationale
>>
>>         Also such series require a cover letter...
>>
>>      2) The dev_err() which is added is not informative at all and cannot
>>         replace actually useful error messages. It's not that hard to
>>         make it useful.
>>
>>      2) Adding the printks unconditionally first will emit two messages
>>         with different content.
>>
>>         This is not how such changes are done.
>>
>>         The proper approach is to create a wrapper function which emits
>>         the error message:
>>
>>         wrapper(....., const char *info)
>>         {
>>              ret = devm_request_threaded_irq(....);
>>              if (ret < 0) {
>>                 dev_err(dev, "Failed to request %sinterrupt %u %s %s: %d\n,
>>                         thread_fn ? "threaded " : "",
>>                         irq, devname, info ? : "", ret);
>>              }
>>              return ret;
>>         }
> 
> 
> Here.
> 
> V3 was modified according to tglx's suggestion, if there is any problem, 
> please point out.

The comment was about request_thread_irq, not about devres alloc. Don't
mix the places. Really, since when do we print any errors on ENOMEM?

Best regards,
Krzysztof



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

* Re: [PATCH v2 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq()
       [not found] <20230627101215.58798-1-frank.li@vivo.com>
       [not found] ` <20230627110025.vgtplc6nluiiuvoh@pengutronix.de>
@ 2023-07-03 16:07 ` Ahmad Fatoum
  1 sibling, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-07-03 16:07 UTC (permalink / raw)
  To: Yangtao Li, miquel.raynal, rafael, daniel.lezcano, amitk,
	rui.zhang, mmayer, bcm-kernel-feedback-list, florian.fainelli,
	shawnguo, s.hauer, kernel, festevam, linux-imx, agross, andersson,
	konrad.dybcio, thara.gopinath, heiko, mcoquelin.stm32,
	alexandre.torgue, thierry.reding, jonathanh, tglx, matthias.bgg,
	angelogioacchino.delregno, srinivas.pandruvada,
	DLG-Adam.Ward.opensource, shangxiaojing, bchihi, wenst,
	u.kleine-koenig, hayashi.kunihiko, niklas.soderlund+renesas,
	chi.minghao, johan+linaro, jernej.skrabec
  Cc: linux-pm, linux-arm-msm, linux-kernel, linux-rockchip,
	linux-mediatek, linux-tegra, linux-stm32, linux-arm-kernel

On 27.06.23 12:12, Yangtao Li wrote:
> Ensure that all error handling branches print error information. In this
> way, when this function fails, the upper-layer functions can directly
> return an error code without missing debugging information. Otherwise,
> the error message will be printed redundantly or missing.
> 
> There are more than 700 calls to the devm_request_threaded_irq method.
> Most drivers only request one interrupt resource, and these error
> messages are basically the same. If error messages are printed
> everywhere, more than 1000 lines of code can be saved by removing the
> msg in the driver.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>  kernel/irq/devres.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c
> index f6e5515ee077..fcb946ffb7ec 100644
> --- a/kernel/irq/devres.c
> +++ b/kernel/irq/devres.c
> @@ -58,8 +58,10 @@ int devm_request_threaded_irq(struct device *dev, unsigned int irq,
>  
>  	dr = devres_alloc(devm_irq_release, sizeof(struct irq_devres),
>  			  GFP_KERNEL);
> -	if (!dr)
> +	if (!dr) {
> +		dev_err(dev, "Failed to allocate device resource data\n");

Why not use dev_err_probe too? Could turn this block into a oneliner.

>  		return -ENOMEM;
> +	}
>  
>  	if (!devname)
>  		devname = dev_name(dev);
> @@ -67,6 +69,7 @@ int devm_request_threaded_irq(struct device *dev, unsigned int irq,
>  	rc = request_threaded_irq(irq, handler, thread_fn, irqflags, devname,
>  				  dev_id);
>  	if (rc) {
> +		dev_err_probe(dev, rc, "Failed to request threaded irq%d: %d\n", irq, rc);

No need to format rc with %d. dev_err_probe will already do this for you.

>  		devres_free(dr);
>  		return rc;
>  	}

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

end of thread, other threads:[~2023-07-03 16:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20230627101215.58798-1-frank.li@vivo.com>
     [not found] ` <20230627110025.vgtplc6nluiiuvoh@pengutronix.de>
2023-06-30 11:11   ` [PATCH v2 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq() Thomas Gleixner
2023-07-03  9:13     ` Yangtao Li
2023-07-03  9:53       ` Uwe Kleine-König
2023-07-03 11:37         ` Yangtao Li
2023-07-03 12:15     ` Yangtao Li
2023-07-03 12:19     ` Yangtao Li
     [not found]     ` <247a8166-f131-2d07-ec2b-479a4c19297f@vivo.com>
2023-07-03 12:28       ` Krzysztof Kozlowski
2023-07-03 16:07 ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).