xiaoxiang781216 commented on a change in pull request #1377:
URL: https://github.com/apache/incubator-nuttx/pull/1377#discussion_r494847227
##########
File path: include/nuttx/sched.h
##########
@@ -748,6 +748,10 @@ struct tcb_s
#if CONFIG_TASK_NAME_SIZE > 0
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NUL terminator)
*/
#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
+ int syscall_nest; /* Syscall nest level */
Review comment:
After search the code base, all arch use the same name(nsyscalls), so we
use tcb->xcpt.nsyscalls directly which simplify the code a lot.
##########
File path: include/nuttx/sched.h
##########
@@ -748,6 +748,10 @@ struct tcb_s
#if CONFIG_TASK_NAME_SIZE > 0
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NUL terminator)
*/
#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
+ int syscall_nest; /* Syscall nest level */
Review comment:
After search the code base, all arch use the same name(nsyscalls), so we
can use tcb->xcpt.nsyscalls directly which simplify the code a lot.
##########
File path: include/nuttx/sched.h
##########
@@ -748,6 +748,10 @@ struct tcb_s
#if CONFIG_TASK_NAME_SIZE > 0
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NUL terminator)
*/
#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
+ int syscall_nest; /* Syscall nest level */
Review comment:
After search the code base, all arch use the same name(nsyscalls), so we
can use tcb->xcpt.nsyscalls directly which simplify the code a lot and avoid
the dup code.
##########
File path: include/nuttx/sched.h
##########
@@ -748,6 +748,10 @@ struct tcb_s
#if CONFIG_TASK_NAME_SIZE > 0
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NUL terminator)
*/
#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
+ int syscall_nest; /* Syscall nest level */
Review comment:
After search the code base, all arch use the same name(nsyscalls), so we
can use tcb->xcpt.nsyscalls directly which simplify the code a lot and avoid
the code dup.
##########
File path: sched/sched/sched_note.c
##########
@@ -100,6 +127,185 @@ static void note_common(FAR struct tcb_s *tcb,
note->nc_systime[3] = (uint8_t)((systime >> 24) & 0xff);
}
+/****************************************************************************
+ * Name: note_isenabled
+ *
+ * Description:
+ * Check whether the instrumentation is enabled.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * True is returned if the instrumentation is enabled.
+ *
+ ****************************************************************************/
+
+static inline int note_isenabled(void)
+{
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+ if (!g_note_filter.mode.enable)
+ {
+ return false;
+ }
+
+#ifdef CONFIG_SMP
+ if ((g_note_filter.mode.cpuset & (1 << this_cpu())) == 0)
+ {
+ return false;
+ }
+#endif
+
+#else
+
+#ifdef CONFIG_SMP
+ /* Ignore notes that are not in the set of monitored CPUs */
+
+ if ((CONFIG_SCHED_INSTRUMENTATION_CPUSET & (1 << this_cpu())) == 0)
Review comment:
should we remove this code and let the SCHED_INSTRUMENTATION_CPUSET
depends on SCHED_INSTRUMENTATION_FILTER?
##########
File path: drivers/note/notectl_driver.c
##########
@@ -0,0 +1,273 @@
+/****************************************************************************
+ * drivers/note/notectl_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 <nuttx/config.h>
+
+#include <sys/types.h>
+#include <errno.h>
+
+#include <nuttx/fs/fs.h>
+#include <nuttx/note/notectl_driver.h>
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static const struct file_operations notectl_fops =
+{
+ NULL, /* open */
+ NULL, /* close */
+ NULL, /* read */
+ NULL, /* write */
+ NULL, /* seek */
+ notectl_ioctl, /* ioctl */
+ NULL /* poll */
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
+ , 0 /* unlink */
+#endif
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: notectl_ioctl
+ ****************************************************************************/
+
+static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg)
+{
+ int ret = -ENOSYS;
+
+ /* Handle the ioctl commands */
+
+ switch (cmd)
+ {
+ /* NOTECTL_START
+ * - Start note recoding
+ * Argument: Ignored
+ */
+
+ case NOTECTL_START:
+ {
+ struct note_filter_mode_s mode;
+
+ sched_note_filter_mode(&mode, NULL);
+ mode.enable = true;
Review comment:
We can do the same thing(NOTECTL_START/NOTECTL_STOP) with
NOTECTL_SETMODE, so why not remove these two ioctl?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]