*/
-/*
- * Reasons for cache flush.
- */
-
-#define NUM_FLUSH_REASONS 8 /* Keep this in sync with the enum below. */
-enum flush_reason_enum { SEEK_FLUSH, READ_FLUSH, WRITE_FLUSH, READRAW_FLUSH,
- OPLOCK_RELEASE_FLUSH, CLOSE_FLUSH, SYNC_FLUSH, SIZECHANGE_FLUSH };
-
/* this file defines the profile structure in the profile shared
memory area */
#define PROF_SHMEM_KEY ((key_t)0x07021999)
#define PROF_SHM_MAGIC 0x6349985
-#define PROF_SHM_VERSION 9
+#define PROF_SHM_VERSION 10
/* time values in the following structure are in microseconds */
unsigned syscall_opendir_time;
unsigned syscall_readdir_count;
unsigned syscall_readdir_time;
+ unsigned syscall_seekdir_count;
+ unsigned syscall_seekdir_time;
+ unsigned syscall_telldir_count;
+ unsigned syscall_telldir_time;
+ unsigned syscall_rewinddir_count;
+ unsigned syscall_rewinddir_time;
unsigned syscall_mkdir_count;
unsigned syscall_mkdir_time;
unsigned syscall_rmdir_count;
unsigned syscall_ftruncate_time;
unsigned syscall_fcntl_lock_count;
unsigned syscall_fcntl_lock_time;
+ unsigned syscall_fcntl_getlock_count;
+ unsigned syscall_fcntl_getlock_time;
unsigned syscall_readlink_count;
unsigned syscall_readlink_time;
unsigned syscall_symlink_count;
extern BOOL do_profile_flag;
extern BOOL do_profile_times;
+#ifdef WITH_PROFILE
+
/* these are helper macros - do not call them directly in the code
* use the DO_PROFILE_* START_PROFILE and END_PROFILE ones
* below which test for the profile flage first
#define INC_PROFILE_COUNT(x) profile_p->x++
#define DEC_PROFILE_COUNT(x) profile_p->x--
#define ADD_PROFILE_COUNT(x,y) profile_p->x += (y)
-#define PROFILE_TIME \
- ((profile_endtime.tv_sec - profile_starttime.tv_sec) *1000000 + \
- ((int)profile_endtime.tv_usec - (int)profile_starttime.tv_usec))
-#define PROFILE_TIME_NESTED \
- ((profile_endtime_nested.tv_sec - profile_starttime_nested.tv_sec) *1000000 + \
- ((int)profile_endtime_nested.tv_usec - (int)profile_starttime_nested.tv_usec))
-#ifdef WITH_PROFILE
+#if defined(HAVE_CLOCK_GETTIME)
+
+extern clockid_t __profile_clock;
+
+static inline SMB_BIG_UINT profile_timestamp(void)
+{
+ struct timespec ts;
+
+ /* FIXME: On a single-CPU system, or a system where we have bound
+ * daemon threads to single CPUs (eg. using cpusets or processor
+ * affinity), it might be preferable to use CLOCK_PROCESS_CPUTIME_ID.
+ */
+
+ clock_gettime(__profile_clock, &ts);
+ return (ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); /* usec */
+}
+
+#else
+
+static inline SMB_BIG_UINT profile_timestamp(void)
+{
+ struct timeval tv;
+ GetTimeOfDay(&tv);
+ return (tv.tv_sec * 1000000) + tv.tv_usec;
+}
+
+#endif
+
+/* end of helper macros */
+
#define DO_PROFILE_INC(x) \
if (do_profile_flag) { \
INC_PROFILE_COUNT(x); \
}
+
#define DO_PROFILE_DEC(x) \
if (do_profile_flag) { \
DEC_PROFILE_COUNT(x); \
}
+
#define DO_PROFILE_DEC_INC(x,y) \
if (do_profile_flag) { \
DEC_PROFILE_COUNT(x); \
INC_PROFILE_COUNT(y); \
}
+
#define DO_PROFILE_ADD(x,n) \
if (do_profile_flag) { \
ADD_PROFILE_COUNT(x,n); \
}
+
#define START_PROFILE(x) \
+ SMB_BIG_UINT __profstamp_##x = 0; \
if (do_profile_flag) { \
- if (do_profile_times) \
- GetTimeOfDay(&profile_starttime); \
+ __profstamp_##x = do_profile_times ? profile_timestamp() : 0;\
INC_PROFILE_COUNT(x##_count); \
- }
-#define START_PROFILE_NESTED(x) \
- if (do_profile_flag) { \
- if (do_profile_times) \
- GetTimeOfDay(&profile_starttime_nested); \
- INC_PROFILE_COUNT(x##_count); \
- }
+ }
+
#define START_PROFILE_BYTES(x,n) \
+ SMB_BIG_UINT __profstamp_##x = 0; \
if (do_profile_flag) { \
- if (do_profile_times) \
- GetTimeOfDay(&profile_starttime); \
+ __profstamp_##x = do_profile_times ? profile_timestamp() : 0;\
INC_PROFILE_COUNT(x##_count); \
- ADD_PROFILE_COUNT(x##_bytes,n); \
- }
+ ADD_PROFILE_COUNT(x##_bytes, n); \
+ }
+
#define END_PROFILE(x) \
if (do_profile_times) { \
- GetTimeOfDay(&profile_endtime); \
- ADD_PROFILE_COUNT(x##_time,PROFILE_TIME); \
- }
-#define END_PROFILE_NESTED(x) \
- if (do_profile_times) { \
- GetTimeOfDay(&profile_endtime_nested); \
- ADD_PROFILE_COUNT(x##_time,PROFILE_TIME_NESTED); \
+ ADD_PROFILE_COUNT(x##_time, \
+ profile_timestamp() - __profstamp_##x); \
}
-#else
+
+#define START_PROFILE_NESTED(x) START_PROFILE(x)
+#define END_PROFILE_NESTED(x) END_PROFILE(x)
+
+#else /* WITH_PROFILE */
+
#define DO_PROFILE_INC(x)
#define DO_PROFILE_DEC(x)
#define DO_PROFILE_DEC_INC(x,y)
#define START_PROFILE_BYTES(x,n)
#define END_PROFILE(x)
#define END_PROFILE_NESTED(x)
-#endif
+
+#endif /* WITH_PROFILE */
#endif