提交 8736f2c6 编写于 作者: A Alexander Shishkin 提交者: Yang Yingliang

intel_th: msu: Add a sysfs attribute to trigger window switch

mainline inclusion
from mainline-v5.2-rc1
commit 6cac7866
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I47H3V
CVE: NA

--------------------------------

Now that we have the means to trigger a window switch for the MSU trace
store, add a sysfs file to allow triggering it from userspace.
Signed-off-by: NAlexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NJackie Liu <liuyun01@kylinos.cn>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 2e2d2d46
...@@ -30,4 +30,12 @@ Description: (RW) Configure MSC buffer size for "single" or "multi" modes. ...@@ -30,4 +30,12 @@ Description: (RW) Configure MSC buffer size for "single" or "multi" modes.
there are no active users and tracing is not enabled) and then there are no active users and tracing is not enabled) and then
allocates a new one. allocates a new one.
What: /sys/bus/intel_th/devices/<intel_th_id>-msc<msc-id>/win_switch
Date: May 2019
KernelVersion: 5.2
Contact: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Description: (RW) Trigger window switch for the MSC's buffer, in
multi-window mode. In "multi" mode, accepts writes of "1", thereby
triggering a window switch for the buffer. Returns an error in any
other operating mode or attempts to write something other than "1".
...@@ -1572,10 +1572,38 @@ nr_pages_store(struct device *dev, struct device_attribute *attr, ...@@ -1572,10 +1572,38 @@ nr_pages_store(struct device *dev, struct device_attribute *attr,
static DEVICE_ATTR_RW(nr_pages); static DEVICE_ATTR_RW(nr_pages);
static ssize_t
win_switch_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t size)
{
struct msc *msc = dev_get_drvdata(dev);
unsigned long val;
int ret;
ret = kstrtoul(buf, 10, &val);
if (ret)
return ret;
if (val != 1)
return -EINVAL;
mutex_lock(&msc->buf_mutex);
if (msc->mode != MSC_MODE_MULTI)
ret = -ENOTSUPP;
else
ret = intel_th_trace_switch(msc->thdev);
mutex_unlock(&msc->buf_mutex);
return ret ? ret : size;
}
static DEVICE_ATTR_WO(win_switch);
static struct attribute *msc_output_attrs[] = { static struct attribute *msc_output_attrs[] = {
&dev_attr_wrap.attr, &dev_attr_wrap.attr,
&dev_attr_mode.attr, &dev_attr_mode.attr,
&dev_attr_nr_pages.attr, &dev_attr_nr_pages.attr,
&dev_attr_win_switch.attr,
NULL, NULL,
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册