@@ -7689,8 +7689,12 @@ trace_min_max_write(struct file *filp, const char __user *ubuf, size_t cnt, loff
if (param->max && val > *param->max)
err = -EINVAL;
- if (!err)
- *param->val = val;
+ if (!err) {
+ if (unlikely(param->write))
+ param->write(param->val, val);
+ else
+ *param->val = val;
+ }
if (param->lock)
mutex_unlock(param->lock);
@@ -7723,7 +7727,10 @@ trace_min_max_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppo
if (!param)
return -EFAULT;
- val = *param->val;
+ if (unlikely(param->read))
+ val = param->read(param->val);
+ else
+ val = *param->val;
if (cnt > sizeof(buf))
cnt = sizeof(buf);
@@ -2159,6 +2159,8 @@ static inline void sanitize_event_name(char *name)
struct trace_min_max_param {
struct mutex *lock;
u64 *val;
+ u64 (*read)(u64 *val);
+ void (*write)(u64 *val, u64 data);
u64 *min;
u64 *max;
};
The 'trace_min_max_fops' implements a generic function to read/write u64 values from tracefs, add support of custom read/write processing to allow special requirements. Signed-off-by: Wei Li <liwei391@huawei.com> --- kernel/trace/trace.c | 13 ++++++++++--- kernel/trace/trace.h | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-)