From: Philippe Gerum <rpm@xenomai.org>
To: "Chen, Hongzhan" <hongzhan.chen@intel.com>
Cc: "xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [PATCH 2/2] cobalt/rtdm: introduce new interface to init timer
Date: Thu, 11 Mar 2021 09:48:19 +0100 [thread overview]
Message-ID: <87pn06gjos.fsf@xenomai.org> (raw)
In-Reply-To: <MWHPR11MB1710261A737D070A6CC0190CF2909@MWHPR11MB1710.namprd11.prod.outlook.com>
Chen, Hongzhan <hongzhan.chen@intel.com> writes:
>>-----Original Message-----
>>From: Philippe Gerum <rpm@xenomai.org>
>>Sent: Thursday, March 11, 2021 4:14 PM
>>To: Chen, Hongzhan <hongzhan.chen@intel.com>
>>Cc: xenomai@xenomai.org
>>Subject: Re: [PATCH 2/2] cobalt/rtdm: introduce new interface to init timer
>>
>>
>>hongzha1 via Xenomai <xenomai@xenomai.org> writes:
>>
>>> Initialise timer on specified cpu.
>>>
>>> Signed-off-by: hongzha1 <hongzhan.chen@intel.com>
>>>
>>> diff --git a/include/cobalt/kernel/rtdm/driver.h b/include/cobalt/kernel/rtdm/driver.h
>>> index 5406e54a5..d58df33ce 100644
>>> --- a/include/cobalt/kernel/rtdm/driver.h
>>> +++ b/include/cobalt/kernel/rtdm/driver.h
>>> @@ -966,6 +966,9 @@ enum rtdm_timer_mode {
>>> int rtdm_timer_init(rtdm_timer_t *timer, rtdm_timer_handler_t handler,
>>> const char *name);
>>>
>>> +int rtdm_timer_init_on_cpu(rtdm_timer_t *timer, rtdm_timer_handler_t handler,
>>> + const char *name, int cpu);
>>> +
>>> void rtdm_timer_destroy(rtdm_timer_t *timer);
>>>
>>> int rtdm_timer_start(rtdm_timer_t *timer, nanosecs_abs_t expiry,
>>> diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c
>>> index 069a442e5..268bf8fbf 100644
>>> --- a/kernel/cobalt/rtdm/drvlib.c
>>> +++ b/kernel/cobalt/rtdm/drvlib.c
>>> @@ -583,15 +583,44 @@ EXPORT_SYMBOL_GPL(rtdm_task_busy_sleep);
>>> int rtdm_timer_init(rtdm_timer_t *timer, rtdm_timer_handler_t handler,
>>> const char *name)
>>> {
>>> + /*cpu0 is used when no affinity was given*/
>>> + return rtdm_timer_init_on_cpu(timer, handler, name, 0);
>>> +}
>>> +EXPORT_SYMBOL_GPL(rtdm_timer_init);
>>> +
>>> +/**
>>> + * @brief Initialise a timer on specified cpu
>>> + *
>>> + * @param[in,out] timer Timer handle
>>> + * @param[in] handler Handler to be called on timer expiry
>>> + * @param[in] name Optional timer name
>>> + * @param[in] cpu that run on
>>> + *
>>> + * @return 0 on success, otherwise negative error code
>>> + *
>>> + * @coretags{task-unrestricted}
>>> + */
>>> +int rtdm_timer_init_on_cpu(rtdm_timer_t *timer,
>>> + rtdm_timer_handler_t handler, const char *name, int cpu)
>>> +{
>>> + struct xnsched *sched;
>>> +
>>> if (!realtime_core_enabled())
>>> return -ENOSYS;
>>>
>>> - xntimer_init((timer), &nkclock, handler, NULL, XNTIMER_IGRAVITY);
>>> + if (!cpu_online(cpu))
>>> + return -EINVAL;
>>> +
>>> + sched = xnsched_struct(cpu);
>>> + if (sched == NULL)
>>> + return -EINVAL;
>>> +
>>> + xntimer_init((timer), &nkclock, handler, sched, XNTIMER_IGRAVITY);
>> xntimer_set_name((timer), (name));
>> +
>> return 0;
>> }
>> -
>> -EXPORT_SYMBOL_GPL(rtdm_timer_init);
>> +EXPORT_SYMBOL_GPL(rtdm_timer_init_on_cpu);
>>
>> /**
>> * @brief Destroy a timer
>>
>>Do we have a potential user for this call?
>
> Yes. Latmus is supposed to use it. Evl Latmus is calling evl_init_timer_on_cpu in
> create_uthread_runner. So I think Xenomai should have corresponding one.
>
Agreed. Today, the timer benchmarking code can only land on CPU0,
regardless of the affinity instruction given to 'latency', which is
wrong. So we need this new call in order to be able to place the
sampling timer on the tested CPU.
--
Philippe.
next prev parent reply other threads:[~2021-03-11 8:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-11 6:48 [PATCH 1/2] cobalt/rtdm: introduce new interfaces to init task hongzha1
2021-03-11 6:48 ` [PATCH 2/2] cobalt/rtdm: introduce new interface to init timer hongzha1
2021-03-11 8:13 ` Philippe Gerum
2021-03-11 8:21 ` Chen, Hongzhan
2021-03-11 8:48 ` Philippe Gerum [this message]
2021-03-11 9:05 ` Philippe Gerum
2021-03-11 8:32 ` [PATCH 1/2] cobalt/rtdm: introduce new interfaces to init task Philippe Gerum
-- strict thread matches above, loose matches on Subject: below --
2021-03-12 2:42 hongzha1
2021-03-12 2:42 ` [PATCH 2/2] cobalt/rtdm: introduce new interface to init timer hongzha1
2021-03-14 16:22 ` Philippe Gerum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pn06gjos.fsf@xenomai.org \
--to=rpm@xenomai.org \
--cc=hongzhan.chen@intel.com \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.