Thread (7 messages) 7 messages, 4 authors, 2017-09-01

Re: [RFC PATCH] net: frag limit checks need to use percpu_counter_compare

flat view

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2017-08-31 15:58:06

On Thu, 31 Aug 2017 12:20:19 +0200
Jesper Dangaard Brouer [off-list ref] wrote:
quoted hunk ↗ jump to hunk
+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;
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help