From: Madhuparna Bhowmik <[email protected]>
list/hlist_for_each_entry_rcu() provides an optional cond argument
to specify the lock held in the updater side.
However for SRCU read side, not providing the cond argument results
into false positive as whether srcu_read_lock is held or not is not
checked implicitly. Therefore, on read side the lockdep expression
srcu_read_lock_held(srcu struct) can solve this issue.
However, the function still fails to check the cases where srcu
protected list is traversed with rcu_read_lock() instead of
srcu_read_lock(). Therefore, to remove the false negative,
this patch introduces two new list traversal primitives :
list_for_each_entry_srcu() and hlist_for_each_entry_srcu().
Both of the functions have non-optional cond argument
as it is required for both read and update side, and simply checks
if the cond is true. For regular read side the lockdep expression
srcu_read_lock_head() can be passed as the cond argument to
list/hlist_for_each_entry_srcu().
Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Madhuparna Bhowmik <[email protected]>
---
include/linux/rculist.h | 48 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/include/linux/rculist.h b/include/linux/rculist.h
index df587d181844..516b4feb2682 100644
--- a/include/linux/rculist.h
+++ b/include/linux/rculist.h
@@ -63,9 +63,17 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list)
RCU_LOCKDEP_WARN(!(cond) && !rcu_read_lock_any_held(), \
"RCU-list traversed in non-reader section!"); \
})
+
+#define __list_check_srcu(cond) \
+ ({ \
+ RCU_LOCKDEP_WARN(!(cond), \
+ "RCU-list traversed without holding the required lock!");\
+ })
#else
#define __list_check_rcu(dummy, cond, extra...) \
({ check_arg_count_one(extra); })
+
+#define __list_check_srcu(cond)
#endif
/*
@@ -383,6 +391,25 @@ static inline void list_splice_tail_init_rcu(struct list_head *list,
&pos->member != (head); \
pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
+/**
+ * list_for_each_entry_srcu - iterate over rcu list of given type
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_head within the struct.
+ * @cond: lockdep expression for the lock required to traverse the list.
+ *
+ * This list-traversal primitive may safely run concurrently with
+ * the _rcu list-mutation primitives such as list_add_rcu()
+ * as long as the traversal is guarded by srcu_read_lock().
+ * The lockdep expression srcu_read_lock_held() can be passed as the
+ * cond argument from read side.
+ */
+#define list_for_each_entry_srcu(pos, head, member, cond) \
+ for (__list_check_srcu(cond), \
+ pos = list_entry_rcu((head)->next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
+
/**
* list_entry_lockless - get the struct for this entry
* @ptr: the &struct list_head pointer.
@@ -681,6 +708,27 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n,
pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(\
&(pos)->member)), typeof(*(pos)), member))
+/**
+ * hlist_for_each_entry_srcu - iterate over rcu list of given type
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the hlist_node within the struct.
+ * @cond: lockdep expression for the lock required to traverse the list.
+ *
+ * This list-traversal primitive may safely run concurrently with
+ * the _rcu list-mutation primitives such as hlist_add_head_rcu()
+ * as long as the traversal is guarded by srcu_read_lock().
+ * The lockdep expression srcu_read_lock_held() can be passed as the
+ * cond argument from read side.
+ */
+#define hlist_for_each_entry_srcu(pos, head, member, cond) \
+ for (__list_check_srcu(cond), \
+ pos = hlist_entry_safe(rcu_dereference_raw(hlist_first_rcu(head)),\
+ typeof(*(pos)), member); \
+ pos; \
+ pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(\
+ &(pos)->member)), typeof(*(pos)), member))
+
/**
* hlist_for_each_entry_rcu_notrace - iterate over rcu list of given type (for tracing)
* @pos: the type * to use as a loop cursor.
--
2.17.1
From: Madhuparna Bhowmik <[email protected]>
Use hlist_for_each_entry_srcu() instead of hlist_for_each_entry_rcu()
as it also checkes if the right lock is held.
Using hlist_for_each_entry_rcu() with a condition argument will not
report the cases where a SRCU protected list is traversed using
rcu_read_lock(). Hence, use hlist_for_each_entry_srcu().
Signed-off-by: Madhuparna Bhowmik <[email protected]>
---
arch/x86/kvm/mmu/page_track.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/mmu/page_track.c b/arch/x86/kvm/mmu/page_track.c
index a7bcde34d1f2..a9cd17625950 100644
--- a/arch/x86/kvm/mmu/page_track.c
+++ b/arch/x86/kvm/mmu/page_track.c
@@ -229,7 +229,8 @@ void kvm_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new,
return;
idx = srcu_read_lock(&head->track_srcu);
- hlist_for_each_entry_rcu(n, &head->track_notifier_list, node)
+ hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
+ srcu_read_lock_held(&head->track_srcu))
if (n->track_write)
n->track_write(vcpu, gpa, new, bytes, n);
srcu_read_unlock(&head->track_srcu, idx);
@@ -254,7 +255,8 @@ void kvm_page_track_flush_slot(struct kvm *kvm, struct kvm_memory_slot *slot)
return;
idx = srcu_read_lock(&head->track_srcu);
- hlist_for_each_entry_rcu(n, &head->track_notifier_list, node)
+ hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
+ srcu_read_lock_held(&head->track_srcu))
if (n->track_flush_slot)
n->track_flush_slot(kvm, slot, n);
srcu_read_unlock(&head->track_srcu, idx);
--
2.17.1
On Sun, Jul 12, 2020 at 06:40:03PM +0530, [email protected] wrote:
> From: Madhuparna Bhowmik <[email protected]>
>
> Use hlist_for_each_entry_srcu() instead of hlist_for_each_entry_rcu()
> as it also checkes if the right lock is held.
> Using hlist_for_each_entry_rcu() with a condition argument will not
> report the cases where a SRCU protected list is traversed using
> rcu_read_lock(). Hence, use hlist_for_each_entry_srcu().
>
> Signed-off-by: Madhuparna Bhowmik <[email protected]>
I queued both for testing and review, thank you!
In particular, this one needs an ack by the maintainer.
Thanx, Paul
> ---
> arch/x86/kvm/mmu/page_track.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/mmu/page_track.c b/arch/x86/kvm/mmu/page_track.c
> index a7bcde34d1f2..a9cd17625950 100644
> --- a/arch/x86/kvm/mmu/page_track.c
> +++ b/arch/x86/kvm/mmu/page_track.c
> @@ -229,7 +229,8 @@ void kvm_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new,
> return;
>
> idx = srcu_read_lock(&head->track_srcu);
> - hlist_for_each_entry_rcu(n, &head->track_notifier_list, node)
> + hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
> + srcu_read_lock_held(&head->track_srcu))
> if (n->track_write)
> n->track_write(vcpu, gpa, new, bytes, n);
> srcu_read_unlock(&head->track_srcu, idx);
> @@ -254,7 +255,8 @@ void kvm_page_track_flush_slot(struct kvm *kvm, struct kvm_memory_slot *slot)
> return;
>
> idx = srcu_read_lock(&head->track_srcu);
> - hlist_for_each_entry_rcu(n, &head->track_notifier_list, node)
> + hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
> + srcu_read_lock_held(&head->track_srcu))
> if (n->track_flush_slot)
> n->track_flush_slot(kvm, slot, n);
> srcu_read_unlock(&head->track_srcu, idx);
> --
> 2.17.1
>
On Sun, 12 Jul 2020 at 21:39, Paul E. McKenney <[email protected]> wrote:
>
> On Sun, Jul 12, 2020 at 06:40:03PM +0530, [email protected] wrote:
> > From: Madhuparna Bhowmik <[email protected]>
> >
> > Use hlist_for_each_entry_srcu() instead of hlist_for_each_entry_rcu()
> > as it also checkes if the right lock is held.
> > Using hlist_for_each_entry_rcu() with a condition argument will not
> > report the cases where a SRCU protected list is traversed using
> > rcu_read_lock(). Hence, use hlist_for_each_entry_srcu().
> >
> > Signed-off-by: Madhuparna Bhowmik <[email protected]>
>
> I queued both for testing and review, thank you!
>
> In particular, this one needs an ack by the maintainer.
>
> Thanx, Paul
>
> > arch/x86/kvm/mmu/page_track.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/x86/kvm/mmu/page_track.c b/arch/x86/kvm/mmu/page_track.c
> > index a7bcde34d1f2..a9cd17625950 100644
> > --- a/arch/x86/kvm/mmu/page_track.c
> > +++ b/arch/x86/kvm/mmu/page_track.c
> > @@ -229,7 +229,8 @@ void kvm_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new,
> > return;
> >
> > idx = srcu_read_lock(&head->track_srcu);
> > - hlist_for_each_entry_rcu(n, &head->track_notifier_list, node)
> > + hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
> > + srcu_read_lock_held(&head->track_srcu))
x86 build failed on linux -next 20200716.
arch/x86/kvm/mmu/page_track.c: In function 'kvm_page_track_write':
include/linux/rculist.h:727:30: error: left-hand operand of comma
expression has no effect [-Werror=unused-value]
for (__list_check_srcu(cond), \
^
arch/x86/kvm/mmu/page_track.c:232:2: note: in expansion of macro
'hlist_for_each_entry_srcu'
hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
^~~~~~~~~~~~~~~~~~~~~~~~~
arch/x86/kvm/mmu/page_track.c: In function 'kvm_page_track_flush_slot':
include/linux/rculist.h:727:30: error: left-hand operand of comma
expression has no effect [-Werror=unused-value]
for (__list_check_srcu(cond), \
^
arch/x86/kvm/mmu/page_track.c:258:2: note: in expansion of macro
'hlist_for_each_entry_srcu'
hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
^~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [arch/x86/kvm/mmu/page_track.o] Error 1
build link,
https://ci.linaro.org/view/lkft/job/openembedded-lkft-linux-next/DISTRO=lkft,MACHINE=intel-corei7-64,label=docker-lkft/815/consoleText
--
Linaro LKFT
https://lkft.linaro.org
On Thu, Jul 16, 2020 at 7:47 AM Naresh Kamboju
<[email protected]> wrote:
>
> On Sun, 12 Jul 2020 at 21:39, Paul E. McKenney <[email protected]> wrote:
> >
> > On Sun, Jul 12, 2020 at 06:40:03PM +0530, [email protected] wrote:
> > > From: Madhuparna Bhowmik <[email protected]>
> > >
> > > Use hlist_for_each_entry_srcu() instead of hlist_for_each_entry_rcu()
> > > as it also checkes if the right lock is held.
> > > Using hlist_for_each_entry_rcu() with a condition argument will not
> > > report the cases where a SRCU protected list is traversed using
> > > rcu_read_lock(). Hence, use hlist_for_each_entry_srcu().
> > >
> > > Signed-off-by: Madhuparna Bhowmik <[email protected]>
> >
> > I queued both for testing and review, thank you!
> >
> > In particular, this one needs an ack by the maintainer.
> >
> > Thanx, Paul
> >
> > > arch/x86/kvm/mmu/page_track.c | 6 ++++--
> > > 1 file changed, 4 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/arch/x86/kvm/mmu/page_track.c b/arch/x86/kvm/mmu/page_track.c
> > > index a7bcde34d1f2..a9cd17625950 100644
> > > --- a/arch/x86/kvm/mmu/page_track.c
> > > +++ b/arch/x86/kvm/mmu/page_track.c
> > > @@ -229,7 +229,8 @@ void kvm_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new,
> > > return;
> > >
> > > idx = srcu_read_lock(&head->track_srcu);
> > > - hlist_for_each_entry_rcu(n, &head->track_notifier_list, node)
> > > + hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
> > > + srcu_read_lock_held(&head->track_srcu))
>
> x86 build failed on linux -next 20200716.
>
> arch/x86/kvm/mmu/page_track.c: In function 'kvm_page_track_write':
> include/linux/rculist.h:727:30: error: left-hand operand of comma
> expression has no effect [-Werror=unused-value]
> for (__list_check_srcu(cond), \
> ^
> arch/x86/kvm/mmu/page_track.c:232:2: note: in expansion of macro
> 'hlist_for_each_entry_srcu'
> hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
> ^~~~~~~~~~~~~~~~~~~~~~~~~
> arch/x86/kvm/mmu/page_track.c: In function 'kvm_page_track_flush_slot':
> include/linux/rculist.h:727:30: error: left-hand operand of comma
> expression has no effect [-Werror=unused-value]
> for (__list_check_srcu(cond), \
> ^
> arch/x86/kvm/mmu/page_track.c:258:2: note: in expansion of macro
> 'hlist_for_each_entry_srcu'
> hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
> ^~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> make[3]: *** [arch/x86/kvm/mmu/page_track.o] Error 1
>
> build link,
> https://ci.linaro.org/view/lkft/job/openembedded-lkft-linux-next/DISTRO=lkft,MACHINE=intel-corei7-64,label=docker-lkft/815/consoleText
>
> --
> Linaro LKFT
> https://lkft.linaro.org
Hi, we're seeing the same building failure with the latest linux-next tree.
Thanks,
Dexuan
On Thu, Jul 16, 2020 at 05:19:52PM -0700, Dexuan-Linux Cui wrote:
> On Thu, Jul 16, 2020 at 7:47 AM Naresh Kamboju
> <[email protected]> wrote:
> >
> > On Sun, 12 Jul 2020 at 21:39, Paul E. McKenney <[email protected]> wrote:
> > >
> > > On Sun, Jul 12, 2020 at 06:40:03PM +0530, [email protected] wrote:
> > > > From: Madhuparna Bhowmik <[email protected]>
> > > >
> > > > Use hlist_for_each_entry_srcu() instead of hlist_for_each_entry_rcu()
> > > > as it also checkes if the right lock is held.
> > > > Using hlist_for_each_entry_rcu() with a condition argument will not
> > > > report the cases where a SRCU protected list is traversed using
> > > > rcu_read_lock(). Hence, use hlist_for_each_entry_srcu().
> > > >
> > > > Signed-off-by: Madhuparna Bhowmik <[email protected]>
> > >
> > > I queued both for testing and review, thank you!
> > >
> > > In particular, this one needs an ack by the maintainer.
> > >
> > > Thanx, Paul
> > >
> > > > arch/x86/kvm/mmu/page_track.c | 6 ++++--
> > > > 1 file changed, 4 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/arch/x86/kvm/mmu/page_track.c b/arch/x86/kvm/mmu/page_track.c
> > > > index a7bcde34d1f2..a9cd17625950 100644
> > > > --- a/arch/x86/kvm/mmu/page_track.c
> > > > +++ b/arch/x86/kvm/mmu/page_track.c
> > > > @@ -229,7 +229,8 @@ void kvm_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new,
> > > > return;
> > > >
> > > > idx = srcu_read_lock(&head->track_srcu);
> > > > - hlist_for_each_entry_rcu(n, &head->track_notifier_list, node)
> > > > + hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
> > > > + srcu_read_lock_held(&head->track_srcu))
> >
> > x86 build failed on linux -next 20200716.
> >
> > arch/x86/kvm/mmu/page_track.c: In function 'kvm_page_track_write':
> > include/linux/rculist.h:727:30: error: left-hand operand of comma
> > expression has no effect [-Werror=unused-value]
> > for (__list_check_srcu(cond), \
> > ^
> > arch/x86/kvm/mmu/page_track.c:232:2: note: in expansion of macro
> > 'hlist_for_each_entry_srcu'
> > hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
> > ^~~~~~~~~~~~~~~~~~~~~~~~~
> > arch/x86/kvm/mmu/page_track.c: In function 'kvm_page_track_flush_slot':
> > include/linux/rculist.h:727:30: error: left-hand operand of comma
> > expression has no effect [-Werror=unused-value]
> > for (__list_check_srcu(cond), \
> > ^
> > arch/x86/kvm/mmu/page_track.c:258:2: note: in expansion of macro
> > 'hlist_for_each_entry_srcu'
> > hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
> > ^~~~~~~~~~~~~~~~~~~~~~~~~
> > cc1: all warnings being treated as errors
> > make[3]: *** [arch/x86/kvm/mmu/page_track.o] Error 1
> >
> > build link,
> > https://ci.linaro.org/view/lkft/job/openembedded-lkft-linux-next/DISTRO=lkft,MACHINE=intel-corei7-64,label=docker-lkft/815/consoleText
> >
> > --
> > Linaro LKFT
> > https://lkft.linaro.org
>
> Hi, we're seeing the same building failure with the latest linux-next tree.
I am not seeing this here. Could you please let us know what compiler
and command-line options you are using to generate this?
Thanx, Paul
Hello!
On Fri, 17 Jul 2020 at 12:07, Paul E. McKenney <[email protected]> wrote:
>
> On Thu, Jul 16, 2020 at 05:19:52PM -0700, Dexuan-Linux Cui wrote:
> > On Thu, Jul 16, 2020 at 7:47 AM Naresh Kamboju
> > <[email protected]> wrote:
> > >
> > > On Sun, 12 Jul 2020 at 21:39, Paul E. McKenney <[email protected]> wrote:
> > > >
> > > > On Sun, Jul 12, 2020 at 06:40:03PM +0530, [email protected] wrote:
> > > > > From: Madhuparna Bhowmik <[email protected]>
> > > > >
> > > > > Use hlist_for_each_entry_srcu() instead of hlist_for_each_entry_rcu()
> > > > > as it also checkes if the right lock is held.
> > > > > Using hlist_for_each_entry_rcu() with a condition argument will not
> > > > > report the cases where a SRCU protected list is traversed using
> > > > > rcu_read_lock(). Hence, use hlist_for_each_entry_srcu().
> > > > >
> > > > > Signed-off-by: Madhuparna Bhowmik <[email protected]>
> > > >
> > > > I queued both for testing and review, thank you!
> > > >
> > > > In particular, this one needs an ack by the maintainer.
> > > >
> > > > Thanx, Paul
> > > >
> > > > > arch/x86/kvm/mmu/page_track.c | 6 ++++--
> > > > > 1 file changed, 4 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/arch/x86/kvm/mmu/page_track.c b/arch/x86/kvm/mmu/page_track.c
> > > > > index a7bcde34d1f2..a9cd17625950 100644
> > > > > --- a/arch/x86/kvm/mmu/page_track.c
> > > > > +++ b/arch/x86/kvm/mmu/page_track.c
> > > > > @@ -229,7 +229,8 @@ void kvm_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new,
> > > > > return;
> > > > >
> > > > > idx = srcu_read_lock(&head->track_srcu);
> > > > > - hlist_for_each_entry_rcu(n, &head->track_notifier_list, node)
> > > > > + hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
> > > > > + srcu_read_lock_held(&head->track_srcu))
> > >
> > > x86 build failed on linux -next 20200716.
> > >
> > > arch/x86/kvm/mmu/page_track.c: In function 'kvm_page_track_write':
> > > include/linux/rculist.h:727:30: error: left-hand operand of comma
> > > expression has no effect [-Werror=unused-value]
> > > for (__list_check_srcu(cond), \
> > > ^
> > > arch/x86/kvm/mmu/page_track.c:232:2: note: in expansion of macro
> > > 'hlist_for_each_entry_srcu'
> > > hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
> > > ^~~~~~~~~~~~~~~~~~~~~~~~~
> > > arch/x86/kvm/mmu/page_track.c: In function 'kvm_page_track_flush_slot':
> > > include/linux/rculist.h:727:30: error: left-hand operand of comma
> > > expression has no effect [-Werror=unused-value]
> > > for (__list_check_srcu(cond), \
> > > ^
> > > arch/x86/kvm/mmu/page_track.c:258:2: note: in expansion of macro
> > > 'hlist_for_each_entry_srcu'
> > > hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
> > > ^~~~~~~~~~~~~~~~~~~~~~~~~
> > > cc1: all warnings being treated as errors
> > > make[3]: *** [arch/x86/kvm/mmu/page_track.o] Error 1
> > >
> > > build link,
> > > https://ci.linaro.org/view/lkft/job/openembedded-lkft-linux-next/DISTRO=lkft,MACHINE=intel-corei7-64,label=docker-lkft/815/consoleText
> > >
> >
> > Hi, we're seeing the same building failure with the latest linux-next tree.
>
> I am not seeing this here. Could you please let us know what compiler
> and command-line options you are using to generate this?
It fails with gcc-8 and gcc-9, but it builds with gcc-10. Quick way to
reproduce:
[host] docker run --rm -it -v /linux:/linux -w /linux
tuxbuild/build-gcc-9_mips
[docker] make ARCH=mips CROSS_COMPILE=mips-linux-gnu- defconfig
[docker] make ARCH=mips CROSS_COMPILE=mips-linux-gnu- mm
You can use these other Docker containers: tuxbuild/build-gcc-8_mips
and tuxbuild/build-gcc-10_mips.
Logs for those builds (and allnoconfig, tinyconfig, with gcc-8, gcc-9
and gcc-10) can also be found here:
https://gitlab.com/Linaro/lkft/kernel-runs/-/jobs/643978135
Greetings!
Daniel Díaz
[email protected]
The sender of this email would like to recall the message. And drink
more coffee. The sender will also avoid making any more commits on
Friday.
On Fri, 17 Jul 2020 at 13:03, Daniel Díaz <[email protected]> wrote:
>
> Hello!
>
> On Fri, 17 Jul 2020 at 12:07, Paul E. McKenney <[email protected]> wrote:
> >
> > On Thu, Jul 16, 2020 at 05:19:52PM -0700, Dexuan-Linux Cui wrote:
> > > On Thu, Jul 16, 2020 at 7:47 AM Naresh Kamboju
> > > <[email protected]> wrote:
> > > >
> > > > On Sun, 12 Jul 2020 at 21:39, Paul E. McKenney <[email protected]> wrote:
> > > > >
> > > > > On Sun, Jul 12, 2020 at 06:40:03PM +0530, [email protected] wrote:
> > > > > > From: Madhuparna Bhowmik <[email protected]>
> > > > > >
> > > > > > Use hlist_for_each_entry_srcu() instead of hlist_for_each_entry_rcu()
> > > > > > as it also checkes if the right lock is held.
> > > > > > Using hlist_for_each_entry_rcu() with a condition argument will not
> > > > > > report the cases where a SRCU protected list is traversed using
> > > > > > rcu_read_lock(). Hence, use hlist_for_each_entry_srcu().
> > > > > >
> > > > > > Signed-off-by: Madhuparna Bhowmik <[email protected]>
> > > > >
> > > > > I queued both for testing and review, thank you!
> > > > >
> > > > > In particular, this one needs an ack by the maintainer.
> > > > >
> > > > > Thanx, Paul
> > > > >
> > > > > > arch/x86/kvm/mmu/page_track.c | 6 ++++--
> > > > > > 1 file changed, 4 insertions(+), 2 deletions(-)
> > > > > >
> > > > > > diff --git a/arch/x86/kvm/mmu/page_track.c b/arch/x86/kvm/mmu/page_track.c
> > > > > > index a7bcde34d1f2..a9cd17625950 100644
> > > > > > --- a/arch/x86/kvm/mmu/page_track.c
> > > > > > +++ b/arch/x86/kvm/mmu/page_track.c
> > > > > > @@ -229,7 +229,8 @@ void kvm_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new,
> > > > > > return;
> > > > > >
> > > > > > idx = srcu_read_lock(&head->track_srcu);
> > > > > > - hlist_for_each_entry_rcu(n, &head->track_notifier_list, node)
> > > > > > + hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
> > > > > > + srcu_read_lock_held(&head->track_srcu))
> > > >
> > > > x86 build failed on linux -next 20200716.
> > > >
> > > > arch/x86/kvm/mmu/page_track.c: In function 'kvm_page_track_write':
> > > > include/linux/rculist.h:727:30: error: left-hand operand of comma
> > > > expression has no effect [-Werror=unused-value]
> > > > for (__list_check_srcu(cond), \
> > > > ^
> > > > arch/x86/kvm/mmu/page_track.c:232:2: note: in expansion of macro
> > > > 'hlist_for_each_entry_srcu'
> > > > hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
> > > > ^~~~~~~~~~~~~~~~~~~~~~~~~
> > > > arch/x86/kvm/mmu/page_track.c: In function 'kvm_page_track_flush_slot':
> > > > include/linux/rculist.h:727:30: error: left-hand operand of comma
> > > > expression has no effect [-Werror=unused-value]
> > > > for (__list_check_srcu(cond), \
> > > > ^
> > > > arch/x86/kvm/mmu/page_track.c:258:2: note: in expansion of macro
> > > > 'hlist_for_each_entry_srcu'
> > > > hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
> > > > ^~~~~~~~~~~~~~~~~~~~~~~~~
> > > > cc1: all warnings being treated as errors
> > > > make[3]: *** [arch/x86/kvm/mmu/page_track.o] Error 1
> > > >
> > > > build link,
> > > > https://ci.linaro.org/view/lkft/job/openembedded-lkft-linux-next/DISTRO=lkft,MACHINE=intel-corei7-64,label=docker-lkft/815/consoleText
> > > >
> > >
> > > Hi, we're seeing the same building failure with the latest linux-next tree.
> >
> > I am not seeing this here. Could you please let us know what compiler
> > and command-line options you are using to generate this?
Please disregard anything below.
Thanks and greetings!
Daniel Díaz
[email protected]
> It fails with gcc-8 and gcc-9, but it builds with gcc-10. Quick way to
> reproduce:
> [host] docker run --rm -it -v /linux:/linux -w /linux
> tuxbuild/build-gcc-9_mips
> [docker] make ARCH=mips CROSS_COMPILE=mips-linux-gnu- defconfig
> [docker] make ARCH=mips CROSS_COMPILE=mips-linux-gnu- mm
>
> You can use these other Docker containers: tuxbuild/build-gcc-8_mips
> and tuxbuild/build-gcc-10_mips.
>
> Logs for those builds (and allnoconfig, tinyconfig, with gcc-8, gcc-9
> and gcc-10) can also be found here:
> https://gitlab.com/Linaro/lkft/kernel-runs/-/jobs/643978135
>
> Greetings!
>
> Daniel Díaz
> [email protected]
Hi Paul,
> I am not seeing this here.
Do you notice any warnings while building linux next master
for x86_64 architecture ?
> Could you please let us know what compiler
> and command-line options you are using to generate this?
We have two build systems one showing it as error and build breaks
and another one showing it as warning and build pass.
tool chain: gcc 9.3.0
build command:
make -sk KBUILD_BUILD_USER=TuxBuild -C/linux -j16 ARCH=x86 HOSTCC=gcc
CC="sccache gcc" O=build
metadata:
git_repo: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git,
target_arch: x86,
toolchain: gcc-9,
git_short_log: aab7ee9f8ff0 (\Add linux-next specific files for 20200717\),
git_sha: aab7ee9f8ff0110bfcd594b33dc33748dc1baf46,
git_describe: next-20200717,
kernel_version: 5.8.0-rc5,
warning log,
--
make -sk KBUILD_BUILD_USER=TuxBuild -C/linux -j16 ARCH=x86 HOSTCC=gcc
CC="sccache gcc" O=build
#
In file included from ../include/linux/pid.h:5,
from ../include/linux/sched.h:14,
from ../include/linux/kvm_host.h:12,
from ../arch/x86/kvm/mmu/page_track.c:14:
../arch/x86/kvm/mmu/page_track.c: In function ‘kvm_page_track_write’:
../include/linux/rculist.h:727:30: warning: left-hand operand of comma
expression has no effect [-Wunused-value]
727 | for (__list_check_srcu(cond), \
| ^
../arch/x86/kvm/mmu/page_track.c:232:2: note: in expansion of macro
‘hlist_for_each_entry_srcu’
232 | hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
../arch/x86/kvm/mmu/page_track.c: In function ‘kvm_page_track_flush_slot’:
../include/linux/rculist.h:727:30: warning: left-hand operand of comma
expression has no effect [-Wunused-value]
727 | for (__list_check_srcu(cond), \
| ^
../arch/x86/kvm/mmu/page_track.c:258:2: note: in expansion of macro
‘hlist_for_each_entry_srcu’
258 | hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
arch/x86/kvm/svm/svm.o: warning: objtool: svm_flush_tlb_gva()+0x12:
call without frame pointer save/setup
kernel/bpf/core.o: warning: objtool: ___bpf_prog_run.cold()+0x7: call
without frame pointer save/setup
ref:
https://gitlab.com/Linaro/lkft/kernel-runs/-/jobs/643978120
> Thanx, Paul
- Naresh
On Sat, Jul 18, 2020 at 12:35:12AM +0530, Naresh Kamboju wrote:
> Hi Paul,
>
> > I am not seeing this here.
>
> Do you notice any warnings while building linux next master
> for x86_64 architecture ?
Idiot here was failing to enable building of KVM. With that, I do see
the error. The patch resolves it for me. Does it help for you?
Thanx, Paul
------------------------------------------------------------------------
diff --git a/include/linux/rculist.h b/include/linux/rculist.h
index de9385b..f8633d3 100644
--- a/include/linux/rculist.h
+++ b/include/linux/rculist.h
@@ -73,7 +73,7 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list)
#define __list_check_rcu(dummy, cond, extra...) \
({ check_arg_count_one(extra); })
-#define __list_check_srcu(cond) true
+#define __list_check_srcu(cond) ({ })
#endif
/*
On Sat, 18 Jul 2020 at 05:43, Paul E. McKenney <[email protected]> wrote:
>
> On Sat, Jul 18, 2020 at 12:35:12AM +0530, Naresh Kamboju wrote:
> > Hi Paul,
> >
> > > I am not seeing this here.
> >
> > Do you notice any warnings while building linux next master
> > for x86_64 architecture ?
>
> Idiot here was failing to enable building of KVM. With that, I do see
> the error. The patch resolves it for me. Does it help for you?
yes.
The below patch applied on top of linux -next 20200717 tag
and build pass.
>
> Thanx, Paul
>
> ------------------------------------------------------------------------
>
> diff --git a/include/linux/rculist.h b/include/linux/rculist.h
> index de9385b..f8633d3 100644
> --- a/include/linux/rculist.h
> +++ b/include/linux/rculist.h
> @@ -73,7 +73,7 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list)
> #define __list_check_rcu(dummy, cond, extra...) \
> ({ check_arg_count_one(extra); })
>
> -#define __list_check_srcu(cond) true
> +#define __list_check_srcu(cond) ({ })
> #endif
>
> /*
- Naresh
On Sun, Jul 19, 2020 at 05:52:44PM +0530, Naresh Kamboju wrote:
> On Sat, 18 Jul 2020 at 05:43, Paul E. McKenney <[email protected]> wrote:
> >
> > On Sat, Jul 18, 2020 at 12:35:12AM +0530, Naresh Kamboju wrote:
> > > Hi Paul,
> > >
> > > > I am not seeing this here.
> > >
> > > Do you notice any warnings while building linux next master
> > > for x86_64 architecture ?
> >
> > Idiot here was failing to enable building of KVM. With that, I do see
> > the error. The patch resolves it for me. Does it help for you?
>
> yes.
> The below patch applied on top of linux -next 20200717 tag
> and build pass.
Thank you! May I add your Tested-by?
Thanx, Paul
> > ------------------------------------------------------------------------
> >
> > diff --git a/include/linux/rculist.h b/include/linux/rculist.h
> > index de9385b..f8633d3 100644
> > --- a/include/linux/rculist.h
> > +++ b/include/linux/rculist.h
> > @@ -73,7 +73,7 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list)
> > #define __list_check_rcu(dummy, cond, extra...) \
> > ({ check_arg_count_one(extra); })
> >
> > -#define __list_check_srcu(cond) true
> > +#define __list_check_srcu(cond) ({ })
> > #endif
> >
> > /*
>
> - Naresh
On Sun, 19 Jul 2020 at 21:38, Paul E. McKenney <[email protected]> wrote:
>
> On Sun, Jul 19, 2020 at 05:52:44PM +0530, Naresh Kamboju wrote:
> > On Sat, 18 Jul 2020 at 05:43, Paul E. McKenney <[email protected]> wrote:
> > >
> > > On Sat, Jul 18, 2020 at 12:35:12AM +0530, Naresh Kamboju wrote:
> > > > Hi Paul,
> > > >
> > > > > I am not seeing this here.
> > > >
> > > > Do you notice any warnings while building linux next master
> > > > for x86_64 architecture ?
> > >
> > > Idiot here was failing to enable building of KVM. With that, I do see
> > > the error. The patch resolves it for me. Does it help for you?
> >
> > yes.
> > The below patch applied on top of linux -next 20200717 tag
> > and build pass.
>
> Thank you! May I add your Tested-by?
That would be great please add
Tested-by: Naresh Kamboju <[email protected]>
Thank you !
- Naresh
On Mon, Jul 20, 2020 at 07:43:50PM +0530, Naresh Kamboju wrote:
> On Sun, 19 Jul 2020 at 21:38, Paul E. McKenney <[email protected]> wrote:
> >
> > On Sun, Jul 19, 2020 at 05:52:44PM +0530, Naresh Kamboju wrote:
> > > On Sat, 18 Jul 2020 at 05:43, Paul E. McKenney <[email protected]> wrote:
> > > >
> > > > On Sat, Jul 18, 2020 at 12:35:12AM +0530, Naresh Kamboju wrote:
> > > > > Hi Paul,
> > > > >
> > > > > > I am not seeing this here.
> > > > >
> > > > > Do you notice any warnings while building linux next master
> > > > > for x86_64 architecture ?
> > > >
> > > > Idiot here was failing to enable building of KVM. With that, I do see
> > > > the error. The patch resolves it for me. Does it help for you?
> > >
> > > yes.
> > > The below patch applied on top of linux -next 20200717 tag
> > > and build pass.
> >
> > Thank you! May I add your Tested-by?
>
> That would be great please add
> Tested-by: Naresh Kamboju <[email protected]>
>
> Thank you !
Done, and thank you for spotting this!
Thanx, Paul