netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Jesper Dangaard Brouer <brouer@redhat.com>
Cc: liujian56@huawei.com, netdev@vger.kernel.org,
	Florian Westphal <fw@strlen.de>
Subject: Re: [RFC PATCH] net: frag limit checks need to use percpu_counter_compare
Date: Thu, 31 Aug 2017 08:58:02 -0700	[thread overview]
Message-ID: <20170831085802.2d4cdc87@xeon-e3> (raw)
In-Reply-To: <150417481955.28907.15567119824187929000.stgit@firesoul>

On Thu, 31 Aug 2017 12:20:19 +0200
Jesper Dangaard Brouer <brouer@redhat.com> wrote:

> +static inline bool frag_mem_over_limit(struct netns_frags *nf, int thresh)
>  {
> -	return percpu_counter_read(&nf->mem);
> +	/* When reading counter here, __percpu_counter_compare() call
> +	 * will invoke __percpu_counter_sum() when needed.  Which
> +	 * depend on num_online_cpus()*batch size, as each CPU can
> +	 * potentential can hold a batch count.
> +	 *
> +	 * With many CPUs this heavier sum operation will
> +	 * unfortunately always occur.
> +	 */
> +	if (__percpu_counter_compare(&nf->mem, thresh,
> +				     frag_percpu_counter_batch) > 0)
> +		return true;
> +	else
> +		return false;

You don't need an if() here.

	return __percpu_counter_compare(&nf->mem, thresh,
				     frag_percpu_counter_batch) > 0;

  reply	other threads:[~2017-08-31 15:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-31 10:20 [RFC PATCH] net: frag limit checks need to use percpu_counter_compare Jesper Dangaard Brouer
2017-08-31 15:58 ` Stephen Hemminger [this message]
2017-08-31 16:23 ` Michal Kubecek
2017-09-01  2:25   ` liujian (CE)
2017-09-01  7:16     ` Jesper Dangaard Brouer
2017-09-01  7:41   ` Jesper Dangaard Brouer
2017-09-01  8:10     ` Michal Kubecek

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=20170831085802.2d4cdc87@xeon-e3 \
    --to=stephen@networkplumber.org \
    --cc=brouer@redhat.com \
    --cc=fw@strlen.de \
    --cc=liujian56@huawei.com \
    --cc=netdev@vger.kernel.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).