Gary-Hobson commented on code in PR #8525: URL: https://github.com/apache/nuttx/pull/8525#discussion_r1108085589
########## drivers/note/note_lastsched_driver.c: ########## @@ -0,0 +1,397 @@ +/**************************************************************************** + * drivers/note/note_lastsched_driver.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <inttypes.h> +#include <stdatomic.h> +#include <syslog.h> + +#include <nuttx/arch.h> +#include <nuttx/note/note_driver.h> +#include <nuttx/sched.h> +#include <nuttx/sched_note.h> +#include <sched/sched.h> + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static void note_lastsched_start(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +static void note_lastsched_stop(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH +static void note_lastsched_suspend(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +static void note_lastsched_resume(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +# ifdef CONFIG_SMP +static void note_lastsched_cpu_start(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, int cpu); +static void note_lastsched_cpu_started(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +static void note_lastsched_cpu_pause(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, int cpu); +static void note_lastsched_cpu_paused(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +static void note_lastsched_cpu_resume(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, int cpu); +static void note_lastsched_cpu_resumed(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +# endif +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION +static void note_lastsched_premption(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, bool locked); +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION +static void note_lastsched_csection(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, bool enter); +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS +static void note_spinlock(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, FAR volatile void *spinlock, + int type); +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL +static void note_lastsched_syscall_enter(FAR struct note_driver_s *drv, + int nr, int argc, va_list *ap); +static void note_lastsched_syscall_leave(FAR struct note_driver_s *drv, + int nr, uintptr_t result); +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER +static void note_lastsched_irqhandler(FAR struct note_driver_s *drv, int irq, + FAR void *handler, bool enter); +#endif + +struct note_lastsched_chunk_s +{ + uint32_t systick; + uint32_t cpu_pid; + enum note_type_e type; + void *args; +}; + +struct note_lastsched_s +{ + uint32_t freq; + size_t index; + struct timespec ts; + struct note_lastsched_chunk_s + buffer[CONFIG_DRIVER_NOTE_LASTSCHED_NBUFFERS]; +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct note_lastsched_s g_note_lastsched; + +static const struct note_driver_ops_s g_note_lastsched_ops = +{ + NULL, + note_lastsched_start, + note_lastsched_stop, +#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH + note_lastsched_suspend, + note_lastsched_resume, +# ifdef CONFIG_SMP + note_lastsched_cpu_start, + note_lastsched_cpu_started, + note_lastsched_cpu_pause, + note_lastsched_cpu_paused, + note_lastsched_cpu_resume, + note_lastsched_cpu_resumed, +# endif +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION + note_lastsched_premption, +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION + note_lastsched_csection, +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS + note_spinlock, +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL + note_lastsched_syscall_enter, + note_lastsched_syscall_leave, +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER + note_lastsched_irqhandler, +#endif +}; + +static const FAR char *note_type_string[] = Review Comment: done ########## drivers/note/note_lastsched_driver.c: ########## @@ -0,0 +1,397 @@ +/**************************************************************************** + * drivers/note/note_lastsched_driver.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <inttypes.h> +#include <stdatomic.h> +#include <syslog.h> + +#include <nuttx/arch.h> +#include <nuttx/note/note_driver.h> +#include <nuttx/sched.h> +#include <nuttx/sched_note.h> +#include <sched/sched.h> + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static void note_lastsched_start(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +static void note_lastsched_stop(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH +static void note_lastsched_suspend(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +static void note_lastsched_resume(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +# ifdef CONFIG_SMP +static void note_lastsched_cpu_start(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, int cpu); +static void note_lastsched_cpu_started(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +static void note_lastsched_cpu_pause(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, int cpu); +static void note_lastsched_cpu_paused(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +static void note_lastsched_cpu_resume(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, int cpu); +static void note_lastsched_cpu_resumed(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +# endif +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION +static void note_lastsched_premption(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, bool locked); +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION +static void note_lastsched_csection(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, bool enter); +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS +static void note_spinlock(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, FAR volatile void *spinlock, + int type); +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL +static void note_lastsched_syscall_enter(FAR struct note_driver_s *drv, + int nr, int argc, va_list *ap); +static void note_lastsched_syscall_leave(FAR struct note_driver_s *drv, + int nr, uintptr_t result); +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER +static void note_lastsched_irqhandler(FAR struct note_driver_s *drv, int irq, + FAR void *handler, bool enter); +#endif + +struct note_lastsched_chunk_s +{ + uint32_t systick; Review Comment: done ########## drivers/note/note_lastsched_driver.c: ########## @@ -0,0 +1,397 @@ +/**************************************************************************** + * drivers/note/note_lastsched_driver.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <inttypes.h> +#include <stdatomic.h> +#include <syslog.h> + +#include <nuttx/arch.h> +#include <nuttx/note/note_driver.h> +#include <nuttx/sched.h> +#include <nuttx/sched_note.h> +#include <sched/sched.h> + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static void note_lastsched_start(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +static void note_lastsched_stop(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH +static void note_lastsched_suspend(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +static void note_lastsched_resume(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +# ifdef CONFIG_SMP +static void note_lastsched_cpu_start(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, int cpu); +static void note_lastsched_cpu_started(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +static void note_lastsched_cpu_pause(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, int cpu); +static void note_lastsched_cpu_paused(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +static void note_lastsched_cpu_resume(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, int cpu); +static void note_lastsched_cpu_resumed(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +# endif +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION +static void note_lastsched_premption(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, bool locked); +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION +static void note_lastsched_csection(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, bool enter); +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS +static void note_spinlock(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, FAR volatile void *spinlock, + int type); +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL +static void note_lastsched_syscall_enter(FAR struct note_driver_s *drv, + int nr, int argc, va_list *ap); +static void note_lastsched_syscall_leave(FAR struct note_driver_s *drv, + int nr, uintptr_t result); +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER +static void note_lastsched_irqhandler(FAR struct note_driver_s *drv, int irq, + FAR void *handler, bool enter); +#endif + +struct note_lastsched_chunk_s +{ + uint32_t systick; + uint32_t cpu_pid; + enum note_type_e type; + void *args; +}; + +struct note_lastsched_s +{ + uint32_t freq; + size_t index; + struct timespec ts; Review Comment: done ########## drivers/note/note_lastsched_driver.c: ########## @@ -0,0 +1,397 @@ +/**************************************************************************** + * drivers/note/note_lastsched_driver.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <inttypes.h> +#include <stdatomic.h> +#include <syslog.h> + +#include <nuttx/arch.h> +#include <nuttx/note/note_driver.h> +#include <nuttx/sched.h> +#include <nuttx/sched_note.h> +#include <sched/sched.h> + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static void note_lastsched_start(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +static void note_lastsched_stop(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH +static void note_lastsched_suspend(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +static void note_lastsched_resume(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +# ifdef CONFIG_SMP +static void note_lastsched_cpu_start(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, int cpu); +static void note_lastsched_cpu_started(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +static void note_lastsched_cpu_pause(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, int cpu); +static void note_lastsched_cpu_paused(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +static void note_lastsched_cpu_resume(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, int cpu); +static void note_lastsched_cpu_resumed(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb); +# endif +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION +static void note_lastsched_premption(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, bool locked); +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION +static void note_lastsched_csection(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, bool enter); +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_SPINLOCKS +static void note_spinlock(FAR struct note_driver_s *drv, + FAR struct tcb_s *tcb, FAR volatile void *spinlock, + int type); +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL +static void note_lastsched_syscall_enter(FAR struct note_driver_s *drv, + int nr, int argc, va_list *ap); +static void note_lastsched_syscall_leave(FAR struct note_driver_s *drv, + int nr, uintptr_t result); +#endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER +static void note_lastsched_irqhandler(FAR struct note_driver_s *drv, int irq, + FAR void *handler, bool enter); +#endif + +struct note_lastsched_chunk_s +{ + uint32_t systick; + uint32_t cpu_pid; + enum note_type_e type; + void *args; +}; + +struct note_lastsched_s +{ + uint32_t freq; Review Comment: done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org