lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 18 Nov 2022 14:22:34 -0800
From:   "Paul E. McKenney" <paulmck@...nel.org>
To:     "Joel Fernandes (Google)" <joel@...lfernandes.org>
Cc:     linux-kernel@...r.kernel.org, David Ahern <dsahern@...nel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
        Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
        Paolo Abeni <pabeni@...hat.com>, rcu@...r.kernel.org,
        rostedt@...dmis.org, fweisbec@...il.com
Subject: Re: [PATCH v2 1/2] net: Use call_rcu_flush() for dst_destroy_rcu

On Fri, Nov 18, 2022 at 07:19:08PM +0000, Joel Fernandes (Google) wrote:
> In a networking test on ChromeOS, we find that using the new
> CONFIG_RCU_LAZY causes a networking test to fail in the teardown phase.
> 
> The failure happens during: ip netns del <name>
> 
> Using ftrace, I found the callbacks it was queuing which this series fixes.
> Use call_rcu_flush() to revert to the old behavior. With that, the test
> passes.
> 
> Signed-off-by: Joel Fernandes (Google) <joel@...lfernandes.org>

Queued and pushed, wordsmithed as shown below, thank you!

							Thanx, Paul

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

commit dee2cd7a0d6f3274bdcfe902cf7914b9553355b3
Author: Joel Fernandes (Google) <joel@...lfernandes.org>
Date:   Fri Nov 18 19:19:08 2022 +0000

    net: Use call_rcu_flush() for dst_release()
    
    In a networking test on ChromeOS, kernels built with the new
    CONFIG_RCU_LAZY=y Kconfig option fail a networking test in the teardown
    phase.
    
    This failure may be reproduced as follows: ip netns del <name>
    
    The CONFIG_RCU_LAZY=y Kconfig option was introduced by earlier commits
    in this series for the benefit of certain battery-powered systems.
    This Kconfig option causes call_rcu() to delay its callbacks in order
    to batch them.  This means that a given RCU grace period covers more
    callbacks, thus reducing the number of grace periods, in turn reducing
    the amount of energy consumed, which increases battery lifetime which
    can be a very good thing.  This is not a subtle effect: In some important
    use cases, the battery lifetime is increased by more than 10%.
    
    This CONFIG_RCU_LAZY=y option is available only for CPUs that offload
    callbacks, for example, CPUs mentioned in the rcu_nocbs kernel boot
    parameter passed to kernels built with CONFIG_RCU_NOCB_CPU=y.
    
    Delaying callbacks is normally not a problem because most callbacks do
    nothing but free memory.  If the system is short on memory, a shrinker
    will kick all currently queued lazy callbacks out of their laziness,
    thus freeing their memory in short order.  Similarly, the rcu_barrier()
    function, which blocks until all currently queued callbacks are invoked,
    will also kick lazy callbacks, thus enabling rcu_barrier() to complete
    in a timely manner.
    
    However, there are some cases where laziness is not a good option.
    For example, synchronize_rcu() invokes call_rcu(), and blocks until
    the newly queued callback is invoked.  It would not be a good for
    synchronize_rcu() to block for ten seconds, even on an idle system.
    Therefore, synchronize_rcu() invokes call_rcu_flush() instead of
    call_rcu().  The arrival of a non-lazy call_rcu_flush() callback on a
    given CPU kicks any lazy callbacks that might be already queued on that
    CPU.  After all, if there is going to be a grace period, all callbacks
    might as well get full benefit from it.
    
    Yes, this could be done the other way around by creating a
    call_rcu_lazy(), but earlier experience with this approach and
    feedback at the 2022 Linux Plumbers Conference shifted the approach
    to call_rcu() being lazy with call_rcu_flush() for the few places
    where laziness is inappropriate.
    
    Returning to the test failure, use of ftrace showed that this failure
    cause caused by the aadded delays due to this new lazy behavior of
    call_rcu() in kernels built with CONFIG_RCU_LAZY=y.
    
    Therefore, make dst_release() use call_rcu_flush() in order to revert
    to the old test-failure-free behavior.
    
    Signed-off-by: Joel Fernandes (Google) <joel@...lfernandes.org>
    Cc: David Ahern <dsahern@...nel.org>
    Cc: "David S. Miller" <davem@...emloft.net>
    Cc: Eric Dumazet <edumazet@...gle.com>
    Cc: Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>
    Cc: Jakub Kicinski <kuba@...nel.org>
    Cc: Paolo Abeni <pabeni@...hat.com>
    Cc: <netdev@...r.kernel.org>
    Signed-off-by: Paul E. McKenney <paulmck@...nel.org>

diff --git a/net/core/dst.c b/net/core/dst.c
index bc9c9be4e0801..15b16322703f4 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -174,7 +174,7 @@ void dst_release(struct dst_entry *dst)
 			net_warn_ratelimited("%s: dst:%p refcnt:%d\n",
 					     __func__, dst, newrefcnt);
 		if (!newrefcnt)
-			call_rcu(&dst->rcu_head, dst_destroy_rcu);
+			call_rcu_flush(&dst->rcu_head, dst_destroy_rcu);
 	}
 }
 EXPORT_SYMBOL(dst_release);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ