* Re: [PATCH] asm-generic/atomic: Add try_cmpxchg() fallbacks
From: Will Deacon @ 2020-02-20 10:39 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Jens Axboe, Carter Li 李通洲, Pavel Begunkov,
io-uring, Oleg Nesterov, Mark Rutland, linux-kernel
In-Reply-To: <20200220103727.GW18400@hirez.programming.kicks-ass.net>
On Thu, Feb 20, 2020 at 11:37:27AM +0100, Peter Zijlstra wrote:
> On Thu, Feb 20, 2020 at 10:30:45AM +0000, Will Deacon wrote:
> > On Tue, Feb 18, 2020 at 03:27:00PM +0100, Peter Zijlstra wrote:
> > > diff --git a/scripts/atomic/gen-atomic-fallback.sh b/scripts/atomic/gen-atomic-fallback.sh
> > > index b6c6f5d306a7..3c9be8d550e0 100755
> > > --- a/scripts/atomic/gen-atomic-fallback.sh
> > > +++ b/scripts/atomic/gen-atomic-fallback.sh
> > > @@ -140,6 +140,32 @@ cat <<EOF
> > > EOF
> > > }
> > >
> > > +gen_try_cmpxchg_fallback()
> > > +{
> > > + local order="$1"; shift;
> > > +
> > > +cat <<EOF
> > > +#ifndef try_cmpxchg${order}
> > > +#define try_cmpxchg${order}(_ptr, _oldp, _new) \\
> > > +({ \\
> > > + typeof(*ptr) ___r, ___o = *(_oldp); \\
> > > + ___r = cmpxchg${order}((_ptr), ___o, (_new)); \\
> > > + if (unlikely(___r != ___o)) \\
> > > + *(_old) = ___r; \\
> >
> > This doesn't compile because _old isn't declared. Probably best to avoid
> > evaluating _oldp twice though.
>
> Compiler had already spotted that, I'll make it something like:
>
> typeof(*ptr) *___op = (_oldp), ___o = *___op;
>
> ...
>
> *___op = ___r;
>
> Which avoids the double eval.
Cool, you can stick my Ack on the patch with that change.
Will
^ permalink raw reply
* [PATCH] rcu_queue: add QSLIST functions
From: Paolo Bonzini @ 2020-02-20 10:38 UTC (permalink / raw)
To: qemu-devel; +Cc: stefanha
QSLIST is the only family of lists for which we do not have RCU-friendly accessors,
add them.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/qemu/queue.h | 15 +++++++++++--
include/qemu/rcu_queue.h | 47 ++++++++++++++++++++++++++++++++++++++++
tests/Makefile.include | 2 ++
tests/test-rcu-list.c | 16 ++++++++++++++
tests/test-rcu-slist.c | 2 ++
5 files changed, 80 insertions(+), 2 deletions(-)
create mode 100644 tests/test-rcu-slist.c
diff --git a/include/qemu/queue.h b/include/qemu/queue.h
index 19425f973f..fcecb70228 100644
--- a/include/qemu/queue.h
+++ b/include/qemu/queue.h
@@ -211,9 +211,20 @@ struct { \
(head)->slh_first = (head)->slh_first->field.sle_next; \
} while (/*CONSTCOND*/0)
-#define QSLIST_REMOVE_AFTER(slistelm, field) do { \
+#define QSLIST_REMOVE_AFTER(slistelm, field) do { \
(slistelm)->field.sle_next = \
- QSLIST_NEXT(QSLIST_NEXT((slistelm), field), field); \
+ QSLIST_NEXT(QSLIST_NEXT((slistelm), field), field); \
+} while (/*CONSTCOND*/0)
+
+#define QSLIST_REMOVE(head, elm, type, field) do { \
+ if ((head)->slh_first == (elm)) { \
+ QSLIST_REMOVE_HEAD((head), field); \
+ } else { \
+ struct type *curelm = (head)->slh_first; \
+ while (curelm->field.sle_next != (elm)) \
+ curelm = curelm->field.sle_next; \
+ curelm->field.sle_next = curelm->field.sle_next->field.sle_next; \
+ } \
} while (/*CONSTCOND*/0)
#define QSLIST_FOREACH(var, head, field) \
diff --git a/include/qemu/rcu_queue.h b/include/qemu/rcu_queue.h
index 2d386f303e..558961cc27 100644
--- a/include/qemu/rcu_queue.h
+++ b/include/qemu/rcu_queue.h
@@ -262,6 +262,53 @@ extern "C" {
(var) && ((next) = atomic_rcu_read(&(var)->field.tqe_next), 1); \
(var) = (next))
+/*
+ * RCU singly-linked list
+ */
+
+/* Singly-linked list access methods */
+#define QSLIST_EMPTY_RCU(head) (atomic_read(&(head)->slh_first) == NULL)
+#define QSLIST_FIRST_RCU(head) atomic_rcu_read(&(head)->slh_first)
+#define QSLIST_NEXT_RCU(elm, field) atomic_rcu_read(&(elm)->field.sle_next)
+
+/* Singly-linked list functions */
+#define QSLIST_INSERT_HEAD_RCU(head, elm, field) do { \
+ (elm)->field.sle_next = (head)->slh_first; \
+ atomic_rcu_set(&(head)->slh_first, (elm)); \
+} while (/*CONSTCOND*/0)
+
+#define QSLIST_INSERT_AFTER_RCU(head, listelm, elm, field) do { \
+ (elm)->field.sle_next = (listelm)->field.sle_next; \
+ atomic_rcu_set(&(listelm)->field.sle_next, (elm)); \
+} while (/*CONSTCOND*/0)
+
+#define QSLIST_REMOVE_HEAD_RCU(head, field) do { \
+ atomic_set(&(head)->slh_first, (head)->slh_first->field.sle_next); \
+} while (/*CONSTCOND*/0)
+
+#define QSLIST_REMOVE_RCU(head, elm, type, field) do { \
+ if ((head)->slh_first == (elm)) { \
+ QSLIST_REMOVE_HEAD_RCU((head), field); \
+ } else { \
+ struct type *curr = (head)->slh_first; \
+ while (curr->field.sle_next != (elm)) { \
+ curr = curr->field.sle_next; \
+ } \
+ atomic_set(&curr->field.sle_next, \
+ curr->field.sle_next->field.sle_next); \
+ } \
+} while (/*CONSTCOND*/0)
+
+#define QSLIST_FOREACH_RCU(var, head, field) \
+ for ((var) = atomic_rcu_read(&(head)->slh_first); \
+ (var); \
+ (var) = atomic_rcu_read(&(var)->field.sle_next))
+
+#define QSLIST_FOREACH_SAFE_RCU(var, head, field, next) \
+ for ((var) = atomic_rcu_read(&(head)->slh_first); \
+ (var) && ((next) = atomic_rcu_read(&(var)->field.sle_next), 1); \
+ (var) = (next))
+
#ifdef __cplusplus
}
#endif
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 2f1cafed72..edcbd475aa 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -98,6 +98,7 @@ check-unit-y += tests/rcutorture$(EXESUF)
check-unit-y += tests/test-rcu-list$(EXESUF)
check-unit-y += tests/test-rcu-simpleq$(EXESUF)
check-unit-y += tests/test-rcu-tailq$(EXESUF)
+check-unit-y += tests/test-rcu-slist$(EXESUF)
check-unit-y += tests/test-qdist$(EXESUF)
check-unit-y += tests/test-qht$(EXESUF)
check-unit-y += tests/test-qht-par$(EXESUF)
@@ -415,6 +416,7 @@ tests/rcutorture$(EXESUF): tests/rcutorture.o $(test-util-obj-y)
tests/test-rcu-list$(EXESUF): tests/test-rcu-list.o $(test-util-obj-y)
tests/test-rcu-simpleq$(EXESUF): tests/test-rcu-simpleq.o $(test-util-obj-y)
tests/test-rcu-tailq$(EXESUF): tests/test-rcu-tailq.o $(test-util-obj-y)
+tests/test-rcu-slist$(EXESUF): tests/test-rcu-slist.o $(test-util-obj-y)
tests/test-qdist$(EXESUF): tests/test-qdist.o $(test-util-obj-y)
tests/test-qht$(EXESUF): tests/test-qht.o $(test-util-obj-y)
tests/test-qht-par$(EXESUF): tests/test-qht-par.o tests/qht-bench$(EXESUF) $(test-util-obj-y)
diff --git a/tests/test-rcu-list.c b/tests/test-rcu-list.c
index 6f076473e0..1442c0c982 100644
--- a/tests/test-rcu-list.c
+++ b/tests/test-rcu-list.c
@@ -93,6 +93,8 @@ struct list_element {
QSIMPLEQ_ENTRY(list_element) entry;
#elif TEST_LIST_TYPE == 3
QTAILQ_ENTRY(list_element) entry;
+#elif TEST_LIST_TYPE == 4
+ QSLIST_ENTRY(list_element) entry;
#else
#error Invalid TEST_LIST_TYPE
#endif
@@ -144,6 +146,20 @@ static QTAILQ_HEAD(, list_element) Q_list_head;
#define TEST_LIST_INSERT_HEAD_RCU QTAILQ_INSERT_HEAD_RCU
#define TEST_LIST_FOREACH_RCU QTAILQ_FOREACH_RCU
#define TEST_LIST_FOREACH_SAFE_RCU QTAILQ_FOREACH_SAFE_RCU
+
+#elif TEST_LIST_TYPE == 4
+static QSLIST_HEAD(, list_element) Q_list_head;
+
+#define TEST_NAME "qslist"
+#define TEST_LIST_REMOVE_RCU(el, f) \
+ QSLIST_REMOVE_RCU(&Q_list_head, el, list_element, f)
+
+#define TEST_LIST_INSERT_AFTER_RCU(list_el, el, f) \
+ QSLIST_INSERT_AFTER_RCU(&Q_list_head, list_el, el, f)
+
+#define TEST_LIST_INSERT_HEAD_RCU QSLIST_INSERT_HEAD_RCU
+#define TEST_LIST_FOREACH_RCU QSLIST_FOREACH_RCU
+#define TEST_LIST_FOREACH_SAFE_RCU QSLIST_FOREACH_SAFE_RCU
#else
#error Invalid TEST_LIST_TYPE
#endif
diff --git a/tests/test-rcu-slist.c b/tests/test-rcu-slist.c
new file mode 100644
index 0000000000..868e1e472e
--- /dev/null
+++ b/tests/test-rcu-slist.c
@@ -0,0 +1,2 @@
+#define TEST_LIST_TYPE 4
+#include "test-rcu-list.c"
--
2.21.1
^ permalink raw reply related
* Re: [PATCH v2 0/7] mm/hotplug: Only use subsection map in VMEMMAP case
From: Michal Hocko @ 2020-02-20 10:38 UTC (permalink / raw)
To: Baoquan He
Cc: linux-kernel, linux-mm, akpm, richardw.yang, david, osalvador,
dan.j.williams, rppt, robin.murphy
In-Reply-To: <20200220043316.19668-1-bhe@redhat.com>
On Thu 20-02-20 12:33:09, Baoquan He wrote:
> Memory sub-section hotplug was added to fix the issue that nvdimm could
> be mapped at non-section aligned starting address. A subsection map is
> added into struct mem_section_usage to implement it. However, sub-section
> is only supported in VMEMMAP case.
Why? Is there any fundamental reason or just a lack of implementation?
VMEMMAP should be really only an implementation detail unless I am
missing something subtle.
> Hence there's no need to operate
> subsection map in SPARSEMEM|!VMEMMAP case. In this patchset, change
> codes to make sub-section map and the relevant operation only available
> in VMEMMAP case.
>
> And since sub-section hotplug added, the hot add/remove functionality
> have been broken in SPARSEMEM|!VMEMMAP case. Wei Yang and I, each of us
> make one patch to fix one of the failures. In this patchset, the patch
> 1/7 from me is used to fix the hot remove failure. Wei Yang's patch has
> been merged by Andrew.
Not sure I understand. Are there more issues to be fixed?
> include/linux/mmzone.h | 2 +
> mm/sparse.c | 178 +++++++++++++++++++++++++++++------------
> 2 files changed, 127 insertions(+), 53 deletions(-)
Why do we need to add so much code to remove a functionality from one
memory model?
--
Michal Hocko
SUSE Labs
^ permalink raw reply
* Re: [PATCH v4 4/6] driver core: Remove driver_deferred_probe_check_state_continue()
From: Rafael J. Wysocki @ 2020-02-20 10:38 UTC (permalink / raw)
To: John Stultz
Cc: lkml, Rob Herring, Rafael J. Wysocki, Kevin Hilman, Ulf Hansson,
Pavel Machek, Len Brown, Todd Kjos, Bjorn Andersson,
Liam Girdwood, Mark Brown, Thierry Reding, Linus Walleij,
Greg Kroah-Hartman, Linux PM
In-Reply-To: <20200220050440.45878-5-john.stultz@linaro.org>
On Thu, Feb 20, 2020 at 6:05 AM John Stultz <john.stultz@linaro.org> wrote:
>
> Now that driver_deferred_probe_check_state() works better, and
> we've converted the only user of
> driver_deferred_probe_check_state_continue() we can simply
> remove it and simplify some of the logic.
>
> Cc: Rob Herring <robh@kernel.org>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Kevin Hilman <khilman@kernel.org>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Len Brown <len.brown@intel.com>
> Cc: Todd Kjos <tkjos@google.com>
> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Thierry Reding <treding@nvidia.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> Change-Id: Id5cd5e9264cfb0fbd70a702715174cc4b10006f4
Nice!
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/base/dd.c | 49 +++++------------------------------
> include/linux/device/driver.h | 1 -
> 2 files changed, 6 insertions(+), 44 deletions(-)
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index fa138f24e2d3..408e4da081da 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -244,19 +244,6 @@ static int __init deferred_probe_timeout_setup(char *str)
> }
> __setup("deferred_probe_timeout=", deferred_probe_timeout_setup);
>
> -static int __driver_deferred_probe_check_state(struct device *dev)
> -{
> - if (!initcalls_done || deferred_probe_timeout > 0)
> - return -EPROBE_DEFER;
> -
> - if (!deferred_probe_timeout) {
> - dev_WARN(dev, "deferred probe timeout, ignoring dependency");
> - return -ETIMEDOUT;
> - }
> -
> - return 0;
> -}
> -
> /**
> * driver_deferred_probe_check_state() - Check deferred probe state
> * @dev: device to check
> @@ -272,43 +259,19 @@ static int __driver_deferred_probe_check_state(struct device *dev)
> */
> int driver_deferred_probe_check_state(struct device *dev)
> {
> - int ret;
> + if (!initcalls_done || deferred_probe_timeout > 0)
> + return -EPROBE_DEFER;
>
> - ret = __driver_deferred_probe_check_state(dev);
> - if (ret < 0)
> - return ret;
> + if (!deferred_probe_timeout) {
> + dev_WARN(dev, "deferred probe timeout, ignoring dependency");
> + return -ETIMEDOUT;
> + }
>
> dev_warn(dev, "ignoring dependency for device, assuming no driver");
>
> return -ENODEV;
> }
>
> -/**
> - * driver_deferred_probe_check_state_continue() - check deferred probe state
> - * @dev: device to check
> - *
> - * Returns -ETIMEDOUT if deferred probe debug timeout has expired, or
> - * -EPROBE_DEFER otherwise.
> - *
> - * Drivers or subsystems can opt-in to calling this function instead of
> - * directly returning -EPROBE_DEFER.
> - *
> - * This is similar to driver_deferred_probe_check_state(), but it allows the
> - * subsystem to keep deferring probe after built-in drivers have had a chance
> - * to probe. One scenario where that is useful is if built-in drivers rely on
> - * resources that are provided by modular drivers.
> - */
> -int driver_deferred_probe_check_state_continue(struct device *dev)
> -{
> - int ret;
> -
> - ret = __driver_deferred_probe_check_state(dev);
> - if (ret < 0)
> - return ret;
> -
> - return -EPROBE_DEFER;
> -}
> -
> static void deferred_probe_timeout_work_func(struct work_struct *work)
> {
> struct device_private *private, *p;
> diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h
> index 1188260f9a02..5242afabfaba 100644
> --- a/include/linux/device/driver.h
> +++ b/include/linux/device/driver.h
> @@ -238,7 +238,6 @@ driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev)
>
> void driver_deferred_probe_add(struct device *dev);
> int driver_deferred_probe_check_state(struct device *dev);
> -int driver_deferred_probe_check_state_continue(struct device *dev);
> void driver_init(void);
>
> /**
> --
^ permalink raw reply
* Re: [dpdk-dev] [PATCH] app/crypto-perf: use common macros for min/max
From: Akhil Goyal @ 2020-02-20 10:38 UTC (permalink / raw)
To: Thomas Monjalon, dev@dpdk.org; +Cc: Declan Doherty
In-Reply-To: <20200219103848.2259134-1-thomas@monjalon.net>
> The macros RTE_MIN and RTE_MAX can be used in DPDK applications.
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
Applied to dpdk-next-crypto
Thanks.
^ permalink raw reply
* Re: [PATCH v10 15/22] fuzz: support for fork-based fuzzing.
From: Darren Kenny @ 2020-02-20 10:34 UTC (permalink / raw)
To: Alexander Bulekov
Cc: Laurent Vivier, Thomas Huth, qemu-devel, bsd, stefanha, pbonzini
In-Reply-To: <20200220041118.23264-16-alxndr@bu.edu>
On Wed, Feb 19, 2020 at 11:11:11PM -0500, Alexander Bulekov wrote:
>fork() is a simple way to ensure that state does not leak in between
>fuzzing runs. Unfortunately, the fuzzer mutation engine relies on
>bitmaps which contain coverage information for each fuzzing run, and
>these bitmaps should be copied from the child to the parent(where the
>mutation occurs). These bitmaps are created through compile-time
>instrumentation and they are not shared with fork()-ed processes, by
>default. To address this, we create a shared memory region, adjust its
>size and map it _over_ the counter region. Furthermore, libfuzzer
>doesn't generally expose the globals that specify the location of the
>counters/coverage bitmap. As a workaround, we rely on a custom linker
>script which forces all of the bitmaps we care about to be placed in a
>contiguous region, which is easy to locate and mmap over.
>
>Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
>---
> tests/qtest/fuzz/Makefile.include | 5 +++
> tests/qtest/fuzz/fork_fuzz.c | 55 +++++++++++++++++++++++++++++++
> tests/qtest/fuzz/fork_fuzz.h | 23 +++++++++++++
> tests/qtest/fuzz/fork_fuzz.ld | 37 +++++++++++++++++++++
> 4 files changed, 120 insertions(+)
> create mode 100644 tests/qtest/fuzz/fork_fuzz.c
> create mode 100644 tests/qtest/fuzz/fork_fuzz.h
> create mode 100644 tests/qtest/fuzz/fork_fuzz.ld
>
>diff --git a/tests/qtest/fuzz/Makefile.include b/tests/qtest/fuzz/Makefile.include
>index 8632bb89f4..a90915d56d 100644
>--- a/tests/qtest/fuzz/Makefile.include
>+++ b/tests/qtest/fuzz/Makefile.include
>@@ -2,5 +2,10 @@ QEMU_PROG_FUZZ=qemu-fuzz-$(TARGET_NAME)$(EXESUF)
>
> fuzz-obj-y += tests/qtest/libqtest.o
> fuzz-obj-y += tests/qtest/fuzz/fuzz.o # Fuzzer skeleton
>+fuzz-obj-y += tests/qtest/fuzz/fork_fuzz.o
>
> FUZZ_CFLAGS += -I$(SRC_PATH)/tests -I$(SRC_PATH)/tests/qtest
>+
>+# Linker Script to force coverage-counters into known regions which we can mark
>+# shared
>+FUZZ_LDFLAGS += -Xlinker -T$(SRC_PATH)/tests/qtest/fuzz/fork_fuzz.ld
>diff --git a/tests/qtest/fuzz/fork_fuzz.c b/tests/qtest/fuzz/fork_fuzz.c
>new file mode 100644
>index 0000000000..2bd0851903
>--- /dev/null
>+++ b/tests/qtest/fuzz/fork_fuzz.c
>@@ -0,0 +1,55 @@
>+/*
>+ * Fork-based fuzzing helpers
>+ *
>+ * Copyright Red Hat Inc., 2019
>+ *
>+ * Authors:
>+ * Alexander Bulekov <alxndr@bu.edu>
>+ *
>+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
>+ * See the COPYING file in the top-level directory.
>+ *
>+ */
>+
>+#include "qemu/osdep.h"
>+#include "fork_fuzz.h"
>+
>+
>+void counter_shm_init(void)
>+{
>+ char *shm_path = g_strdup_printf("/qemu-fuzz-cntrs.%d", getpid());
>+ int fd = shm_open(shm_path, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
>+ g_free(shm_path);
>+
>+ if (fd == -1) {
>+ perror("Error: ");
>+ exit(1);
>+ }
>+ if (ftruncate(fd, &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START) == -1) {
>+ perror("Error: ");
>+ exit(1);
>+ }
>+ /* Copy what's in the counter region to the shm.. */
>+ void *rptr = mmap(NULL ,
>+ &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START,
>+ PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
>+ memcpy(rptr,
>+ &__FUZZ_COUNTERS_START,
>+ &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START);
>+
>+ munmap(rptr, &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START);
>+
>+ /* And map the shm over the counter region */
>+ rptr = mmap(&__FUZZ_COUNTERS_START,
>+ &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START,
>+ PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, 0);
>+
>+ close(fd);
>+
>+ if (!rptr) {
>+ perror("Error: ");
>+ exit(1);
>+ }
>+}
>+
>+
>diff --git a/tests/qtest/fuzz/fork_fuzz.h b/tests/qtest/fuzz/fork_fuzz.h
>new file mode 100644
>index 0000000000..9ecb8b58ef
>--- /dev/null
>+++ b/tests/qtest/fuzz/fork_fuzz.h
>@@ -0,0 +1,23 @@
>+/*
>+ * Fork-based fuzzing helpers
>+ *
>+ * Copyright Red Hat Inc., 2019
>+ *
>+ * Authors:
>+ * Alexander Bulekov <alxndr@bu.edu>
>+ *
>+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
>+ * See the COPYING file in the top-level directory.
>+ *
>+ */
>+
>+#ifndef FORK_FUZZ_H
>+#define FORK_FUZZ_H
>+
>+extern uint8_t __FUZZ_COUNTERS_START;
>+extern uint8_t __FUZZ_COUNTERS_END;
>+
>+void counter_shm_init(void);
>+
>+#endif
>+
>diff --git a/tests/qtest/fuzz/fork_fuzz.ld b/tests/qtest/fuzz/fork_fuzz.ld
>new file mode 100644
>index 0000000000..b23a59f194
>--- /dev/null
>+++ b/tests/qtest/fuzz/fork_fuzz.ld
>@@ -0,0 +1,37 @@
>+/* We adjust linker script modification to place all of the stuff that needs to
>+ * persist across fuzzing runs into a contiguous seciton of memory. Then, it is
>+ * easy to re-map the counter-related memory as shared.
>+*/
>+
>+SECTIONS
>+{
>+ .data.fuzz_start : ALIGN(4K)
>+ {
>+ __FUZZ_COUNTERS_START = .;
>+ __start___sancov_cntrs = .;
>+ *(_*sancov_cntrs);
>+ __stop___sancov_cntrs = .;
>+
>+ /* Lowest stack counter */
>+ *(__sancov_lowest_stack);
>+ }
>+ .data.fuzz_ordered :
>+ {
>+ /* Coverage counters. They're not necessary for fuzzing, but are useful
>+ * for analyzing the fuzzing performance
>+ */
>+ __start___llvm_prf_cnts = .;
>+ *(*llvm_prf_cnts);
>+ __stop___llvm_prf_cnts = .;
>+
>+ /* Internal Libfuzzer TracePC object which contains the ValueProfileMap */
>+ FuzzerTracePC*(.bss*);
>+ }
>+ .data.fuzz_end : ALIGN(4K)
>+ {
>+ __FUZZ_COUNTERS_END = .;
>+ }
>+}
>+/* Dont overwrite the SECTIONS in the default linker script. Instead insert the
>+ * above into the default script */
>+INSERT AFTER .data;
>--
>2.25.0
>
^ permalink raw reply
* Re: [PATCH v3 22/22] x86/int3: Ensure that poke_int3_handler() is not sanitized
From: Dmitry Vyukov @ 2020-02-20 10:37 UTC (permalink / raw)
To: Peter Zijlstra
Cc: LKML, linux-arch, Steven Rostedt, Ingo Molnar, Joel Fernandes,
Greg Kroah-Hartman, Gustavo A. R. Silva, Thomas Gleixner,
Paul E. McKenney, Josh Triplett, Mathieu Desnoyers, Lai Jiangshan,
Andy Lutomirski, tony.luck, Frederic Weisbecker, Dan Carpenter,
Masami Hiramatsu, Andrey Ryabinin, kasan-dev
In-Reply-To: <20200219172014.GI14946@hirez.programming.kicks-ass.net>
On Wed, Feb 19, 2020 at 6:20 PM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Wed, Feb 19, 2020 at 05:30:25PM +0100, Peter Zijlstra wrote:
>
> > By inlining everything in poke_int3_handler() (except bsearch :/) we can
> > mark the whole function off limits to everything and call it a day. That
> > simplicity has been the guiding principle so far.
> >
> > Alternatively we can provide an __always_inline variant of bsearch().
>
> This reduces the __no_sanitize usage to just the exception entry
> (do_int3) and the critical function: poke_int3_handler().
>
> Is this more acceptible?
Let's say it's more acceptable.
Acked-by: Dmitry Vyukov <dvyukov@google.com>
I guess there is no ideal solution here.
Just a straw man proposal: expected number of elements is large enough
to make bsearch profitable, right? I see 1 is a common case, but the
other case has multiple entries.
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -979,7 +979,7 @@ static __always_inline void *text_poke_a
> return _stext + tp->rel_addr;
> }
>
> -static int notrace __no_sanitize patch_cmp(const void *key, const void *elt)
> +static __always_inline int patch_cmp(const void *key, const void *elt)
> {
> struct text_poke_loc *tp = (struct text_poke_loc *) elt;
>
> @@ -989,7 +989,6 @@ static int notrace __no_sanitize patch_c
> return 1;
> return 0;
> }
> -NOKPROBE_SYMBOL(patch_cmp);
>
> int notrace __no_sanitize poke_int3_handler(struct pt_regs *regs)
> {
> @@ -1024,9 +1023,9 @@ int notrace __no_sanitize poke_int3_hand
> * Skip the binary search if there is a single member in the vector.
> */
> if (unlikely(desc->nr_entries > 1)) {
> - tp = bsearch(ip, desc->vec, desc->nr_entries,
> - sizeof(struct text_poke_loc),
> - patch_cmp);
> + tp = __bsearch(ip, desc->vec, desc->nr_entries,
> + sizeof(struct text_poke_loc),
> + patch_cmp);
> if (!tp)
> goto out_put;
> } else {
> --- a/include/linux/bsearch.h
> +++ b/include/linux/bsearch.h
> @@ -4,7 +4,29 @@
>
> #include <linux/types.h>
>
> -void *bsearch(const void *key, const void *base, size_t num, size_t size,
> - cmp_func_t cmp);
> +static __always_inline
> +void *__bsearch(const void *key, const void *base, size_t num, size_t size, cmp_func_t cmp)
> +{
> + const char *pivot;
> + int result;
> +
> + while (num > 0) {
> + pivot = base + (num >> 1) * size;
> + result = cmp(key, pivot);
> +
> + if (result == 0)
> + return (void *)pivot;
> +
> + if (result > 0) {
> + base = pivot + size;
> + num--;
> + }
> + num >>= 1;
> + }
> +
> + return NULL;
> +}
> +
> +extern void *bsearch(const void *key, const void *base, size_t num, size_t size, cmp_func_t cmp);
>
> #endif /* _LINUX_BSEARCH_H */
> --- a/lib/bsearch.c
> +++ b/lib/bsearch.c
> @@ -28,27 +28,9 @@
> * the key and elements in the array are of the same type, you can use
> * the same comparison function for both sort() and bsearch().
> */
> -void __no_sanitize *bsearch(const void *key, const void *base, size_t num, size_t size,
> - cmp_func_t cmp)
> +void *bsearch(const void *key, const void *base, size_t num, size_t size, cmp_func_t cmp)
> {
> - const char *pivot;
> - int result;
> -
> - while (num > 0) {
> - pivot = base + (num >> 1) * size;
> - result = cmp(key, pivot);
> -
> - if (result == 0)
> - return (void *)pivot;
> -
> - if (result > 0) {
> - base = pivot + size;
> - num--;
> - }
> - num >>= 1;
> - }
> -
> - return NULL;
> + __bsearch(key, base, num, size, cmp);
> }
> EXPORT_SYMBOL(bsearch);
> NOKPROBE_SYMBOL(bsearch);
^ permalink raw reply
* Re: [PATCH] asm-generic/atomic: Add try_cmpxchg() fallbacks
From: Peter Zijlstra @ 2020-02-20 10:37 UTC (permalink / raw)
To: Will Deacon
Cc: Jens Axboe, Carter Li 李通洲, Pavel Begunkov,
io-uring, Oleg Nesterov, Mark Rutland, linux-kernel
In-Reply-To: <20200220103044.GA13608@willie-the-truck>
On Thu, Feb 20, 2020 at 10:30:45AM +0000, Will Deacon wrote:
> On Tue, Feb 18, 2020 at 03:27:00PM +0100, Peter Zijlstra wrote:
> > On Tue, Feb 18, 2020 at 02:13:10PM +0100, Peter Zijlstra wrote:
> > > (with the caveat that try_cmpxchg() doesn't seem available on !x86 -- I
> > > should go fix that)
> >
> > Completely untested (lemme go do that shortly), but something like so I
> > suppose.
> >
> > ---
> > Subject: asm-generic/atomic: Add try_cmpxchg() fallbacks
> >
> > Only x86 provides try_cmpxchg() outside of the atomic_t interfaces,
> > provide generic fallbacks to create this interface from the widely
> > available cmpxchg() function.
> >
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > ---
> > diff --git a/include/linux/atomic-fallback.h b/include/linux/atomic-fallback.h
> > index 656b5489b673..243f61d6c35f 100644
> > --- a/include/linux/atomic-fallback.h
> > +++ b/include/linux/atomic-fallback.h
> > @@ -77,6 +77,50 @@
> >
> > #endif /* cmpxchg64_relaxed */
> >
> > +#ifndef try_cmpxchg
> > +#define try_cmpxchg(_ptr, _oldp, _new) \
> > +({ \
> > + typeof(*ptr) ___r, ___o = *(_oldp); \
>
> Probably worth pointing out that this will have the nasty behaviour
> for volatile pointers that we're tackling for READ_ONCE. Obviously no
> need to hold this up, but just mentioning it here in the hope that one
> of us remembers to fix it later on.
Right :/
> > diff --git a/scripts/atomic/gen-atomic-fallback.sh b/scripts/atomic/gen-atomic-fallback.sh
> > index b6c6f5d306a7..3c9be8d550e0 100755
> > --- a/scripts/atomic/gen-atomic-fallback.sh
> > +++ b/scripts/atomic/gen-atomic-fallback.sh
> > @@ -140,6 +140,32 @@ cat <<EOF
> > EOF
> > }
> >
> > +gen_try_cmpxchg_fallback()
> > +{
> > + local order="$1"; shift;
> > +
> > +cat <<EOF
> > +#ifndef try_cmpxchg${order}
> > +#define try_cmpxchg${order}(_ptr, _oldp, _new) \\
> > +({ \\
> > + typeof(*ptr) ___r, ___o = *(_oldp); \\
> > + ___r = cmpxchg${order}((_ptr), ___o, (_new)); \\
> > + if (unlikely(___r != ___o)) \\
> > + *(_old) = ___r; \\
>
> This doesn't compile because _old isn't declared. Probably best to avoid
> evaluating _oldp twice though.
Compiler had already spotted that, I'll make it something like:
typeof(*ptr) *___op = (_oldp), ___o = *___op;
...
*___op = ___r;
Which avoids the double eval.
^ permalink raw reply
* Re: [dpdk-dev] [PATCH] test/ipsec: fix a typo in function name
From: Akhil Goyal @ 2020-02-20 10:37 UTC (permalink / raw)
To: Ananyev, Konstantin, Thomas Monjalon, dev@dpdk.org
Cc: stable@dpdk.org, Iremonger, Bernard, Medvedkin, Vladimir,
Awal, Mohammad Abdul, Doherty, Declan
In-Reply-To: <SN6PR11MB25582EE2BC68856B95735C649A100@SN6PR11MB2558.namprd11.prod.outlook.com>
> >
> > The name of the static function check_cryptodev_capablity()
> > is fixed for the word "capability".
> > There is no functional change.
> >
> > The same typo is fixed in a comment in ip_fragmentation example.
> >
> > Fixes: 05fe65eb66b2 ("test/ipsec: introduce functional test")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > ---
>
> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Applied to dpdk-next-crypto
Thanks.
^ permalink raw reply
* Re: [PATCH v4 3/3] clocksource: Add Low Power STM32 timers driver
From: Daniel Lezcano @ 2020-02-20 10:36 UTC (permalink / raw)
To: Benjamin Gaignard, lee.jones, robh+dt, mark.rutland,
mcoquelin.stm32, alexandre.torgue, tglx, fabrice.gasnier
Cc: devicetree, linux-kernel, Pascal Paillet, Benjamin Gaignard,
linux-stm32, linux-arm-kernel
In-Reply-To: <20200217134546.14562-4-benjamin.gaignard@st.com>
On 17/02/2020 14:45, Benjamin Gaignard wrote:
> From: Benjamin Gaignard <benjamin.gaignard@linaro.org>
>
> Implement clock event driver using low power STM32 timers.
> Low power timer counters running even when CPUs are stopped.
> It could be used as clock event broadcaster to wake up CPUs but not like
> a clocksource because each it rise an interrupt the counter restart from 0.
>
> Low power timers have a 16 bits counter and a prescaler which allow to
> divide the clock per power of 2 to up 128 to target a 32KHz rate.
>
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
> Signed-off-by: Pascal Paillet <p.paillet@st.com>
> ---
> version 4:
> - move defines in mfd/stm32-lptimer.h
> - change compatiblename
> - reword commit message
> - make driver Kconfig depends of MFD_STM32_LPTIMER
> - remove useless include
> - remove rate and clk fields from the private structure
> - to add comments about the registers sequence in stm32_clkevent_lp_set_timer
> - rework probe function and use devm_request_irq()
> - do not allow module to be removed
> - make sure that wakeup interrupt is set
>
> drivers/clocksource/Kconfig | 7 ++
> drivers/clocksource/Makefile | 1 +
> drivers/clocksource/timer-stm32-lp.c | 213 +++++++++++++++++++++++++++++++++++
> 3 files changed, 221 insertions(+)
> create mode 100644 drivers/clocksource/timer-stm32-lp.c
>
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index cc909e465823..9fc2b513db6f 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -292,6 +292,13 @@ config CLKSRC_STM32
> select CLKSRC_MMIO
> select TIMER_OF
>
> +config CLKSRC_STM32_LP
> + bool "Low power clocksource for STM32 SoCs"
> + depends on MFD_STM32_LPTIMER || COMPILE_TEST
> + help
> + This option enables support for STM32 low power clockevent available
> + on STM32 SoCs
> +
> config CLKSRC_MPS2
> bool "Clocksource for MPS2 SoCs" if COMPILE_TEST
> depends on GENERIC_SCHED_CLOCK
> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> index 713686faa549..c00fffbd4769 100644
> --- a/drivers/clocksource/Makefile
> +++ b/drivers/clocksource/Makefile
> @@ -44,6 +44,7 @@ obj-$(CONFIG_BCM_KONA_TIMER) += bcm_kona_timer.o
> obj-$(CONFIG_CADENCE_TTC_TIMER) += timer-cadence-ttc.o
> obj-$(CONFIG_CLKSRC_EFM32) += timer-efm32.o
> obj-$(CONFIG_CLKSRC_STM32) += timer-stm32.o
> +obj-$(CONFIG_CLKSRC_STM32_LP) += timer-stm32-lp.o
> obj-$(CONFIG_CLKSRC_EXYNOS_MCT) += exynos_mct.o
> obj-$(CONFIG_CLKSRC_LPC32XX) += timer-lpc32xx.o
> obj-$(CONFIG_CLKSRC_MPS2) += mps2-timer.o
> diff --git a/drivers/clocksource/timer-stm32-lp.c b/drivers/clocksource/timer-stm32-lp.c
> new file mode 100644
> index 000000000000..50eecdb88216
> --- /dev/null
> +++ b/drivers/clocksource/timer-stm32-lp.c
> @@ -0,0 +1,213 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) STMicroelectronics 2019 - All Rights Reserved
> + * Authors: Benjamin Gaignard <benjamin.gaignard@st.com> for STMicroelectronics.
> + * Pascal Paillet <p.paillet@st.com> for STMicroelectronics.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/clockchips.h>
> +#include <linux/interrupt.h>
> +#include <linux/mfd/stm32-lptimer.h>
> +#include <linux/module.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>
> +#include <linux/platform_device.h>
> +#include <linux/pm_wakeirq.h>
> +
> +#define CFGR_PSC_OFFSET 9
> +#define STM32_LP_RATING 400
> +#define STM32_TARGET_CLKRATE (32000 * HZ)
> +#define STM32_LP_MAX_PSC 7
> +
> +struct stm32_lp_private {
> + struct regmap *reg;
> + struct clock_event_device clkevt;
> + unsigned long period;
> +};
> +
> +static struct stm32_lp_private*
> +to_priv(struct clock_event_device *clkevt)
> +{
> + return container_of(clkevt, struct stm32_lp_private, clkevt);
> +}
> +
> +static int stm32_clkevent_lp_shutdown(struct clock_event_device *clkevt)
> +{
> + struct stm32_lp_private *priv = to_priv(clkevt);
> +
> + regmap_write(priv->reg, STM32_LPTIM_CR, 0);
> + regmap_write(priv->reg, STM32_LPTIM_IER, 0);
> + /* clear pending flags */
> + regmap_write(priv->reg, STM32_LPTIM_ICR, STM32_LPTIM_ARRMCF);
> +
> + return 0;
> +}
> +
> +static int stm32_clkevent_lp_set_timer(unsigned long evt,
> + struct clock_event_device *clkevt,
> + int is_periodic)
> +{
> + struct stm32_lp_private *priv = to_priv(clkevt);
> +
> + /* disable LPTIMER to be able to write into IER register*/
> + regmap_write(priv->reg, STM32_LPTIM_CR, 0);
> + /* enable ARR interrupt */
> + regmap_write(priv->reg, STM32_LPTIM_IER, STM32_LPTIM_ARRMIE);
> + /* enable LPTIMER to be able to write into ARR register */
> + regmap_write(priv->reg, STM32_LPTIM_CR, STM32_LPTIM_ENABLE);
> + /* set next event counter */
> + regmap_write(priv->reg, STM32_LPTIM_ARR, evt);
> +
> + /* start counter */
> + if (is_periodic)
> + regmap_write(priv->reg, STM32_LPTIM_CR,
> + STM32_LPTIM_CNTSTRT | STM32_LPTIM_ENABLE);
> + else
> + regmap_write(priv->reg, STM32_LPTIM_CR,
> + STM32_LPTIM_SNGSTRT | STM32_LPTIM_ENABLE);
The regmap config in stm32-lptimer is not defined with the fast_io flag
(on purpose or not?) that means we can potentially deadlock here as the
lock is a mutex.
Isn't it detected with the lock validation scheme?
> + return 0;
> +}
> +static int stm32_clkevent_lp_remove(struct platform_device *pdev)
> +{
> + return -EBUSY; /* cannot unregister clockevent */
> +}
Won't be the mfd into an inconsistent state here? The other subsystems
will be removed but this one will prevent to unload the module leading
to a situation where the mfd is partially removed but still there
without a possible recovery, no?
> +static const struct of_device_id stm32_clkevent_lp_of_match[] = {
> + { .compatible = "st,stm32-lptimer-timer", },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, stm32_clkevent_lp_of_match);
> +
> +static struct platform_driver stm32_clkevent_lp_driver = {
> + .probe = stm32_clkevent_lp_probe,
> + .remove = stm32_clkevent_lp_remove,
> + .driver = {
> + .name = "stm32-lptimer-timer",
> + .of_match_table = of_match_ptr(stm32_clkevent_lp_of_match),
> + },
> +};
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply
* Re: [PATCH v4 3/3] clocksource: Add Low Power STM32 timers driver
From: Daniel Lezcano @ 2020-02-20 10:36 UTC (permalink / raw)
To: Benjamin Gaignard, lee.jones, robh+dt, mark.rutland,
mcoquelin.stm32, alexandre.torgue, tglx, fabrice.gasnier
Cc: devicetree, linux-stm32, linux-arm-kernel, linux-kernel,
Benjamin Gaignard, Pascal Paillet
In-Reply-To: <20200217134546.14562-4-benjamin.gaignard@st.com>
On 17/02/2020 14:45, Benjamin Gaignard wrote:
> From: Benjamin Gaignard <benjamin.gaignard@linaro.org>
>
> Implement clock event driver using low power STM32 timers.
> Low power timer counters running even when CPUs are stopped.
> It could be used as clock event broadcaster to wake up CPUs but not like
> a clocksource because each it rise an interrupt the counter restart from 0.
>
> Low power timers have a 16 bits counter and a prescaler which allow to
> divide the clock per power of 2 to up 128 to target a 32KHz rate.
>
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
> Signed-off-by: Pascal Paillet <p.paillet@st.com>
> ---
> version 4:
> - move defines in mfd/stm32-lptimer.h
> - change compatiblename
> - reword commit message
> - make driver Kconfig depends of MFD_STM32_LPTIMER
> - remove useless include
> - remove rate and clk fields from the private structure
> - to add comments about the registers sequence in stm32_clkevent_lp_set_timer
> - rework probe function and use devm_request_irq()
> - do not allow module to be removed
> - make sure that wakeup interrupt is set
>
> drivers/clocksource/Kconfig | 7 ++
> drivers/clocksource/Makefile | 1 +
> drivers/clocksource/timer-stm32-lp.c | 213 +++++++++++++++++++++++++++++++++++
> 3 files changed, 221 insertions(+)
> create mode 100644 drivers/clocksource/timer-stm32-lp.c
>
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index cc909e465823..9fc2b513db6f 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -292,6 +292,13 @@ config CLKSRC_STM32
> select CLKSRC_MMIO
> select TIMER_OF
>
> +config CLKSRC_STM32_LP
> + bool "Low power clocksource for STM32 SoCs"
> + depends on MFD_STM32_LPTIMER || COMPILE_TEST
> + help
> + This option enables support for STM32 low power clockevent available
> + on STM32 SoCs
> +
> config CLKSRC_MPS2
> bool "Clocksource for MPS2 SoCs" if COMPILE_TEST
> depends on GENERIC_SCHED_CLOCK
> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> index 713686faa549..c00fffbd4769 100644
> --- a/drivers/clocksource/Makefile
> +++ b/drivers/clocksource/Makefile
> @@ -44,6 +44,7 @@ obj-$(CONFIG_BCM_KONA_TIMER) += bcm_kona_timer.o
> obj-$(CONFIG_CADENCE_TTC_TIMER) += timer-cadence-ttc.o
> obj-$(CONFIG_CLKSRC_EFM32) += timer-efm32.o
> obj-$(CONFIG_CLKSRC_STM32) += timer-stm32.o
> +obj-$(CONFIG_CLKSRC_STM32_LP) += timer-stm32-lp.o
> obj-$(CONFIG_CLKSRC_EXYNOS_MCT) += exynos_mct.o
> obj-$(CONFIG_CLKSRC_LPC32XX) += timer-lpc32xx.o
> obj-$(CONFIG_CLKSRC_MPS2) += mps2-timer.o
> diff --git a/drivers/clocksource/timer-stm32-lp.c b/drivers/clocksource/timer-stm32-lp.c
> new file mode 100644
> index 000000000000..50eecdb88216
> --- /dev/null
> +++ b/drivers/clocksource/timer-stm32-lp.c
> @@ -0,0 +1,213 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) STMicroelectronics 2019 - All Rights Reserved
> + * Authors: Benjamin Gaignard <benjamin.gaignard@st.com> for STMicroelectronics.
> + * Pascal Paillet <p.paillet@st.com> for STMicroelectronics.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/clockchips.h>
> +#include <linux/interrupt.h>
> +#include <linux/mfd/stm32-lptimer.h>
> +#include <linux/module.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>
> +#include <linux/platform_device.h>
> +#include <linux/pm_wakeirq.h>
> +
> +#define CFGR_PSC_OFFSET 9
> +#define STM32_LP_RATING 400
> +#define STM32_TARGET_CLKRATE (32000 * HZ)
> +#define STM32_LP_MAX_PSC 7
> +
> +struct stm32_lp_private {
> + struct regmap *reg;
> + struct clock_event_device clkevt;
> + unsigned long period;
> +};
> +
> +static struct stm32_lp_private*
> +to_priv(struct clock_event_device *clkevt)
> +{
> + return container_of(clkevt, struct stm32_lp_private, clkevt);
> +}
> +
> +static int stm32_clkevent_lp_shutdown(struct clock_event_device *clkevt)
> +{
> + struct stm32_lp_private *priv = to_priv(clkevt);
> +
> + regmap_write(priv->reg, STM32_LPTIM_CR, 0);
> + regmap_write(priv->reg, STM32_LPTIM_IER, 0);
> + /* clear pending flags */
> + regmap_write(priv->reg, STM32_LPTIM_ICR, STM32_LPTIM_ARRMCF);
> +
> + return 0;
> +}
> +
> +static int stm32_clkevent_lp_set_timer(unsigned long evt,
> + struct clock_event_device *clkevt,
> + int is_periodic)
> +{
> + struct stm32_lp_private *priv = to_priv(clkevt);
> +
> + /* disable LPTIMER to be able to write into IER register*/
> + regmap_write(priv->reg, STM32_LPTIM_CR, 0);
> + /* enable ARR interrupt */
> + regmap_write(priv->reg, STM32_LPTIM_IER, STM32_LPTIM_ARRMIE);
> + /* enable LPTIMER to be able to write into ARR register */
> + regmap_write(priv->reg, STM32_LPTIM_CR, STM32_LPTIM_ENABLE);
> + /* set next event counter */
> + regmap_write(priv->reg, STM32_LPTIM_ARR, evt);
> +
> + /* start counter */
> + if (is_periodic)
> + regmap_write(priv->reg, STM32_LPTIM_CR,
> + STM32_LPTIM_CNTSTRT | STM32_LPTIM_ENABLE);
> + else
> + regmap_write(priv->reg, STM32_LPTIM_CR,
> + STM32_LPTIM_SNGSTRT | STM32_LPTIM_ENABLE);
The regmap config in stm32-lptimer is not defined with the fast_io flag
(on purpose or not?) that means we can potentially deadlock here as the
lock is a mutex.
Isn't it detected with the lock validation scheme?
> + return 0;
> +}
> +static int stm32_clkevent_lp_remove(struct platform_device *pdev)
> +{
> + return -EBUSY; /* cannot unregister clockevent */
> +}
Won't be the mfd into an inconsistent state here? The other subsystems
will be removed but this one will prevent to unload the module leading
to a situation where the mfd is partially removed but still there
without a possible recovery, no?
> +static const struct of_device_id stm32_clkevent_lp_of_match[] = {
> + { .compatible = "st,stm32-lptimer-timer", },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, stm32_clkevent_lp_of_match);
> +
> +static struct platform_driver stm32_clkevent_lp_driver = {
> + .probe = stm32_clkevent_lp_probe,
> + .remove = stm32_clkevent_lp_remove,
> + .driver = {
> + .name = "stm32-lptimer-timer",
> + .of_match_table = of_match_ptr(stm32_clkevent_lp_of_match),
> + },
> +};
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply
* Re: [PATCH] drm/amdgpu: fix a bug NULL pointer dereference
From: Nirmoy @ 2020-02-20 10:39 UTC (permalink / raw)
To: amd-gfx
In-Reply-To: <MN2PR12MB3167C68A5B6AF0E97613A6A4ED130@MN2PR12MB3167.namprd12.prod.outlook.com>
On 2/20/20 9:41 AM, Li, Dennis wrote:
> [AMD Official Use Only - Internal Distribution Only]
>
> Hi, Christian and Monk,
> When doing SDMA copy, a RAS uncorrectable error happens, which will cause this issue. The RAS uncorrectable error event will trigger driver to do BACO reset which will set the status of SDMA scheduler to no ready. And then drm_sched_entity_get_free_sched will return NULL in drm_sched_entity_select_rq, which cause entity->rq to NULL.
This can happen only in drm_sched_job_init() which gets called in
amdgpu_job_submit() which is after when we get this NULL ptr exception.
entity = p->direct ? &p->vm->direct : &p->vm->delayed;
ring = container_of(entity->rq->sched, struct amdgpu_ring, sched);
WARN_ON(ib->length_dw == 0);
amdgpu_ring_pad_ib(ring, ib);
WARN_ON(ib->length_dw > p->num_dw_left);
r = amdgpu_job_submit(p->job, entity, AMDGPU_FENCE_OWNER_VM,
&f); <-- Here
if (r)
goto error;
Could it be possible that we are doing drm_sched_entity_init() for
direct and indirect entity with zero scheds in amdgpu_vm_init() ?
Regards,
Nirmoy
> Best Regards
> Dennis Li
> -----Original Message-----
> From: Liu, Monk <Monk.Liu@amd.com>
> Sent: Wednesday, February 19, 2020 7:30 PM
> To: Koenig, Christian <Christian.Koenig@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>; Li, Dennis <Dennis.Li@amd.com>; amd-gfx@lists.freedesktop.org; Deucher, Alexander <Alexander.Deucher@amd.com>; Zhou1, Tao <Tao.Zhou1@amd.com>; Chen, Guchun <Guchun.Chen@amd.com>
> Subject: 回复: [PATCH] drm/amdgpu: fix a bug NULL pointer dereference
>
>> + if (!entity->rq)
>> + return 0;
>> +
> Yes, supposedly we shouldn't get 'entity->rq == NULL' case , that looks the true bug
>
> -----邮件原件-----
> 发件人: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 Christian K?nig
> 发送时间: 2020年2月19日 18:50
> 收件人: Zhang, Hawking <Hawking.Zhang@amd.com>; Li, Dennis <Dennis.Li@amd.com>; amd-gfx@lists.freedesktop.org; Deucher, Alexander <Alexander.Deucher@amd.com>; Zhou1, Tao <Tao.Zhou1@amd.com>; Chen, Guchun <Guchun.Chen@amd.com>
> 主题: Re: [PATCH] drm/amdgpu: fix a bug NULL pointer dereference
>
> Well of hand this patch looks like a clear NAK to me.
>
> Returning without raising an error is certainly the wrong thing to do here because we just drop the necessary page table updates.
>
> How does the entity->rq ends up as NULL in the first place?
>
> Regards,
> Christian.
>
> Am 19.02.20 um 07:26 schrieb Zhang, Hawking:
>> [AMD Official Use Only - Internal Distribution Only]
>>
>> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
>>
>> Regards,
>> Hawking
>> -----Original Message-----
>> From: Dennis Li <Dennis.Li@amd.com>
>> Sent: Wednesday, February 19, 2020 12:05
>> To: amd-gfx@lists.freedesktop.org; Deucher, Alexander
>> <Alexander.Deucher@amd.com>; Zhou1, Tao <Tao.Zhou1@amd.com>; Zhang,
>> Hawking <Hawking.Zhang@amd.com>; Chen, Guchun <Guchun.Chen@amd.com>
>> Cc: Li, Dennis <Dennis.Li@amd.com>
>> Subject: [PATCH] drm/amdgpu: fix a bug NULL pointer dereference
>>
>> check whether the queue of entity is null to avoid null pointer dereference.
>>
>> Change-Id: I08d56774012cf229ba2fe7a011c1359e8d1e2781
>> Signed-off-by: Dennis Li <Dennis.Li@amd.com>
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c
>> index 4cc7881f438c..67cca463ddcc 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c
>> @@ -95,6 +95,9 @@ static int amdgpu_vm_sdma_commit(struct amdgpu_vm_update_params *p,
>> int r;
>>
>> entity = p->direct ? &p->vm->direct : &p->vm->delayed;
>> + if (!entity->rq)
>> + return 0;
>> +
>> ring = container_of(entity->rq->sched, struct amdgpu_ring, sched);
>>
>> WARN_ON(ib->length_dw == 0);
>> --
>> 2.17.1
>> _______________________________________________
>> amd-gfx mailing list
>> amd-gfx@lists.freedesktop.org
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flist
>> s.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Cmo
>> nk.liu%40amd.com%7C28e7260af3a24eec758f08d7b52975e3%7C3dd8961fe4884e60
>> 8e11a82d994e183d%7C0%7C0%7C637177062003213431&sdata=vMXmhwTlN8lAav
>> uqhYhpmKLM6V%2F%2B2%2FubFBbsk%2BGY%2Bjw%3D&reserved=0
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Cnirmoy.das%40amd.com%7C3af940db61dd474eb3f608d7b5e0a5cb%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637177848788408220&sdata=QiKFb5KAI21G4%2B5OiNxf22OIlmSu0078xhFquDVrIXA%3D&reserved=0
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Cnirmoy.das%40amd.com%7C3af940db61dd474eb3f608d7b5e0a5cb%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637177848788408220&sdata=QiKFb5KAI21G4%2B5OiNxf22OIlmSu0078xhFquDVrIXA%3D&reserved=0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply
* Re: [dpdk-dev] [PATCH] ipsec: fix use of uninitialized variable
From: Akhil Goyal @ 2020-02-20 10:36 UTC (permalink / raw)
To: Mcnamara, John, Iremonger, Bernard, Ananyev, Konstantin,
dev@dpdk.org
Cc: Ananyev, Konstantin
In-Reply-To: <MWHPR1101MB21581AC3A635DB6AAD630661FC100@MWHPR1101MB2158.namprd11.prod.outlook.com>
> > > Defects reported by coverity scan
> > > uninit_use_in_call: Using uninitialized element of array clen when
> > > calling cpu_crypto_bulk.
> > >
> > > Coverity issue: 354233, 354234
> > > Fixes: 957394f72658 ("ipsec: support CPU crypto mode")
> > >
> > > Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> >
> > Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
>
> If possible can we get this merged into RC4.
Applied to dpdk-next-crypto
Thanks.
^ permalink raw reply
* Re: [PATCH v10 20/22] fuzz: add virtio-net fuzz target
From: Darren Kenny @ 2020-02-20 10:35 UTC (permalink / raw)
To: Alexander Bulekov
Cc: Laurent Vivier, Thomas Huth, qemu-devel, bsd, stefanha, pbonzini
In-Reply-To: <20200220041118.23264-21-alxndr@bu.edu>
On Wed, Feb 19, 2020 at 11:11:16PM -0500, Alexander Bulekov wrote:
>The virtio-net fuzz target feeds inputs to all three virtio-net
>virtqueues, and uses forking to avoid leaking state between fuzz runs.
>
>Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
>---
> tests/qtest/fuzz/Makefile.include | 1 +
> tests/qtest/fuzz/virtio_net_fuzz.c | 198 +++++++++++++++++++++++++++++
> 2 files changed, 199 insertions(+)
> create mode 100644 tests/qtest/fuzz/virtio_net_fuzz.c
>
>diff --git a/tests/qtest/fuzz/Makefile.include b/tests/qtest/fuzz/Makefile.include
>index 38b8cdd9f1..77385777ef 100644
>--- a/tests/qtest/fuzz/Makefile.include
>+++ b/tests/qtest/fuzz/Makefile.include
>@@ -8,6 +8,7 @@ fuzz-obj-y += tests/qtest/fuzz/qos_fuzz.o
>
> # Targets
> fuzz-obj-y += tests/qtest/fuzz/i440fx_fuzz.o
>+fuzz-obj-y += tests/qtest/fuzz/virtio_net_fuzz.o
>
> FUZZ_CFLAGS += -I$(SRC_PATH)/tests -I$(SRC_PATH)/tests/qtest
>
>diff --git a/tests/qtest/fuzz/virtio_net_fuzz.c b/tests/qtest/fuzz/virtio_net_fuzz.c
>new file mode 100644
>index 0000000000..d08a47e278
>--- /dev/null
>+++ b/tests/qtest/fuzz/virtio_net_fuzz.c
>@@ -0,0 +1,198 @@
>+/*
>+ * virtio-net Fuzzing Target
>+ *
>+ * Copyright Red Hat Inc., 2019
>+ *
>+ * Authors:
>+ * Alexander Bulekov <alxndr@bu.edu>
>+ *
>+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
>+ * See the COPYING file in the top-level directory.
>+ */
>+
>+#include "qemu/osdep.h"
>+
>+#include "standard-headers/linux/virtio_config.h"
>+#include "tests/qtest/libqtest.h"
>+#include "tests/qtest/libqos/virtio-net.h"
>+#include "fuzz.h"
>+#include "fork_fuzz.h"
>+#include "qos_fuzz.h"
>+
>+
>+#define QVIRTIO_NET_TIMEOUT_US (30 * 1000 * 1000)
>+#define QVIRTIO_RX_VQ 0
>+#define QVIRTIO_TX_VQ 1
>+#define QVIRTIO_CTRL_VQ 2
>+
>+static int sockfds[2];
>+static bool sockfds_initialized;
>+
>+static void virtio_net_fuzz_multi(QTestState *s,
>+ const unsigned char *Data, size_t Size, bool check_used)
>+{
>+ typedef struct vq_action {
>+ uint8_t queue;
>+ uint8_t length;
>+ uint8_t write;
>+ uint8_t next;
>+ uint8_t rx;
>+ } vq_action;
>+
>+ uint32_t free_head = 0;
>+
>+ QGuestAllocator *t_alloc = fuzz_qos_alloc;
>+
>+ QVirtioNet *net_if = fuzz_qos_obj;
>+ QVirtioDevice *dev = net_if->vdev;
>+ QVirtQueue *q;
>+ vq_action vqa;
>+ while (Size >= sizeof(vqa)) {
>+ memcpy(&vqa, Data, sizeof(vqa));
>+ Data += sizeof(vqa);
>+ Size -= sizeof(vqa);
>+
>+ q = net_if->queues[vqa.queue % 3];
>+
>+ vqa.length = vqa.length >= Size ? Size : vqa.length;
>+
>+ /*
>+ * Only attempt to write incoming packets, when using the socket
>+ * backend. Otherwise, always place the input on a virtqueue.
>+ */
>+ if (vqa.rx && sockfds_initialized) {
>+ write(sockfds[0], Data, vqa.length);
>+ } else {
>+ vqa.rx = 0;
>+ uint64_t req_addr = guest_alloc(t_alloc, vqa.length);
>+ /*
>+ * If checking used ring, ensure that the fuzzer doesn't trigger
>+ * trivial asserion failure on zero-zied buffer
>+ */
>+ qtest_memwrite(s, req_addr, Data, vqa.length);
>+
>+
>+ free_head = qvirtqueue_add(s, q, req_addr, vqa.length,
>+ vqa.write, vqa.next);
>+ qvirtqueue_add(s, q, req_addr, vqa.length, vqa.write , vqa.next);
>+ qvirtqueue_kick(s, dev, q, free_head);
>+ }
>+
>+ /* Run the main loop */
>+ qtest_clock_step(s, 100);
>+ flush_events(s);
>+
>+ /* Wait on used descriptors */
>+ if (check_used && !vqa.rx) {
>+ gint64 start_time = g_get_monotonic_time();
>+ /*
>+ * normally, we could just use qvirtio_wait_used_elem, but since we
>+ * must manually run the main-loop for all the bhs to run, we use
>+ * this hack with flush_events(), to run the main_loop
>+ */
>+ while (!vqa.rx && q != net_if->queues[QVIRTIO_RX_VQ]) {
>+ uint32_t got_desc_idx;
>+ /* Input led to a virtio_error */
>+ if (dev->bus->get_status(dev) & VIRTIO_CONFIG_S_NEEDS_RESET) {
>+ break;
>+ }
>+ if (dev->bus->get_queue_isr_status(dev, q) &&
>+ qvirtqueue_get_buf(s, q, &got_desc_idx, NULL)) {
>+ g_assert_cmpint(got_desc_idx, ==, free_head);
>+ break;
>+ }
>+ g_assert(g_get_monotonic_time() - start_time
>+ <= QVIRTIO_NET_TIMEOUT_US);
>+
>+ /* Run the main loop */
>+ qtest_clock_step(s, 100);
>+ flush_events(s);
>+ }
>+ }
>+ Data += vqa.length;
>+ Size -= vqa.length;
>+ }
>+}
>+
>+static void virtio_net_fork_fuzz(QTestState *s,
>+ const unsigned char *Data, size_t Size)
>+{
>+ if (fork() == 0) {
>+ virtio_net_fuzz_multi(s, Data, Size, false);
>+ flush_events(s);
>+ _Exit(0);
>+ } else {
>+ wait(NULL);
>+ }
>+}
>+
>+static void virtio_net_fork_fuzz_check_used(QTestState *s,
>+ const unsigned char *Data, size_t Size)
>+{
>+ if (fork() == 0) {
>+ virtio_net_fuzz_multi(s, Data, Size, true);
>+ flush_events(s);
>+ _Exit(0);
>+ } else {
>+ wait(NULL);
>+ }
>+}
>+
>+static void virtio_net_pre_fuzz(QTestState *s)
>+{
>+ qos_init_path(s);
>+ counter_shm_init();
>+}
>+
>+static void *virtio_net_test_setup_socket(GString *cmd_line, void *arg)
>+{
>+ int ret = socketpair(PF_UNIX, SOCK_STREAM, 0, sockfds);
>+ g_assert_cmpint(ret, !=, -1);
>+ fcntl(sockfds[0], F_SETFL, O_NONBLOCK);
>+ sockfds_initialized = true;
>+ g_string_append_printf(cmd_line, " -netdev socket,fd=%d,id=hs0 ",
>+ sockfds[1]);
>+ return arg;
>+}
>+
>+static void *virtio_net_test_setup_user(GString *cmd_line, void *arg)
>+{
>+ g_string_append_printf(cmd_line, " -netdev user,id=hs0 ");
>+ return arg;
>+}
>+
>+static void register_virtio_net_fuzz_targets(void)
>+{
>+ fuzz_add_qos_target(&(FuzzTarget){
>+ .name = "virtio-net-socket",
>+ .description = "Fuzz the virtio-net virtual queues. Fuzz incoming "
>+ "traffic using the socket backend",
>+ .pre_fuzz = &virtio_net_pre_fuzz,
>+ .fuzz = virtio_net_fork_fuzz,},
>+ "virtio-net",
>+ &(QOSGraphTestOptions){.before = virtio_net_test_setup_socket}
>+ );
>+
>+ fuzz_add_qos_target(&(FuzzTarget){
>+ .name = "virtio-net-socket-check-used",
>+ .description = "Fuzz the virtio-net virtual queues. Wait for the "
>+ "descriptors to be used. Timeout may indicate improperly handled "
>+ "input",
>+ .pre_fuzz = &virtio_net_pre_fuzz,
>+ .fuzz = virtio_net_fork_fuzz_check_used,},
>+ "virtio-net",
>+ &(QOSGraphTestOptions){.before = virtio_net_test_setup_socket}
>+ );
>+ fuzz_add_qos_target(&(FuzzTarget){
>+ .name = "virtio-net-slirp",
>+ .description = "Fuzz the virtio-net virtual queues with the slirp "
>+ " backend. Warning: May result in network traffic emitted from the "
>+ " process. Run in an isolated network environment.",
>+ .pre_fuzz = &virtio_net_pre_fuzz,
>+ .fuzz = virtio_net_fork_fuzz,},
>+ "virtio-net",
>+ &(QOSGraphTestOptions){.before = virtio_net_test_setup_user}
>+ );
>+}
>+
>+fuzz_target_init(register_virtio_net_fuzz_targets);
>--
>2.25.0
>
^ permalink raw reply
* Re: [PATCH v4 2/6] driver core: Set deferred_probe_timeout to a longer default if CONFIG_MODULES is set
From: Rafael J. Wysocki @ 2020-02-20 10:36 UTC (permalink / raw)
To: John Stultz
Cc: lkml, Rob Herring, Rafael J. Wysocki, Kevin Hilman, Ulf Hansson,
Pavel Machek, Len Brown, Todd Kjos, Bjorn Andersson,
Liam Girdwood, Mark Brown, Thierry Reding, Linus Walleij,
Greg Kroah-Hartman, Linux PM
In-Reply-To: <20200220050440.45878-3-john.stultz@linaro.org>
On Thu, Feb 20, 2020 at 6:05 AM John Stultz <john.stultz@linaro.org> wrote:
>
> When using modules, its common for the modules not to be loaded
> until quite late by userland. With the current code,
> driver_deferred_probe_check_state() will stop returning
> EPROBE_DEFER after late_initcall, which can cause module
> dependency resolution to fail after that.
>
> So allow a longer window of 30 seconds (picked somewhat
> arbitrarily, but influenced by the similar regulator core
> timeout value) in the case where modules are enabled.
>
> Cc: Rob Herring <robh@kernel.org>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Kevin Hilman <khilman@kernel.org>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Len Brown <len.brown@intel.com>
> Cc: Todd Kjos <tkjos@google.com>
> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Thierry Reding <treding@nvidia.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> Change-Id: I9c5a02a54915ff53f9f14d49c601f41d7105e05e
> ---
> v4:
> * Split out into its own patch as suggested by Mark
> * Made change conditional on CONFIG_MODULES
> ---
> drivers/base/dd.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index bb383dca39c1..fa138f24e2d3 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -224,7 +224,16 @@ static int deferred_devs_show(struct seq_file *s, void *data)
> }
> DEFINE_SHOW_ATTRIBUTE(deferred_devs);
>
> +#ifdef CONFIG_MODULES
> +/*
> + * In the case of modules, set the default probe timeout to
> + * 30 seconds to give userland some time to load needed modules
> + */
> +static int deferred_probe_timeout = 30;
> +#else
> +/* In the case of !modules, no probe timeout needed */
> static int deferred_probe_timeout = -1;
> +#endif
Looks reasonable to me.
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> static int __init deferred_probe_timeout_setup(char *str)
> {
> int timeout;
> --
^ permalink raw reply
* RE: [PATCH v4] tools/perf/metricgroup: Fix printing event names of metric group with multiple events incase of overlapping events
From: Joakim Zhang @ 2020-02-20 10:36 UTC (permalink / raw)
To: kajoljain, acme@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Jiri Olsa, Alexander Shishkin, Andi Kleen, Kan Liang,
Peter Zijlstra, Jin Yao, Madhavan Srinivasan, Anju T Sudhakar,
Ravi Bangoria
In-Reply-To: <be86ba99-ab5a-c845-46b6-8081edee00ca@linux.ibm.com>
> -----Original Message-----
> From: kajoljain <kjain@linux.ibm.com>
> Sent: 2020年2月20日 17:54
> To: Joakim Zhang <qiangqing.zhang@nxp.com>; acme@kernel.org
> Cc: linux-kernel@vger.kernel.org; linux-perf-users@vger.kernel.org; Jiri Olsa
> <jolsa@kernel.org>; Alexander Shishkin <alexander.shishkin@linux.intel.com>;
> Andi Kleen <ak@linux.intel.com>; Kan Liang <kan.liang@linux.intel.com>; Peter
> Zijlstra <peterz@infradead.org>; Jin Yao <yao.jin@linux.intel.com>; Madhavan
> Srinivasan <maddy@linux.vnet.ibm.com>; Anju T Sudhakar
> <anju@linux.vnet.ibm.com>; Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> Subject: Re: [PATCH v4] tools/perf/metricgroup: Fix printing event names of
> metric group with multiple events incase of overlapping events
>
>
>
> On 2/17/20 8:41 AM, Joakim Zhang wrote:
> >
> >> -----Original Message-----
> >> From: linux-perf-users-owner@vger.kernel.org
> >> <linux-perf-users-owner@vger.kernel.org> On Behalf Of Kajol Jain
> >> Sent: 2020年2月12日 13:41
> >> To: acme@kernel.org
> >> Cc: linux-kernel@vger.kernel.org; linux-perf-users@vger.kernel.org;
> >> kjain@linux.ibm.com; Jiri Olsa <jolsa@kernel.org>; Alexander Shishkin
> >> <alexander.shishkin@linux.intel.com>; Andi Kleen
> >> <ak@linux.intel.com>; Kan Liang <kan.liang@linux.intel.com>; Peter
> >> Zijlstra <peterz@infradead.org>; Jin Yao <yao.jin@linux.intel.com>;
> >> Madhavan Srinivasan <maddy@linux.vnet.ibm.com>; Anju T Sudhakar
> >> <anju@linux.vnet.ibm.com>; Ravi Bangoria
> >> <ravi.bangoria@linux.ibm.com>
> >> Subject: [PATCH v4] tools/perf/metricgroup: Fix printing event names
> >> of metric group with multiple events incase of overlapping events
> >>
> >> Commit f01642e4912b ("perf metricgroup: Support multiple events for
> >> metricgroup") introduced support for multiple events in a metric
> >> group. But with the current upstream, metric events names are not
> >> printed properly incase we try to run multiple metric groups with
> overlapping event.
> >>
> >> With current upstream version, incase of overlapping metric events
> >> issue is, we always start our comparision logic from start.
> >> So, the events which already matched with some metric group also take
> >> part in comparision logic. Because of that when we have overlapping
> >> events, we end up matching current metric group event with already
> matched one.
> >>
> >> For example, in skylake machine we have metric event CoreIPC and
> >> Instructions. Both of them need 'inst_retired.any' event value.
> >> As events in Instructions is subset of events in CoreIPC, they endup
> >> in pointing to same 'inst_retired.any' value.
> >>
> >> In skylake platform:
> >>
> >> command:# ./perf stat -M CoreIPC,Instructions -C 0 sleep 1
> >>
> >> Performance counter stats for 'CPU(s) 0':
> >>
> >> 1,254,992,790 inst_retired.any # 1254992790.0
> >>
> Instructions
> >> # 1.3
> >> CoreIPC
> >> 977,172,805 cycles
> >> 1,254,992,756 inst_retired.any
> >>
> >> 1.000802596 seconds time elapsed
> >>
> >> command:# sudo ./perf stat -M UPI,IPC sleep 1
> >>
> >> Performance counter stats for 'sleep 1':
> >>
> >> 948,650 uops_retired.retire_slots
> >> 866,182 inst_retired.any # 0.7 IPC
> >> 866,182 inst_retired.any
> >> 1,175,671 cpu_clk_unhalted.thread
> >>
> >> Patch fixes the issue by adding a new bool pointer 'evlist_used' to
> >> keep track of events which already matched with some group by setting it
> true.
> >> So, we skip all used events in list when we start comparision logic.
> >> Patch also make some changes in comparision logic, incase we get a
> >> match miss, we discard the whole match and start again with first
> >> event id in metric event.
> >>
> >> With this patch:
> >> In skylake platform:
> >>
> >> command:# ./perf stat -M CoreIPC,Instructions -C 0 sleep 1
> >>
> >> Performance counter stats for 'CPU(s) 0':
> >>
> >> 3,348,415 inst_retired.any # 0.3
> CoreIPC
> >> 11,779,026 cycles
> >> 3,348,381 inst_retired.any # 3348381.0
> >>
> Instructions
> >>
> >> 1.001649056 seconds time elapsed
> >>
> >> command:# ./perf stat -M UPI,IPC sleep 1
> >>
> >> Performance counter stats for 'sleep 1':
> >>
> >> 1,023,148 uops_retired.retire_slots # 1.1 UPI
> >> 924,976 inst_retired.any
> >> 924,976 inst_retired.any # 0.6 IPC
> >> 1,489,414 cpu_clk_unhalted.thread
> >>
> >> 1.003064672 seconds time elapsed
> >>
> >> Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
> >> Cc: Jiri Olsa <jolsa@kernel.org>
> >> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> >> Cc: Andi Kleen <ak@linux.intel.com>
> >> Cc: Kan Liang <kan.liang@linux.intel.com>
> >> Cc: Peter Zijlstra <peterz@infradead.org>
> >> Cc: Jin Yao <yao.jin@linux.intel.com>
> >> Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
> >> Cc: Anju T Sudhakar <anju@linux.vnet.ibm.com>
> >> Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> >> ---
> >> tools/perf/util/metricgroup.c | 50
> >> ++++++++++++++++++++++-------------
> >> 1 file changed, 31 insertions(+), 19 deletions(-)
> >
> > Hi Kajol,
> >
> > I am not sure if it is good to ask a question here :-)
> >
> > I encountered a perf metricgroup issue, the result is incorrect when the
> metric includes more than 2 events.
> >
> > git log --oneline tools/perf/util/metricgroup.c
> > 3635b27cc058 perf metricgroup: Fix printing event names of metric
> > group with multiple events f01642e4912b perf metricgroup: Support
> > multiple events for metricgroup
> > 287f2649f791 perf metricgroup: Scale the metric result
> >
> > I did a simple test, below is the JSON file and result.
> > [
> > {
> > "PublicDescription": "Calculate DDR0 bus actual utilization
> which vary from DDR0 controller clock frequency",
> > "BriefDescription": "imx8qm: ddr0 bus actual utilization",
> > "MetricName": "imx8qm-ddr0-bus-util",
> > "MetricExpr": "( imx8_ddr0\\/read\\-cycles\\/ +
> imx8_ddr0\\/write\\-cycles\\/ )",
> > "MetricGroup": "i.MX8QM_DDR0_BUS_UTIL"
> > }
> > ]
> > ./perf stat -I 1000 -M imx8qm-ddr0-bus-util
> > # time counts unit events
> > 1.000104250 16720 imx8_ddr0/read-cycles/
> # 22921.0 imx8qm-ddr0-bus-util
> > 1.000104250 6201 imx8_ddr0/write-cycles/
> > 2.000525625 8316 imx8_ddr0/read-cycles/
> # 12785.5 imx8qm-ddr0-bus-util
> > 2.000525625 2738 imx8_ddr0/write-cycles/
> > 3.000819125 1056 imx8_ddr0/read-cycles/
> # 4136.7 imx8qm-ddr0-bus-util
> > 3.000819125 303 imx8_ddr0/write-cycles/
> > 4.001103750 6260 imx8_ddr0/read-cycles/
> # 9149.8 imx8qm-ddr0-bus-util
> > 4.001103750 2317 imx8_ddr0/write-cycles/
> > 5.001392750 2084 imx8_ddr0/read-cycles/
> # 4516.0 imx8qm-ddr0-bus-util
> > 5.001392750 601 imx8_ddr0/write-cycles/
> >
> > You can see that only the first result is correct, could this be reproduced at
> you side?
>
> Hi Joakim,
> Will try to look into it from my side.
Thanks Kajol for your help, I look into this issue, but don't know how to fix it.
The results are always correct if signal event used in "MetricExpr" with "-I" parameters, but the results are incorrect when more than one events used in "MetricExpr".
Hope you can find the root cause :-)
Best Regards,
Joakim Zhang
> Thanks,
> Kajol
> >
> > Thanks a lot!
> >
> > Best Regards,
> > Joakim Zhang
> >
^ permalink raw reply
* Re: [Xen-devel] [PATCH 0/3] tools/xentop: Fix calculation of used memory and some cleanups
From: Sander Eikelenboom @ 2020-02-20 10:35 UTC (permalink / raw)
To: Wei Liu; +Cc: xen-devel, Ian Jackson
In-Reply-To: <20200220005330.bigbb7e7okuvez3x@debian>
On 20/02/2020 01:53, Wei Liu wrote:
> On Wed, Feb 19, 2020 at 09:31:29PM +0100, Sander Eikelenboom wrote:
>> Fixes some fallout from: c588c002cc1 ('tools: remove tmem code and commands')
>
> Thanks. I made some suggestions on adding commit messages. Let me know
> if you're okay with those.
>
> Wei.
>
Yes, they all seem improvements, thanks !
--
Sander
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply
* Re: [Xen-devel] [PATCH 1/5] libxl/PCI: honor multiple per-device reserved memory regions
From: Wei Liu @ 2020-02-20 10:35 UTC (permalink / raw)
To: Jan Beulich
Cc: Anthony Perard, xen-devel@lists.xenproject.org, Ian Jackson,
Wei Liu
In-Reply-To: <aa33b232-43b9-1853-7ef4-8b58e5245982@suse.com>
On Tue, Feb 18, 2020 at 04:46:17PM +0100, Jan Beulich wrote:
> While in "host" strategy all regions get processed, of the per-device
> ones only the first entry has been consumed so far.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Liu <wl@xen.org>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply
* Firmware files for QCA BT chip WCN3991.
From: bgodavar @ 2020-02-20 10:35 UTC (permalink / raw)
To: linux-firmware
Cc: mka, linux-kernel, linux-bluetooth, hemantg, linux-arm-msm,
gubbaven
Hi,
The following changes since commit
54b017d06a44bfd9b4c2757cace6cc349afd5bf2:
qca: Add firmware files for BT chip wcn3991. (2020-02-20 16:01:04
+0530)
are available in the Git repository at:
https://github.com/bgodavar/qca_bt_wcn3991.git
for you to fetch changes up to 54b017d06a44bfd9b4c2757cace6cc349afd5bf2:
qca: Add firmware files for BT chip wcn3991. (2020-02-20 16:01:04
+0530)
Regards
Balakrishna
^ permalink raw reply
* Re: [PATCH v10 16/22] fuzz: add support for qos-assisted fuzz targets
From: Darren Kenny @ 2020-02-20 10:35 UTC (permalink / raw)
To: Alexander Bulekov
Cc: Laurent Vivier, Thomas Huth, qemu-devel, bsd, stefanha, pbonzini
In-Reply-To: <20200220041118.23264-17-alxndr@bu.edu>
On Wed, Feb 19, 2020 at 11:11:12PM -0500, Alexander Bulekov wrote:
>Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
>---
> tests/qtest/fuzz/Makefile.include | 2 +
> tests/qtest/fuzz/qos_fuzz.c | 234 ++++++++++++++++++++++++++++++
> tests/qtest/fuzz/qos_fuzz.h | 33 +++++
> 3 files changed, 269 insertions(+)
> create mode 100644 tests/qtest/fuzz/qos_fuzz.c
> create mode 100644 tests/qtest/fuzz/qos_fuzz.h
>
>diff --git a/tests/qtest/fuzz/Makefile.include b/tests/qtest/fuzz/Makefile.include
>index a90915d56d..e3bdd33ff4 100644
>--- a/tests/qtest/fuzz/Makefile.include
>+++ b/tests/qtest/fuzz/Makefile.include
>@@ -1,8 +1,10 @@
> QEMU_PROG_FUZZ=qemu-fuzz-$(TARGET_NAME)$(EXESUF)
>
> fuzz-obj-y += tests/qtest/libqtest.o
>+fuzz-obj-y += $(libqos-obj-y)
> fuzz-obj-y += tests/qtest/fuzz/fuzz.o # Fuzzer skeleton
> fuzz-obj-y += tests/qtest/fuzz/fork_fuzz.o
>+fuzz-obj-y += tests/qtest/fuzz/qos_fuzz.o
>
> FUZZ_CFLAGS += -I$(SRC_PATH)/tests -I$(SRC_PATH)/tests/qtest
>
>diff --git a/tests/qtest/fuzz/qos_fuzz.c b/tests/qtest/fuzz/qos_fuzz.c
>new file mode 100644
>index 0000000000..bbb17470ff
>--- /dev/null
>+++ b/tests/qtest/fuzz/qos_fuzz.c
>@@ -0,0 +1,234 @@
>+/*
>+ * QOS-assisted fuzzing helpers
>+ *
>+ * Copyright (c) 2018 Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
>+ *
>+ * This library is free software; you can redistribute it and/or
>+ * modify it under the terms of the GNU Lesser General Public
>+ * License version 2 as published by the Free Software Foundation.
>+ *
>+ * This library is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>+ * Lesser General Public License for more details.
>+ *
>+ * You should have received a copy of the GNU Lesser General Public
>+ * License along with this library; if not, see <http://www.gnu.org/licenses/>
>+ */
>+
>+#include "qemu/osdep.h"
>+#include "qemu/units.h"
>+#include "qapi/error.h"
>+#include "qemu-common.h"
>+#include "exec/memory.h"
>+#include "exec/address-spaces.h"
>+#include "sysemu/sysemu.h"
>+#include "qemu/main-loop.h"
>+
>+#include "tests/qtest/libqtest.h"
>+#include "tests/qtest/libqos/malloc.h"
>+#include "tests/qtest/libqos/qgraph.h"
>+#include "tests/qtest/libqos/qgraph_internal.h"
>+#include "tests/qtest/libqos/qos_external.h"
>+
>+#include "fuzz.h"
>+#include "qos_fuzz.h"
>+
>+#include "qapi/qapi-commands-machine.h"
>+#include "qapi/qapi-commands-qom.h"
>+#include "qapi/qmp/qlist.h"
>+
>+
>+void *fuzz_qos_obj;
>+QGuestAllocator *fuzz_qos_alloc;
>+
>+static const char *fuzz_target_name;
>+static char **fuzz_path_vec;
>+
>+/*
>+ * Replaced the qmp commands with direct qmp_marshal calls.
>+ * Probably there is a better way to do this
>+ */
>+static void qos_set_machines_devices_available(void)
>+{
>+ QDict *req = qdict_new();
>+ QObject *response;
>+ QDict *args = qdict_new();
>+ QList *lst;
>+ Error *err = NULL;
>+
>+ qmp_marshal_query_machines(NULL, &response, &err);
>+ assert(!err);
>+ lst = qobject_to(QList, response);
>+ apply_to_qlist(lst, true);
>+
>+ qobject_unref(response);
>+
>+
>+ qdict_put_str(req, "execute", "qom-list-types");
>+ qdict_put_str(args, "implements", "device");
>+ qdict_put_bool(args, "abstract", true);
>+ qdict_put_obj(req, "arguments", (QObject *) args);
>+
>+ qmp_marshal_qom_list_types(args, &response, &err);
>+ assert(!err);
>+ lst = qobject_to(QList, response);
>+ apply_to_qlist(lst, false);
>+ qobject_unref(response);
>+ qobject_unref(req);
>+}
>+
>+static char **current_path;
>+
>+void *qos_allocate_objects(QTestState *qts, QGuestAllocator **p_alloc)
>+{
>+ return allocate_objects(qts, current_path + 1, p_alloc);
>+}
>+
>+static const char *qos_build_main_args(void)
>+{
>+ char **path = fuzz_path_vec;
>+ QOSGraphNode *test_node;
>+ GString *cmd_line = g_string_new(path[0]);
>+ void *test_arg;
>+
>+ if (!path) {
>+ fprintf(stderr, "QOS Path not found\n");
>+ abort();
>+ }
>+
>+ /* Before test */
>+ current_path = path;
>+ test_node = qos_graph_get_node(path[(g_strv_length(path) - 1)]);
>+ test_arg = test_node->u.test.arg;
>+ if (test_node->u.test.before) {
>+ test_arg = test_node->u.test.before(cmd_line, test_arg);
>+ }
>+ /* Prepend the arguments that we need */
>+ g_string_prepend(cmd_line,
>+ TARGET_NAME " -display none -machine accel=qtest -m 64 ");
>+ return cmd_line->str;
>+}
>+
>+/*
>+ * This function is largely a copy of qos-test.c:walk_path. Since walk_path
>+ * is itself a callback, its a little annoying to add another argument/layer of
>+ * indirection
>+ */
>+static void walk_path(QOSGraphNode *orig_path, int len)
>+{
>+ QOSGraphNode *path;
>+ QOSGraphEdge *edge;
>+
>+ /* etype set to QEDGE_CONSUMED_BY so that machine can add to the command line */
>+ QOSEdgeType etype = QEDGE_CONSUMED_BY;
>+
>+ /* twice QOS_PATH_MAX_ELEMENT_SIZE since each edge can have its arg */
>+ char **path_vec = g_new0(char *, (QOS_PATH_MAX_ELEMENT_SIZE * 2));
>+ int path_vec_size = 0;
>+
>+ char *after_cmd, *before_cmd, *after_device;
>+ GString *after_device_str = g_string_new("");
>+ char *node_name = orig_path->name, *path_str;
>+
>+ GString *cmd_line = g_string_new("");
>+ GString *cmd_line2 = g_string_new("");
>+
>+ path = qos_graph_get_node(node_name); /* root */
>+ node_name = qos_graph_edge_get_dest(path->path_edge); /* machine name */
>+
>+ path_vec[path_vec_size++] = node_name;
>+ path_vec[path_vec_size++] = qos_get_machine_type(node_name);
>+
>+ for (;;) {
>+ path = qos_graph_get_node(node_name);
>+ if (!path->path_edge) {
>+ break;
>+ }
>+
>+ node_name = qos_graph_edge_get_dest(path->path_edge);
>+
>+ /* append node command line + previous edge command line */
>+ if (path->command_line && etype == QEDGE_CONSUMED_BY) {
>+ g_string_append(cmd_line, path->command_line);
>+ g_string_append(cmd_line, after_device_str->str);
>+ g_string_truncate(after_device_str, 0);
>+ }
>+
>+ path_vec[path_vec_size++] = qos_graph_edge_get_name(path->path_edge);
>+ /* detect if edge has command line args */
>+ after_cmd = qos_graph_edge_get_after_cmd_line(path->path_edge);
>+ after_device = qos_graph_edge_get_extra_device_opts(path->path_edge);
>+ before_cmd = qos_graph_edge_get_before_cmd_line(path->path_edge);
>+ edge = qos_graph_get_edge(path->name, node_name);
>+ etype = qos_graph_edge_get_type(edge);
>+
>+ if (before_cmd) {
>+ g_string_append(cmd_line, before_cmd);
>+ }
>+ if (after_cmd) {
>+ g_string_append(cmd_line2, after_cmd);
>+ }
>+ if (after_device) {
>+ g_string_append(after_device_str, after_device);
>+ }
>+ }
>+
>+ path_vec[path_vec_size++] = NULL;
>+ g_string_append(cmd_line, after_device_str->str);
>+ g_string_free(after_device_str, true);
>+
>+ g_string_append(cmd_line, cmd_line2->str);
>+ g_string_free(cmd_line2, true);
>+
>+ /*
>+ * here position 0 has <arch>/<machine>, position 1 has <machine>.
>+ * The path must not have the <arch>, qtest_add_data_func adds it.
>+ */
>+ path_str = g_strjoinv("/", path_vec + 1);
>+
>+ /* Check that this is the test we care about: */
>+ char *test_name = strrchr(path_str, '/') + 1;
>+ if (strcmp(test_name, fuzz_target_name) == 0) {
>+ /*
>+ * put arch/machine in position 1 so run_one_test can do its work
>+ * and add the command line at position 0.
>+ */
>+ path_vec[1] = path_vec[0];
>+ path_vec[0] = g_string_free(cmd_line, false);
>+
>+ fuzz_path_vec = path_vec;
>+ } else {
>+ g_free(path_vec);
>+ }
>+
>+ g_free(path_str);
>+}
>+
>+static const char *qos_get_cmdline(FuzzTarget *t)
>+{
>+ /*
>+ * Set a global variable that we use to identify the qos_path for our
>+ * fuzz_target
>+ */
>+ fuzz_target_name = t->name;
>+ qos_set_machines_devices_available();
>+ qos_graph_foreach_test_path(walk_path);
>+ return qos_build_main_args();
>+}
>+
>+void fuzz_add_qos_target(
>+ FuzzTarget *fuzz_opts,
>+ const char *interface,
>+ QOSGraphTestOptions *opts
>+ )
>+{
>+ qos_add_test(fuzz_opts->name, interface, NULL, opts);
>+ fuzz_opts->get_init_cmdline = qos_get_cmdline;
>+ fuzz_add_target(fuzz_opts);
>+}
>+
>+void qos_init_path(QTestState *s)
>+{
>+ fuzz_qos_obj = qos_allocate_objects(s , &fuzz_qos_alloc);
>+}
>diff --git a/tests/qtest/fuzz/qos_fuzz.h b/tests/qtest/fuzz/qos_fuzz.h
>new file mode 100644
>index 0000000000..477f11b02b
>--- /dev/null
>+++ b/tests/qtest/fuzz/qos_fuzz.h
>@@ -0,0 +1,33 @@
>+/*
>+ * QOS-assisted fuzzing helpers
>+ *
>+ * Copyright Red Hat Inc., 2019
>+ *
>+ * Authors:
>+ * Alexander Bulekov <alxndr@bu.edu>
>+ *
>+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
>+ * See the COPYING file in the top-level directory.
>+ */
>+
>+#ifndef _QOS_FUZZ_H_
>+#define _QOS_FUZZ_H_
>+
>+#include "tests/qtest/fuzz/fuzz.h"
>+#include "tests/qtest/libqos/qgraph.h"
>+
>+int qos_fuzz(const unsigned char *Data, size_t Size);
>+void qos_setup(void);
>+
>+extern void *fuzz_qos_obj;
>+extern QGuestAllocator *fuzz_qos_alloc;
>+
>+void fuzz_add_qos_target(
>+ FuzzTarget *fuzz_opts,
>+ const char *interface,
>+ QOSGraphTestOptions *opts
>+ );
>+
>+void qos_init_path(QTestState *);
>+
>+#endif
>--
>2.25.0
>
^ permalink raw reply
* Re: [PATCH net-next v3 6/9] drivers/base/power: add dpm_sysfs_change_owner()
From: Christian Brauner @ 2020-02-20 10:35 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: David S. Miller, Greg Kroah-Hartman, Linux Kernel Mailing List,
netdev, Pavel Machek, Jakub Kicinski, Eric Dumazet,
Stephen Hemminger, Linux PM
In-Reply-To: <CAJZ5v0itDdfdNd6TzLi=2J517CyjEBbKb+K4OfkkSt-B+w9taw@mail.gmail.com>
On Thu, Feb 20, 2020 at 11:30:32AM +0100, Rafael J. Wysocki wrote:
> On Thu, Feb 20, 2020 at 11:21 AM Christian Brauner
> <christian.brauner@ubuntu.com> wrote:
> >
> > On Thu, Feb 20, 2020 at 11:02:04AM +0100, Rafael J. Wysocki wrote:
> > > On Tue, Feb 18, 2020 at 5:30 PM Christian Brauner
> > > <christian.brauner@ubuntu.com> wrote:
> > > >
> > > > Add a helper to change the owner of a device's power entries. This
> > > > needs to happen when the ownership of a device is changed, e.g. when
> > > > moving network devices between network namespaces.
> > > > This function will be used to correctly account for ownership changes,
> > > > e.g. when moving network devices between network namespaces.
> > > >
> > > > Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
> > > > ---
> > > > /* v2 */
> > > > - "Rafael J. Wysocki" <rafael@kernel.org>:
> > > > - Fold if (dev->power.wakeup && dev->power.wakeup->dev) check into
> > > > if (device_can_wakeup(dev)) check since the former can never be true if
> > > > the latter is false.
> > > >
> > > > - Christian Brauner <christian.brauner@ubuntu.com>:
> > > > - Place (dev->power.wakeup && dev->power.wakeup->dev) check under
> > > > CONFIG_PM_SLEEP ifdefine since it will wakeup_source will only be available
> > > > when this config option is set.
> > > >
> > > > /* v3 */
> > > > - Greg Kroah-Hartman <gregkh@linuxfoundation.org>:
> > > > - Add explicit uid/gid parameters.
> > > > ---
> > > > drivers/base/core.c | 4 ++++
> > > > drivers/base/power/power.h | 3 +++
> > > > drivers/base/power/sysfs.c | 42 ++++++++++++++++++++++++++++++++++++++
> > > > 3 files changed, 49 insertions(+)
> > > >
> > > > diff --git a/drivers/base/core.c b/drivers/base/core.c
> > > > index ec0d5e8cfd0f..efec2792f5d7 100644
> > > > --- a/drivers/base/core.c
> > > > +++ b/drivers/base/core.c
> > > > @@ -3522,6 +3522,10 @@ int device_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid)
> > > > if (error)
> > > > goto out;
> > > >
> > > > + error = dpm_sysfs_change_owner(dev, kuid, kgid);
> > > > + if (error)
> > > > + goto out;
> > > > +
> > > > #ifdef CONFIG_BLOCK
> > > > if (sysfs_deprecated && dev->class == &block_class)
> > > > goto out;
> > > > diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
> > > > index 444f5c169a0b..54292cdd7808 100644
> > > > --- a/drivers/base/power/power.h
> > > > +++ b/drivers/base/power/power.h
> > > > @@ -74,6 +74,7 @@ extern int pm_qos_sysfs_add_flags(struct device *dev);
> > > > extern void pm_qos_sysfs_remove_flags(struct device *dev);
> > > > extern int pm_qos_sysfs_add_latency_tolerance(struct device *dev);
> > > > extern void pm_qos_sysfs_remove_latency_tolerance(struct device *dev);
> > > > +extern int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid);
> > > >
> > > > #else /* CONFIG_PM */
> > > >
> > > > @@ -88,6 +89,8 @@ static inline void pm_runtime_remove(struct device *dev) {}
> > > >
> > > > static inline int dpm_sysfs_add(struct device *dev) { return 0; }
> > > > static inline void dpm_sysfs_remove(struct device *dev) {}
> > > > +static inline int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid,
> > > > + kgid_t kgid) { return 0; }
> > > >
> > > > #endif
> > > >
> > > > diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
> > > > index d7d82db2e4bc..4e79afcd5ca8 100644
> > > > --- a/drivers/base/power/sysfs.c
> > > > +++ b/drivers/base/power/sysfs.c
> > > > @@ -684,6 +684,48 @@ int dpm_sysfs_add(struct device *dev)
> > > > return rc;
> > > > }
> > > >
> > > > +int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid)
> > > > +{
> > > > + int rc;
> > > > +
> > > > + if (device_pm_not_required(dev))
> > > > + return 0;
> > > > +
> > > > + rc = sysfs_group_change_owner(&dev->kobj, &pm_attr_group, kuid, kgid);
> > > > + if (rc)
> > > > + return rc;
> > > > +
> > > > + if (pm_runtime_callbacks_present(dev)) {
> > > > + rc = sysfs_group_change_owner(
> > > > + &dev->kobj, &pm_runtime_attr_group, kuid, kgid);
> > > > + if (rc)
> > > > + return rc;
> > > > + }
> > > > + if (device_can_wakeup(dev)) {
> > > > + rc = sysfs_group_change_owner(&dev->kobj, &pm_wakeup_attr_group,
> > > > + kuid, kgid);
> > > > + if (rc)
> > > > + return rc;
> > > > +
> > > > +#ifdef CONFIG_PM_SLEEP
> > > > + if (dev->power.wakeup && dev->power.wakeup->dev) {
> > > > + rc = device_change_owner(dev->power.wakeup->dev, kuid,
> > > > + kgid);
> > > > + if (rc)
> > > > + return rc;
> > > > + }
> > > > +#endif
> > >
> > > First off, I don't particularly like #ifdefs in function bodies. In
> > > particular, there is a CONFIG_PM_SLEEP block in this file already and
> > > you could define a new function in there to carry out the above
> > > operations, and provide an empty stub of it for the "unset" case.
> > > Failing to do so is somewhat on the "rushing things in" side in my
> > > view.
> >
> > How ifdefines are used is highly dependent on the subsystem; networking
> > ofen uses in-place ifdefines in some parts and not in others. That has
> > nothing to do with rushing things. I'm happy to change it to your
> > preferences.
>
> Thanks!
>
> > Thanks for pointing out your expectations. But please don't
> > assume bad intentions on my part because I'm not meeting them right
> > away. It often is the case that adding a helper that is called in one
> > place is not well-received.
>
> Fair enough, sorry for being harsh.
Np, I didn't read it as such. I was really just worried you thought
that I was trying to rush things in. It's Thursday anyway, usually about
the time where we're all grumpy because we can't wait until we made it
to Friday. :)
Christian
^ permalink raw reply
* Re: [PATCH v3 08/22] rcu,tracing: Create trace_rcu_{enter,exit}()
From: Peter Zijlstra @ 2020-02-20 10:34 UTC (permalink / raw)
To: Paul E. McKenney
Cc: Steven Rostedt, linux-kernel, linux-arch, mingo, joel, gregkh,
gustavo, tglx, josh, mathieu.desnoyers, jiangshanlai, luto,
tony.luck, frederic, dan.carpenter, mhiramat
In-Reply-To: <20200219164449.GC2935@paulmck-ThinkPad-P72>
On Wed, Feb 19, 2020 at 08:44:50AM -0800, Paul E. McKenney wrote:
> On Wed, Feb 19, 2020 at 05:35:35PM +0100, Peter Zijlstra wrote:
> > Possibly, and I suppose the current version is less obviously dependent
> > on the in_nmi() functionality as was the previous, seeing how Paul
> > frobbed that all the way into the rcu_irq_enter*() implementation.
> >
> > So sure, I can go move it I suppose.
>
> No objections here.
It now looks like so:
---
Subject: rcu,tracing: Create trace_rcu_{enter,exit}()
From: Peter Zijlstra <peterz@infradead.org>
Date: Wed Feb 12 09:18:57 CET 2020
To facilitate tracers that need RCU, add some helpers to wrap the
magic required.
The problem is that we can call into tracers (trace events and
function tracing) while RCU isn't watching and this can happen from
any context, including NMI.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/rcupdate.h | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -175,6 +175,35 @@ do { \
#error "Unknown RCU implementation specified to kernel configuration"
#endif
+/**
+ * trace_rcu_enter - Force RCU to be active, for code that needs RCU readers
+ *
+ * Very similar to RCU_NONIDLE() above.
+ *
+ * Tracing can happen while RCU isn't active yet, for instance in the idle loop
+ * between rcu_idle_enter() and rcu_idle_exit(), or early in exception entry.
+ * RCU will happily ignore any read-side critical sections in this case.
+ *
+ * This function ensures that RCU is aware hereafter and the code can readily
+ * rely on RCU read-side critical sections working as expected.
+ *
+ * This function is NMI safe -- provided in_nmi() is correct and will nest up-to
+ * INT_MAX/2 times.
+ */
+static inline int trace_rcu_enter(void)
+{
+ int state = !rcu_is_watching();
+ if (state)
+ rcu_irq_enter_irqsave();
+ return state;
+}
+
+static inline void trace_rcu_exit(int state)
+{
+ if (state)
+ rcu_irq_exit_irqsave();
+}
+
/*
* The init_rcu_head_on_stack() and destroy_rcu_head_on_stack() calls
* are needed for dynamic initialization and destruction of rcu_head
^ permalink raw reply
* Re: [PATCH 01/19] vfs: syscall: Add fsinfo() to query filesystem information [ver #16]
From: David Howells @ 2020-02-20 10:34 UTC (permalink / raw)
To: Darrick J. Wong
Cc: dhowells, viro, raven, mszeredi, christian, linux-api,
linux-fsdevel, linux-kernel
In-Reply-To: <20200219163128.GB9496@magnolia>
Darrick J. Wong <darrick.wong@oracle.com> wrote:
> > + p->f_blocks.hi = 0;
> > + p->f_blocks.lo = buf.f_blocks;
>
> Er... are there filesystems (besides that (xfs++)++ one) that require
> u128 counters? I suspect that the Very Large Fields are for future
> expandability, but I also wonder about the whether it's worth the
> complexity of doing this, since the structures can always be
> version-revved later.
I'm making a relatively cheap allowance for future expansion. Dave Chinner
has mentioned at one of the LSFs that 16EiB may be exceeded soon (though I
hate to think of fscking such a beastie). I know that the YFS variant of AFS
supports 96-bit vnode numbers (which I translate to inode numbers). What I'm
trying to avoid is the problem we have with stat/statfs where under some
circumstances we have to return an error (ERANGE?) because we can't represent
the number if someone asks for an older version of the struct.
Since the buffer is (meant to be) pre-cleared, the filesystem can just ignore
the high word if it's never going to set it. In fact, fsinfo_generic_statfs
doesn't need to set them either.
> XFS inodes are u64 values...
> ...and the max symlink target length is 1k, not PAGE_SIZE...
Yeah, and AFS(YFS) has 96-bit inode numbers. The filesystem's fsinfo table is
read first so that the filesystem can override this.
> ...so is the usage model here that XFS should call fsinfo_generic_limits
> to fill out the fsinfo_limits structure, modify the values in
> ctx->buffer as appropriate for XFS, and then return the structure size?
Actually, I should export some these so that you can do that. I'll export
fsinfo_generic_{timestamp_info,supports,limits} for now.
> > +#define FSINFO_ATTR_VOLUME_ID 0x05 /* Volume ID (string) */
> > +#define FSINFO_ATTR_VOLUME_UUID 0x06 /* Volume UUID (LE uuid) */
> > +#define FSINFO_ATTR_VOLUME_NAME 0x07 /* Volume name (string) */
>
> I think I've muttered about the distinction between volume id and
> volume name before, but I'm still wondering how confusing that will be
> for users? Let me check my assumptions, though:
>
> Volume ID is whatever's in super_block.s_id, which (at least for xfs and
> ext4) is the device name (e.g. "sda1"). I guess that's useful for
> correlating a thing you can call fsinfo() on against strings that were
> logged in dmesg.
>
> Volume name I think is the fs label (e.g. "home"), which I think will
> have to be implemented separately by each filesystem, and that's why
> there's no generic vfs implementation.
Yes. For AFS, for example, this would be the name of the volume (which may be
changed), whereas the volume ID is the number in the protocol that actually
refers to the volume (which cannot be changed).
And, as you say, for blockdev mounts, the ID is the device name and the volume
name is filesystem specific.
> The 7 -> 0 -> 1 sequence here confused me until I figured out that
> QUERY_TYPE is the mask for QUERY_{PATH,FD}.
Changed to FSINFO_FLAGS_QUERY_MASK.
> > +struct fsinfo_limits {
> > +...
> > + __u32 __reserved[1];
>
> I wonder if these structures ought to reserve more space than a single u32...
No need. Part of the way the interface is designed is that the version number
for a particular VSTRUCT-type attribute is also the length. So a newer
version is also longer. All the old fields must be retained and filled in.
New fields are tagged on the end.
If userspace asks for an older version than is supported, it gets a truncated
return. If it asks for a newer version, the extra fields it is expecting are
all set to 0. Either way, the length (and thus the version) the kernel
supports is returned - not the length copied.
The __reserved fields are there because they represent padding (the struct is
going to be aligned/padded according to __u64 in this case). Ideally, I'd
mark the structs __packed, but this messes with the alignment and may make the
compiler do funny tricks to get out any field larger than a byte.
I've renamed them to __padding.
> > +struct fsinfo_supports {
> > + __u64 stx_attributes; /* What statx::stx_attributes are supported */
> > + __u32 stx_mask; /* What statx::stx_mask bits are supported */
> > + __u32 ioc_flags; /* What FS_IOC_* flags are supported */
>
> "IOC"? That just means 'ioctl'. Is this field supposed to return the
> supported FS_IOC_GETFLAGS flags, or the supported FS_IOC_FSGETXATTR
> flags?
FS_IOC_[GS]ETFLAGS is what I meant.
> I suspect it would also be a big help to be able to tell userspace which
> of the flags can be set, and which can be cleared.
How about:
__u32 fs_ioc_getflags; /* What FS_IOC_GETFLAGS may return */
__u32 fs_ioc_setflags_set; /* What FS_IOC_SETFLAGS may set */
__u32 fs_ioc_setflags_clear; /* What FS_IOC_SETFLAGS may clear */
> > +struct fsinfo_timestamp_one {
> > + __s64 minimum; /* Minimum timestamp value in seconds */
> > + __u64 maximum; /* Maximum timestamp value in seconds */
>
> Given that time64_t is s64, why is the maximum here u64?
Well, I assume it extremely unlikely that the maximum can be before 1970, so
there doesn't seem any need to allow the maximum to be negative. Furthermore,
it would be feasible that you could encounter a filesystem with a u64
filesystem that doesn't support dates before 1970.
On the other hand, if Linux is still going when __s64 seconds from 1970 wraps,
it will be impressive, but I'm not sure we'll be around to see it... Someone
will have to cast a resurrection spell on Arnd to fix that one.
However, since signed/unsigned comparisons may have issues, I can turn it into
an __s64 also if that is preferred.
David
^ permalink raw reply
* Re: [PATCH v10 01/22] softmmu: move vl.c to softmmu/
From: Darren Kenny @ 2020-02-20 10:33 UTC (permalink / raw)
To: Alexander Bulekov; +Cc: pbonzini, bsd, qemu-devel, stefanha
In-Reply-To: <20200220041118.23264-2-alxndr@bu.edu>
On Wed, Feb 19, 2020 at 11:10:57PM -0500, Alexander Bulekov wrote:
>Move vl.c to a separate directory, similar to linux-user/
>Update the chechpatch and get_maintainer scripts, since they relied on
>/vl.c for top_of_tree checks.
>
>Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
>---
> MAINTAINERS | 2 +-
> Makefile.objs | 2 --
> Makefile.target | 1 +
> scripts/checkpatch.pl | 2 +-
> scripts/get_maintainer.pl | 3 ++-
> softmmu/Makefile.objs | 2 ++
> vl.c => softmmu/vl.c | 0
> 7 files changed, 7 insertions(+), 5 deletions(-)
> create mode 100644 softmmu/Makefile.objs
> rename vl.c => softmmu/vl.c (100%)
>
>diff --git a/MAINTAINERS b/MAINTAINERS
>index c7717df720..98cbeaab97 100644
>--- a/MAINTAINERS
>+++ b/MAINTAINERS
>@@ -2023,7 +2023,7 @@ F: include/qemu/main-loop.h
> F: include/sysemu/runstate.h
> F: util/main-loop.c
> F: util/qemu-timer.c
>-F: vl.c
>+F: softmmu/vl.c
> F: qapi/run-state.json
>
> Human Monitor (HMP)
>diff --git a/Makefile.objs b/Makefile.objs
>index 26b9cff954..8a1cbe8000 100644
>--- a/Makefile.objs
>+++ b/Makefile.objs
>@@ -58,8 +58,6 @@ common-obj-y += ui/
> common-obj-m += ui/
>
> common-obj-y += dma-helpers.o
>-common-obj-y += vl.o
>-vl.o-cflags := $(GPROF_CFLAGS) $(SDL_CFLAGS)
> common-obj-$(CONFIG_TPM) += tpm.o
>
> common-obj-y += backends/
>diff --git a/Makefile.target b/Makefile.target
>index 6e61f607b1..06c36d1161 100644
>--- a/Makefile.target
>+++ b/Makefile.target
>@@ -160,6 +160,7 @@ obj-y += qapi/
> obj-y += memory.o
> obj-y += memory_mapping.o
> obj-y += migration/ram.o
>+obj-y += softmmu/
> LIBS := $(libs_softmmu) $(LIBS)
>
> # Hardware support
>diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>index ce43a306f8..c85ad11de1 100755
>--- a/scripts/checkpatch.pl
>+++ b/scripts/checkpatch.pl
>@@ -462,7 +462,7 @@ sub top_of_kernel_tree {
> my @tree_check = (
> "COPYING", "MAINTAINERS", "Makefile",
> "README.rst", "docs", "VERSION",
>- "vl.c"
>+ "linux-user", "softmmu"
> );
>
> foreach my $check (@tree_check) {
>diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
>index 27991eb1cf..271f5ff42a 100755
>--- a/scripts/get_maintainer.pl
>+++ b/scripts/get_maintainer.pl
>@@ -795,7 +795,8 @@ sub top_of_tree {
> && (-f "${lk_path}Makefile")
> && (-d "${lk_path}docs")
> && (-f "${lk_path}VERSION")
>- && (-f "${lk_path}vl.c")) {
>+ && (-d "${lk_path}linux-user/")
>+ && (-d "${lk_path}softmmu/")) {
> return 1;
> }
> return 0;
>diff --git a/softmmu/Makefile.objs b/softmmu/Makefile.objs
>new file mode 100644
>index 0000000000..d80a5ffe5a
>--- /dev/null
>+++ b/softmmu/Makefile.objs
>@@ -0,0 +1,2 @@
>+obj-y += vl.o
>+vl.o-cflags := $(GPROF_CFLAGS) $(SDL_CFLAGS)
>diff --git a/vl.c b/softmmu/vl.c
>similarity index 100%
>rename from vl.c
>rename to softmmu/vl.c
>--
>2.25.0
>
^ permalink raw reply
* Re: Hard Disk consumes lots of power in s2idle
From: Rafael J. Wysocki @ 2020-02-20 10:34 UTC (permalink / raw)
To: Kai-Heng Feng
Cc: Rafael J. Wysocki, Srinivas Pandruvada, Linux PM,
open list:LIBATA SUBSYSTEM (Serial and Parallel ATA drivers),
open list, Kent Lin, Tejun Heo
In-Reply-To: <CA007B3C-C084-429E-B774-70264A9E609F@canonical.com>
On Thu, Feb 20, 2020 at 11:25 AM Kai-Heng Feng
<kai.heng.feng@canonical.com> wrote:
>
>
>
> > On Feb 20, 2020, at 18:12, Rafael J. Wysocki <rafael@kernel.org> wrote:
> >
> > On Thu, Feb 20, 2020 at 9:08 AM Kai-Heng Feng
> > <kai.heng.feng@canonical.com> wrote:
> >>
> >> Hi Srinivas,
> >>
> >>> On Feb 20, 2020, at 02:36, Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> wrote:
> >>>
> >>> Hi Kai,
> >>>
> >>> On Wed, 2020-02-19 at 22:22 +0800, Kai-Heng Feng wrote:
> >>>> Hi Srinivas,
> >>>>
> >>>> Your previous work to support DEVSLP works well on SATA SSDs, so I am
> >>>> asking you the issue I am facing:
> >>>> Once a laptop has a HDD installed, the power consumption during
> >>>> S2Idle increases ~0.4W, which is quite a lot.
> >>>> However, HDDs don't seem to support DEVSLP, so I wonder if you know
> >>>> to do proper power management for HDDs?
> >>> What is the default here
> >>> cat /sys/power/mem_sleep
> >>> s2idle or deep?
> >>
> >> It defaults to s2idle.
> >>
> >>>
> >>> Please follow debug steps here:
> >>> https://01.org/blogs/qwang59/2018/how-achieve-s0ix-states-linux
> >>>
> >>> We need to check whether you get any PC10 residency or not.
> >>
> >> Yes it reaches PC10. It doesn't reach SLP_S0 though.
> >> The real number on S2Idle power consumption:
> >> No HDD: ~1.4W
> >> One HDD: ~1.8W
> >>
> >> If the SoC doesn't hit PC10 the number should be significantly higher.
> >> That's why I think the issue is the power management on HDD itself.
> >
> > I'm assuming that you mean a non-SSD device here.
>
> Yes, it's spinning rust here.
>
> >
> > That would be handled via ata_port_suspend() I gather and whatever
> > that does should do the right thing.
> >
> > Do you think that the disk doesn't spin down or it spins down, but the
> > logic stays on?
>
> The spin sound is audible, so I am certain the HDD spins down during S2Idle.
OK
> How do I know if the logic is on or off?
Well, if it were off, it would not draw power. :-)
So IMO it is reasonable to assume that the logic on the drive stays
on. I'm not aware of anything that can be done to turn it off,
however.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.