Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp476016ybh; Wed, 18 Mar 2020 03:31:26 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvVQrYl2AUoc80nUwxiw2hvhw7vxFMbeHuhR3X445cnVmM4W7M9l8gMLl/RcgdzZyBH1RoC X-Received: by 2002:a54:478a:: with SMTP id o10mr2625352oic.45.1584527486172; Wed, 18 Mar 2020 03:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584527486; cv=none; d=google.com; s=arc-20160816; b=N0f3i+MsIfDhKircQdeQnsCxT/XpuyLSZcoxDr0hWa6MqRsDi7diMC0o2bxIa2oDHF kfaUyXB7OT0xJ3s3AEsswrIfTqzJqPgF1SfT8HCkXXEfCYtAnnlnexICCku85dCOkbAI ZsKfqPFQncF8NXydQ3ORHmP0S5DbkvVTWLTuOGcUYy9EqFvuSA6qPfyLfim4pPRGW4E2 XIJlvQWZ+1k5vPggEzSwgjtE/xrvAcUONms57Z/cbo8IYBc0YYsI66uo6354L4/s/upL +Pa/oKCIOikBY+Rgu9ZW1XW8crEMEx7gbmMcuV1OTk4ovpAKPKjezzI0JfO3BjlFCEth 5O0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=JVZrvNAzWrVxsCsTkfTj9P/mTGywvCxCIjqxU+DFY9w=; b=IQPOTW/2UTNcKBsSThvktrCBDkUvb56Ley6MtJoY1ocOAQF95I0MOG7lbM0q6A25Uc /X9J2J9hceKIYRNwndlqKaqCHvoy7dATx2F77C/UAUwa2t+Fe4vI48T+/hGKU3Xu9ZCu 6K1A/tJfJ+HVPFIE8VoDkVMw7s1ruY+Zb4Z+4WVryZ/LZESBgzY9N9stqoUmWsj00aK/ FiszoaxL96fCjSuGhwRKBeYid50QHydnH4QHe1m7B0EC0TStEM7aDqULcbAlRFWvwtSg 0fRDcCV3uVgd5Hr13+tA1DvouBRcmn76yOXGqRVFJxzChc9Fuxiy8ICq/EhB3gm7CVqw Q72w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nd+qyIkk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u5si3416133otg.42.2020.03.18.03.31.13; Wed, 18 Mar 2020 03:31:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nd+qyIkk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727572AbgCRKak (ORCPT + 99 others); Wed, 18 Mar 2020 06:30:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:34436 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726310AbgCRKaj (ORCPT ); Wed, 18 Mar 2020 06:30:39 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 61C3B2076C; Wed, 18 Mar 2020 10:30:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584527438; bh=/cPJrKlaajGGqIzhjwhJr72cHDtvetySQiq4otDw5ik=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nd+qyIkkhWzh2wnZik/yHMqgaEm2msvE4kjolKbkpKuxRzUYQ38e+mfVUoeETvkcq DzORZtOeWMvtcQ+FmCHIHrvx0QfJqfEAw9tQmG7lJnIAKOpHqnRbpXGsKV+b0fLhHc t4SILl4A7uvruZI5DQca8tfSaL05WLz3LnMwHiDw= Date: Wed, 18 Mar 2020 11:30:36 +0100 From: Greg Kroah-Hartman To: Alexander Shishkin Cc: linux-kernel@vger.kernel.org, Andy Shevchenko Subject: Re: [GIT PULL 3/6] intel_th: msu: Make stopping the trace optional Message-ID: <20200318103036.GA2183221@kroah.com> References: <20200317062215.15598-1-alexander.shishkin@linux.intel.com> <20200317062215.15598-4-alexander.shishkin@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200317062215.15598-4-alexander.shishkin@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 17, 2020 at 08:22:12AM +0200, Alexander Shishkin wrote: > Some use cases prefer to keep collecting the trace data into the last > available window while the other windows are being offloaded instead of > stopping the trace. In this scenario, the window switch happens > automatically when the next window becomes available again. > > Add an option to allow this and a sysfs attribute to enable it. > > Signed-off-by: Alexander Shishkin > Reviewed-by: Andy Shevchenko > --- > .../testing/sysfs-bus-intel_th-devices-msc | 8 ++++ > drivers/hwtracing/intel_th/msu.c | 37 ++++++++++++++++++- > 2 files changed, 44 insertions(+), 1 deletion(-) > > diff --git a/Documentation/ABI/testing/sysfs-bus-intel_th-devices-msc b/Documentation/ABI/testing/sysfs-bus-intel_th-devices-msc > index 456cb62b384c..7fd2601c2831 100644 > --- a/Documentation/ABI/testing/sysfs-bus-intel_th-devices-msc > +++ b/Documentation/ABI/testing/sysfs-bus-intel_th-devices-msc > @@ -40,3 +40,11 @@ Description: (RW) Trigger window switch for the MSC's buffer, in > triggering a window switch for the buffer. Returns an error in any > other operating mode or attempts to write something other than "1". > > +What: /sys/bus/intel_th/devices/-msc/stop_on_full > +Date: March 2020 > +KernelVersion: 5.7 > +Contact: Alexander Shishkin > +Description: (RW) Configure whether trace stops when the last available window > + becomes full (1/y/Y) or wraps around and continues until the next > + window becomes available again (0/n/N). > + > diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c > index 6e118b790d83..45916b48bcf0 100644 > --- a/drivers/hwtracing/intel_th/msu.c > +++ b/drivers/hwtracing/intel_th/msu.c > @@ -138,6 +138,7 @@ struct msc { > struct list_head win_list; > struct sg_table single_sgt; > struct msc_window *cur_win; > + struct msc_window *switch_on_unlock; > unsigned long nr_pages; > unsigned long single_sz; > unsigned int single_wrap : 1; > @@ -154,6 +155,8 @@ struct msc { > > struct list_head iter_list; > > + bool stop_on_full; > + > /* config */ > unsigned int enabled : 1, > wrap : 1, > @@ -1717,6 +1720,10 @@ void intel_th_msc_window_unlock(struct device *dev, struct sg_table *sgt) > return; > > msc_win_set_lockout(win, WIN_LOCKED, WIN_READY); > + if (msc->switch_on_unlock == win) { > + msc->switch_on_unlock = NULL; > + msc_win_switch(msc); > + } > } > EXPORT_SYMBOL_GPL(intel_th_msc_window_unlock); > > @@ -1757,7 +1764,11 @@ static irqreturn_t intel_th_msc_interrupt(struct intel_th_device *thdev) > > /* next window: if READY, proceed, if LOCKED, stop the trace */ > if (msc_win_set_lockout(next_win, WIN_READY, WIN_INUSE)) { > - schedule_work(&msc->work); > + if (msc->stop_on_full) > + schedule_work(&msc->work); > + else > + msc->switch_on_unlock = next_win; > + > return IRQ_HANDLED; > } > > @@ -2050,11 +2061,35 @@ win_switch_store(struct device *dev, struct device_attribute *attr, > > static DEVICE_ATTR_WO(win_switch); > > +static ssize_t stop_on_full_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct msc *msc = dev_get_drvdata(dev); > + > + return scnprintf(buf, PAGE_SIZE, "%d\n", msc->stop_on_full); No need for the scnprinf() crazyness for a single boolean value. Just use sprintf() and keep it simple. > +static ssize_t stop_on_full_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 = kstrtobool(buf, &msc->stop_on_full); > + > + return ret ? ret : size; > +} Here's the problem, you don't use val. And spell out the ? : crazyness: if (ret) return ret; return size; much simpler for people to read and understand. thanks, greg k-h