xiaoxiang781216 commented on code in PR #18607:
URL: https://github.com/apache/nuttx/pull/18607#discussion_r2992630240


##########
fs/mnemofs/mnemofs.h:
##########


Review Comment:
   could you move mnemofs to the new pr



##########
fs/vfs/fs_profile.c:
##########
@@ -0,0 +1,65 @@
+/****************************************************************************
+ * fs/vfs/fs_profile.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * 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 <nuttx/fs/fs_profile.h>
+#include <nuttx/clock.h>
+#include <nuttx/irq.h>
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+struct vfs_profile_s g_vfs_profile;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+void vfs_profile_start(FAR struct timespec *start)
+{
+  clock_systime_timespec(start);
+}
+
+void vfs_profile_stop(FAR struct timespec *start, FAR uint64_t *total,
+                      FAR uint32_t *count)
+{
+  struct timespec stop;
+  uint64_t nsec;
+  irqstate_t flags;
+
+  clock_systime_timespec(&stop);
+
+  nsec = (stop.tv_sec - start->tv_sec) * 1000000000ULL +
+         (stop.tv_nsec - start->tv_nsec);
+
+  /* Ensure thread-safe update using interrupts disable. */
+
+  flags = enter_critical_section();

Review Comment:
   let's use atomic api from include/nuttx/atomic.h?



##########
fs/vfs/fs_open.c:
##########
@@ -236,6 +237,11 @@ static int file_vopen(FAR struct file *filep, FAR const 
char *path,
    * because it may also be closed that many times.
    */
 
+#ifdef CONFIG_FS_PROFILER

Review Comment:
   why need check CONFIG_FS_PROFILER if you already prrovide the empty macro in 
case of CONFIG_FS_PROFILER=n?



##########
fs/procfs/fs_procfs.c:
##########
@@ -74,6 +74,10 @@ extern const struct procfs_operations g_thermal_operations;
 extern const struct procfs_operations g_uptime_operations;
 extern const struct procfs_operations g_version_operations;
 extern const struct procfs_operations g_pressure_operations;
+#if defined(CONFIG_FS_PROFILER) && \
+    !defined(CONFIG_FS_PROCFS_EXCLUDE_PROFILE)
+extern const struct procfs_operations g_profile_operations;

Review Comment:
   the name is too general since the current implementation is specific to vfs



##########
fs/vfs/fs_profile.c:
##########
@@ -0,0 +1,65 @@
+/****************************************************************************
+ * fs/vfs/fs_profile.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * 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 <nuttx/fs/fs_profile.h>
+#include <nuttx/clock.h>
+#include <nuttx/irq.h>
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+struct vfs_profile_s g_vfs_profile;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+void vfs_profile_start(FAR struct timespec *start)
+{
+  clock_systime_timespec(start);

Review Comment:
   why not call perf_gettime



##########
fs/procfs/fs_procfsprofile.c:
##########
@@ -0,0 +1,126 @@
+/****************************************************************************
+ * fs/procfs/fs_procfsprofile.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * 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>
+
+#if defined(CONFIG_FS_PROCFS) && defined(CONFIG_FS_PROFILER) && \
+    !defined(CONFIG_FS_PROCFS_EXCLUDE_PROFILE)
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <nuttx/fs/fs.h>
+#include <nuttx/fs/procfs.h>
+#include <nuttx/fs/fs_profile.h>
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static int profile_open(FAR struct file *filep, FAR const char *relpath,
+                        int oflags, mode_t mode)
+{
+  return OK;
+}
+
+static int profile_close(FAR struct file *filep)
+{
+  return OK;
+}
+
+static ssize_t profile_read(FAR struct file *filep, FAR char *buffer,
+                            size_t buflen)
+{
+  char buf[256];
+  size_t linesize;
+  off_t offset = filep->f_pos;
+
+  if (offset > 0)
+    {
+      return 0;
+    }
+
+  snprintf(buf, sizeof(buf),

Review Comment:
   use procfs_snprintf



##########
include/nuttx/fs/fs_profile.h:
##########
@@ -0,0 +1,77 @@
+/****************************************************************************
+ * include/nuttx/fs/fs_profile.h

Review Comment:
   why put in the public header file for the internal vfs function? move to 
fs/vfs/vfs.h



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to