diff mbox

linux-generic: timer: check for zero timer resolution

Message ID 1428958907-11382-1-git-send-email-ola.liljedahl@linaro.org
State Accepted
Commit d7f375ed76653ea681fb4ee03d3f100566f810d1
Headers show

Commit Message

Ola Liljedahl April 13, 2015, 9:01 p.m. UTC
Fail to create timer pool with zero timer resolution.
https://bugs.linaro.org/show_bug.cgi?id=1451

Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org>
---
(This document/code contribution attached is provided under the terms of
agreement LES-LTM-21309)

 platform/linux-generic/odp_timer.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Mike Holmes April 13, 2015, 9:27 p.m. UTC | #1
On 13 April 2015 at 17:01, Ola Liljedahl <ola.liljedahl@linaro.org> wrote:

> Fail to create timer pool with zero timer resolution.
> https://bugs.linaro.org/show_bug.cgi?id=1451
>
> Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org>
> ---
> (This document/code contribution attached is provided under the terms of
> agreement LES-LTM-21309)
>
>  platform/linux-generic/odp_timer.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/platform/linux-generic/odp_timer.c
> b/platform/linux-generic/odp_timer.c
> index 500f7f1..e5391dc 100644
> --- a/platform/linux-generic/odp_timer.c
> +++ b/platform/linux-generic/odp_timer.c
> @@ -691,6 +691,11 @@ odp_timer_pool_create(const char *name,
>                       const odp_timer_pool_param_t *param)
>  {
>         /* Verify that buffer pool can be used for timeouts */
> +       /* Verify that we have a valid (non-zero) timer resolution */
> +       if (param->res_ns == 0) {
> +               __odp_errno = EINVAL;
> +               return NULL;
> +       }
>         odp_timer_pool_t tp = odp_timer_pool_new(name, param);
>         return tp;
>  }
>

Running this case again gives a somewhat opaque error message.

odp_shared_memory.c:265:odp_shm_reserve(): msg_pool:
No huge pages, fall back to normal pages,
check: /proc/sys/vm/nr_hugepages.
odp_timer_test.c:394:main():Timer pool create failed.

I wonder if that is informative enough given it was caused by passing a
specific command line argument  "-r0" - maybe the help should say -r0 is
illegal ?

I think there be an error message to the user as soon as they pass 0 for r.



> --
> 1.9.1
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
Ola Liljedahl April 13, 2015, 9:43 p.m. UTC | #2
On 13 April 2015 at 23:27, Mike Holmes <mike.holmes@linaro.org> wrote:

>
>
> On 13 April 2015 at 17:01, Ola Liljedahl <ola.liljedahl@linaro.org> wrote:
>
>> Fail to create timer pool with zero timer resolution.
>> https://bugs.linaro.org/show_bug.cgi?id=1451
>>
>> Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org>
>> ---
>> (This document/code contribution attached is provided under the terms of
>> agreement LES-LTM-21309)
>>
>>  platform/linux-generic/odp_timer.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/platform/linux-generic/odp_timer.c
>> b/platform/linux-generic/odp_timer.c
>> index 500f7f1..e5391dc 100644
>> --- a/platform/linux-generic/odp_timer.c
>> +++ b/platform/linux-generic/odp_timer.c
>> @@ -691,6 +691,11 @@ odp_timer_pool_create(const char *name,
>>                       const odp_timer_pool_param_t *param)
>>  {
>>         /* Verify that buffer pool can be used for timeouts */
>> +       /* Verify that we have a valid (non-zero) timer resolution */
>> +       if (param->res_ns == 0) {
>> +               __odp_errno = EINVAL;
>> +               return NULL;
>> +       }
>>         odp_timer_pool_t tp = odp_timer_pool_new(name, param);
>>         return tp;
>>  }
>>
>
> Running this case again gives a somewhat opaque error message.
>
> odp_shared_memory.c:265:odp_shm_reserve(): msg_pool:
> No huge pages, fall back to normal pages,
> check: /proc/sys/vm/nr_hugepages.
> odp_timer_test.c:394:main():Timer pool create failed.
>
> I wonder if that is informative enough given it was caused by passing a
> specific command line argument  "-r0" - maybe the help should say -r0 is
> illegal ?
>
Possibly the timer example should check for obviously invalid parameters
(although I don't think every illegal parameter and illegal combinations of
parameters can be checked for by the application). This would be an
enhancement of the timer example and not the original bug fix of the
linux-generic timer implementation. So another patch.


>
> I think there be an error message to the user as soon as they pass 0 for r.
>
>
>
>> --
>> 1.9.1
>>
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> https://lists.linaro.org/mailman/listinfo/lng-odp
>>
>
>
>
> --
> Mike Holmes
> Technical Manager - Linaro Networking Group
> Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs
>
>
>
diff mbox

Patch

diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c
index 500f7f1..e5391dc 100644
--- a/platform/linux-generic/odp_timer.c
+++ b/platform/linux-generic/odp_timer.c
@@ -691,6 +691,11 @@  odp_timer_pool_create(const char *name,
 		      const odp_timer_pool_param_t *param)
 {
 	/* Verify that buffer pool can be used for timeouts */
+	/* Verify that we have a valid (non-zero) timer resolution */
+	if (param->res_ns == 0) {
+		__odp_errno = EINVAL;
+		return NULL;
+	}
 	odp_timer_pool_t tp = odp_timer_pool_new(name, param);
 	return tp;
 }