From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org, davem@davemloft.net,
netdev@vger.kernel.org
Subject: Re: [PATCH 06/12] sched: add cond_resched_rcu() helper
Date: Wed, 12 Jun 2013 08:50:08 -0700 [thread overview]
Message-ID: <20130612155008.GY5146@linux.vnet.ibm.com> (raw)
In-Reply-To: <1370464832-4216-7-git-send-email-pablo@netfilter.org>
On Wed, Jun 05, 2013 at 10:40:27PM +0200, Pablo Neira Ayuso wrote:
> From: Simon Horman <horms@verge.net.au>
>
> This is intended for use in loops which read data protected by RCU and may
> have a large number of iterations. Such an example is dumping the list of
> connections known to IPVS: ip_vs_conn_array() and ip_vs_conn_seq_next().
>
> The benefits are for CONFIG_PREEMPT_RCU=y where we save CPU cycles
> by moving rcu_read_lock and rcu_read_unlock out of large loops
> but still allowing the current task to be preempted after every
> loop iteration for the CONFIG_PREEMPT_RCU=n case.
>
> The call to cond_resched() is not needed when CONFIG_PREEMPT_RCU=y.
> Thanks to Paul E. McKenney for explaining this and for the
> final version that checks the context with CONFIG_DEBUG_ATOMIC_SLEEP=y
> for all possible configurations.
>
> The function can be empty in the CONFIG_PREEMPT_RCU case,
> rcu_read_lock and rcu_read_unlock are not needed in this case
> because the task can be preempted on indication from scheduler.
> Thanks to Peter Zijlstra for catching this and for his help
> in trying a solution that changes __might_sleep.
>
> Initial cond_resched_rcu_lock() function suggested by Eric Dumazet.
>
> Tested-by: Julian Anastasov <ja@ssi.bg>
> Signed-off-by: Julian Anastasov <ja@ssi.bg>
> Signed-off-by: Simon Horman <horms@verge.net.au>
> Acked-by: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> ---
> include/linux/sched.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 178a8d9..4ff8da1 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -2444,6 +2444,15 @@ extern int __cond_resched_softirq(void);
> __cond_resched_softirq(); \
> })
>
> +static inline void cond_resched_rcu(void)
> +{
> +#if defined(CONFIG_DEBUG_ATOMIC_SLEEP) || !defined(CONFIG_PREEMPT_RCU)
> + rcu_read_unlock();
> + cond_resched();
> + rcu_read_lock();
> +#endif
> +}
> +
> /*
> * Does a critical section need to be broken due to another
> * task waiting?: (technically does not depend on CONFIG_PREEMPT,
> --
> 1.7.10.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2013-06-12 16:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-05 20:40 [PATCH 00/12] Netfilter/IPVS updates for net-next Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 01/12] netfilter: xt_CT: optimize XT_CT_NOTRACK Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 02/12] netfilter: xt_socket: use IP early demux Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 03/12] bridge: netfilter: using strlcpy() instead of strncpy() Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 04/12] netfilter: don't panic on error while walking through the init path Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 05/12] netfilter: {ipt,ebt}_ULOG: rise warning on deprecation Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 06/12] sched: add cond_resched_rcu() helper Pablo Neira Ayuso
2013-06-12 15:50 ` Paul E. McKenney [this message]
2013-06-05 20:40 ` [PATCH 07/12] ipvs: use cond_resched_rcu() helper when walking connections Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 08/12] ipvs: change type of netns_ipvs->sysctl_sync_qlen_max Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 10/12] netfilter: Implement RFC 1123 for FTP conntrack Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 11/12] netfilter: nfnetlink_queue: cleanup copy_range usage Pablo Neira Ayuso
2013-06-05 20:40 ` [PATCH 12/12] netfilter: nfnetlink_queue: only add CAP_LEN attr when needed Pablo Neira Ayuso
2013-06-06 9:03 ` [PATCH 00/12] Netfilter/IPVS updates for net-next David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130612155008.GY5146@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).